-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsdp.py
57 lines (46 loc) · 1.39 KB
/
sdp.py
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
###
#
# SDP Message (RTSP version)
#
###
import NTP
import helpers
server_ip = helpers.tcpLocalIp()
terminator = "\r\n"
class SDPMessage:
def __init__(self, program, subject, session):
self.v = "0"
self.s = subject
self.o = program+" "+str(session)+" "+NTP.timestamp()+" IN IP4 "\
+server_ip
self.m = ""#"audio 0 RTP/AVP 0" #u-law PCM! <-- Fix me for A-law # removed /2
self.mode = ""
self.rtpmap = ""
self.c = ""
self.t = ""
def setPort(self, port):
self.m = "audio "+str(port)+" RTP/AVP 0"
def setMode(self, mode):
self.mode = mode
def setRtpmap(self):
self.rtpmap = "rtpmap:0 PCMU/8000/1"
def setC(self):
self.c = "IN IP4 " + server_ip
def setT(self):
self.t = "0 0"
def getMessage(self):
#print self.sdpMsg
self.sdpMsg = "v="+self.v+terminator
self.sdpMsg +="o="+self.o+terminator
self.sdpMsg +="s="+self.s+terminator
if self.c != "":
self.sdpMsg +="c="+self.c+terminator
if self.t != "":
self.sdpMsg +="t="+self.t+terminator
if self.m != "":
self.sdpMsg +="m="+self.m+terminator
if self.rtpmap != "":
self.sdpMsg +="a="+self.rtpmap+terminator
if self.mode != "":
self.sdpMsg +="a="+self.mode
return self.sdpMsg