def test_audio_remove_track(self):
     recorder = MediaBlackhole()
     track = AudioStreamTrack()
     recorder.addTrack(track)
     recorder.start()
     run(asyncio.sleep(1))
     recorder.removeTrack(track)
     run(asyncio.sleep(1))
     recorder.stop()
Beispiel #2
0
 def test_audio_and_video(self):
     recorder = MediaBlackhole()
     recorder.addTrack(AudioStreamTrack())
     recorder.addTrack(VideoStreamTrack())
     run(recorder.start())
     run(asyncio.sleep(2))
     run(recorder.stop())
Beispiel #3
0
    def test_video_ended(self):
        track = VideoStreamTrack()

        recorder = MediaBlackhole()
        recorder.addTrack(track)
        run(recorder.start())
        run(asyncio.sleep(1))
        track.stop()
        run(asyncio.sleep(1))

        run(recorder.stop())
Beispiel #4
0
            await pc.addIceCandidate(obj)
        elif obj is BYE:
            print("Exiting")
            break


if __name__ == "__main__":
    room = "".join([random.choice("0123456789") for x in range(10)])
    # room = input("输入房间号:")
    urls = "https://wangxin1210.xyz"
    signaling = ApprtcSignaling(room)
    signaling._origin = urls

    config = RTCConfiguration([
        RTCIceServer("turn:42.194.190.40:3478",
                     username='******',
                     credential='926492',
                     credentialType='password')
    ])
    pc = RTCPeerConnection(configuration=config)
    recorder = MediaBlackhole()
    loop = asyncio.get_event_loop()
    try:
        loop.run_until_complete(run(pc, recorder, signaling))
    except KeyboardInterrupt:
        pass
    finally:
        loop.run_until_complete(recorder.stop())
        loop.run_until_complete(signaling.close())
        loop.run_until_complete(pc.close())
Beispiel #5
0
        video_player = None
        audio_player = None
    # create media sink
    if args.record_to:
        audio_recorder = MediaRecorder(args.record_to)
        video_recorder = MediaBlackhole()
    else:
        video_recorder = MediaBlackhole()
        audio_recorder = MediaBlackhole()

    # run event loop
    loop = asyncio.get_event_loop()
    try:
        loop.run_until_complete(
            run(pc=pc,
                audio_player=audio_player,
                audio_recorder=audio_recorder,
                video_recorder=video_recorder,
                signaling=signaling,
                role=args.role,
                video_player=video_player,
                sio=sio))
    except KeyboardInterrupt:
        pass
    finally:
        # cleanup
        if audio_recorder and video_recorder:
            loop.run_until_complete(audio_recorder.stop())
            loop.run_until_complete(video_recorder.stop())
        loop.run_until_complete(signaling.close())
        loop.run_until_complete(pc.close())