Exemplo n.º 1
0
    def run(self):
        try:
            rtmp = RTMP(url='rtmp://127.0.0.1:1935/live/test')

            print '1'
            print rtmp

            print '2'
            print rtmp.connect()

            print '3'
            pkt = rtmp.read_packet()

            print '4'
            print pkt

            print '5'
            stream = rtmp.create_stream()

            print '6'
            print stream

            # data = stream.read(1024)

        except RTMPError, e:
            print e
Exemplo n.º 2
0
    def run(self):
        try:
            rtmp = RTMP(url='rtmp://127.0.0.1:1935/live/test')

            print '1'
            print rtmp

            print '2'
            print rtmp.connect()

            print '3'
            pkt = rtmp.read_packet()

            print '4'
            print pkt

            print '5'
            stream = rtmp.create_stream()

            print '6'
            print stream

            # data = stream.read(1024)

        except RTMPError, e:
            print e
Exemplo n.º 3
0
class RTMPClient():
    def __init__(self, audio_url, video_url, stoken):
        self.audio_url = audio_url
        self.video_url = video_url
        self.stoken = stoken
        self.audio_client = RTMP(self.audio_url, live=True, token=self.stoken)
        self.video_client = RTMP(self.video_url, live=True, token=self.stoken)

        self.audio_client.connect()
        self.video_client.connect()

        self.audio_stream = self.audio_client.create_stream()
        self.video_stream = self.video_client.create_stream()

        self.recieve_done = False
        self.continue_recieve = True

    def recieve(self, size=1024):
        while self.continue_recieve:
            self.recieve_done = False
            audio_data = self.audio_stream.read(size)
            video_data = self.video_stream.read(size)
            self.recieve_done = True
            logger.info(len(video_data))
            if len(video_data) == 0:
                self.close()
            del audio_data
            del video_data

    def close(self):
        self.continue_recieve = False
        while True:
            if self.recieve_done:
                self.audio_stream.close()
                self.video_stream.close()
                self.audio_client.close()
                self.video_client.close()
                break
            time.sleep(0.5)
Exemplo n.º 4
0
def test_connect():
    with raises(RTMPError):
        conn = RTMP("rtmp://localhost/app/playpath", live=True)
        conn.connect()