Everyone On The Bus!
Written by
on .The Gstreamer framework is multi-threaded, which means it runs in a different thread (or many threads)... and thus you can not directly communicate with it via Python. Requests have to be sent to the pipeline, and they are completed as soon as possible. However, it goes both ways. When Gstreamer wants to communicate with your program, it must send messages through what they call a "bus".
Think of the bus as a signal. All you have to do in Python is create a signal handler method and connect it to the bus signal.
def on_message(self, bus, message):
self.bus = self.pipeline.get_bus()
self.bus.enable_sync_message_emission()
self.bus.add_signal_watch()
self.bus.connect('sync-message::element', self.on_sync_message)
self.bus.connect('message', self.on_message)
def on_message(self, bus, message):
print message
All sorts of interesting information is passed through the bus, such as:
- MP3 Tags: Artist, Album, Track, Genre, etc...
- Codec
- Bitrate
- and many more...