-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathflv_common.h
107 lines (86 loc) · 1.63 KB
/
flv_common.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
/*
* video_common.h
*
* Created on: 2015年11月17日
* Author: xie
*/
#ifndef __VIDEO_COMMON_H__
#define __VIDEO_COMMON_H__
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <inttypes.h>
#include <ts/ink_inet.h>
#include <ts/ts.h>
#include <ts/experimental.h>
#include <ts/remap.h>
#include "flv_tag.h"
class IOHandle
{
public:
IOHandle() : vio(NULL), buffer(NULL), reader(NULL){};
~IOHandle()
{
if(reader) {
TSIOBufferReaderFree(reader);
reader = NULL;
}
if(buffer) {
TSIOBufferDestroy(buffer);
buffer = NULL;
}
}
public:
TSVIO vio;
TSIOBuffer buffer;
TSIOBufferReader reader;
};
class FlvTransformContext
{
public:
FlvTransformContext(int16_t video_type,int64_t st, int64_t n, u_char *des_key) : total(0), parse_over(false)
{
res_buffer = TSIOBufferCreate();
res_reader = TSIOBufferReaderAlloc(res_buffer);
ftag.start = st;
ftag.cl = n;
ftag.video_type = video_type;
ftag.tdes_key = des_key;
}
~FlvTransformContext()
{
if (res_reader) {
TSIOBufferReaderFree(res_reader);
}
if (res_buffer) {
TSIOBufferDestroy(res_buffer);
}
}
public:
IOHandle output;
TSIOBuffer res_buffer;
TSIOBufferReader res_reader;
FlvTag ftag;
int64_t total;
bool parse_over;
};
class FlvContext
{
public:
FlvContext(int16_t videotype, int64_t s) :start(s), cl(0) , video_type(videotype), transform_added(false),ftc(NULL){};
~FlvContext()
{
if(ftc) {
delete ftc;
ftc = NULL;
}
}
public:
int64_t start;
int64_t cl;
int16_t video_type;
bool transform_added;
FlvTransformContext *ftc;
};
#endif /* __VIDEO_COMMON_H__ */