Commit 9382e923 authored by Daniel Brötzmann's avatar Daniel Brötzmann
Browse files

Improve type annotations for video preview and gstreamer

parent e88c58ba
......@@ -231,8 +231,8 @@ def detect_dependencies() -> None:
conference = Gst.ElementFactory.make('fsrtpconference', None)
conference.new_session(Farstream.MediaType.AUDIO)
from gajim.gui.gstreamer import create_gtk_widget
sink, _, _ = create_gtk_widget()
if sink is not None:
gtk_widget = create_gtk_widget()
if gtk_widget is not None:
_dependencies['AV'] = True
except Exception as error:
log('gajim').warning('AV dependency test failed: %s', error)
......
......@@ -471,8 +471,10 @@ def _update_video(self) -> None:
self._ui.outgoing_viewport.set_no_show_all(True)
self._ui.outgoing_viewport.hide()
sink_other, self._video_widget_other, _name = create_gtk_widget()
sink_self, self._video_widget_self, _name = create_gtk_widget()
other_gtk_widget = create_gtk_widget()
self_gtk_widget = create_gtk_widget()
sink_other, self._video_widget_other, _name = other_gtk_widget
sink_self, self._video_widget_self, _name = self_gtk_widget
self._ui.incoming_viewport.add(self._video_widget_other)
self._ui.outgoing_viewport.add(self._video_widget_self)
......
......@@ -22,14 +22,14 @@
pass
def create_gtk_widget() -> Tuple[Optional[Gst.Element],
Optional[Gtk.Widget],
Optional[str]]:
def create_gtk_widget() -> Optional[Tuple[Gst.Element,
Gtk.Widget,
str]]:
gtkglsink = Gst.ElementFactory.make('gtkglsink', None)
if gtkglsink is not None:
glsinkbin = Gst.ElementFactory.make('glsinkbin', None)
if glsinkbin is None:
return None, None, None
return None
glsinkbin.set_property('sink', gtkglsink)
sink = glsinkbin
widget = gtkglsink.get_property('widget')
......@@ -37,7 +37,7 @@ def create_gtk_widget() -> Tuple[Optional[Gst.Element],
else:
sink = Gst.ElementFactory.make('gtksink', None)
if sink is None:
return None, None, None
return None
widget = sink.get_property('widget')
name = 'gtksink'
widget.set_visible(True)
......
......@@ -70,13 +70,14 @@ def _enable_preview(self) -> None:
self._set_error_text()
return
sink, widget, name = create_gtk_widget()
if sink is None:
gtk_widget = create_gtk_widget()
if gtk_widget is None:
log.error('Failed to obtain a working Gstreamer GTK+ sink, '
'video support will be disabled')
self._set_error_text()
return
sink, widget, name = gtk_widget
self._set_sink_text(name)
if self._av_pipeline is None:
......@@ -94,6 +95,7 @@ def _enable_preview(self) -> None:
self._ui.video_preview_box.pack_end(widget, True, True, 0)
self._av_widget = widget
assert self._av_src is not None
self._av_pipeline.add(self._av_src)
self._av_src.link(self._av_sink)
self._av_pipeline.set_state(Gst.State.PLAYING)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment