mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
examples/gstfile.py: Update gstfile example so that... it works :)
Original commit message from CVS: * examples/gstfile.py: Update gstfile example so that... it works :)
This commit is contained in:
parent
fc520c8a72
commit
6e384e2e97
2 changed files with 30 additions and 19 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2005-09-29 Edward Hervey <edward@fluendo.com>
|
||||||
|
|
||||||
|
* examples/gstfile.py:
|
||||||
|
Update gstfile example so that... it works :)
|
||||||
|
|
||||||
2005-09-29 Edward Hervey <edward@fluendo.com>
|
2005-09-29 Edward Hervey <edward@fluendo.com>
|
||||||
|
|
||||||
* gst/gst.defs:
|
* gst/gst.defs:
|
||||||
|
|
|
@ -116,6 +116,7 @@ class Discoverer(gst.Pipeline):
|
||||||
"""iterate on ourself to find the information on the given file"""
|
"""iterate on ourself to find the information on the given file"""
|
||||||
if self.finished:
|
if self.finished:
|
||||||
return
|
return
|
||||||
|
self.info("setting to PLAY")
|
||||||
if not self.set_state(gst.STATE_PLAYING):
|
if not self.set_state(gst.STATE_PLAYING):
|
||||||
# the pipeline wasn't able to be set to playing
|
# the pipeline wasn't able to be set to playing
|
||||||
self.finished = True
|
self.finished = True
|
||||||
|
@ -123,34 +124,35 @@ class Discoverer(gst.Pipeline):
|
||||||
bus = self.get_bus()
|
bus = self.get_bus()
|
||||||
while 1:
|
while 1:
|
||||||
if self.finished:
|
if self.finished:
|
||||||
#print "self.finished, stopping"
|
self.debug("self.finished, stopping")
|
||||||
break
|
break
|
||||||
msg = bus.poll(gst.MESSAGE_ANY, gst.SECOND)
|
msg = bus.poll(gst.MESSAGE_ANY, gst.SECOND)
|
||||||
if msg:
|
if not msg:
|
||||||
msg = bus.pop()
|
print "got empty message..."
|
||||||
else:
|
break
|
||||||
continue
|
#print "##", msg.type
|
||||||
if msg.type & gst.MESSAGE_STATE_CHANGED:
|
if msg.type & gst.MESSAGE_STATE_CHANGED:
|
||||||
#print "state changed", msg.src.get_name()
|
#print "## state changed\t", msg.src.get_name() ,
|
||||||
#print msg.parse_state_changed()
|
#print msg.parse_state_changed()
|
||||||
pass
|
pass
|
||||||
elif msg.type & gst.MESSAGE_EOS:
|
elif msg.type & gst.MESSAGE_EOS:
|
||||||
|
#print "EOS"
|
||||||
break
|
break
|
||||||
elif msg.type & gst.MESSAGE_TAG:
|
elif msg.type & gst.MESSAGE_TAG:
|
||||||
for key in msg.parse_tag().keys():
|
for key in msg.parse_tag().keys():
|
||||||
self.tags[key] = msg.structure[key]
|
self.tags[key] = msg.structure[key]
|
||||||
print msg.structure.to_string()
|
#print msg.structure.to_string()
|
||||||
elif msg.type & gst.MESSAGE_ERROR:
|
elif msg.type & gst.MESSAGE_ERROR:
|
||||||
print "whooops, error"
|
print "whooops, error", msg.parse_error()
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print "unknown message type"
|
print "unknown message type"
|
||||||
|
|
||||||
print "going to PAUSED"
|
# self.info( "going to PAUSED")
|
||||||
#self.set_state(gst.STATE_PAUSED)
|
self.set_state(gst.STATE_PAUSED)
|
||||||
print "going to ready"
|
# self.info("going to ready")
|
||||||
#self.set_state(gst.STATE_READY)
|
self.set_state(gst.STATE_READY)
|
||||||
print "now in ready"
|
# print "now in ready"
|
||||||
self.finished = True
|
self.finished = True
|
||||||
|
|
||||||
def print_info(self):
|
def print_info(self):
|
||||||
|
@ -205,7 +207,7 @@ class Discoverer(gst.Pipeline):
|
||||||
|
|
||||||
def _notify_caps_cb(self, pad, args):
|
def _notify_caps_cb(self, pad, args):
|
||||||
caps = pad.get_negotiated_caps()
|
caps = pad.get_negotiated_caps()
|
||||||
print "caps notify on", pad, ":", caps
|
# print "caps notify on", pad, ":", caps
|
||||||
if not caps:
|
if not caps:
|
||||||
return
|
return
|
||||||
# the caps are fixed
|
# the caps are fixed
|
||||||
|
@ -246,7 +248,7 @@ class Discoverer(gst.Pipeline):
|
||||||
def _new_decoded_pad_cb(self, dbin, pad, is_last):
|
def _new_decoded_pad_cb(self, dbin, pad, is_last):
|
||||||
# Does the file contain got audio or video ?
|
# Does the file contain got audio or video ?
|
||||||
caps = pad.get_caps()
|
caps = pad.get_caps()
|
||||||
print "new decoded pad", caps.to_string()
|
# print "new decoded pad", caps.to_string()
|
||||||
if "audio" in caps.to_string():
|
if "audio" in caps.to_string():
|
||||||
self.is_audio = True
|
self.is_audio = True
|
||||||
if caps.is_fixed():
|
if caps.is_fixed():
|
||||||
|
@ -267,13 +269,17 @@ class Discoverer(gst.Pipeline):
|
||||||
return
|
return
|
||||||
# we connect a fakesink to the new pad...
|
# we connect a fakesink to the new pad...
|
||||||
fakesink = gst.element_factory_make("fakesink")
|
fakesink = gst.element_factory_make("fakesink")
|
||||||
self.add(fakesink)
|
queue = gst.element_factory_make("queue")
|
||||||
|
self.add_many(fakesink, queue)
|
||||||
|
queue.link(fakesink)
|
||||||
sinkpad = fakesink.get_pad("sink")
|
sinkpad = fakesink.get_pad("sink")
|
||||||
|
queuepad = queue.get_pad("sink")
|
||||||
# ... and connect a callback for when the caps are fixed
|
# ... and connect a callback for when the caps are fixed
|
||||||
sinkpad.connect("notify::caps", self._notify_caps_cb)
|
sinkpad.connect("notify::caps", self._notify_caps_cb)
|
||||||
if pad.link(sinkpad):
|
if pad.link(queuepad):
|
||||||
print "##### Couldn't link pad to fakesink"
|
print "##### Couldn't link pad to queue"
|
||||||
#fakesink.set_state(gst.STATE_PLAYING)
|
queue.set_state(gst.STATE_PLAYING)
|
||||||
|
fakesink.set_state(gst.STATE_PLAYING)
|
||||||
|
|
||||||
def _found_tag_cb(self, dbin, source, tags):
|
def _found_tag_cb(self, dbin, source, tags):
|
||||||
self.tags.update(tags)
|
self.tags.update(tags)
|
||||||
|
|
Loading…
Reference in a new issue