-
Notifications
You must be signed in to change notification settings - Fork 0
/
datasink.h
69 lines (52 loc) · 1.65 KB
/
datasink.h
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
#ifndef MEDIA_PROCESSING_DATA_SINK_H__
#define MEDIA_PROCESSING_DATA_SINK_H__
#include <QObject>
#include <stdint.h>
#include <string>
typedef struct {
unsigned char* imgBuffer;
uint32_t fourcc;
uint32_t width;
uint32_t height;
}VideoImage;
typedef struct DataFrame
{
unsigned char* mBuffer;
unsigned long mSize;
unsigned long mSizeInBuff;
int64_t mTimestamp;
unsigned long mReserved1;
unsigned long mReserved2;
bool WriteTo(const unsigned char* data, unsigned long size,
int64_t timestamp, unsigned long reserved1, unsigned long reserved2);
bool ReadOut(unsigned char* data, unsigned long &size, int64_t& timestamp,
unsigned long &reserved1, unsigned long &reserved2);
}DataFrame;
class DataSink : public QObject
{
Q_OBJECT
protected:
typedef enum {
CIRCULAR_QUEUE_MID,
CIRCULAR_QUEUE_EMPTY,
CIRCULAR_QUEUE_FULL
} cq_level_t;
cq_level_t mState;
uint32_t mRear;
uint32_t mFront;
uint32_t mMaxFrames;
DataFrame* mBuffer;
bool mIsLost;
std::string mName;
public:
explicit DataSink(const char* name, unsigned int maxFrames, unsigned int frameSize, QObject *parent = 0);
virtual ~DataSink();
bool PushBackData(const unsigned char* data, unsigned long size,
int64_t timestamp, unsigned long reserved1, unsigned long reserved2);
bool PopUpData(unsigned char* data, unsigned long &size, int64_t& timestamp,
unsigned long &reserved1, unsigned long &reserved2);
void PopUpNoCopy();
// void SetLost(bool flag) { mIsLost = flag; }
// const char* GetSinkName() { return mName.c_str(); }
};
#endif//MEDIA_PROCESSING_DATA_SINK_H__