Bug 1355933: P6. Hook up ADTS sniffer. r?kamidphish
MozReview-Commit-ID: 3aYmCRRbRzg
--- a/netwerk/mime/nsMimeTypes.h
+++ b/netwerk/mime/nsMimeTypes.h
@@ -83,16 +83,17 @@
#define AUDIO_MP3 "audio/mpeg"
#define AUDIO_MP4 "audio/mp4"
#define AUDIO_AMR "audio/amr"
#define AUDIO_FLAC "audio/flac"
#define AUDIO_3GPP "audio/3gpp"
#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"
#define IMAGE_GIF "image/gif"
#define IMAGE_JPEG "image/jpeg"
#define IMAGE_JPG "image/jpg"
#define IMAGE_PJPEG "image/pjpeg"
#define IMAGE_PNG "image/png"
--- a/toolkit/components/mediasniffer/nsMediaSniffer.cpp
+++ b/toolkit/components/mediasniffer/nsMediaSniffer.cpp
@@ -1,14 +1,15 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 tw=80 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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"
#include "mp3sniff.h"
#include "nestegg/nestegg.h"
#include "nsIClassInfoImpl.h"
#include "nsIHttpChannel.h"
#include "nsMediaSniffer.h"
@@ -125,16 +126,21 @@ static bool MatchesMP3(const uint8_t* aD
return mp3_sniff(aData, (long)aLength);
}
static bool 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,
const uint32_t aLength,
nsACString& aSniffedType)
{
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
if (channel) {
@@ -192,13 +198,18 @@ nsMediaSniffer::GetMIMETypeFromContent(n
// 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.
if (MatchesFLAC(aData, clampedLength)) {
aSniffedType.AssignLiteral(AUDIO_FLAC);
return NS_OK;
}
+ if (MatchesADTS(aData, clampedLength)) {
+ aSniffedType.AssignLiteral(AUDIO_AAC);
+ return NS_OK;
+ }
+
// Could not sniff the media type, we are required to set it to
// application/octet-stream.
aSniffedType.AssignLiteral(APPLICATION_OCTET_STREAM);
return NS_ERROR_NOT_AVAILABLE;
}