forked from dhorth/LiveProxy
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMediaQueue.h
More file actions
94 lines (81 loc) · 1.3 KB
/
MediaQueue.h
File metadata and controls
94 lines (81 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once
#include "util.h"
/**
The type, size and timestamp of the frame
In live mode time is always 0
*/
typedef struct __FrameHeader
{
long TimeStamp;
long FrameType;
long FrameLen;
}FrameHeader;
/**
The frame header and the buffer
this is what we queue up
*/
typedef struct __FrameInfo
{
FrameHeader frameHead;
char* pdata;
}FrameInfo;
/**
This is the queue of video frames
*/
typedef struct __MediaQueue
{
FrameInfo *frame;
struct __MediaQueue *next;
}MediaQueue;
/**
This class manages the queue of of video frames
*/
class CMediaQueue
{
MediaQueue *head, *tail;
MediaQueue *writepos, *readpos;
MediaQueue *ptr, *pstatic;
MyMutex* hFrameListLock;
MyEvent* hRecvEvent;
MyMutex* hDestroyMutex;
int count;
int size;
int m_EngineID;
public:
CMediaQueue(int queueSize, int engineId);
~CMediaQueue();
void put(FrameInfo* frame);
//FrameInfo* get();
bool get(unsigned char* transBuf, int bufSize);
void reset();
public:
/**
The capacity of the queue
*/
int get_Size()
{
return(size);
}
/**
The number of frames in the queue
*/
int get_Count()
{
return(count);
}
/**
Helper to see if queue is empty
*/
int get_isEmpty()
{
return(count<=0?1:0);
}
/**
remove all items from the queue
*/
int empty()
{
hRecvEvent -> SetEvent();
return(count=0);
}
};