Bug 1788119 - Part 2 - Rename dom/media/mp4/Index.h's Index class to MP4SampleIndex to prevent name conflicts. r=media-playback-reviewers,alwu

Depends on D156650

Differential Revision: https://phabricator.services.mozilla.com/D156651
This commit is contained in:
zaggy1024 2023-01-27 18:35:13 +00:00
Родитель 13ebc5f3b4
Коммит 665da8f4a1
8 изменённых файлов: 42 добавлений и 39 удалений

Просмотреть файл

@ -316,7 +316,7 @@ TEST(MP4Metadata, test_case_mp4)
<< tests[test].mFilename;
if (tests[test].mHasVideoIndice) {
for (size_t i = 0; i < indices.Ref()->Length(); i++) {
Index::Indice data;
MP4SampleIndex::Indice data;
EXPECT_TRUE(indices.Ref()->GetIndice(i, data))
<< tests[test].mFilename;
EXPECT_TRUE(data.start_offset <= data.end_offset)
@ -349,7 +349,7 @@ TEST(MP4Metadata, test_case_mp4)
metadata.GetTrackIndice(audioInfo->mTrackId);
EXPECT_TRUE(!!indices.Ref()) << tests[test].mFilename;
for (size_t i = 0; i < indices.Ref()->Length(); i++) {
Index::Indice data;
MP4SampleIndex::Indice data;
EXPECT_TRUE(indices.Ref()->GetIndice(i, data)) << tests[test].mFilename;
EXPECT_TRUE(data.start_offset <= data.end_offset)
<< tests[test].mFilename;

Просмотреть файл

@ -19,9 +19,9 @@
#ifdef MOZ_FMP4
# include "AtomType.h"
# include "BufferReader.h"
# include "Index.h"
# include "MP4Interval.h"
# include "ByteStream.h"
# include "MP4Interval.h"
# include "SampleIterator.h"
#endif
#include "SourceBufferResource.h"
#include <algorithm>

Просмотреть файл

@ -13,7 +13,6 @@
#include "AnnexB.h"
#include "BufferStream.h"
#include "H264.h"
#include "Index.h"
#include "MP4Decoder.h"
#include "MP4Metadata.h"
#include "MoofParser.h"
@ -23,6 +22,7 @@
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/Telemetry.h"
#include "nsPrintfCString.h"
#include "SampleIterator.h"
extern mozilla::LazyLogModule gMediaDemuxerLog;
mozilla::LogModule* GetDemuxerLog() { return gMediaDemuxerLog; }
@ -66,7 +66,7 @@ class MP4TrackDemuxer : public MediaTrackDemuxer,
RefPtr<MediaResource> mResource;
RefPtr<ResourceStream> mStream;
UniquePtr<TrackInfo> mInfo;
RefPtr<Index> mIndex;
RefPtr<MP4SampleIndex> mIndex;
UniquePtr<SampleIterator> mIterator;
Maybe<media::TimeUnit> mNextKeyframeTime;
// Queued samples extracted by the demuxer, but not yet returned.
@ -309,7 +309,8 @@ MP4TrackDemuxer::MP4TrackDemuxer(MediaResource* aResource,
: mResource(aResource),
mStream(new ResourceStream(aResource)),
mInfo(std::move(aInfo)),
mIndex(new Index(aIndices, mStream, mInfo->mTrackId, mInfo->IsAudio())),
mIndex(new MP4SampleIndex(aIndices, mStream, mInfo->mTrackId,
mInfo->IsAudio())),
mIterator(MakeUnique<SampleIterator>(mIndex)),
mNeedReIndex(true) {
EnsureUpToDateIndex(); // Force update of index

Просмотреть файл

@ -32,7 +32,8 @@ IndiceWrapper::IndiceWrapper(Mp4parseByteData& aIndice) {
size_t IndiceWrapper::Length() const { return mIndice.length; }
bool IndiceWrapper::GetIndice(size_t aIndex, Index::Indice& aIndice) const {
bool IndiceWrapper::GetIndice(size_t aIndex,
MP4SampleIndex::Indice& aIndice) const {
if (aIndex >= mIndice.length) {
MOZ_LOG(gMP4MetadataLog, LogLevel::Error, ("Index overflow in indice"));
return false;

Просмотреть файл

@ -9,12 +9,12 @@
#include "mozilla/UniquePtr.h"
#include "DecoderData.h"
#include "Index.h"
#include "MediaData.h"
#include "MediaInfo.h"
#include "MediaResult.h"
#include "ByteStream.h"
#include "mp4parse.h"
#include "SampleIterator.h"
namespace mozilla {
@ -26,7 +26,7 @@ class IndiceWrapper {
public:
size_t Length() const;
bool GetIndice(size_t aIndex, Index::Indice& aIndice) const;
bool GetIndice(size_t aIndex, MP4SampleIndex::Indice& aIndice) const;
explicit IndiceWrapper(Mp4parseByteData& aRustIndice);

Просмотреть файл

@ -2,7 +2,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 "Index.h"
#include "SampleIterator.h"
#include <algorithm>
#include <limits>
@ -71,7 +71,7 @@ bool RangeFinder::Contains(MediaByteRange aByteRange) {
return false;
}
SampleIterator::SampleIterator(Index* aIndex)
SampleIterator::SampleIterator(MP4SampleIndex* aIndex)
: mIndex(aIndex), mCurrentMoof(0), mCurrentSample(0) {
mIndex->RegisterIterator(this);
}
@ -413,8 +413,9 @@ Microseconds SampleIterator::GetNextKeyframeTime() {
return -1;
}
Index::Index(const IndiceWrapper& aIndices, ByteStream* aSource,
uint32_t aTrackId, bool aIsAudio)
MP4SampleIndex::MP4SampleIndex(const IndiceWrapper& aIndices,
ByteStream* aSource, uint32_t aTrackId,
bool aIsAudio)
: mSource(aSource), mIsAudio(aIsAudio) {
if (!aIndices.Length()) {
mMoofParser =
@ -495,14 +496,14 @@ Index::Index(const IndiceWrapper& aIndices, ByteStream* aSource,
}
}
Index::~Index() = default;
MP4SampleIndex::~MP4SampleIndex() = default;
void Index::UpdateMoofIndex(const MediaByteRangeSet& aByteRanges) {
void MP4SampleIndex::UpdateMoofIndex(const MediaByteRangeSet& aByteRanges) {
UpdateMoofIndex(aByteRanges, false);
}
void Index::UpdateMoofIndex(const MediaByteRangeSet& aByteRanges,
bool aCanEvict) {
void MP4SampleIndex::UpdateMoofIndex(const MediaByteRangeSet& aByteRanges,
bool aCanEvict) {
if (!mMoofParser) {
return;
}
@ -529,7 +530,7 @@ void Index::UpdateMoofIndex(const MediaByteRangeSet& aByteRanges,
}
}
Microseconds Index::GetEndCompositionIfBuffered(
Microseconds MP4SampleIndex::GetEndCompositionIfBuffered(
const MediaByteRangeSet& aByteRanges) {
FallibleTArray<Sample>* index;
if (mMoofParser) {
@ -556,7 +557,7 @@ Microseconds Index::GetEndCompositionIfBuffered(
return 0;
}
TimeIntervals Index::ConvertByteRangesToTimeRanges(
TimeIntervals MP4SampleIndex::ConvertByteRangesToTimeRanges(
const MediaByteRangeSet& aByteRanges) {
if (aByteRanges == mLastCachedRanges) {
return mLastBufferedRanges;
@ -670,7 +671,7 @@ TimeIntervals Index::ConvertByteRangesToTimeRanges(
return ranges;
}
uint64_t Index::GetEvictionOffset(Microseconds aTime) {
uint64_t MP4SampleIndex::GetEvictionOffset(Microseconds aTime) {
uint64_t offset = std::numeric_limits<uint64_t>::max();
if (mMoofParser) {
// We need to keep the whole moof if we're keeping any of it because the
@ -696,11 +697,11 @@ uint64_t Index::GetEvictionOffset(Microseconds aTime) {
return offset;
}
void Index::RegisterIterator(SampleIterator* aIterator) {
void MP4SampleIndex::RegisterIterator(SampleIterator* aIterator) {
mIterators.AppendElement(aIterator);
}
void Index::UnregisterIterator(SampleIterator* aIterator) {
void MP4SampleIndex::UnregisterIterator(SampleIterator* aIterator) {
mIterators.RemoveElement(aIterator);
}

Просмотреть файл

@ -2,8 +2,8 @@
* 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 INDEX_H_
#define INDEX_H_
#ifndef DOM_MEDIA_MP4_SAMPLE_ITERATOR_H_
#define DOM_MEDIA_MP4_SAMPLE_ITERATOR_H_
#include "ByteStream.h"
#include "MediaData.h"
@ -15,17 +15,17 @@
#include "TimeUnits.h"
namespace mozilla {
class IndiceWrapper;
struct Sample;
struct CencSampleEncryptionInfoEntry;
class Index;
struct CencSampleEncryptionInfoEntry;
class IndiceWrapper;
class MP4SampleIndex;
struct Sample;
typedef int64_t Microseconds;
class SampleIterator {
public:
explicit SampleIterator(Index* aIndex);
explicit SampleIterator(MP4SampleIndex* aIndex);
~SampleIterator();
already_AddRefed<mozilla::MediaRawData> GetNext();
void Seek(Microseconds aTime);
@ -48,15 +48,15 @@ class SampleIterator {
Result<CryptoScheme, nsCString> GetEncryptionScheme();
void Next();
RefPtr<Index> mIndex;
friend class Index;
RefPtr<MP4SampleIndex> mIndex;
friend class MP4SampleIndex;
size_t mCurrentMoof;
size_t mCurrentSample;
};
class Index {
class MP4SampleIndex {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Index)
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MP4SampleIndex)
struct Indice {
uint64_t start_offset;
@ -99,8 +99,8 @@ class Index {
MP4Interval<Microseconds> mTime;
};
Index(const mozilla::IndiceWrapper& aIndices, ByteStream* aSource,
uint32_t aTrackId, bool aIsAudio);
MP4SampleIndex(const mozilla::IndiceWrapper& aIndices, ByteStream* aSource,
uint32_t aTrackId, bool aIsAudio);
void UpdateMoofIndex(const mozilla::MediaByteRangeSet& aByteRanges,
bool aCanEvict);
@ -115,7 +115,7 @@ class Index {
friend class SampleIterator;
private:
~Index();
~MP4SampleIndex();
void RegisterIterator(SampleIterator* aIterator);
void UnregisterIterator(SampleIterator* aIterator);

Просмотреть файл

@ -11,13 +11,13 @@ EXPORTS += [
"BufferStream.h",
"ByteStream.h",
"DecoderData.h",
"Index.h",
"MoofParser.h",
"MP4Decoder.h",
"MP4Demuxer.h",
"MP4Interval.h",
"MP4Metadata.h",
"ResourceStream.h",
"SampleIterator.h",
"SinfParser.h",
]
@ -25,12 +25,12 @@ UNIFIED_SOURCES += [
"Box.cpp",
"BufferStream.cpp",
"DecoderData.cpp",
"Index.cpp",
"MoofParser.cpp",
"MP4Decoder.cpp",
"MP4Demuxer.cpp",
"MP4Metadata.cpp",
"ResourceStream.cpp",
"SampleIterator.cpp",
"SinfParser.cpp",
]