[pitivi] Check what videosink is useable as soon as possible
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Check what videosink is useable as soon as possible
- Date: Wed, 23 Sep 2015 08:16:05 +0000 (UTC)
commit 0f8e8a91b7eb94618071df9c4d748f982065cec2
Author: Thibault Saunier <tsaunier gnome org>
Date: Mon Sep 21 18:51:17 2015 +0200
Check what videosink is useable as soon as possible
pitivi/check.py | 34 +++++++++++++++++++++++++++++++---
pitivi/utils/pipeline.py | 40 +++++++---------------------------------
2 files changed, 38 insertions(+), 36 deletions(-)
---
diff --git a/pitivi/check.py b/pitivi/check.py
index ea6e8e6..b7d880c 100644
--- a/pitivi/check.py
+++ b/pitivi/check.py
@@ -38,6 +38,7 @@ import sys
from gettext import gettext as _
missing_soft_deps = {}
+videosink_factory = None
def _version_to_string(version):
@@ -197,11 +198,38 @@ def _check_audiosinks():
def _check_videosink():
from gi.repository import Gst
+ from gi.repository import Gdk
+ from gi.repository import GObject
+
+ 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
+
# 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):
+ sink = Gst.ElementFactory.make("gtkglsink", None)
+ if not sink:
+ sink = Gst.ElementFactory.make("gtksink", None)
+ if not sink:
return False
- return True
+
+ if sink.set_state(Gst.State.READY) == Gst.StateChangeReturn.SUCCESS:
+ global videosink_factory
+ videosink_factory = sink.get_factory()
+ else:
+ sink = Gst.ElementFactory.make("gtksink", None)
+ videosink_factory = sink.get_factory()
+
+ sink.set_state(Gst.State.NULL)
+
+ if videosink_factory:
+ return True
+ return False
def _check_gst_python():
diff --git a/pitivi/utils/pipeline.py b/pitivi/utils/pipeline.py
index 4022d46..e59e530 100644
--- a/pitivi/utils/pipeline.py
+++ b/pitivi/utils/pipeline.py
@@ -35,6 +35,7 @@ from gi.repository import GES
from pitivi.utils.loggable import Loggable
from pitivi.utils.misc import format_ns
+from pitivi.check import videosink_factory
PIPELINE_SIGNALS = {
@@ -169,8 +170,6 @@ class SimplePipeline(GObject.Object, Loggable):
__gsignals__ = PIPELINE_SIGNALS
- use_glsink = None
-
class RecoveryState(object):
NOT_RECOVERING = "not-recovering"
STARTED_RECOVERING = "started-recovering"
@@ -198,40 +197,15 @@ class SimplePipeline(GObject.Object, Loggable):
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():
+ sink = Gst.ElementFactory.make(videosink_factory.get_name(), None)
+ if videosink_factory.get_name() == "gtksink":
self.info("Using gtksink")
- return Gst.ElementFactory.make("gtksink", None)
+ return sink
- sink = Gst.ElementFactory.make("glsinkbin", None)
- sink.props.sink = Gst.ElementFactory.make("gtkglsink", None)
- return sink
+ sinkbin = Gst.ElementFactory.make("glsinkbin", None)
+ sinkbin.props.sink = sink
+ return sinkbin
def setSink(self, sink):
self.video_sink = sink
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]