Skip to content

Commit

Permalink
Merge pull request #413 from philippe44/bitrate
Browse files Browse the repository at this point in the history
fix bitrate with icy data
  • Loading branch information
mherger authored Sep 4, 2020
2 parents 5eb63f9 + 888e7ab commit edbf8a2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions Slim/Player/Protocols/HTTP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,12 @@ sub parseDirectHeaders {
($oggType) = $url->content_type =~ /(ogf|ogg|ops)/;
$url = $url->url;
}

my $song = ${*$self}{'song'} if blessed $self;

if (!$song && $client->controller()->songStreamController()) {
$song = $client->controller()->songStreamController()->song();
}

my ($title, $bitrate, $metaint, $redir, $contentType, $length, $body);
my ($rangeLength, $startOffset);
Expand All @@ -567,9 +573,11 @@ sub parseDirectHeaders {
$title = Slim::Utils::Unicode::utf8decode_guess($1);
}

elsif ($header =~ /^(?:icy-br|x-audiocast-bitrate):\s*(.+)/i) {
$bitrate = $1;
$bitrate *= 1000 if $bitrate < 1000;
elsif ($header =~ /^(?:icy-br|x-audiocast-bitrate):\s*(.+)/i)
if ($song && !$song->bitrate) {
$bitrate = $1;
$bitrate *= 1000 if $bitrate < 8000;
}
}

elsif ($header =~ /^icy-metaint:\s*(.+)/i) {
Expand Down Expand Up @@ -606,12 +614,6 @@ sub parseDirectHeaders {
$length = $rangeLength;
}

my $song = ${*self}{'song'} if blessed $self;

if (!$song && $client->controller()->songStreamController()) {
$song = $client->controller()->songStreamController()->song();
}

if ($song && $length) {
my $seekdata = $song->seekdata();

Expand Down

0 comments on commit edbf8a2

Please sign in to comment.