GStreamer and Gtk3



Hi,

I'm trying to write a Gtk3 application in Perl that would show a number of
videos. To do so, I've written the following:

---
package Gsw::Media::Player;

use strict;
use warnings;

use GStreamer -init;
use GStreamer::Interfaces;

use base "GStreamer::Element";

sub bus_call {
        my ($bus, $msg, $self) = @_;
        
        print $msg->type . "\n";

        if($msg->type & "element") {
                print "foo\n";
                if(defined($self->{inited})) {
                        return;
                }
                my $win = $self->{widget}->get_parent_window();
                $self->{sink}->set_xwindow_id($win->get_xid());
                $self->{sink}->set("force-aspect-ratio", 1);
                print "bar\n";
        }
}

sub new {
        my $class = shift;
        my $widget = shift;
        my $name = shift;

        my $self = {};

        $self->{widget} = $widget;

        my $rgba = Gtk3::Gdk::RGBA->new;
        $rgba->parse("black");
        $widget->override_background_color("normal", $rgba);

        my $pipe = GStreamer::Pipeline->new($name);

        $pipe->get_bus()->add_watch(\&bus_call, $widget);
        my $src = GStreamer::ElementFactory->make("videotestsrc", "source");
        my $sink = GStreamer::ElementFactory->make("xvimagesink", "videosink");
        my $win = $widget->get_parent_window();
        $pipe->add($src, $sink);
        $self->{sink} = $sink;
        $self->{pipe} = $pipe;

        bless $self, $class;

        $widget->signal_connect_swapped("realize", \&start, $self);

        return $self;
}

sub start {
        my $self = shift;

        $self->{pipe}->set_state('playing');
}

1;
---

The idea is to do something like

$widget = Gtk3::DrawingArea->new();
[...place it inside a window somewhere...]
Gsw::Media::Player->new($widget, "preview");
Gtk3->main();

and that then a video starts playing (currently "just" the test source, but
eventually obviously that would be something else)

Unfortunately, this doesn't work, and I can't figure out what the issue is. The
program currently outputs the following:

[ unknown state-changed ]
Argument "[ unknown ]" isn't numeric in subroutine entry at /usr/share/perl5/Gtk3.pm line 318.

Both lines are output by the bus_call sub. The first is the msg->type thing;
the second one is (I believe) the 'msg->type & "element"' line.

I've been pouring over documentation and a bunch of examples that I've
found, but so far without luck.

Any hints as to what I'm doing wrong?

-- 
Wouter Verhelst
NixSys BVBA
M: +32 486 836 198


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