File: bus.pl

package info (click to toggle)
libgstreamer-perl 0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 900 kB
  • ctags: 59
  • sloc: perl: 2,456; ansic: 32; makefile: 6
file content (35 lines) | stat: -rw-r--r-- 706 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl
use strict;
use warnings;
use Glib qw(TRUE FALSE);
use GStreamer;

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

  if ($message -> type & "error") {
    warn $message -> error;
    $loop -> quit();
  }

  elsif ($message -> type & "eos") {
    $loop -> quit();
  }

  # remove message from the queue
  return TRUE;
}

# init
GStreamer -> init();

# create pipeline, add handler
my $pipeline = GStreamer::Pipeline -> new("my_pipeline");

my $loop = Glib::MainLoop -> new(undef, FALSE);

$pipeline -> get_bus() -> add_watch(\&my_bus_callback, $loop);

# in the mainloop, all messages posted to the bus by the pipeline
# will automatically be sent to our callback.
$loop -> run();