diff --git a/raspberry/roberto/camera/camera_gstreamer_webrtc.py b/raspberry/roberto/camera/camera_gstreamer_webrtc.py index 4a7b631..0f5f457 100644 --- a/raspberry/roberto/camera/camera_gstreamer_webrtc.py +++ b/raspberry/roberto/camera/camera_gstreamer_webrtc.py @@ -46,30 +46,54 @@ except (ImportError, RuntimeError): # webrtcbin name=sendrecv #''' -PIPELINE_DESC = ''' -webrtcbin name=sendrecv bundle-policy=max-bundle stun-server=stun://stun.l.google.com:19302 latency=40 - 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. -''' +#PIPELINE_DESC = ''' +#webrtcbin name=sendrecv bundle-policy=max-bundle stun-server=stun://stun.l.google.com:19302 latency=40 +# 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. +#''' # rpicamsrc name=src preview=0 fullscreen=0 ! h264parse ! omxh264dec ! glimagesink sync=0 -if platform == 'raspberry': - PIPELINE_DESC = ''' - webrtcbin name=sendrecv bundle-policy=max-bundle stun-server=stun://stun.l.google.com:19302 latency=40 - rpicamsrc bitrate=1000000 keyframe-interval=25 rotation=180 exposure-mode=sports annotation-mode=12 annotation-text-size=10 preview=false name=rpicamsrc ! video/x-h264,profile=constrained-baseline,width=1280,height=720,framerate=49/1,level=3.0 ! queue max-size-time=100000000 ! h264parse ! - rtph264pay config-interval=-1 name=payloader ! - application/x-rtp,media=video,encoding-name=H264,payload=96 ! 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. - ''' +#if platform == 'raspberry': +# PIPELINE_DESC = ''' +# webrtcbin name=sendrecv bundle-policy=max-bundle stun-server=stun://stun.l.google.com:19302 latency=40 +# rpicamsrc bitrate=1000000 keyframe-interval=25 rotation=180 exposure-mode=sports annotation-mode=12 annotation-text-size=10 preview=false name=rpicamsrc ! video/x-h264,profile=constrained-baseline,width=1280,height=720,framerate=49/1,level=3.0 ! queue max-size-time=100000000 ! h264parse ! +# rtph264pay config-interval=-1 name=payloader ! +# application/x-rtp,media=video,encoding-name=H264,payload=96 ! 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 = ''' +# videotestsrc is-live=true ! vp8enc deadline=1 ! rtpvp8pay pt=96 ! tee name=video-tee ! +# queue ! fakesink sync=true +# audiotestsrc wave=ticks is-live=true ! opusenc ! rtpopuspay pt=97 ! tee name=audio-tee ! +# queue ! fakesink sync=true +# ''' + +#PEER_BIN_DESC = ''' +# queue name=video-queue ! webrtcbin. +# queue name=audio-queue ! webrtcbin. +# webrtcbin name=webrtcbin +# ''' + +############# PIPELINE_DESC = ''' - videotestsrc is-live=true ! vp8enc deadline=1 ! rtpvp8pay pt=96 ! tee name=video-tee ! + v4l2src device=/dev/video0 ! videoconvert ! queue ! vp8enc deadline=1 ! rtpvp8pay pt=96 ! tee name=video-tee ! queue ! fakesink sync=true - audiotestsrc wave=ticks is-live=true ! opusenc ! rtpopuspay pt=97 ! tee name=audio-tee ! + audiotestsrc wave=red-noise is-live=true ! opusenc ! rtpopuspay pt=97 ! tee name=audio-tee ! + queue ! fakesink sync=true + ''' + +PIPELINE_DESC_RASPBERRY = ''' + rpicamsrc bitrate=1000000 keyframe-interval=25 rotation=180 exposure-mode=sports annotation-mode=12 annotation-text-size=10 preview=false name=rpicamsrc ! video/x-h264,profile=constrained-baseline,width=1280,height=720,framerate=49/1,level=3.0 ! queue max-size-time=100000000 ! h264parse ! + rtph264pay config-interval=-1 name=payloader ! + application/x-rtp,media=video,encoding-name=H264,payload=96 ! tee name=video-tee ! + queue ! fakesink sync=true + audiotestsrc wave=red-noise is-live=true ! opusenc ! rtpopuspay pt=97 ! tee name=audio-tee ! queue ! fakesink sync=true ''' @@ -79,6 +103,7 @@ PEER_BIN_DESC = ''' webrtcbin name=webrtcbin ''' + class WebRTCCamera(Thread): def __init__(self): self.pipe = None @@ -143,7 +168,10 @@ class WebRTCCamera(Thread): def start_global_pipeline(self): print("STARTING PIPELINE") - self.pipe = Gst.parse_launch(PIPELINE_DESC) + desc = PIPELINE_DESC + if platform == 'raspberry': + desc = PIPELINE_DESC_RASPBERRY + self.pipe = Gst.parse_launch(desc) if platform == 'raspberry': rpicamsrc = self.pipe.get_by_name ("rpicamsrc")