Bug 1355933: P5. Fix coding style. r?gerald
MozReview-Commit-ID: JcwOH7FkyMU
--- a/toolkit/components/mediasniffer/nsMediaSniffer.cpp
+++ b/toolkit/components/mediasniffer/nsMediaSniffer.cpp
@@ -1,25 +1,25 @@
/* -*- 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 "nsMediaSniffer.h"
-#include "nsIHttpChannel.h"
-#include "nsString.h"
-#include "nsMimeTypes.h"
+#include "FlacDemuxer.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/ModuleUtils.h"
#include "mp3sniff.h"
#include "nestegg/nestegg.h"
-#include "FlacDemuxer.h"
+#include "nsIClassInfoImpl.h"
+#include "nsIHttpChannel.h"
+#include "nsMediaSniffer.h"
+#include "nsMimeTypes.h"
+#include "nsString.h"
-#include "nsIClassInfoImpl.h"
#include <algorithm>
// The minimum number of bytes that are needed to attempt to sniff an mp4 file.
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.
@@ -51,17 +51,18 @@ nsMediaSnifferEntry sFtypEntries[] = {
PATTERN_ENTRY("\xFF\xFF\xFF\xFF", "mmp4", VIDEO_MP4),
};
static bool MatchesBrands(const uint8_t aData[4], nsACString& aSniffedType)
{
for (size_t i = 0; i < mozilla::ArrayLength(sFtypEntries); ++i) {
const auto& currentEntry = sFtypEntries[i];
bool matched = true;
- MOZ_ASSERT(currentEntry.mLength <= 4, "Pattern is too large to match brand strings.");
+ MOZ_ASSERT(currentEntry.mLength <= 4,
+ "Pattern is too large to match brand strings.");
for (uint32_t j = 0; j < currentEntry.mLength; ++j) {
if ((currentEntry.mMask[j] & aData[j]) != currentEntry.mPattern[j]) {
matched = false;
break;
}
}
if (matched) {
aSniffedType.AssignASCII(currentEntry.mContentType);
@@ -70,23 +71,26 @@ static bool MatchesBrands(const uint8_t
}
return false;
}
// This function implements sniffing algorithm for MP4 family file types,
// including MP4 (described at http://mimesniff.spec.whatwg.org/#signature-for-mp4),
// M4A (Apple iTunes audio), and 3GPP.
-static bool MatchesMP4(const uint8_t* aData, const uint32_t aLength, nsACString& aSniffedType)
+static bool
+MatchesMP4(const uint8_t* aData, const uint32_t aLength,
+ nsACString& aSniffedType)
{
if (aLength <= MP4_MIN_BYTES_COUNT) {
return false;
}
// Conversion from big endian to host byte order.
- uint32_t boxSize = (uint32_t)(aData[3] | aData[2] << 8 | aData[1] << 16 | aData[0] << 24);
+ uint32_t boxSize =
+ (uint32_t)(aData[3] | aData[2] << 8 | aData[1] << 16 | aData[0] << 24);
// Boxsize should be evenly divisible by 4.
if (boxSize % 4 || aLength < boxSize) {
return false;
}
// The string "ftyp".
if (aData[4] != 0x66 ||
aData[5] != 0x74 ||
@@ -132,18 +136,18 @@ nsMediaSniffer::GetMIMETypeFromContent(n
const uint32_t aLength,
nsACString& aSniffedType)
{
nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
if (channel) {
nsLoadFlags loadFlags = 0;
channel->GetLoadFlags(&loadFlags);
if (!(loadFlags & nsIChannel::LOAD_MEDIA_SNIFFER_OVERRIDES_CONTENT_TYPE)) {
- // For media, we want to sniff only if the Content-Type is unknown, or if it
- // is application/octet-stream.
+ // For media, we want to sniff only if the Content-Type is unknown, or if
+ // it is application/octet-stream.
nsAutoCString contentType;
nsresult rv = channel->GetContentType(contentType);
NS_ENSURE_SUCCESS(rv, rv);
if (!contentType.IsEmpty() &&
!contentType.EqualsLiteral(APPLICATION_OCTET_STREAM) &&
!contentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE)) {
return NS_ERROR_NOT_AVAILABLE;
}