From 34e16670beb0b97df3430af3bc3d910a9966dfa1 Mon Sep 17 00:00:00 2001 From: Philippe G Date: Mon, 28 Dec 2020 12:31:14 -0800 Subject: [PATCH 1/3] Add proxies for transcoding rules matcher --- Slim/Player/TranscodingHelper.pm | 11 ++++++++--- convert.conf | 8 ++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Slim/Player/TranscodingHelper.pm b/Slim/Player/TranscodingHelper.pm index afab929d90c..837f040e117 100644 --- a/Slim/Player/TranscodingHelper.pm +++ b/Slim/Player/TranscodingHelper.pm @@ -33,6 +33,7 @@ sub init { our %commandTable = (); our %capabilities = (); our %binaries = (); +my %proxies = (); sub Conversions { return \%commandTable; @@ -85,7 +86,10 @@ sub loadConversionTables { $line =~ s/^\s*//o; $line =~ s/\s*$//o; - if ($line =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/) { + if ($line =~ /^proxy\s+(\S+)\s+(\S+)/i) { + $proxies{$1} = $2; + } + elsif ($line =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/) { my $inputtype = $1; my $outputtype = $2; @@ -361,10 +365,11 @@ sub getConvertCommand2 { } if ($prefs->get('prioritizeNative')) { - my @types = $type eq 'wav' ? ('pcm', $type) : ($type); + my $proxy = $proxies{$type} || $type; + my @types = $proxy eq 'wav' ? ('pcm', $proxy) : ($proxy); foreach my $type (@types) { my ($format) = grep /$type/, @supportedformats; - @supportedformats = ($format, grep { $_ !~ $type } @supportedformats) if $format; + @supportedformats = ($format, grep { $_ !~ $proxy } @supportedformats) if $format; } } diff --git a/convert.conf b/convert.conf index 0c8fa3b62e8..21bc42d9089 100644 --- a/convert.conf +++ b/convert.conf @@ -86,6 +86,14 @@ # %q, $QUALITY$ - quality # %Q, - quality ( fractal notation: if = '0' return '01' ) # ${FILENAME}$ - contents of {FILENAME} (may contain other $*$ substitutions ) +# +# It's also possible to define "proxies" who tell rules matcher what format a helper +# spits out. This is useful to use player's native format whenever possible. +# proxy +# For example if a plugin has created a new format named 'spt' whose helper's output +# is always 'ogg', you would use +# proxy spt ogg + # specific combinations match before wildcards From 23a4f2dc084a1d56600f5def63b80fc75625769f Mon Sep 17 00:00:00 2001 From: Philippe G Date: Mon, 28 Dec 2020 14:05:43 -0800 Subject: [PATCH 2/3] add multiple proxies --- Slim/Player/TranscodingHelper.pm | 8 ++++---- convert.conf | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Slim/Player/TranscodingHelper.pm b/Slim/Player/TranscodingHelper.pm index 837f040e117..916630aa20d 100644 --- a/Slim/Player/TranscodingHelper.pm +++ b/Slim/Player/TranscodingHelper.pm @@ -87,7 +87,7 @@ sub loadConversionTables { $line =~ s/\s*$//o; if ($line =~ /^proxy\s+(\S+)\s+(\S+)/i) { - $proxies{$1} = $2; + push @{$proxies{$1}}, $2; } elsif ($line =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/) { @@ -365,11 +365,11 @@ sub getConvertCommand2 { } if ($prefs->get('prioritizeNative')) { - my $proxy = $proxies{$type} || $type; - my @types = $proxy eq 'wav' ? ('pcm', $proxy) : ($proxy); + my @types = $proxies{$type} ? @{$proxies{$type}} : ($type); + unshift @types, 'pcm' if grep /wav/, @types; foreach my $type (@types) { my ($format) = grep /$type/, @supportedformats; - @supportedformats = ($format, grep { $_ !~ $proxy } @supportedformats) if $format; + @supportedformats = ($format, grep { $_ !~ $type } @supportedformats) if $format; } } diff --git a/convert.conf b/convert.conf index 21bc42d9089..0e12680a124 100644 --- a/convert.conf +++ b/convert.conf @@ -88,13 +88,13 @@ # ${FILENAME}$ - contents of {FILENAME} (may contain other $*$ substitutions ) # # It's also possible to define "proxies" who tell rules matcher what format a helper -# spits out. This is useful to use player's native format whenever possible. +# spits out. This is useful to stick to player's native format whenever possible. Use +# multiple lines if an helper can output different formats (increasing priority) # proxy # For example if a plugin has created a new format named 'spt' whose helper's output # is always 'ogg', you would use # proxy spt ogg - # specific combinations match before wildcards mp4 mp3 * * From 3c4fc88d338e7566e258551d3d95e8bf2cfe06a3 Mon Sep 17 00:00:00 2001 From: Philippe G Date: Sat, 9 Jan 2021 13:18:40 -0800 Subject: [PATCH 3/3] multi-formats on a single line --- Slim/Player/TranscodingHelper.pm | 6 +++--- convert.conf | 13 +++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Slim/Player/TranscodingHelper.pm b/Slim/Player/TranscodingHelper.pm index 916630aa20d..e760bd39529 100644 --- a/Slim/Player/TranscodingHelper.pm +++ b/Slim/Player/TranscodingHelper.pm @@ -86,8 +86,8 @@ sub loadConversionTables { $line =~ s/^\s*//o; $line =~ s/\s*$//o; - if ($line =~ /^proxy\s+(\S+)\s+(\S+)/i) { - push @{$proxies{$1}}, $2; + if ($line =~ /^proxy\s+(\S+)\s+(\S+)/i) { + $proxies{$1} = $2; } elsif ($line =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/) { @@ -365,7 +365,7 @@ sub getConvertCommand2 { } if ($prefs->get('prioritizeNative')) { - my @types = $proxies{$type} ? @{$proxies{$type}} : ($type); + my @types = split /,/, ($proxies{$type} || $type); unshift @types, 'pcm' if grep /wav/, @types; foreach my $type (@types) { my ($format) = grep /$type/, @supportedformats; diff --git a/convert.conf b/convert.conf index 0e12680a124..ea072e7a824 100644 --- a/convert.conf +++ b/convert.conf @@ -87,13 +87,14 @@ # %Q, - quality ( fractal notation: if = '0' return '01' ) # ${FILENAME}$ - contents of {FILENAME} (may contain other $*$ substitutions ) # -# It's also possible to define "proxies" who tell rules matcher what format a helper -# spits out. This is useful to stick to player's native format whenever possible. Use -# multiple lines if an helper can output different formats (increasing priority) -# proxy +# It's also possible to define "proxies" who tell rules matcher what format(s) a +# helper spits out. This is useful to stick to player's native format whenever +# possible. Use comma-separated list for multiple output formats, from least +# favorite to most favorite +# proxy [,] # For example if a plugin has created a new format named 'spt' whose helper's output -# is always 'ogg', you would use -# proxy spt ogg +# is 'ogg' or 'pcm', and you want 'ogg' to be most desired, then add +# proxy spt pcm,ogg # specific combinations match before wildcards