[Slim-Checkins] r33922 - in /7.8/trunk/server: Changelog7.html Slim/Formats.pm Slim/Formats/Ogg.pm Slim/Formats/OggFLAC.pm Slim/Player/Squeezebox.pm Slim/Schema.pm Slim/Utils/Scanner/Remote.pm convert.conf strings.txt

[email protected] Thu, 29 Mar 2012 07:19:27 -0000
Newsgroups gmane.music.equipment.slimdevices.cvs
Message-ID <[email protected]>
Author: ayoung
Date: Thu Mar 29 00:19:26 2012
New Revision: 33922

URL: http://svn.slimdevices.com/slim?rev=33922&view=rev
Log:
bug 12893: Support OggFLAC - server support

This is intended only to support streaming, not local files.
Transcoding to ordinary FLAC is included.

Added:
    7.8/trunk/server/Slim/Formats/OggFLAC.pm   (with props)
Modified:
    7.8/trunk/server/Changelog7.html
    7.8/trunk/server/Slim/Formats.pm
    7.8/trunk/server/Slim/Formats/Ogg.pm
    7.8/trunk/server/Slim/Player/Squeezebox.pm
    7.8/trunk/server/Slim/Schema.pm
    7.8/trunk/server/Slim/Utils/Scanner/Remote.pm
    7.8/trunk/server/convert.conf
    7.8/trunk/server/strings.txt

Modified: 7.8/trunk/server/Changelog7.html
URL: http://svn.slimdevices.com/slim/7.8/trunk/server/Changelog7.html?rev=33922&r1=33921&r2=33922&view=diff
==============================================================================
--- 7.8/trunk/server/Changelog7.html (original)
+++ 7.8/trunk/server/Changelog7.html Thu Mar 29 00:19:26 2012
@@ -5,6 +5,7 @@
 		<li>The default behaviour on power-on is changed to resume what was playing before power-off.
 		This change will only apply to new players attached to the server;
 		the behaviour for existing players can be changed with Settings / Player / Audio.</li>
+		<li>Support for Ogg FLAC in the server and Squeezeplay-based players</li>
 	</ul>
 	<br />
 

Modified: 7.8/trunk/server/Slim/Formats.pm
URL: http://svn.slimdevices.com/slim/7.8/trunk/server/Slim/Formats.pm?rev=33922&r1=33921&r2=33922&view=diff
==============================================================================
--- 7.8/trunk/server/Slim/Formats.pm (original)
+++ 7.8/trunk/server/Slim/Formats.pm Thu Mar 29 00:19:26 2012
@@ -63,6 +63,7 @@
 		'mpc' => 'Slim::Formats::Musepack',
 		'ape' => 'Slim::Formats::APE',
 		'wvp' => 'Slim::Formats::WavPack',
+		'ogf' => 'Slim::Formats::OggFLAC',
 
 		# Playlist types
 		'asx' => 'Slim::Formats::Playlists::ASX',
@@ -168,7 +169,11 @@
 					}
 				}
 
-				$tags = $tagReaderClass->getTag($filepath, $anchor);
+				($tags, my $ctOverride) = $tagReaderClass->getTag($filepath, $anchor);
+
+				if ($ctOverride) {
+					$type = $ctOverride;
+				}
 				
 				$loadedTagClasses{$type} = 1;
 			}

Modified: 7.8/trunk/server/Slim/Formats/Ogg.pm
URL: http://svn.slimdevices.com/slim/7.8/trunk/server/Slim/Formats/Ogg.pm?rev=33922&r1=33921&r2=33922&view=diff
==============================================================================
--- 7.8/trunk/server/Slim/Formats/Ogg.pm (original)
+++ 7.8/trunk/server/Slim/Formats/Ogg.pm Thu Mar 29 00:19:26 2012
@@ -76,6 +76,12 @@
 	my $tags = $s->{tags};
 	
 	return unless $info->{song_length_ms};
+
+	# Use Formats::FLAC for OggFlac and force the content type
+	if ($s->{info}->{ogg_type} eq 'flac') {
+		Slim::Formats->loadTagFormatForType('flc');
+		return (Slim::Formats::FLAC->_getStandardTag($s), 'ogf');
+	}
 	
 	# Map tags
 	while ( my ($old, $new) = each %tagMapping ) {

Added: 7.8/trunk/server/Slim/Formats/OggFLAC.pm
URL: http://svn.slimdevices.com/slim/7.8/trunk/server/Slim/Formats/OggFLAC.pm?rev=33922&view=auto
==============================================================================
--- 7.8/trunk/server/Slim/Formats/OggFLAC.pm (added)
+++ 7.8/trunk/server/Slim/Formats/OggFLAC.pm Thu Mar 29 00:19:26 2012
@@ -1,0 +1,13 @@
+package Slim::Formats::OggFLAC;
+
+use base qw(Slim::Formats::FLAC);
+
+sub findFrameBoundaries { 0 }
+
+sub scanBitrate{ 
+	return (-1, undef);
+}
+
+sub canSeek { 0 }
+
+1;

Propchange: 7.8/trunk/server/Slim/Formats/OggFLAC.pm
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: 7.8/trunk/server/Slim/Player/Squeezebox.pm
URL: http://svn.slimdevices.com/slim/7.8/trunk/server/Slim/Player/Squeezebox.pm?rev=33922&r1=33921&r2=33922&view=diff
==============================================================================
--- 7.8/trunk/server/Slim/Player/Squeezebox.pm (original)
+++ 7.8/trunk/server/Slim/Player/Squeezebox.pm Thu Mar 29 00:19:26 2012
@@ -656,7 +656,7 @@
 			}
 		 }
 
-	} elsif ($format eq 'flc') {
+	} elsif ($format eq 'flc' || $format eq 'ogf') {
 
 		$formatbyte      = 'f';
 		$pcmsamplesize   = '?';
@@ -670,6 +670,13 @@
 			if ( $track->samplerate() && $track->samplerate() >= 88200 ) {
 		    	$outputThreshold = 20;
 			}
+		}
+
+		# Oggflac support for Squeezeplay - uses same decoder with flag to indicate ogg transport stream 
+		# increase default output buffer threshold as this is used for high bitrate internet radio streams
+		if ($format eq 'ogf') {
+			$pcmsamplesize   = 'o';
+			$outputThreshold = 20;
 		}
 
 	} elsif ( $format =~ /(?:wma|asx)/ ) {

Modified: 7.8/trunk/server/Slim/Schema.pm
URL: http://svn.slimdevices.com/slim/7.8/trunk/server/Slim/Schema.pm?rev=33922&r1=33921&r2=33922&view=diff
==============================================================================
--- 7.8/trunk/server/Slim/Schema.pm (original)
+++ 7.8/trunk/server/Slim/Schema.pm Thu Mar 29 00:19:26 2012
@@ -726,6 +726,12 @@
 	}
 
 	return $contentType;
+}
+
+# The contentTypeCache can used above can erroneously be set to type inferred from url path - allow it to be cleared
+sub clearContentTypeCache {
+	my ($self, $urlOrObj) = @_;
+	delete $contentTypeCache{$urlOrObj};
 }
 
 =head2 objectForUrl( $args )

Modified: 7.8/trunk/server/Slim/Utils/Scanner/Remote.pm
URL: http://svn.slimdevices.com/slim/7.8/trunk/server/Slim/Utils/Scanner/Remote.pm?rev=33922&r1=33921&r2=33922&view=diff
==============================================================================
--- 7.8/trunk/server/Slim/Utils/Scanner/Remote.pm (original)
+++ 7.8/trunk/server/Slim/Utils/Scanner/Remote.pm Thu Mar 29 00:19:26 2012
@@ -457,6 +457,17 @@
 			$http->read_body( {
 				readLimit   => 4 * 1024,
 				onBody      => \&parseAACHeader,
+				passthrough => [ $track, $args ],
+			} );
+		}
+		elsif ( $type eq 'ogg' ) {
+
+			# Read the header to allow support for oggflac as it requires different decode path
+			main::DEBUGLOG && $log->is_debug && $log->debug('Reading Ogg header');
+			
+			$http->read_body( {
+				readLimit   => 64,
+				onBody      => \&parseOggHeader,
 				passthrough => [ $track, $args ],
 			} );
 		}
@@ -714,6 +725,29 @@
 		main::DEBUGLOG && $log->is_debug && $log->debug("AAC samplerate: $samplerate");
 	}
 	
+	# All done
+	$cb->( $track, undef, @{$pt} );
+}
+
+sub parseOggHeader {
+	my ( $http, $track, $args ) = @_;
+	
+	my $client = $args->{client};
+	my $cb	   = $args->{cb} || sub {};
+	my $pt	   = $args->{pt} || [];
+
+	my $header = $http->response->content;
+	my $data   = substr($header, 28);
+
+	# search for Ogg FLAC headers within the data - if so change the content type to ogf for OggFlac
+	# OggFlac header defined: http://flac.sourceforge.net/ogg_mapping.html
+	if (substr($data, 0, 5) eq "\x7fFLAC" && substr($data, 9,4) eq 'fLaC') {
+		main::DEBUGLOG && $log->is_debug && $log->debug("Ogg stream is OggFlac - setting content type [ogf]");
+		Slim::Schema->clearContentTypeCache( $track->url );
+		Slim::Music::Info::setContentType( $track->url, 'ogf' );
+		$track->content_type('ogf');
+	}
+
 	# All done
 	$cb->( $track, undef, @{$pt} );
 }

Modified: 7.8/trunk/server/convert.conf
URL: http://svn.slimdevices.com/slim/7.8/trunk/server/convert.conf?rev=33922&r1=33921&r2=33922&view=diff
==============================================================================
--- 7.8/trunk/server/convert.conf (original)
+++ 7.8/trunk/server/convert.conf Thu Mar 29 00:19:26 2012
@@ -147,6 +147,12 @@
 	# FT:{START=--skip=%t}U:{END=--until=%v}
 	[flac] -dcs --force-raw-format --endian=big --sign=signed $START$ $END$ -- $FILE$
 
+ogf ogf * *
+	-
+
+ogf flc * *
+	[flac] --ogg -dcs -- $FILE$ | [flac] -cs --ignore-chunk-sizes --totally-silent --compression-level-0 - 
+
 ogg ogg * *
 	-
 

Modified: 7.8/trunk/server/strings.txt
URL: http://svn.slimdevices.com/slim/7.8/trunk/server/strings.txt?rev=33922&r1=33921&r2=33922&view=diff
==============================================================================
--- 7.8/trunk/server/strings.txt (original)
+++ 7.8/trunk/server/strings.txt Thu Mar 29 00:19:26 2012
@@ -11776,6 +11776,22 @@
 	RU	Ogg Vorbis
 	SV	Ogg Vorbis
 
+OGF
+	CS	Ogg FLAC
+	DA	Ogg FLAC
+	DE	Ogg FLAC
+	EN	Ogg FLAC
+	ES	Ogg FLAC
+	FI	Ogg FLAC
+	FR	Ogg FLAC
+	HE	Ogg FLAC
+	IT	Ogg FLAC
+	NL	Ogg FLAC
+	NO	Ogg FLAC
+	PL	Ogg FLAC
+	RU	Ogg FLAC
+	SV	Ogg FLAC
+
 MODIFIED
 	CS	Upraveno
 	DA	Ændret

_______________________________________________
checkins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/checkins