Esempio 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
Esempio n. 2
0
    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
Esempio n. 3
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
Esempio n. 4
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)
Esempio n. 5
0
def test_connect():
    with raises(RTMPError):
        conn = RTMP("rtmp://localhost/app/playpath", live=True)
        conn.connect()
Esempio n. 6
0
def test_remote_method():
    conn = RTMP("rtmp://localhost/app/playpath", live=True)
    my_remote_method = conn.remote_method("MyRemoteMethod", block=True)

    assert callable(my_remote_method) == True
    assert my_remote_method.__name__ == "MyRemoteMethod"