webrtc_sendrecv.py: Don't try to set state on a None pipe

```
ERROR peer '5762' not found
Traceback (most recent call last):
  File "/../gstreamer/subprojects/gst-examples/webrtc/sendrecv/gst/webrtc_sendrecv.py", line 190, in <module>
    res = loop.run_until_complete(c.loop())
  File "/usr/lib64/python3.10/asyncio/base_events.py", line 641, in run_until_complete
    return future.result()
  File "/../gstreamer/subprojects/gst-examples/webrtc/sendrecv/gst/webrtc_sendrecv.py", line 155, in loop
    self.close_pipeline()
  File "/../gstreamer/subprojects/gst-examples/webrtc/sendrecv/gst/webrtc_sendrecv.py", line 142, in close_pipeline
    self.pipe.set_state(Gst.State.NULL)
AttributeError: 'NoneType' object has no attribute 'set_state'
```

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1832>
This commit is contained in:
Nirbheek Chauhan 2022-03-01 19:57:06 +05:30 committed by Tim-Philipp Müller
parent 4a36e32ff2
commit 4008e6d741

View file

@ -138,8 +138,9 @@ class WebRTCClient:
self.webrtc.emit('add-ice-candidate', sdpmlineindex, candidate)
def close_pipeline(self):
self.pipe.set_state(Gst.State.NULL)
self.pipe = None
if self.pipe:
self.pipe.set_state(Gst.State.NULL)
self.pipe = None
self.webrtc = None
async def loop(self):