forked from dhorth/LiveProxy
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlive.h
More file actions
187 lines (161 loc) · 5.02 KB
/
live.h
File metadata and controls
187 lines (161 loc) · 5.02 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#pragma once
#include "BasicUsageEnvironment.hh"
#include "GroupsockHelper.hh"
#include "UsageEnvironment.hh"
#include "liveMedia.hh"
//#include "MyRTSPClient.h"
#include "MediaQueue.h"
#include "trace.h"
#include "stdafx.h"
#ifdef _LP_FOR_LINUX_
#else
# ifdef MY_DLL
# define MY_DLL_EXPORTS __declspec(dllexport)
# else
# define MY_DLL_EXPORTS __declspec(dllimport)
# endif // MY_DLL
#endif
// some type shortcuts
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned int fourcc_t;
//
#define FOURCC(a, b, c, d) \
(((uint32_t)a) | (((uint32_t)b) << 8) | (((uint32_t)c) << 16) | (((uint32_t)d) << 24))
// The different types of codecs
enum CodecType
{
CODEC_TYPE_UNKNOWN = -1,
CODEC_TYPE_VIDEO,
CODEC_TYPE_AUDIO,
CODEC_TYPE_DATA,
CODEC_TYPE_SUBTITLE,
CODEC_TYPE_ATTACHMENT,
CODEC_TYPE_NB
};
// The current state of the RTSP stream
enum RTSPClientState
{
RTSP_STATE_IDLE, // Nothing happening yet
RTSP_STATE_OPENING, // Thread started and RTSP commands in progress
RTSP_STATE_OPENED, // Sessions being set up
RTSP_STATE_PLAYING,
RTSP_STATE_PAUSED,
RTSP_STATE_CLOSING, // Started shutting down Sessions and Thread
RTSP_STATE_CLOSED, // Sessions and Thread shutdown and cleaned up
RTSP_STATE_SHUTDOWN, // CstreamMedia cleaned up
RTSP_STATE_ERROR
};
// If we could get the video format from the VSM
// this is where would put it
typedef struct __VideoFormat
{
int width;
int height;
int fps;
int bitrate;
} VideoFormat;
typedef struct __MediaInfo
{
enum CodecType codecType;
fourcc_t i_format;
char codecName[50];
VideoFormat video;
int duration;
int b_packetized;
char* extra;
int extra_size;
} MediaInfo;
class CstreamMedia;
typedef struct __StreamTrack
{
// CstreamMedia * pstreammedia;
int waiting;
MediaInfo mediainfo;
MediaSubsession* sub;
char* p_buffer;
unsigned int i_buffer;
} StreamTrack;
// our worker thread to receive frames on
// DWORD WINAPI rtspRecvDataThread( LPVOID lpParam );
void* rtspRecvDataThread(void* lpParam);
/**
*/
class MyRTSPClient;
class MY_DLL_EXPORTS CstreamMedia
{
private:
bool m_recvThreadFlag;
MediaSession* ms;
TaskScheduler* scheduler;
UsageEnvironment* env;
MyRTSPClient* rtsp;
int i_stream;
StreamTrack** stream;
int b_tcp_stream;
enum RTSPClientState m_state;
char event;
MyMutex* hFrameListLock;
MyThread* hRecvDataThread;
// MyEvent* hDataThreadReady;
MyEvent* hRecvEvent;
int nostream;
int m_frameQueueSize;
int m_streamPort;
int m_iTunnelOverHTTPPortNum; // renamed for clarity
// if non-zero, HTTP-Tunneling will be used regardless of m_bStreamUsingTCP
public:
/*
* !!!!!!!!!!!!IMPORTANT!!!!!!!!!!!!!!!!!!!!
* We Must define the version here.
*
* Whenever LiveProxy is updated, new build must be tar'ed
* and pushed to artifactory from ../sse as follows:
* - modify LIVEPROXY-VERSION in Makefile to match what is defined here
* - make tar-liveproxy-build
* - make push-liveproxy-build
*/
static const std::string& VERSION(void)
{
static const std::string str = "3.0.0.12";
return str;
}
CstreamMedia(int frameQueueSize, int engineId, int logLevel);
~CstreamMedia();
// The rtsp thread
int rtspClientPlayStream(const char* url);
int rtspClientCloseStream(void);
void rtspClientStopStream(void);
// State management
RTSPClientState GetRTSPState() { return m_state; }
void SetRTSPState(RTSPClientState state);
// Queue management
bool GetFrame(BYTE* pData, int bufferSize);
bool GetFramePtr(FrameInfo** ppframe);
void DeleteFrame(FrameInfo* frame);
int GetQueueSize();
const char* get_Url() { return m_url.c_str(); }
int GetVideoParms(int* piWidth, int* piHeight);
void SetStreamPort(int streamPort) { m_streamPort = streamPort; }
void SetHTTPTunnelPort(int tunnelPort) { m_iTunnelOverHTTPPortNum = tunnelPort; } // renamed for clarity
void SetTCPStreamPort(int tunnelPort) { m_iTunnelOverHTTPPortNum = tunnelPort; } // backwards compatibility with IBM VA SSE
void SetStreamUsingTCP(bool useTCP) { m_bStreamUsingTCP = useTCP; }
const StreamTrack* GetTrack()
{
printf("cstreammed get track, num %d, ptr %p\n", i_stream, stream[0]);
return stream[0];
}
std::string m_url;
unsigned rtspClientCount;
int m_LogLevel;
int m_EngineID;
char eventLoopWatchVariable = 0; // used to break out of event loop
bool streamUp = false; // indicates if stream is up
bool threadUp = false; // indicates if thread is up
bool m_bStreamUsingTCP = false; // indicates whether to stream over TCP (interleaved, not HTTP-Tunneled)
private:
// our data thread
// friend DWORD WINAPI rtspRecvDataThread( LPVOID lpParam );
friend void* rtspRecvDataThread(void* lpParam);
};