Permalink
Browse files

add support for gstreamer-1.x and small gstreamer updates/improvements

gstreamer-1.x requires Glib::Object::Introspection and the gstreamer introspection data (Gst-1.0.typelib)
Only one of gstreamer-1.x and gstreamer-0.10 can be loaded at the same time
Will prefer 1.x, unless the option -gst0 is used
The option -nogst will now disable loading gstreamer entirely, and the option -gst has been removed
Can now ask the system to install missing gstreamer-1.x plugins
  • Loading branch information...
squentin committed Jan 31, 2015
1 parent ba6ed71 commit fe20c1a4c79fa2be60065acaeee258825cc90011
View
@@ -9,8 +9,8 @@ Standards-Version: 3.7.3
Package: gmusicbrowser
Architecture: all
Depends: perl, libgtk2-perl, libgtk2.0-0 (>= 2.6)
Recommends: libintl-perl, libnet-dbus-perl, libgstreamer-perl, libdigest-crc-perl, libcairo-perl, libhtml-parser-perl, libio-compress-perl
Suggests: mplayer, mpg321, vorbis-tools, alsa-utils, libgtk2-mozembed-perl, libgstreamer-interfaces-perl, libgtk2-notify-perl, libgnome2-wnck-perl, poppler-utils
Recommends: libintl-perl, libnet-dbus-perl, libglib-object-introspection-perl, gir1.2-gstreamer-1.0, libdigest-crc-perl, libcairo-perl, libhtml-parser-perl, libio-compress-perl
Suggests: mplayer, mpg321, vorbis-tools, alsa-utils, libgtk2-mozembed-perl, libgstreamer-perl, libgtk2-notify-perl, libgnome2-wnck-perl, poppler-utils
Description: very customizable jukebox for large collections of music files
The interface is extremely customizable. It has easy access to related songs
(same artist/album/title), supports multiple genres per song, ratings, and
View
@@ -12,7 +12,7 @@ gmusicbrowser \- Jukebox for large collections of music files
[\-rotags]
[\-play]
[\-nodbus]
[\-gst|\-nogst]
[\-gst0|\-nogst]
[\-server]
[\-port N]
[\-cfg FILE]
@@ -66,11 +66,11 @@ prevent modifying tags of music files
\fB\-play\fR
start playing on startup
.TP
\fB\-gst\fR
use gstreamer
.TP
\fB\-nogst\fR
do not use gstreamer
do not load any gstreamer librairies
.TP
\fB\-gst0\fR
prefer gstreamer\-0.10 over gstreamer\-1.x if both are available
.TP
\fB\-nodbus\fR
do not use DBus
View
@@ -254,8 +254,8 @@ BEGIN
-ro : prevent modifying/renaming/deleting song files
-rotags : prevent modifying tags of music files
-play : start playing on startup
-gst : use gstreamer
-nogst : do not use gstreamer
-gst0 : prefer gstreamer-0.10 over gstreamer-1.x if both are available
-nogst : do not load any gstreamer librairies
-server : send playing song to connected icecast clent
-port N : listen for connection on port N in icecast server mode
-verbose: print some info, like the file being played
@@ -301,7 +301,6 @@ BEGIN
-listlayout : list the available layouts and exit
";
unshift @ARGV,'-tagedit' if $0=~m/tagedit/;
$CmdLine{gst}=0;
my (@files,$filescmd,@cmd,$ignore);
my $ifnotrunning='normal';
while (defined (my $arg=shift))
@@ -312,8 +311,8 @@ BEGIN
elsif($arg eq '-hide') {$CmdLine{hide}=1}
elsif($arg eq '-server') {$CmdLine{server}=1}
elsif($arg eq '-nodbus') {$CmdLine{noDBus}=1}
elsif($arg eq '-nogst') {$CmdLine{gst}=0}
elsif($arg eq '-gst') {$CmdLine{gst}=1}
elsif($arg eq '-nogst') {$CmdLine{nogst}=1}
elsif($arg eq '-gst0') {$CmdLine{gst0}=1} #prefer gstreamer-0.10
elsif($arg eq '-ro') {$CmdLine{ro}=$CmdLine{rotags}=1}
elsif($arg eq '-rotags') {$CmdLine{rotags}=1}
elsif($arg eq '-port') {$CmdLine{port}=shift if $ARGV[0]}
@@ -429,6 +428,7 @@ BEGIN
# end of command line handling
our $HTTP_module;
our ($Play_package,%PlayPacks); my ($PlayNext_package,$Vol_package);
BEGIN{
require 'gmusicbrowser_songs.pm';
require 'gmusicbrowser_tags.pm';
@@ -439,7 +439,33 @@ BEGIN
'simple_http.pm';
#warn "using $HTTP_module for http requests\n";
#require $HTTP_module;
$TempDir= Glib::get_tmp_dir.SLASH; _utf8_off($TempDir); #turn utf8 flag off to not auto-utf8-upgrade other filenames in the same strings
# load gstreamer backend module
if (!$CmdLine{nogst})
{ my @gst= ('gmusicbrowser_gstreamer-1.x.pm', 'gmusicbrowser_gstreamer-0.10.pm');
my $error;
@gst= reverse @gst if $CmdLine{gst0};
{ my $file= shift @gst;
eval { require $file; }; #each file sets $::PlayPacks{PACKAGENAME} to 1 for each of its included playback packages
if ($@)
{ warn $@ if $::debug;
if (@gst) {$error=$@; redo unless $::gstreamer_version} # keep first error message, try next file unless parts already loaded
$error=~s/\n.*//s; #only keep first line, others are noise
my $error0= "Can't load either gstreamer-1.x (via Glib::Object::Introspection) or gstreamer-0.10 (via GStreamer)";
if (@gst) { $error0= "Error loading gstreamer-$::gstreamer_version" }
warn "\n$error0 -> gstreamer output won't be available :\n $error\n\n";
}
warn "Using gstreamer-.$::gstreamer_version.\n" if $::debug;
}
}
# load non-gstreamer backend modules
for my $file (qw/gmusicbrowser_123.pm gmusicbrowser_mplayer.pm gmusicbrowser_server.pm/)
{ eval { require $file } || warn $@; #each file sets $::PlayPacks{PACKAGENAME} to 1 for each of its included playback packages
}
$TempDir= Glib::get_tmp_dir.SLASH; _utf8_off($TempDir); #turn utf8 flag off to not auto-utf8-upgrade other filenames in the same strings
}
our $CairoOK;
@@ -1075,6 +1101,7 @@ sub ConvertSize
gst_rg_preamp => 0,
gst_rg_fallback => 0,
gst_rg_songmenu => 0,
use_GST_for_server=>1,
Icecast_port => '8000',
UseTray => 1,
CloseToTray => 0,
@@ -1495,10 +1522,6 @@ sub forksystem
Watch(undef,NextSongs => sub { UpdateRelatedFilter('Next'); });
Watch(undef,CurSong => sub { UpdateRelatedFilter('Play'); });
}
our ($Play_package,%PlayPacks); my ($PlayNext_package,$Vol_package);
for my $file (qw/gmusicbrowser_123.pm gmusicbrowser_mplayer.pm gmusicbrowser_gstreamer-0.10.pm gmusicbrowser_server.pm/)
{ eval { require $file } || warn $@; #each file sets $::PlayPacks{PACKAGENAME} to 1 for each of its included playback packages
}
LoadPlugins();
if ($CmdLine{pluginlist}) { warn "$_ : $Plugins{$_}{name}\n" for sort keys %Plugins; exit; }
@@ -1520,7 +1543,6 @@ sub forksystem
{ my $pp=$Options{AudioOut};
$pp= $Options{use_GST_for_server} ? 'Play_GST_server' : 'Play_Server' if $CmdLine{server};
$pp='Play_GST' if $CmdLine{gst};
for my $p ($pp, qw/Play_GST Play_123 Play_mplayer Play_GST_server Play_Server/)
{ next unless $p && $PlayPacks{$p};
$pp=$p;
@@ -6250,8 +6272,10 @@ sub SetDefaultOptions
sub PrefAudio
{ my $sg1=Gtk2::SizeGroup->new('horizontal');
my $sg2=Gtk2::SizeGroup->new('horizontal');
my $gst_string="gstreamer";
$gst_string.= ' '.$::gstreamer_version if $::gstreamer_version;
my ($radio_gst,$radio_123,$radio_mp,$radio_ice)=NewPrefRadio('AudioOut',
[ gstreamer => 'Play_GST',
[ $gst_string => 'Play_GST',
'mpg123/ogg123/...' => 'Play_123',
mplayer => 'Play_mplayer',
_"icecast server" => sub {$Options{use_GST_for_server}? 'Play_GST_server' : 'Play_Server'},
View
@@ -11,8 +11,8 @@ Packager: Quentin Sculo <squentin@free.fr>
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildArch: noarch
BuildRequires: /usr/bin/markdown
Requires: perl >= 5.8, gtk2 >= 2.6.0, perl-Gtk2, perl(Locale::Messages), perl-GStreamer, perl-Digest-CRC, perl-Cairo, perl-HTML-Parser perl-IO-Compress, perl-Net-DBus
Requires(hint): mpg123, vorbis-tools, alsa-utils, perl-Gtk2-WebKit, perl-Gtk2-MozEmbed, perl-Net-DBus-GLib, gstreamer0.10-lame, gstreamer0.10-plugins-ugly, gstreamer0.10-plugins-bad, perl-Gnome2-Wnck, perl-GStreamer-Interfaces, perl-Gtk2-Notify, poppler-utils
Requires: perl >= 5.8, gtk2 >= 2.6.0, perl-Gtk2, perl(Locale::Messages), perl-Glib-Object-Introspection, typelib-1_0-Gst-1_0, perl-Digest-CRC, perl-Cairo, perl-HTML-Parser, perl-IO-Compress, perl-Net-DBus
Requires(hint): mpg123, vorbis-tools, alsa-utils, perl-Gtk2-WebKit, perl-Gtk2-MozEmbed, perl-Net-DBus-GLib, gstreamer0.10-lame, gstreamer0.10-plugins-ugly, gstreamer0.10-plugins-bad, perl-Gnome2-Wnck, perl-GStreamer-Interfaces, perl-Gtk2-Notify, poppler-utils, perl-GStreamer
AutoReq: no
AutoProv: no
View
@@ -192,7 +192,7 @@ sub _eos_cb
Glib::Source->remove($WatchTag2);
$WatchTag=$WatchTag2=$ChildPID=undef;
if ($Error) { ::ErrorPlay($Error,_("Command used :")."\n@cmd_and_args"); }
::end_of_file;
::end_of_file();
return 1;
}
@@ -1,15 +1,26 @@
# Copyright (C) 2005-2014 Quentin Sculo <squentin@free.fr>
# Copyright (C) 2005-2015 Quentin Sculo <squentin@free.fr>
#
# This file is part of Gmusicbrowser.
# Gmusicbrowser is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
# published by the Free Software Foundation
BEGIN
{ require GStreamer;
$::gstreamer_version='0.10';
die "Needs GStreamer version >= 0.05\n" if GStreamer->VERSION<.05;
die "Can't initialize GStreamer.\n" unless GStreamer->init_check;
GStreamer->init;
my $reg=GStreamer::Registry->get_default;
$Play_GST::reg_keep=$reg if GStreamer->CHECK_VERSION(0,10,4); #work-around to keep the register from being finalized in gstreamer<0.10.4 (see http://bugzilla.gnome.org/show_bug.cgi?id=324818)
$reg->lookup_feature('playbin') or die "gstreamer plugin 'playbin' not found.\nYou need to install at least gst-plugins-base.\n";
}
package Play_GST;
use strict;
use warnings;
my ($GST_ok,$GST_visuals_ok,$GST_EQ_ok,$GST_RG_ok,$playbin2_ok); our $GST_RGA_ok;
my ($GST_visuals_ok,$GST_EQ_ok,$GST_RG_ok,$playbin2_ok); our $GST_RGA_ok;
my ($PlayBin,$Sink);
my ($WatchTag,$Skip,$StateAfterSkip);
my (%Plugins,%Sinks);
@@ -20,13 +31,12 @@ my ($VolumeBusy,$VolumeHasChanged);
$::PlayPacks{Play_GST}=1; #register the package
my $reg_keep; #work-around to keep the register from being finalized in gstreamer<0.10.4 (see http://bugzilla.gnome.org/show_bug.cgi?id=324818)
BEGIN
{ %Sinks=
( autoaudio => { name => _"auto detect", },
oss => { option => 'device' },
oss4 => { option => 'device' },
esd => { option => 'host'},
alsa => { option => 'device'},
artsd => {},
@@ -38,64 +48,49 @@ BEGIN
osxaudio => {},
directsound => {},
#alsaspdif => { name => "alsa S/PDIF", option => 'card' },
#oss4 => {},
#nas => {},
);
%Plugins=( mp3 => 'mad', oga => 'vorbisdec', ape => 'ffdec_ape',
flac => 'flacdec', mpc => 'musepackdec', wv => 'wavpackdec',
m4a => 'faad',
);
my $error;
my $reg;
if (grep -f $_.'/GStreamer.pm',@INC)
{ eval {require GStreamer};
$error="Needs GStreamer version >= 0.05\n" if !$@ && GStreamer->VERSION<.05;
if (!$@ && !$error && GStreamer->init_check)
{ GStreamer->init;
$reg=GStreamer::Registry->get_default;
$reg_keep=$reg if GStreamer->CHECK_VERSION(0,10,4);
$playbin2_ok= $reg->lookup_feature('playbin2');
if ( $playbin2_ok || $reg->lookup_feature('playbin') ) { $GST_ok=1; }
else { $error="gstreamer plugin 'playbin' not found\nYou need to install at least gst-plugins-base\n"; }
}
else { $error=$@? $@ : "Can't initialize GStreamer.\n"; }
}
else {$error="GStreamer.pm not found\n";}
if ($error) {warn "$error -> gstreamer output won't be available.\n"}
if ($GST_ok)
{ $::Options{gst_sink}||= (grep ($reg->lookup_feature($_.'sink'), qw/autoaudio gconfaudio alsa esd pulse oss/),'alsa')[0]; #find a default sink
if ($reg->lookup_feature('equalizer-10bands')) { $GST_EQ_ok=1; }
else {warn "gstreamer plugin 'equalizer-10bands' not found -> equalizer not available\n";}
if ($reg->lookup_feature('rglimiter') && $reg->lookup_feature('rgvolume')) { $GST_RG_ok=1; }
else {warn "gstreamer plugins 'rglimiter' and/or 'rgvolume' not found -> replaygain not available\n";}
if ($reg->lookup_feature('rganalysis')) { $GST_RGA_ok=1; }
else {warn "gstreamer plugins 'rganalysis' not found -> replaygain analysis not available\n";}
$GST_visuals_ok=1;
eval {require GStreamer::Interfaces};
if ($@) {warn "GStreamer::Interfaces perl module not found -> visuals not available\n"; $GST_visuals_ok=0;}
unless ($reg->lookup_feature('ximagesink'))
{ warn "gstreamer plugin 'ximagesink' not found -> visuals not available\n"; $GST_visuals_ok=0;
}
}
%Plugins=( mp3 => 'flump3dec mad mpg123audiodec avdec_mp3',
oga => 'vorbisdec', flac=> 'flacdec',
ape => 'avdec_ape ffdec_ape', wv => 'wavpackdec',
mpc => 'musepackdec avdec_mpc8', m4a => 'faad',
);
my $reg=GStreamer::Registry->get_default;
$playbin2_ok= $reg->lookup_feature('playbin2');
if ($reg->lookup_feature('equalizer-10bands')) { $GST_EQ_ok=1; }
else {warn "gstreamer plugin 'equalizer-10bands' not found -> equalizer not available\n";}
if ($reg->lookup_feature('rglimiter') && $reg->lookup_feature('rgvolume')) { $GST_RG_ok=1; }
else {warn "gstreamer plugins 'rglimiter' and/or 'rgvolume' not found -> replaygain not available\n";}
if ($reg->lookup_feature('rganalysis')) { $GST_RGA_ok=1; }
else {warn "gstreamer plugins 'rganalysis' not found -> replaygain analysis not available\n";}
$GST_visuals_ok=1;
eval {require GStreamer::Interfaces};
if ($@) {warn "GStreamer::Interfaces perl module not found -> visuals not available\n"; $GST_visuals_ok=0;}
unless ($reg->lookup_feature('ximagesink'))
{ warn "gstreamer plugin 'ximagesink' not found -> visuals not available\n"; $GST_visuals_ok=0;
}
}
sub supported_formats
{ return '' unless $GST_ok;
my $reg=GStreamer::Registry->get_default;
return grep $reg->lookup_feature($Plugins{$_}), keys %Plugins;
{ my $reg=GStreamer::Registry->get_default;
my @found;
for my $type (keys %Plugins)
{ push @found, $type if grep $reg->lookup_feature($_), split / +/, $Plugins{$type};
}
return @found;
}
sub supported_sinks
{ return {} unless $GST_ok;
my $reg=GStreamer::Registry->get_default;
{ my $reg=GStreamer::Registry->get_default;
$Sinks{$_}{ok}= ! !$reg->lookup_feature($_.'sink') for keys %Sinks;
#$::Options{gst_sink}='autoaudio' unless $Sinks{$::Options{gst_sink}};
return {map { $_ => $Sinks{$_}{name}||$_ } grep $Sinks{$_}{ok}, keys %Sinks};
}
sub init
{ return undef unless $GST_ok;
#createPlayBin();
{ my $reg= GStreamer1::Registry::get();
$::Options{gst_sink}='' unless $reg->lookup_feature( ($::Options{gst_sink}||'').'sink' );
$::Options{gst_sink}||= (grep ($reg->lookup_feature($_.'sink'), qw/autoaudio gconfaudio pulse alsa esd oss oss4/),'autoaudio')[0]; #find a default sink
return bless { EQ=>$GST_EQ_ok, visuals => $GST_visuals_ok, RG=>$GST_RG_ok },__PACKAGE__;
}
@@ -637,7 +632,7 @@ sub process_next
my $f= Songs::Get($ID,'fullfilename_raw');
::_utf8_on($f); # pretend it's utf8 to prevent a conversion to utf8 by the bindings
$RGA_pipeline->{ID}=$ID;
warn "Analysing [$ID] $f\n" if $::verbose;
warn "Analysing [$ID] $f\n" if $::Verbose;
$RGA_pipeline->get_by_name('filesrc')->set(location => $f);
$rganalysis->set_locked_state(0);
$RGA_pipeline->set_state('playing');
@@ -719,14 +714,12 @@ use Socket;
use constant { EOL => "\015\012" };
our @ISA=('Play_GST');
our %sockets;
my ($stream,$Server);
my (%sockets,$stream,$Server);
$::PlayPacks{Play_GST_server}=1; #register the package
sub init
{ return undef unless $GST_ok;
my $ok=1;
{ my $ok=1;
my $reg=GStreamer::Registry->get_default;
for my $feature (qw/multifdsink lame audioresample audioconvert/)
{ next if $reg->lookup_feature($feature);
@@ -850,5 +843,8 @@ sub Connection
return 1; #keep listening
}
sub get_connections
{ return map $sockets{$_}[2], grep $sockets{$_}[1],keys %sockets;
}
1;
Oops, something went wrong.

0 comments on commit fe20c1a

Please sign in to comment.