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.It resulted in:But when I added that instead of add_watch():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 example.pl
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 thereThis 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:
https://github.com/Elleo/gst-opencv/blob/master/examples/python/facedetect.py
$bus->connect( 'message::element', \&bus_callback, $loop );
Can't locate object method "connect" via package "GStreamer1::Bus"On Mon, Jun 22, 2015 at 7:34 PM, Quentin Sculo <squentin free fr> wrote:Hi,In case you still haven't found the solution, adding this line before the add_watch fixes the error :
$bus->add_signal_watch;On Sat, Jun 20, 2015 at 5:31 PM, Timm Murray <tmurray wumpus-cave net> wrote:_______________________________________________Timm MurrayThanks,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:Which is the "$loop->run" line. Is there some incantation that needs to run on GStreamer1 for the callback reference to be accepted?
Not a CODE reference at hello_callback.pl line 17.
#!perl
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" );
$loop->run;
$pipeline->set_state( "null" );
sub bus_callback
{
my ($bus, $message, $loop) = @_;
if( $message->type & "error" ) {
warn $message->error;
$loop->quit;
}
elsif( $message->type & "eos" ) {
$loop->quit;
}
return TRUE;
}
gtk-perl-list mailing list
gtk-perl-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list