Bug 1417795 - remove mp4_demuxer namespace part3. r?kinetik
MozReview-Commit-ID: 9fM2VjY4Ckk
--- a/dom/media/BitReader.cpp
+++ b/dom/media/BitReader.cpp
@@ -1,19 +1,17 @@
/* 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/. */
// Derived from Stagefright's ABitReader.
#include "BitReader.h"
-using namespace mozilla;
-
-namespace mp4_demuxer
+namespace mozilla
{
BitReader::BitReader(const mozilla::MediaByteBuffer* aBuffer)
: BitReader(aBuffer->Elements(), aBuffer->Length() * 8)
{
}
BitReader::BitReader(const mozilla::MediaByteBuffer* aBuffer, size_t aBits)
@@ -154,9 +152,9 @@ BitReader::FillReservoir()
mData++;
mSize--;
}
mNumBitsLeft = 8 * i;
mReservoir <<= 32 - mNumBitsLeft;
}
-} // namespace mp4_demuxer
+} // namespace mozilla
--- a/dom/media/BitReader.h
+++ b/dom/media/BitReader.h
@@ -2,17 +2,17 @@
* 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/. */
#ifndef BIT_READER_H_
#define BIT_READER_H_
#include "MediaData.h"
-namespace mp4_demuxer
+namespace mozilla
{
class BitReader
{
public:
explicit BitReader(const mozilla::MediaByteBuffer* aBuffer);
BitReader(const mozilla::MediaByteBuffer* aBuffer, size_t aBits);
BitReader(const uint8_t* aBuffer, size_t aBits);
@@ -40,11 +40,11 @@ private:
const uint8_t* mData;
const size_t mOriginalBitSize;
size_t mTotalBitsLeft;
size_t mSize; // Size left in bytes
uint32_t mReservoir; // Left-aligned bits
size_t mNumBitsLeft; // Number of bits left in reservoir.
};
-} // namespace mp4_demuxer
+} // namespace mozilla
-#endif // BIT_READER_H_
\ No newline at end of file
+#endif // BIT_READER_H_
--- a/dom/media/BufferReader.h
+++ b/dom/media/BufferReader.h
@@ -7,17 +7,17 @@
#include "mozilla/EndianUtils.h"
#include "nscore.h"
#include "nsTArray.h"
#include "MediaData.h"
#include "mozilla/Logging.h"
#include "mozilla/Result.h"
-namespace mp4_demuxer {
+namespace mozilla {
extern mozilla::LazyLogModule gMP4MetadataLog;
class MOZ_RAII BufferReader
{
public:
BufferReader() : mPtr(nullptr), mRemaining(0) {}
BufferReader(const uint8_t* aData, size_t aSize)
@@ -304,11 +304,11 @@ public:
}
private:
const uint8_t* mPtr;
size_t mRemaining;
size_t mLength;
};
-} // namespace mp4_demuxer
+} // namespace mozilla
#endif
--- a/dom/media/ByteWriter.h
+++ b/dom/media/ByteWriter.h
@@ -3,17 +3,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef BYTE_WRITER_H_
#define BYTE_WRITER_H_
#include "mozilla/EndianUtils.h"
#include "nsTArray.h"
-namespace mp4_demuxer {
+namespace mozilla {
class ByteWriter
{
public:
explicit ByteWriter(nsTArray<uint8_t>& aData)
: mPtr(aData)
{
}
@@ -65,11 +65,11 @@ public:
{
return mPtr.AppendElements(aSrc, aCount, mozilla::fallible);
}
private:
nsTArray<uint8_t>& mPtr;
};
-} // namespace mp4_demuxer
+} // namespace mozilla
#endif
--- a/dom/media/flac/FlacDemuxer.cpp
+++ b/dom/media/flac/FlacDemuxer.cpp
@@ -41,17 +41,17 @@ public:
int64_t Index() const { return mIndex; }
// Parse the current packet and check that it made a valid flac frame header.
// From https://xiph.org/flac/format.html#frame_header
// A valid header is one that can be decoded without error and that has a
// valid CRC.
bool Parse(const uint8_t* aPacket, size_t aBytes)
{
- mp4_demuxer::BitReader br(aPacket, aBytes * 8);
+ BitReader br(aPacket, aBytes * 8);
// Frame sync code.
if ((br.ReadBits(15) & 0x7fff) != 0x7ffc) {
return false;
}
// Variable block size stream code.
mVariableBlockSize = br.ReadBit();
--- a/dom/media/flac/FlacFrameParser.cpp
+++ b/dom/media/flac/FlacFrameParser.cpp
@@ -7,18 +7,16 @@
#include "FlacFrameParser.h"
#include "nsTArray.h"
#include "OggCodecState.h"
#include "OpusParser.h"
#include "VideoUtils.h"
#include "BufferReader.h"
#include "mozilla/ResultExtensions.h"
-using mp4_demuxer::BufferReader;
-
namespace mozilla
{
#define OGG_FLAC_METADATA_TYPE_STREAMINFO 0x7F
#define FLAC_STREAMINFO_SIZE 34
#define BITMASK(x) ((1ULL << x)-1)
--- a/dom/media/mediasource/ContainerParser.cpp
+++ b/dom/media/mediasource/ContainerParser.cpp
@@ -460,17 +460,17 @@ private:
{
mValid = Init(aType, aData, aStop).isOk();
}
Result<Ok, nsresult> Init(const MediaContainerType& aType, const MediaByteBuffer* aData,
StopAt aStop)
{
const MediaContainerType mType(aType); // for logging macro.
- mp4_demuxer::BufferReader reader(aData);
+ BufferReader reader(aData);
mp4_demuxer::AtomType initAtom("moov");
mp4_demuxer::AtomType mediaAtom("moof");
mp4_demuxer::AtomType dataAtom("mdat");
// Valid top-level boxes defined in ISO/IEC 14496-12 (Table 1)
static const mp4_demuxer::AtomType validBoxes[] = {
"ftyp", "moov", // init segment
"pdin", "free", "sidx", // optional prior moov box
--- a/dom/media/mp3/MP3Demuxer.cpp
+++ b/dom/media/mp3/MP3Demuxer.cpp
@@ -19,17 +19,17 @@ extern mozilla::LazyLogModule gMediaDemu
#define MP3LOG(msg, ...) \
MOZ_LOG(gMediaDemuxerLog, LogLevel::Debug, ("MP3Demuxer " msg, ##__VA_ARGS__))
#define MP3LOGV(msg, ...) \
MOZ_LOG(gMediaDemuxerLog, LogLevel::Verbose, ("MP3Demuxer " msg, ##__VA_ARGS__))
using mozilla::media::TimeUnit;
using mozilla::media::TimeInterval;
using mozilla::media::TimeIntervals;
-using mp4_demuxer::BufferReader;
+using mozilla::BufferReader;
namespace mozilla {
// MP3Demuxer
MP3Demuxer::MP3Demuxer(MediaResource* aSource) : mSource(aSource) { }
bool
--- a/dom/media/mp3/MP3FrameParser.cpp
+++ b/dom/media/mp3/MP3FrameParser.cpp
@@ -16,18 +16,16 @@
#include "VideoUtils.h"
extern mozilla::LazyLogModule gMediaDemuxerLog;
#define MP3LOG(msg, ...) \
MOZ_LOG(gMediaDemuxerLog, LogLevel::Debug, ("MP3Demuxer " msg, ##__VA_ARGS__))
#define MP3LOGV(msg, ...) \
MOZ_LOG(gMediaDemuxerLog, LogLevel::Verbose, ("MP3Demuxer " msg, ##__VA_ARGS__))
-using mp4_demuxer::BufferReader;
-
namespace mozilla {
// FrameParser
namespace frame_header {
// FrameHeader mRaw byte offsets.
static const int SYNC1 = 0;
static const int SYNC2_VERSION_LAYER_PROTECTION = 1;
--- a/dom/media/mp3/MP3FrameParser.h
+++ b/dom/media/mp3/MP3FrameParser.h
@@ -79,17 +79,17 @@ public:
int mPos;
};
// Returns the parsed ID3 header. Note: check for validity.
const ID3Header& Header() const;
// Parses contents of given BufferReader for a valid ID3v2 header.
// Returns the total ID3v2 tag size if successful and zero otherwise.
- Result<uint32_t, nsresult> Parse(mp4_demuxer::BufferReader* aReader);
+ Result<uint32_t, nsresult> Parse(BufferReader* aReader);
// Resets the state to allow for a new parsing session.
void Reset();
private:
// The currently parsed ID3 header. Reset via Reset, updated via Parse.
ID3Header mHeader;
};
@@ -223,30 +223,30 @@ public:
// Returns the byte offset for the given duration percentage as a factor
// (0: begin, 1.0: end).
int64_t Offset(float aDurationFac) const;
// Parses contents of given ByteReader for a valid VBR header.
// The offset of the passed ByteReader needs to point to an MPEG frame
// begin, as a VBRI-style header is searched at a fixed offset relative to
// frame begin. Returns whether a valid VBR header was found in the range.
- bool Parse(mp4_demuxer::BufferReader* aReader);
+ bool Parse(BufferReader* aReader);
private:
// Parses contents of given ByteReader for a valid Xing header.
// The initial ByteReader offset will be preserved.
// Returns whether a valid Xing header was found in the range.
- Result<bool, nsresult> ParseXing(mp4_demuxer::BufferReader* aReader);
+ Result<bool, nsresult> ParseXing(BufferReader* aReader);
// Parses contents of given ByteReader for a valid VBRI header.
// The initial ByteReader offset will be preserved. It also needs to point
// to the beginning of a valid MPEG frame, as VBRI headers are searched
// at a fixed offset relative to frame begin.
// Returns whether a valid VBRI header was found in the range.
- Result<bool, nsresult> ParseVBRI(mp4_demuxer::BufferReader* aReader);
+ Result<bool, nsresult> ParseVBRI(BufferReader* aReader);
// The total number of frames expected as parsed from a VBR header.
Maybe<uint32_t> mNumAudioFrames;
// The total number of bytes expected in the stream.
Maybe<uint32_t> mNumBytes;
// The VBR scale factor.
@@ -311,23 +311,23 @@ public:
// - resets the CurrentFrame
// - resets ID3Header if no valid header was parsed yet
void EndFrameSession();
// Parses contents of given BufferReader for a valid frame header and returns
// true if one was found. After returning, the variable passed to
// 'aBytesToSkip' holds the amount of bytes to be skipped (if any) in order to
// jump across a large ID3v2 tag spanning multiple buffers.
- Result<bool, nsresult> Parse(mp4_demuxer::BufferReader* aReader, uint32_t* aBytesToSkip);
+ Result<bool, nsresult> Parse(BufferReader* aReader, uint32_t* aBytesToSkip);
// Parses contents of given BufferReader for a valid VBR header.
// The offset of the passed BufferReader needs to point to an MPEG frame begin,
// as a VBRI-style header is searched at a fixed offset relative to frame
// begin. Returns whether a valid VBR header was found.
- bool ParseVBRHeader(mp4_demuxer::BufferReader* aReader);
+ bool ParseVBRHeader(BufferReader* aReader);
private:
// ID3 header parser.
ID3Parser mID3Parser;
// VBR header parser.
VBRHeader mVBRHeader;
--- a/dom/media/mp4/MP4Metadata.cpp
+++ b/dom/media/mp4/MP4Metadata.cpp
@@ -17,21 +17,23 @@
#include "mp4parse.h"
#include <limits>
#include <stdint.h>
#include <vector>
using mozilla::media::TimeUnit;
+namespace mozilla {
+LazyLogModule gMP4MetadataLog("MP4Metadata");
+}
+
namespace mp4_demuxer
{
-LazyLogModule gMP4MetadataLog("MP4Metadata");
-
// the owner of mIndice is rust mp4 paser, so lifetime of this class
// SHOULD NOT longer than rust parser.
class IndiceWrapperRust : public IndiceWrapper
{
public:
size_t Length() const override;
bool GetIndice(size_t aIndex, Index::Indice& aIndice) const override;
--- a/dom/media/platforms/agnostic/WAVDecoder.cpp
+++ b/dom/media/platforms/agnostic/WAVDecoder.cpp
@@ -72,17 +72,17 @@ WaveDataDecoder::Decode(MediaRawData* aS
return InvokeAsync<MediaRawData*>(mTaskQueue, this, __func__,
&WaveDataDecoder::ProcessDecode, aSample);
}
RefPtr<MediaDataDecoder::DecodePromise>
WaveDataDecoder::ProcessDecode(MediaRawData* aSample)
{
size_t aLength = aSample->Size();
- mp4_demuxer::BufferReader aReader(aSample->Data(), aLength);
+ BufferReader aReader(aSample->Data(), aLength);
int64_t aOffset = aSample->mOffset;
int32_t frames = aLength * 8 / mInfo.mBitDepth / mInfo.mChannels;
AlignedAudioBuffer buffer(frames * mInfo.mChannels);
if (!buffer) {
return DecodePromise::CreateAndReject(
MediaResult(NS_ERROR_OUT_OF_MEMORY, __func__), __func__);
--- a/dom/media/platforms/agnostic/bytestreams/AnnexB.h
+++ b/dom/media/platforms/agnostic/bytestreams/AnnexB.h
@@ -6,23 +6,23 @@
#define MP4_DEMUXER_ANNEX_B_H_
#include "mozilla/Result.h"
#include "ErrorList.h"
template <class T> struct already_AddRefed;
namespace mozilla {
+class BufferReader;
class MediaRawData;
class MediaByteBuffer;
}
namespace mp4_demuxer
{
-class BufferReader;
class AnnexB
{
public:
// All conversions assume size of NAL length field is 4 bytes.
// Convert a sample from AVCC format to Annex B.
static mozilla::Result<mozilla::Ok, nsresult>
ConvertSampleToAnnexB(mozilla::MediaRawData* aSample, bool aAddSPS = true);
@@ -37,14 +37,14 @@ public:
// Returns true if format is AVCC and sample has valid extradata.
static bool IsAVCC(const mozilla::MediaRawData* aSample);
// Returns true if format is AnnexB.
static bool IsAnnexB(const mozilla::MediaRawData* aSample);
private:
// AVCC box parser helper.
static mozilla::Result<mozilla::Ok, nsresult>
- ConvertSPSOrPPS(BufferReader& aReader, uint8_t aCount, mozilla::MediaByteBuffer* aAnnexB);
+ ConvertSPSOrPPS(mozilla::BufferReader& aReader, uint8_t aCount, mozilla::MediaByteBuffer* aAnnexB);
};
} // namespace mp4_demuxer
#endif // MP4_DEMUXER_ANNEX_B_H_
--- a/dom/media/platforms/agnostic/bytestreams/H264.h
+++ b/dom/media/platforms/agnostic/bytestreams/H264.h
@@ -2,16 +2,20 @@
* 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/. */
#ifndef MP4_DEMUXER_H264_H_
#define MP4_DEMUXER_H264_H_
#include "DecoderData.h"
+namespace mozilla {
+class BitReader;
+}
+
namespace mp4_demuxer {
// Spec 7.4.2.1
#define MAX_SPS_COUNT 32
#define MAX_PPS_COUNT 256
// NAL unit types
enum NAL_TYPES {
@@ -29,18 +33,16 @@ enum NAL_TYPES {
H264_NAL_FILLER_DATA = 12,
H264_NAL_SPS_EXT = 13,
H264_NAL_PREFIX = 14,
H264_NAL_AUXILIARY_SLICE = 19,
H264_NAL_SLICE_EXT = 20,
H264_NAL_SLICE_EXT_DVC = 21,
};
-class BitReader;
-
struct SPSData
{
bool operator==(const SPSData& aOther) const;
bool operator!=(const SPSData& aOther) const;
bool valid;
/* Decoded Members */
@@ -480,19 +482,19 @@ private:
/* Extract RAW BYTE SEQUENCE PAYLOAD from NAL content.
Returns nullptr if invalid content.
This is compliant to ITU H.264 7.3.1 Syntax in tabular form NAL unit syntax
*/
static already_AddRefed<mozilla::MediaByteBuffer> DecodeNALUnit(
const uint8_t* aNAL, size_t aLength);
/* Decode SPS NAL RBSP and fill SPSData structure */
static bool DecodeSPS(const mozilla::MediaByteBuffer* aSPS, SPSData& aDest);
- static bool vui_parameters(BitReader& aBr, SPSData& aDest);
+ static bool vui_parameters(mozilla::BitReader& aBr, SPSData& aDest);
// Read HRD parameters, all data is ignored.
- static void hrd_parameters(BitReader& aBr);
+ static void hrd_parameters(mozilla::BitReader& aBr);
static uint8_t NumSPS(const mozilla::MediaByteBuffer* aExtraData);
// Decode SEI payload and return true if the SEI NAL indicates a recovery
// point.
static bool DecodeRecoverySEI(const mozilla::MediaByteBuffer* aSEI,
SEIRecoveryData& aDest);
};
} // namespace mp4_demuxer
--- a/dom/media/wave/WaveDemuxer.h
+++ b/dom/media/wave/WaveDemuxer.h
@@ -3,22 +3,18 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef WAV_DEMUXER_H_
#define WAV_DEMUXER_H_
#include "MediaDataDemuxer.h"
#include "MediaResource.h"
-namespace mp4_demuxer {
+namespace mozilla {
class BufferReader;
-}
-using mp4_demuxer::BufferReader;
-
-namespace mozilla {
static const uint32_t FRMT_CODE = 0x666d7420;
static const uint32_t DATA_CODE = 0x64617461;
static const uint32_t LIST_CODE = 0x4c495354;
static const uint32_t INFO_CODE = 0x494e464f;
static const uint8_t RIFF[4] = {'R', 'I', 'F', 'F'};
static const uint8_t WAVE[4] = {'W', 'A', 'V', 'E'};