mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-30 11:07:29 +09:00
Issue #2673 - Part 4: Hook up the ADTS sniffer + raw AAC MIME type.
This commit is contained in:
parent
8f52da3288
commit
d63a56adac
2 changed files with 14 additions and 0 deletions
|
|
@ -88,6 +88,7 @@
|
||||||
#define AUDIO_3GPP2 "audio/3gpp2"
|
#define AUDIO_3GPP2 "audio/3gpp2"
|
||||||
#define AUDIO_MIDI "audio/x-midi"
|
#define AUDIO_MIDI "audio/x-midi"
|
||||||
#define AUDIO_MATROSKA "audio/x-matroska"
|
#define AUDIO_MATROSKA "audio/x-matroska"
|
||||||
|
#define AUDIO_AAC "audio/aac"
|
||||||
|
|
||||||
#define BINARY_OCTET_STREAM "binary/octet-stream"
|
#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
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#include "ADTSDemuxer.h"
|
||||||
#include "FlacDemuxer.h"
|
#include "FlacDemuxer.h"
|
||||||
#include "mozilla/ArrayUtils.h"
|
#include "mozilla/ArrayUtils.h"
|
||||||
#include "mozilla/ModuleUtils.h"
|
#include "mozilla/ModuleUtils.h"
|
||||||
|
|
@ -125,6 +126,11 @@ MatchesFLAC(const uint8_t* aData, const uint32_t aLength) {
|
||||||
return mozilla::FlacDemuxer::FlacSniffer(aData, 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
|
NS_IMETHODIMP
|
||||||
nsMediaSniffer::GetMIMETypeFromContent(nsIRequest* aRequest,
|
nsMediaSniffer::GetMIMETypeFromContent(nsIRequest* aRequest,
|
||||||
const uint8_t* aData,
|
const uint8_t* aData,
|
||||||
|
|
@ -183,6 +189,13 @@ nsMediaSniffer::GetMIMETypeFromContent(nsIRequest* aRequest,
|
||||||
return NS_OK;
|
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.
|
// Flac frames are generally big, often in excess of 24kB.
|
||||||
// Using a size of MAX_BYTES_SNIFFED effectively means that we will only
|
// Using a size of MAX_BYTES_SNIFFED effectively means that we will only
|
||||||
// recognize flac content if it starts with a frame.
|
// recognize flac content if it starts with a frame.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue