webrtc_sendrecv.py: Fix PEP8 warnings in CI lint

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3742>
This commit is contained in:
Nirbheek Chauhan 2023-01-18 07:38:51 +05:30 committed by GStreamer Marge Bot
parent 6a83602601
commit 32e8ff4e2a

View file

@ -6,6 +6,10 @@
# Demo gstreamer app for negotiating and streaming a sendrecv webrtc stream # Demo gstreamer app for negotiating and streaming a sendrecv webrtc stream
# with a browser JS app, implemented in Python. # with a browser JS app, implemented in Python.
from websockets.version import version as wsv
from gi.repository import GstSdp
from gi.repository import GstWebRTC
from gi.repository import Gst
import random import random
import ssl import ssl
import websockets import websockets
@ -17,11 +21,8 @@ import argparse
import gi import gi
gi.require_version('Gst', '1.0') gi.require_version('Gst', '1.0')
from gi.repository import Gst
gi.require_version('GstWebRTC', '1.0') gi.require_version('GstWebRTC', '1.0')
from gi.repository import GstWebRTC
gi.require_version('GstSdp', '1.0') gi.require_version('GstSdp', '1.0')
from gi.repository import GstSdp
# Ensure that gst-python is installed # Ensure that gst-python is installed
try: try:
@ -53,8 +54,6 @@ PIPELINE_DESC = {
'VP8': PIPELINE_DESC_VP8, 'VP8': PIPELINE_DESC_VP8,
} }
from websockets.version import version as wsv
def print_status(msg): def print_status(msg):
print(f'--- {msg}') print(f'--- {msg}')
@ -159,7 +158,7 @@ class WebRTCClient:
self.send_soon(msg) self.send_soon(msg)
def on_offer_created(self, promise, _, __): def on_offer_created(self, promise, _, __):
assert(promise.wait() == Gst.PromiseResult.REPLIED) assert promise.wait() == Gst.PromiseResult.REPLIED
reply = promise.get_reply() reply = promise.get_reply()
offer = reply['offer'] offer = reply['offer']
promise = Gst.Promise.new() promise = Gst.Promise.new()
@ -235,7 +234,7 @@ class WebRTCClient:
self.pipe.set_state(Gst.State.PLAYING) self.pipe.set_state(Gst.State.PLAYING)
def on_answer_created(self, promise, _, __): def on_answer_created(self, promise, _, __):
assert(promise.wait() == Gst.PromiseResult.REPLIED) assert promise.wait() == Gst.PromiseResult.REPLIED
reply = promise.get_reply() reply = promise.get_reply()
answer = reply['answer'] answer = reply['answer']
promise = Gst.Promise.new() promise = Gst.Promise.new()
@ -244,7 +243,7 @@ class WebRTCClient:
self.send_sdp(answer) self.send_sdp(answer)
def on_offer_set(self, promise, _, __): def on_offer_set(self, promise, _, __):
assert(promise.wait() == Gst.PromiseResult.REPLIED) assert promise.wait() == Gst.PromiseResult.REPLIED
promise = Gst.Promise.new_with_change_func(self.on_answer_created, None, None) promise = Gst.Promise.new_with_change_func(self.on_answer_created, None, None)
self.webrtc.emit('create-answer', None, promise) self.webrtc.emit('create-answer', None, promise)
@ -270,17 +269,17 @@ class WebRTCClient:
if not self.webrtc: if not self.webrtc:
print_status('Incoming call: received an offer, creating pipeline') print_status('Incoming call: received an offer, creating pipeline')
pts = get_payload_types(sdpmsg, video_encoding=self.video_encoding, audio_encoding='OPUS') pts = get_payload_types(sdpmsg, video_encoding=self.video_encoding, audio_encoding='OPUS')
assert(self.video_encoding in pts) assert self.video_encoding in pts
assert('OPUS' in pts) assert 'OPUS' in pts
self.start_pipeline(create_offer=False, video_pt=pts[self.video_encoding], audio_pt=pts['OPUS']) self.start_pipeline(create_offer=False, video_pt=pts[self.video_encoding], audio_pt=pts['OPUS'])
assert(self.webrtc) assert self.webrtc
offer = GstWebRTC.WebRTCSessionDescription.new(GstWebRTC.WebRTCSDPType.OFFER, sdpmsg) offer = GstWebRTC.WebRTCSessionDescription.new(GstWebRTC.WebRTCSDPType.OFFER, sdpmsg)
promise = Gst.Promise.new_with_change_func(self.on_offer_set, None, None) promise = Gst.Promise.new_with_change_func(self.on_offer_set, None, None)
self.webrtc.emit('set-remote-description', offer, promise) self.webrtc.emit('set-remote-description', offer, promise)
elif 'ice' in msg: elif 'ice' in msg:
assert(self.webrtc) assert self.webrtc
ice = msg['ice'] ice = msg['ice']
candidate = ice['candidate'] candidate = ice['candidate']
sdpmlineindex = ice['sdpMLineIndex'] sdpmlineindex = ice['sdpMLineIndex']