-
Notifications
You must be signed in to change notification settings - Fork 1
/
chunk.h
116 lines (101 loc) · 2.55 KB
/
chunk.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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef _CHUNK_H
#define _CHUNK_H
#include <stdint.h>
#include <string.h>
const uint32_t SUBPIECE_SIZE = 1024;
enum SourceImageAndChunckCMD {
CMD_GET_MEDIA_INFO = 0x101,
CMD_MEDIA_DATA = 0x102,
CMD_READYED = 0x103,
CMD_KEEP_ALIVE = 0x104
};
#pragma pack(1)
typedef struct SRC_HEAD_{
uint32_t len;
uint32_t cmd;
uint8_t encrypt;
SRC_HEAD_():len(0),cmd(0),encrypt(0){}
SRC_HEAD_(SourceImageAndChunckCMD mycmd):len(0),cmd(mycmd),encrypt(0){}
}SRC_HEAD;
typedef SRC_HEAD GetMediaInfo;
typedef struct GetMediaInfoRsp_{
SRC_HEAD head;
uint32_t bit_rate;
uint32_t media_head_size;
uint8_t *media_head_data;
GetMediaInfoRsp_():head(CMD_GET_MEDIA_INFO),bit_rate(0),media_head_size(0),media_head_data(NULL){}
}GetMediaInfoRsp;
typedef struct ReceiveData_{
SRC_HEAD head;
uint32_t lasted_piece_index_;
uint32_t lasted_subpiece_index_;
ReceiveData_():lasted_piece_index_(0),lasted_subpiece_index_(0) { }
}ReceiveData;
struct Subpiece
{
int32_t pieceid;
int32_t subpieceid;
int32_t offset;
uint32_t datalen;
uint8_t data[SUBPIECE_SIZE];
Subpiece():pieceid(0),subpieceid(0),offset(-1),datalen(SUBPIECE_SIZE)
{
memset(data, 0, SUBPIECE_SIZE);
}
void ReSet()
{
pieceid = 0;
subpieceid = 0;
offset = -1;
datalen = SUBPIECE_SIZE;
memset(data, 0, SUBPIECE_SIZE);
}
};
//typedef Subpiece TransSubpieceInfo;
/*
typedef struct MediaData_{
SRC_HEAD head;
TransSubpieceInfo subpieceinfo;
uint32_t data_len;
uint8_t *data;
MediaData_():head(CMD_MEDIA_DATA){ }
}MediaData;
*/
typedef SRC_HEAD KeepAlive;
struct FlvHeader
{
uint8_t sF;
uint8_t sL;
uint8_t sV;
uint8_t ver;
uint8_t flag;
//uint32_t headlen;
uint8_t head1;
uint8_t head2;
uint8_t head3;
uint8_t head4;
uint32_t firsttag_size;
FlvHeader() : sF(0x46),sL(0x4c),sV(0x56)
{
ver = 0x01;
flag = 0x00; //no vedio no audio
flag = 0x05; // has vedio ,has audio
//headlen = 0x00000009;
head1=0x00;
head2=0x00;
head3=0x00;
head4=0x09;
firsttag_size = 0x00000000;
};
FlvHeader(uint8_t vert, uint8_t flags) : sF(0x46),sL(0x4c),sV(0x56),ver(vert),flag(flags)
{
//headlen = 0x00000009;
head1=0x00;
head2=0x00;
head3=0x00;
head4=0x09;
firsttag_size = 0x00000000;
}
};
#pragma pack()
#endif