[pitivi] Try to expose singledecodebin pads when they get fixed caps.
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pitivi] Try to expose singledecodebin pads when they get fixed caps.
- Date: Wed, 12 Aug 2009 14:21:03 +0000 (UTC)
commit c85305aebf854bb58cbe659810d193f33a1cc72c
Author: Alessandro Decina <alessandro d gmail com>
Date: Tue Aug 11 21:15:51 2009 +0200
Try to expose singledecodebin pads when they get fixed caps.
pitivi/elements/singledecodebin.py | 46 +++++++++++++++++++++++++++++++++++-
1 files changed, 45 insertions(+), 1 deletions(-)
---
diff --git a/pitivi/elements/singledecodebin.py b/pitivi/elements/singledecodebin.py
index c93f6e2..7b971bc 100644
--- a/pitivi/elements/singledecodebin.py
+++ b/pitivi/elements/singledecodebin.py
@@ -89,6 +89,8 @@ class SingleDecodeBin(gst.Bin):
self.debug("stream:%r" % self.stream)
+ self.pending_newsegment = False
+ self.eventProbeId = None
## internal methods
@@ -283,12 +285,54 @@ class SingleDecodeBin(gst.Bin):
return
self._markValidElements(element)
gobject.idle_add(self._removeUnusedElements, self.typefind)
- self.log("ghosting pad %s" % pad.get_name())
+ if pad.props.caps is not None:
+ caps = pad.props.caps
+ else:
+ caps = pad.get_caps()
+
self._srcpad = gst.GhostPad("src", pad)
self._srcpad.set_active(True)
+
+ if caps.is_fixed():
+ self._exposePad(target=pad)
+ else:
+ self._blockPad(target=pad)
+
+ def _exposePad(self, target):
+ self.log("ghosting pad %s" % target.get_name())
self.add_pad(self._srcpad)
self.post_message(gst.message_new_state_dirty(self))
+ def _blockPad(self, target):
+ self._eventProbeId = target.add_event_probe(self._padEventCb)
+ self._srcpad.set_blocked_async(True, self._padBlockedCb, target)
+
+ def _unblockPad(self, target):
+ target.remove_event_probe(self._eventProbeId)
+ self._eventProbeId = None
+ self._srcpad.set_blocked_async(False, self._padBlockedCb, target)
+
+ def _padBlockedCb(self, ghost, blocked, target):
+ if not blocked:
+ if self.pending_newsegment is not None:
+ self._srcpad.push_event(self.pending_newsegment)
+ self.pending_newsegment = None
+ return
+
+ self._exposePad(target=target)
+ self._unblockPad(target=target)
+
+ def _padEventCb(self, pad, event):
+ if event.type != gst.EVENT_NEWSEGMENT:
+ self.warning("first event: %s is not a NEWSEGMENT, bailing out" %
+ event)
+ self._exposePad(target=pad)
+ self._unblockPad(target=pad)
+ return True
+
+ self.pending_newsegment = event
+ return False
+
def _markValidElements(self, element):
"""
Mark this element and upstreams as valid
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]