Bug 967007 - Bump the sniffing limit for mp3. r=rillian

This commit is contained in:
Paul Adenot 2014-02-03 16:55:34 +01:00
parent 1ed386a14c
commit cfb33ac697

View File

@ -22,6 +22,10 @@
static const unsigned MP4_MIN_BYTES_COUNT = 12;
// The maximum number of bytes to consider when attempting to sniff a file.
static const uint32_t MAX_BYTES_SNIFFED = 512;
// The maximum number of bytes to consider when attempting to sniff for a mp3
// bitstream.
// This is 320kbps * 144 / 32kHz + 1 padding byte + 4 bytes of capture pattern.
static const uint32_t MAX_BYTES_SNIFFED_MP3 = 320 * 144 / 32 + 1 + 4;
NS_IMPL_ISUPPORTS1(nsMediaSniffer, nsIContentSniffer)
@ -142,7 +146,8 @@ nsMediaSniffer::GetMIMETypeFromContent(nsIRequest* aRequest,
return NS_OK;
}
if (MatchesMP3(aData, clampedLength)) {
// Bug 950023: 512 bytes are often not enough to sniff for mp3.
if (MatchesMP3(aData, std::min(aLength, MAX_BYTES_SNIFFED_MP3))) {
aSniffedType.AssignLiteral(AUDIO_MP3);
return NS_OK;
}