From d8e76871328a9d6b128ed66806898408abc58fb9 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Tue, 28 Jan 2020 00:03:39 +1100 Subject: [PATCH] janus: Add options near the top Add some script configuration options to choose between VP8 and H.264 near the top, to modify the video input source, and to enable/disable RTX support --- webrtc/janus/janusvideoroom.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/webrtc/janus/janusvideoroom.py b/webrtc/janus/janusvideoroom.py index 80ee47fef5..c1b2cd5a26 100644 --- a/webrtc/janus/janusvideoroom.py +++ b/webrtc/janus/janusvideoroom.py @@ -15,6 +15,15 @@ from websockets.exceptions import ConnectionClosed import attr +# Set to False to send H.264 +DO_VP8 = True +# Set to False to disable RTX (lost packet retransmission) +DO_RTX = True +# Choose the video source: +VIDEO_SRC="videotestsrc pattern=ball" +# VIDEO_SRC="v4l2src" + + @attr.s class JanusEvent: sender = attr.ib(validator=attr.validators.instance_of(int)) @@ -66,8 +75,6 @@ from gi.repository import GstWebRTC gi.require_version('GstSdp', '1.0') from gi.repository import GstSdp -DO_VP8 = True - if DO_VP8: ( encoder, payloader, rtp_encoding) = ( "vp8enc target-bitrate=500000", "rtpvp8pay", "VP8" ) else: @@ -75,9 +82,9 @@ else: PIPELINE_DESC = ''' webrtcbin name=sendrecv stun-server=stun://stun.l.google.com:19302 - videotestsrc pattern=ball ! video/x-raw,width=320,height=240 ! videoconvert ! queue ! + {} ! video/x-raw,width=640,height=480 ! videoconvert ! queue ! {} ! {} ! queue ! application/x-rtp,media=video,encoding-name={},payload=96 ! sendrecv. -'''.format(encoder, payloader, rtp_encoding) +'''.format(VIDEO_SRC, encoder, payloader, rtp_encoding) def transaction_id(): return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8)) @@ -328,6 +335,10 @@ class WebRTCClient: self.webrtc.connect('on-negotiation-needed', self.on_negotiation_needed) self.webrtc.connect('on-ice-candidate', self.send_ice_candidate_message) self.webrtc.connect('pad-added', self.on_incoming_stream) + + trans = self.webrtc.emit('get-transceiver', 0) + if DO_RTX: + trans.set_property ('do-nack', True) self.pipe.set_state(Gst.State.PLAYING) def extract_ice_from_sdp(self, sdp):