Lack of GstMiniObject means Gst.Message is broken, can't get EOS signal

Bug #873712 reported by Jason Gerard DeRose on 2011-10-13
24
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Novacut
High
Unassigned
pygobject
Confirmed
Medium
pygobject (Ubuntu)
Undecided
Unassigned

Bug Description

It's almost possible to use GStreamer from PyGI. The hang up is that currently you can't get EOS signals from a pipeline, and that the message bus is overall broken.

As far as I know, this is because pygobject doesn't grok the GstMiniObject type, which mean Gst.Message is an unknown type. There is an upstream bug with a patch (work in progress):

https://bugzilla.gnome.org/show_bug.cgi?id=631901

I'm not sure if this would be too invasive a change to deliver to Oneiric users through a SRU, but this would help smooth the transition to PyGI (and possibly only shipping Python3 on the CD) for Precise as app devs could be working with PyGI and GStreamer right now on Oneiric.

For what it's worth, this would really help Novacut. Either way, lets make sure PyGI + GStreamer rocks in Precise!

(Side note: this also raises a question... GStreamer 0.10 or 1.0 in Precise?)

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: python3-gobject 3.0.0-0ubuntu2
ProcVersionSignature: Ubuntu 3.0.0-12.20-generic 3.0.4
Uname: Linux 3.0.0-12-generic x86_64
ApportVersion: 1.23-0ubuntu3
Architecture: amd64
Date: Thu Oct 13 15:24:09 2011
EcryptfsInUse: Yes
InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Beta amd64 (20110921.2)
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: pygobject
UpgradeStatus: No upgrade log present (probably fresh install)

Jason Gerard DeRose (jderose) wrote :
Jason Gerard DeRose (jderose) wrote :

I consider this a good test case for this bug. Same problem whether you use Python2 or Python3 (but for Novacut, we care about Python3). Currently this script will fail with:

TypeError: unknown type GstMessage

#!/usr/bin/python3

from gi.repository import GObject
GObject.threads_init()

from gi.repository import Gst
Gst.init(None)

mainloop = GObject.MainLoop()
pipeline = Gst.Pipeline()

def on_eos(bus, msg):
    print('eos: {!r}'.format(msg))
    pipeline.set_state(gst.STATE_NULL)
    mainloop.quit()

def on_message(bus, msg):
    print('message: {!r}'.format(msg))

bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect('message::eos', on_eos)
bus.connect('message', on_message)

bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect('message::eos', on_eos)

src = Gst.ElementFactory.make('videotestsrc', None)
src.set_property('num-buffers', 10)
sink = Gst.ElementFactory.make('fakesink', None)
pipeline.add(src)
pipeline.add(sink)
src.link(sink)

pipeline.set_state(Gst.State.PLAYING)
mainloop.run()

Changed in pygobject:
importance: Unknown → Medium
status: Unknown → Confirmed
Changed in novacut:
importance: Undecided → High
status: New → Triaged
milestone: none → 11.10
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in pygobject (Ubuntu):
status: New → Confirmed
ChristianSchaller (uraeus) wrote :

Tried this in GStreamer 0.11 and apart from having to change gst.STATE_NULL to Gst.State.NULL, it seems to work fine there :)

Changed in novacut:
milestone: 11.10 → 11.11
Martin Pitt (pitti) on 2011-10-31
Changed in pygobject (Ubuntu):
status: Confirmed → Triaged
Changed in novacut:
milestone: 11.11 → 12.01
Changed in novacut:
milestone: 12.01 → 12.02
Changed in novacut:
milestone: 12.02 → 12.03
Changed in novacut:
milestone: 12.03 → none
Martin Pitt (pitti) wrote :

Just a note, gstreamer 0.10 works very poorly with GI. This has been worked on in gstreamer 0.11 git head, where it works reasonably well, but there is no chance that this will ever work in 0.10. Please use the static bindings in the python-gst0.10 package.

Jason Gerard DeRose (jderose) wrote :

Martin,

Yeah, I haven't updated this bug for a while... I marked it as "invalid" for Ubuntu as this isn't an issue that gstreamer or python-gi can really fix anyway in 0.10.

I've had great luck so far with gstreamer 0.11 and PyGI, and using Python3 to top it off.

Thanks!

Changed in novacut:
status: Triaged → Won't Fix
Changed in pygobject (Ubuntu):
status: Triaged → Invalid
Angel Guzman Maeso (shakaran) wrote :

Actually this issue with message::eos and other messages is fixed with Gstreamer 1.0 aka currently as Gstreamer 0.11.91-2 on Ubuntu 12.10 (note you need previously install gstreamer1.0 packages).

You can verify this with this slightly modified code:

#!/usr/bin/python3

from gi.repository import GObject
GObject.threads_init()

import gi
try:
    gi.require_version('Gst', '1.0')
except ValueError:
    print 'Could not find required Gstreamer 1.0 library.'
    sys.exit(1)

from gi.repository import Gst

Gst.init(None)

mainloop = GObject.MainLoop()
pipeline = Gst.Pipeline()

def on_eos(bus, msg):
    print('eos: {!r}'.format(msg))
    pipeline.set_state(Gst.State.NULL)
    mainloop.quit()

def on_message(bus, msg):
    print('message: {!r}'.format(msg))

bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect('message::eos', on_eos)
bus.connect('message', on_message)

bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect('message::eos', on_eos)

src = Gst.ElementFactory.make('videotestsrc', None)
src.set_property('num-buffers', 10)
sink = Gst.ElementFactory.make('fakesink', None)
pipeline.add(src)
pipeline.add(sink)
src.link(sink)

pipeline.set_state(Gst.State.PLAYING)
mainloop.run()

Could fix be backported? Something abnormal is that we can not use python+gtk3+gstreamer on our pixel-perfect release...

Jason Gerard DeRose (jderose) wrote :

Oleg,

As far as I know, this fix can't be backported. I don't think it's possible to properly support GstMiniObject because it wasn't designed with introspection in mind (remember, the GStreamer 0.10 API is almost 7 years old now). I don't believe it's possible to fix this without breaking the 0.10 API. And this is just one of many issues that make it impossible to fully use GStreamer 0.10 from PyGI.

However, I imagine that GStreamer 1.0 will be made available through at least precise-backports. As it's parallel installable with GStreamer 0.10, it's quite safe to backport as it wont effect any existing 0.10 using applications. I think a case could be made for even backporting GStreamer 1.0 packages into Universe, but I don't know what the policy is there.

Anyway, I agree it's a bummer that Python + Gtk3 + GStreamer isn't usable in Precise. But g-i and PyGI are big transitions, and these things just take time.

If you want to start porting your app, there are GStreamer 1.0 packages in Quantal and there are packages for Precise in the GStreamer dev PPA (also in the Novacut stable PPA now):

https://wiki.ubuntu.com/Novacut/GStreamer1.0

Cheers!

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.