mirror of
https://github.com/roytam1/basilisk55.git
synced 2026-05-26 13:31:57 +00:00
import from UXP: Issue #2673 - Part 4: Hook up the ADTS sniffer + raw AAC MIME type. (d63a56ad)
This commit is contained in:
@@ -88,6 +88,7 @@
|
||||
#define AUDIO_3GPP2 "audio/3gpp2"
|
||||
#define AUDIO_MIDI "audio/x-midi"
|
||||
#define AUDIO_MATROSKA "audio/x-matroska"
|
||||
#define AUDIO_AAC "audio/aac"
|
||||
|
||||
#define BINARY_OCTET_STREAM "binary/octet-stream"
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ADTSDemuxer.h"
|
||||
#include "FlacDemuxer.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/ModuleUtils.h"
|
||||
@@ -125,6 +126,11 @@ MatchesFLAC(const uint8_t* aData, const uint32_t aLength) {
|
||||
return mozilla::FlacDemuxer::FlacSniffer(aData, aLength);
|
||||
}
|
||||
|
||||
static bool MatchesADTS(const uint8_t* aData, const uint32_t aLength)
|
||||
{
|
||||
return mozilla::ADTSDemuxer::ADTSSniffer(aData, aLength);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMediaSniffer::GetMIMETypeFromContent(nsIRequest* aRequest,
|
||||
const uint8_t* aData,
|
||||
@@ -183,6 +189,13 @@ nsMediaSniffer::GetMIMETypeFromContent(nsIRequest* aRequest,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Note: Sniff for ADTS content before flac.
|
||||
// The flac decoder can easily produce false negatives.
|
||||
if (MatchesADTS(aData, clampedLength)) {
|
||||
aSniffedType.AssignLiteral(AUDIO_AAC);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Flac frames are generally big, often in excess of 24kB.
|
||||
// Using a size of MAX_BYTES_SNIFFED effectively means that we will only
|
||||
// recognize flac content if it starts with a frame.
|
||||
|
||||
Reference in New Issue
Block a user