[pitivi] viewer: Allow using gtksink when gtkglsink is not accessible
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] viewer: Allow using gtksink when gtkglsink is not accessible
- Date: Sat, 19 Sep 2015 10:50:07 +0000 (UTC)
commit 43d22f14481f9cb16ffed8e852f484c8f8288a44
Author: Thibault Saunier <tsaunier gnome org>
Date: Sat Sep 19 10:40:51 2015 +0200
viewer: Allow using gtksink when gtkglsink is not accessible
Fixes T3305
pitivi/check.py | 14 ++++++++++++++
pitivi/utils/pipeline.py | 38 +++++++++++++++++++++++++++++++++++++-
pitivi/viewer.py | 8 +++++---
3 files changed, 56 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/check.py b/pitivi/check.py
index 6548aae..ea6e8e6 100644
--- a/pitivi/check.py
+++ b/pitivi/check.py
@@ -195,6 +195,15 @@ def _check_audiosinks():
return True
+def _check_videosink():
+ from gi.repository import Gst
+ # Yes, this can still fail, if PulseAudio is non-responsive for example.
+ if not Gst.ElementFactory.make("gtkglsink", None):
+ if not Gst.ElementFactory.make("gtksink", None):
+ return False
+ return True
+
+
def _check_gst_python():
from gi.repository import Gst
try:
@@ -246,6 +255,11 @@ def check_requirements():
"Make sure you have a valid one (pulsesink, alsasink or osssink).")))
return False
+ if not _check_videosink():
+ print((_("Could not create video output sink. "
+ "Make sure you have a gtksink avalaible.")))
+ return False
+
return True
diff --git a/pitivi/utils/pipeline.py b/pitivi/utils/pipeline.py
index c74f4cf..4022d46 100644
--- a/pitivi/utils/pipeline.py
+++ b/pitivi/utils/pipeline.py
@@ -27,6 +27,7 @@ High-level pipelines
import os
+from gi.repository import Gdk
from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gst
@@ -168,6 +169,8 @@ class SimplePipeline(GObject.Object, Loggable):
__gsignals__ = PIPELINE_SIGNALS
+ use_glsink = None
+
class RecoveryState(object):
NOT_RECOVERING = "not-recovering"
STARTED_RECOVERING = "started-recovering"
@@ -193,9 +196,42 @@ class SimplePipeline(GObject.Object, Loggable):
self._timeout_async_id = 0
self._force_position_listener = False
+ self.setSink(self.createSink())
+
+ def __canUseGlSink(self):
+ if SimplePipeline.use_glsink is not None:
+ return SimplePipeline.use_glsink
+
+ try:
+ if GObject.type_is_a(Gdk.Display.get_default().__gtype__,
+ GObject.type_from_name("GdkBroadwayDisplay")):
+ SimplePipeline.use_glsink = False
+
+ return SimplePipeline.use_glsink
+ except RuntimeError:
+ # GdkBroadwayDisplay not available
+ pass
+
+ glsink = Gst.ElementFactory.make("gtkglsink", None)
+ if glsink:
+ if glsink.set_state(Gst.State.READY) == Gst.StateChangeReturn.SUCCESS:
+ SimplePipeline.use_glsink = True
+ else:
+ SimplePipeline.use_glsink = False
+ glsink.set_state(Gst.State.NULL)
+ else:
+ SimplePipeline.use_glsink = False
+
+ return SimplePipeline.use_glsink
+
+ def createSink(self):
+ if not self.__canUseGlSink():
+ self.info("Using gtksink")
+ return Gst.ElementFactory.make("gtksink", None)
+
sink = Gst.ElementFactory.make("glsinkbin", None)
sink.props.sink = Gst.ElementFactory.make("gtkglsink", None)
- self.setSink(sink)
+ return sink
def setSink(self, sink):
self.video_sink = sink
diff --git a/pitivi/viewer.py b/pitivi/viewer.py
index 1c05269..aa816a8 100644
--- a/pitivi/viewer.py
+++ b/pitivi/viewer.py
@@ -135,8 +135,7 @@ class ViewerContainer(Gtk.Box, Loggable):
self.pipeline.pause()
def __createNewViewer(self):
- self.sink = Gst.ElementFactory.make("glsinkbin", None)
- self.sink.props.sink = Gst.ElementFactory.make("gtkglsink", None)
+ self.sink = self.pipeline.createSink()
self.pipeline.setSink(self.sink)
self.target = ViewerWidget(self.sink, self.app)
@@ -598,7 +597,10 @@ class ViewerWidget(Gtk.AspectFrame, Loggable):
self.__transformationBox = TransformationBox(app)
# We only work with a gtkglsink inside a glsinkbin
- self.drawing_area = sink.props.sink.props.widget
+ try:
+ self.drawing_area = sink.props.sink.props.widget
+ except AttributeError:
+ self.drawing_area = sink.props.widget
# We keep the ViewerWidget hidden initially, or the desktop wallpaper
# would show through the non-double-buffered widget!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]