示例#1
0
    def send_options(self, conn, cmd):
        if self.debug:
            tools.printc(
                "           Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE",
                serverColour)

        conn.send(b'Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE\r\n')
        tools.printc(
            "[SERVER]:  Returned OPTIONS (Describe, Setup, Teardown, Play, Pause)",
            serverColour)
示例#2
0
    def send_sdp(self, conn, cmd):
        sdpStr = open(self.sdpPath, "r").read()

        if self.debug:
            tools.printc("\r\n" + sdpStr, serverColour)

        conn.send(b'Content-Type: application/sdp\r\n')
        conn.send(b'Content-Length: ' +
                  bytes(str(len(sdpStr)), encoding="utf-8") + b'\r\n')

        conn.send(b'\r\n' + bytes(sdpStr, encoding="utf-8") + b'\r\n')
        tools.printc("[SERVER]:  Sent SDP", serverColour)
示例#3
0
    def parse_msgs(self, msgs, conn):
        cmd = [""]
        cseq = -1

        for msg in msgs:
            if self.debug and msg:  # If debug output enabled
                tools.printc("           {0}".format(msg), clientColour)

            if str.startswith(msg, "OPTIONS"):
                cmd = self.parse_options(msg)
            elif str.startswith(msg, "DESCRIBE"):
                cmd = self.parse_describe(msg)
            elif str.startswith(msg, "SETUP"):
                cmd = self.parse_setup(msg)
            elif str.startswith(msg, "CSeq"):
                cseq = self.parse_cseq(msg)
            elif str.startswith(msg, "User-Agent"):
                self.parse_ua(msg)
            elif str.startswith(msg, "Accept"):
                cmd.append(self.parse_accept(msg))
            elif str.startswith(msg, "Transport"):
                self.parse_transport(msg)

        self.build_response(conn, cmd, cseq)
示例#4
0
 def parse_transport(self, msg):
     keys = msg[11:].split(';')
     keys[2] = str.replace(keys[2], "client_port=", "")
     tools.printc(
         "[CLIENT]:  Transport {0} as {1} on ports {2}".format(
             keys[0], keys[1], keys[2]), clientColour)
示例#5
0
 def parse_accept(self, msg):
     accept = msg.split("/")[1]
     tools.printc("[CLIENT]:  Accepting {0}".format(accept.upper()),
                  clientColour)
     return accept
示例#6
0
 def parse_ua(self, msg):
     if str.startswith(msg[12:], "LibVLC"):
         tools.printc("[CLIENT]:  Detected VLC", clientColour)
示例#7
0
 def parse_cseq(self, msg):
     cseq = int(msg[6:])
     tools.printc("[CLIENT]:  Sequence: {0}".format(cseq), clientColour)
     return cseq
示例#8
0
 def parse_setup(self, msg):
     path = msg[6:-9]
     tools.printc("[CLIENT]:  Requested SETUP for \"{0}\"".format(path),
                  clientColour)
     return ["SETUP", path]
示例#9
0
 def parse_describe(self, msg):
     path = msg[9:-9]
     tools.printc("[CLIENT]:  Requested DESCRIBE for \"{0}\"".format(path),
                  clientColour)
     return ["DESCRIBE", path]
示例#10
0
 def parse_options(self, msg):
     path = msg[8:-9]
     tools.printc("[CLIENT]:  Requested OPTIONS for \"{0}\"".format(path),
                  clientColour)
     return ["OPTIONS", path]
示例#11
0
    def send_cseq(self, conn, cseq):
        if self.debug:
            tools.printc("           CSeq: {0}".format(cseq), serverColour)

        conn.send(b'CSeq: ' + bytes(str(cseq), encoding="utf-8") + b'\r\n')
        tools.printc("[SERVER]:  Sequence: {0}".format(cseq), serverColour)
示例#12
0
    def send_ack(self, conn):
        if self.debug:
            tools.printc("           RTSP/1.0 200 OK", serverColour)

        conn.send(b'RTSP/1.0 200 OK\r\n')
        tools.printc("[SERVER]:  Acknowledge", serverColour)