-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathsdpclient.h
70 lines (61 loc) · 2.07 KB
/
sdpclient.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
/* ---------------------------------------------------------------------------
** This software is in the public domain, furnished "as is", without technical
** support, and with no warranty, express or implied, as to its usefulness for
** any purpose.
**
** sdpclient.h
**
** Interface to an SDP client
**
** -------------------------------------------------------------------------*/
#pragma once
#include "environment.h"
#include "SessionSink.h"
#include "liveMedia.hh"
#include <string>
#include <map>
#include <sstream>
/* ---------------------------------------------------------------------------
** SDP client connection interface
** -------------------------------------------------------------------------*/
class SDPClient
{
public:
static std::string getSdpFromRtpUrl(const std::string & url) {
std::string sdp;
if (url.find("rtp://") == 0) {
std::istringstream is(url.substr(strlen("rtp://")));
std::string ip;
std::getline(is, ip, ':');
std::string port;
std::getline(is, port, '/');
std::string rtppayloadtype("96");
std::getline(is, rtppayloadtype, '/');
std::string codec("H264");
std::getline(is, codec);
std::ostringstream os;
os << "m=video " << port << " RTP/AVP " << rtppayloadtype << "\r\n"
<< "c=IN IP4 " << ip <<"\r\n"
<< "a=rtpmap:" << rtppayloadtype << " " << codec << "\r\n";
sdp.assign(os.str());
}
return sdp;
}
/* ---------------------------------------------------------------------------
** SDP client callback interface
** -------------------------------------------------------------------------*/
class Callback : public SessionCallback
{
public:
virtual void onError(SDPClient&, const char*) {}
};
public:
SDPClient(Environment& env, Callback* callback, const char* SDP, const std::map<std::string,std::string> & opts, int verbosityLevel=1);
virtual ~SDPClient();
void start() {};
void stop() {};
protected:
Environment& m_env;
Callback* m_callback;
MediaSession* m_session;
};