Re: Callbacks with GStreamer1

Sorry, I was happy with fixing the error message, didn't notice that it didn't work.

This works :
$bus->signal_connect('message::error' => sub {warn "error"; exit});

Other signals should work too, as I use them in my program.
Though, speaking of gstreamer errors, $msg->parse_error doesn't work currently (last time I've checked) so I found this work around :
$bus->signal_connect('message::error' => \&error);
sub error
{    my ($bus,$msg)= _;
    #warn $msg->parse_error; # doesn't work : FIXME - GI_TYPE_TAG_ERROR
    my $s=$msg->get_structure;
    warn $s->get_value('gerror')->message;
    #more details
    warn $s->get_string('debug');

On Wed, Jul 8, 2015 at 1:42 AM, Timm Murray <tmurray wumpus-cave net> wrote:
Thanks for your help, Quentin.  Doing add_signal_watch() does prevent the error from occurring, but it also seems that the callback is not actually set.  Using GST_DEBUG reveals:

$ GST_DEBUG=3 perl
0:00:00.046825784  2484      0x2702b50 ERROR                GST_BUS gstbus.c:851:gst_bus_add_watch_full_unlocked:<bus1> Tried to add new watch while one was already there

This is not a fatal error, but it seems that add_signal_watch() sets a generic handler, and add_watch() is not allowed to set a new one after that.

I happened across a Python example that suggests that using connect() is the answer:

But when I added that instead of add_watch():

    $bus->connect( 'message::element', \&bus_callback, $loop );

It resulted in:

    Can't locate object method "connect" via package "GStreamer1::Bus"

Going by the inheritance from the C API docs, I would expect connect() to be there for Bus, but perhaps not for the Perl bindings.

On Mon, Jun 22, 2015 at 7:34 PM, Quentin Sculo <squentin free fr> wrote:
In case you still haven't found the solution, adding this line before the add_watch fixes the error :

On Sat, Jun 20, 2015 at 5:31 PM, Timm Murray <tmurray wumpus-cave net> wrote:
I'm trying to pass along a code reference to add_watch() (from of GstBus).  My attempt, which is based on the examples in the old GStreamer module, is below.  It fails with the message:

    Not a CODE reference at line 17.

Which is the "$loop->run" line.  Is there some incantation that needs to run on GStreamer1 for the callback reference to be accepted?

Timm Murray

use v5.12;
use warnings;
use GStreamer1;
use Glib qw( TRUE FALSE );

my $URI = shift || die "Need URI to play\n";

my $loop = Glib::MainLoop->new( undef, FALSE );
GStreamer1::init([ $0, @ARGV ]);
my $pipeline = GStreamer1::parse_launch( "playbin uri=$URI" );

my $bus = $pipeline->get_bus;
$bus->add_watch( \&bus_callback, $loop );

$pipeline->set_state( "playing" );
$pipeline->set_state( "null" );

sub bus_callback
    my ($bus, $message, $loop) = @_;

    if( $message->type & "error" ) {
        warn $message->error;
    elsif( $message->type & "eos" ) {

    return TRUE;

gtk-perl-list mailing list
gtk-perl-list gnome org

gtk-perl-list mailing list
gtk-perl-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]