-
Notifications
You must be signed in to change notification settings - Fork 154
/
rtsp.h
170 lines (131 loc) · 4.85 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
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
/*
* rtsp.h
*
* Copyright (C) 2014-2015 Andrey Burbovskiy, OpenMCU-ru, All Rights Reserved
*
* The Initial Developer of the Original Code is Andrey Burbovskiy ([email protected]), All Rights Reserved
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* Contributor(s): Andrey Burbovskiy ([email protected])
*
*/
#include "precompile.h"
#ifndef _MCU_RTSP_H
#define _MCU_RTSP_H
#include "sockets.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
static const PString METHOD_OPTIONS = "OPTIONS";
static const PString METHOD_DESCRIBE = "DESCRIBE";
static const PString METHOD_SETUP = "SETUP";
static const PString METHOD_PLAY = "PLAY";
static const PString METHOD_TEARDOWN = "TEARDOWN";
class ConferenceStreamMember;
////////////////////////////////////////////////////////////////////////////////////////////////////
class MCURtspConnection : public MCUSipConnection
{
friend class MCURtspServer;
public:
virtual BOOL ClearCall(CallEndReason reason = EndedByLocalUser);
virtual void CleanUpOnCallEnd();
protected:
enum RtspStates
{
RTSP_NONE = 0,
RTSP_CONNECT,
RTSP_DESCRIBE,
RTSP_SETUP,
RTSP_SETUP_AUDIO,
RTSP_SETUP_VIDEO,
RTSP_PLAY,
RTSP_PLAYING,
RTSP_TEARDOWN
};
RtspStates rtsp_state;
MCURtspConnection(MCUH323EndPoint *_ep, PString _callToken);
~MCURtspConnection();
BOOL Connect(PString room, PString address);
BOOL Connect(MCUSocket *socket, const msg_t *msg);
void CreateLocalSipCaps();
BOOL CreateInboundCaps();
BOOL SendSetup(MediaTypes mtype, int pt);
BOOL SendPlay();
BOOL SendOptions();
BOOL SendTeardown();
BOOL SendDescribe();
BOOL OnResponseReceived(const msg_t *msg);
BOOL OnResponseDescribe(const msg_t *msg);
BOOL OnResponseSetup(const msg_t *msg);
BOOL OnResponsePlay(const msg_t *msg);
BOOL OnRequestReceived(const msg_t *msg);
BOOL OnRequestDescribe(const msg_t *msg);
BOOL OnRequestSetup(const msg_t *msg);
BOOL OnRequestPlay(const msg_t *msg);
BOOL OnRequestTeardown(const msg_t *msg);
BOOL OnRequestOptions(const msg_t *msg);
BOOL RtspCheckAuth(const msg_t *msg);
BOOL ParseTransportStr(SipCapability *sc, PString & transport_str);
void AddHeaders(char *buffer, PString method_name="");
BOOL SendRequest(char *buffer);
int cseq;
PString rtsp_session_str;
PString rtsp_path;
PString luri_str;
static int OnReceived_wrap(void *context, MCUSocket *socket, PString data)
{ return ((MCURtspConnection *)context)->OnReceived(socket, data); }
int OnReceived(MCUSocket *socket, PString data);
MCUListener *listener;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
class MCURtspServer
{
public:
MCURtspServer(MCUH323EndPoint *ep, MCUSipEndPoint *sep);
~MCURtspServer();
bool CreateConnection(const PString & room, const PString & address, const PString & callToken);
void StartListeners();
void RemoveListeners();
void AddListener(const PString & address);
BOOL HasListener(const PString & host, const PString & port);
protected:
BOOL CreateConnection(MCUSocket *socket, const msg_t *msg);
void SendResponse(MCUSocket *socket, const msg_t *msg, const PString & status_str);
PString trace_section;
static int OnReceived_wrap(void *context, MCUSocket *socket, PString data)
{ return ((MCURtspServer *)context)->OnReceived(socket, data); }
int OnReceived(MCUSocket *socket, PString data);
MCUListenerList listenerList;
MCUH323EndPoint *ep;
MCUSipEndPoint *sep;
PMutex rtspMutex;
PMutex listenerListMutex;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
class ConferenceStreamMember : public ConferenceMember
{
PCLASSINFO(ConferenceStreamMember, ConferenceMember);
public:
ConferenceStreamMember(Conference *_conference, const PString & _name, const PString & _callToken)
: ConferenceMember(_conference)
{
memberType = MEMBER_TYPE_STREAM;
callToken = _callToken;
name = _name;
nameID = MCUURL(name).GetMemberNameId();
}
~ConferenceStreamMember()
{
}
virtual PString GetName() const
{ return name; }
};
////////////////////////////////////////////////////////////////////////////////////////////////////
#endif // _MCU_RTSP_H