From 1649ea29bede2e6af67bd63e21aa101c43557c95 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Sat, 1 Aug 2020 15:53:02 +0200 Subject: [PATCH] v4l2 pipeline --- .../roberto/camera/camera_gstreamer_webrtc.py | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/raspberry/roberto/camera/camera_gstreamer_webrtc.py b/raspberry/roberto/camera/camera_gstreamer_webrtc.py index 5055fee..c24b8e7 100644 --- a/raspberry/roberto/camera/camera_gstreamer_webrtc.py +++ b/raspberry/roberto/camera/camera_gstreamer_webrtc.py @@ -18,13 +18,13 @@ from gi.repository import GstSdp import json -PIPELINE_DESC = ''' -webrtcbin name=sendrecv bundle-policy=max-bundle stun-server=stun://stun.l.google.com:19302 - videotestsrc is-live=true pattern=ball ! videoconvert ! queue ! vp8enc deadline=1 ! rtpvp8pay ! - queue ! application/x-rtp,media=video,encoding-name=VP8,payload=97 ! sendrecv. - audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc !rtpopuspay ! - queue ! application/x-rtp,media=audio,encoding-name=OPUS,payload=96 ! sendrecv. -''' +#PIPELINE_DESC = ''' +#webrtcbin name=sendrecv bundle-policy=max-bundle stun-server=stun://stun.l.google.com:19302 +# videotestsrc is-live=true pattern=ball ! videoconvert ! queue ! vp8enc deadline=1 ! rtpvp8pay ! +# queue ! application/x-rtp,media=video,encoding-name=VP8,payload=97 ! sendrecv. +# audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc !rtpopuspay ! +# queue ! application/x-rtp,media=audio,encoding-name=OPUS,payload=96 ! sendrecv. +#''' #PIPELINE_DESC = ''' #webrtcbin name=webrtcbin stun-server=stun://stun://stun.l.google.com:19302 @@ -39,6 +39,13 @@ webrtcbin name=sendrecv bundle-policy=max-bundle stun-server=stun://stun.l.googl # webrtcbin name=sendrecv #''' +PIPELINE_DESC = ''' +webrtcbin name=sendrecv bundle-policy=max-bundle stun-server=stun://stun.l.google.com:19302 + v4l2src device=/dev/video0 ! videoconvert ! queue ! vp8enc deadline=1 ! rtpvp8pay ! + queue ! application/x-rtp,media=video,encoding-name=VP8,payload=97 ! sendrecv. + audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc !rtpopuspay ! + queue ! application/x-rtp,media=audio,encoding-name=OPUS,payload=96 ! sendrecv. +''' class WebRTCCamera(Thread): def __init__(self): @@ -91,12 +98,15 @@ class WebRTCCamera(Thread): def connect_client(self, sid, room): if not self.is_alive(): self.start() + if sid == self.sid: + return self._queue.put({'job':'connect_client', 'sid':sid}) def disconnect_client(self, sid, room): self._queue.put({'job':'disconnect_client', 'sid':sid}) def start_pipeline(self, client_sid): # ok + print("STARTING PIPELINE") self.pipe = Gst.parse_launch(PIPELINE_DESC) self.webrtc = self.pipe.get_by_name('sendrecv') self.webrtc.connect('on-negotiation-needed', self.on_negotiation_needed)