-
Notifications
You must be signed in to change notification settings - Fork 16
/
rtsp.h
121 lines (103 loc) · 3.3 KB
/
rtsp.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
117
118
119
120
/*
* satip: RTSP processing
*
* Copyright (C) 2014 [email protected]
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __RTSP_H__
#define __RTSP_H__
#include "timer.h"
#include "config.h"
#include "rtp.h"
#include <string>
enum
{
RTSP_STATUS_CONFIG_WAITING = 0, // need to check if tuner config is completed.
RTSP_STATUS_SERVER_CONNECTING, // try to server connecting..
RTSP_STATUS_SESSION_ESTABLISHING, // connected, send to setup..and receive response to get streamID, sessionID, timeout..
RTSP_STATUS_SESSION_PLAYING, // session established, send to play and wait until receive play ok.
RTSP_STATUS_SESSION_TRANSMITTING,// play ok, data transmitting..check channel or pid changed. if tuner config invalid, status move to teardown.
RTSP_STATUS_SESSION_TEARDOWNING, // send teardown and if receive, go to waiting.
};
enum
{
RTSP_REQUEST_NONE = 0,
RTSP_REQUEST_OPTION, // use to keep alive message..
RTSP_REQUEST_SETUP, // send tuning params.. (and pids)
RTSP_REQUEST_PLAY, // send play commend.. and tuning params or addpid, delpid (channel change)
RTSP_REQUEST_TEARDOWN, // request server disconnect.
RTSP_REQUEST_DESCRIBE, // request stream infomation
};
class satipRTSP
{
public:
satipRTSP(satipConfig* satip_config,
const char* host,
const char* rtsp_port,
satipRTP *rtp);
~satipRTSP();
void handleRTSPStatus();
int getRtspSocketFd();
short getPollEvent();
int getPollTimeout();
void handleNextTimer();
void handlePollEvents(short events);
static void timeoutConnect(void *ptr);
static void timeoutKeepAlive(void *ptr);
static void timeoutStreamInfo(void *ptr);
private:
char *m_host;
char* m_port;
satipRTP *m_rtp;
satipConfig *m_satip_config;
satipTimer m_satip_timer;
timer_elem *m_timer_reset_connect;
timer_elem *m_timer_keep_alive;
int m_fd;
char m_txbuf[1024];
char *m_rx_data;
int m_rx_data_len;
int m_rx_data_pos;
int m_rtsp_status;
int m_rtsp_request;
enum { RTSP_FAILED = -1, RTSP_OK = 0, RTSP_ERROR = 1, RTSP_RESPONSE_COMPLETE = 2 };
std::string m_rtsp_session_id;
int m_rtsp_stream_id;
int m_rtsp_timeout;
int m_rtsp_cseq;
bool m_wait_response;
void resetConnect();
int connectToServer();
int rtpData(size_t len);
int handleResponse();
int handleResponseSetup();
int handleResponsePlay();
int handleResponseOption();
int handleResponseTeardown();
int handleResponseDescribe();
int sendRequest(int request);
int sendSetup();
int sendPlay();
int sendOption();
int sendTearDown();
int sendDescribe();
int setTuneParams();
int getPidList(int get_changed = 0);
void startTimerResetConnect(long timeout);
void stopTimerResetConnect();
void startTimerKeepAliveMessage();
void stopTimerKeepAliveMessage();
};
#endif // __RTSP_H__