webrtc_sendrecv.py: Link pads instead of elements
authorNirbheek Chauhan <nirbheek@centricular.com>
Wed, 23 Mar 2022 09:59:55 +0000 (15:29 +0530)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 23 Mar 2022 21:04:39 +0000 (21:04 +0000)
This was not a problem here because even if we end up accidentally
linking to the wrong pad, things will work out eventually as long as
one pad-added is emitted for each pad that is added.

But it will be a huge problem if someone copies this code and changes
something that requires different handling for different sorts of
pads. The resultant code will be racy. Let's not do this, it's a bad
example.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2008>

subprojects/gst-examples/webrtc/sendrecv/gst/webrtc_sendrecv.py

index 900365db9318e52abcb4bea54c16e2d4d4f7b623..6c5442bc2cd01d57854f12f72e3995032a2e4c72 100755 (executable)
@@ -188,7 +188,7 @@ class WebRTCClient:
         decodebin.connect('pad-added', self.on_incoming_decodebin_stream)
         self.pipe.add(decodebin)
         decodebin.sync_state_with_parent()
-        self.webrtc.link(decodebin)
+        pad.link(decodebin.get_static_pad('sink'))
 
     def start_pipeline(self, create_offer=True, opus_pt=96, vp8_pt=97):
         print_status(f'Creating pipeline, create_offer: {create_offer}')