mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1227396: P9. Remove unnecessary monitor. r=cpearce
The Index and MoofParser are now only used via the MP4Demuxer which is guaranteed to always be called on the same taskqueue.
This commit is contained in:
parent
a7975b198f
commit
fdf27ff498
@ -59,9 +59,6 @@ private:
|
||||
RefPtr<MP4Demuxer> mParent;
|
||||
RefPtr<mp4_demuxer::ResourceStream> mStream;
|
||||
UniquePtr<TrackInfo> mInfo;
|
||||
// We do not actually need a monitor, however MoofParser (in mIndex) will
|
||||
// assert if a monitor isn't held.
|
||||
Monitor mMonitor;
|
||||
RefPtr<mp4_demuxer::Index> mIndex;
|
||||
UniquePtr<mp4_demuxer::SampleIterator> mIterator;
|
||||
Maybe<media::TimeUnit> mNextKeyframeTime;
|
||||
@ -228,12 +225,10 @@ MP4TrackDemuxer::MP4TrackDemuxer(MP4Demuxer* aParent,
|
||||
: mParent(aParent)
|
||||
, mStream(new mp4_demuxer::ResourceStream(mParent->mResource))
|
||||
, mInfo(Move(aInfo))
|
||||
, mMonitor("MP4TrackDemuxer")
|
||||
, mIndex(new mp4_demuxer::Index(indices,
|
||||
mStream,
|
||||
mInfo->mTrackId,
|
||||
mInfo->IsAudio(),
|
||||
&mMonitor))
|
||||
mInfo->IsAudio()))
|
||||
, mIterator(MakeUnique<mp4_demuxer::SampleIterator>(mIndex))
|
||||
, mNeedReIndex(true)
|
||||
{
|
||||
@ -269,7 +264,6 @@ MP4TrackDemuxer::EnsureUpToDateIndex()
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
MonitorAutoLock mon(mMonitor);
|
||||
mIndex->UpdateMoofIndex(byteRanges);
|
||||
mNeedReIndex = false;
|
||||
}
|
||||
@ -280,7 +274,6 @@ MP4TrackDemuxer::Seek(media::TimeUnit aTime)
|
||||
int64_t seekTime = aTime.ToMicroseconds();
|
||||
mQueuedSample = nullptr;
|
||||
|
||||
MonitorAutoLock mon(mMonitor);
|
||||
mIterator->Seek(seekTime);
|
||||
|
||||
// Check what time we actually seeked to.
|
||||
@ -307,7 +300,6 @@ MP4TrackDemuxer::GetSamples(int32_t aNumSamples)
|
||||
mQueuedSample = nullptr;
|
||||
aNumSamples--;
|
||||
}
|
||||
MonitorAutoLock mon(mMonitor);
|
||||
RefPtr<MediaRawData> sample;
|
||||
while (aNumSamples && (sample = mIterator->GetNext())) {
|
||||
samples->mSamples.AppendElement(sample);
|
||||
@ -338,7 +330,6 @@ MP4TrackDemuxer::Reset()
|
||||
{
|
||||
mQueuedSample = nullptr;
|
||||
// TODO, Seek to first frame available, which isn't always 0.
|
||||
MonitorAutoLock mon(mMonitor);
|
||||
mIterator->Seek(0);
|
||||
SetNextKeyFrameTime();
|
||||
}
|
||||
@ -386,7 +377,6 @@ MP4TrackDemuxer::GetNextRandomAccessPoint(media::TimeUnit* aTime)
|
||||
RefPtr<MP4TrackDemuxer::SkipAccessPointPromise>
|
||||
MP4TrackDemuxer::SkipToNextRandomAccessPoint(media::TimeUnit aTimeThreshold)
|
||||
{
|
||||
MonitorAutoLock mon(mMonitor);
|
||||
mQueuedSample = nullptr;
|
||||
// Loop until we reach the next keyframe after the threshold.
|
||||
uint32_t parsed = 0;
|
||||
@ -421,7 +411,6 @@ MP4TrackDemuxer::GetBuffered()
|
||||
}
|
||||
nsTArray<mp4_demuxer::Interval<int64_t>> timeRanges;
|
||||
|
||||
MonitorAutoLock mon(mMonitor);
|
||||
mIndex->ConvertByteRangesToTimeRanges(byteRanges, &timeRanges);
|
||||
// convert timeRanges.
|
||||
media::TimeIntervals ranges = media::TimeIntervals();
|
||||
|
@ -334,7 +334,6 @@ class MP4ContainerParser : public ContainerParser {
|
||||
public:
|
||||
explicit MP4ContainerParser(const nsACString& aType)
|
||||
: ContainerParser(aType)
|
||||
, mMonitor("MP4ContainerParser Index Monitor")
|
||||
{}
|
||||
|
||||
bool IsInitSegmentPresent(MediaByteBuffer* aData) override
|
||||
@ -421,8 +420,6 @@ public:
|
||||
bool ParseStartAndEndTimestamps(MediaByteBuffer* aData,
|
||||
int64_t& aStart, int64_t& aEnd) override
|
||||
{
|
||||
MonitorAutoLock mon(mMonitor); // We're not actually racing against anything,
|
||||
// but mParser requires us to hold a monitor.
|
||||
bool initSegment = IsInitSegmentPresent(aData);
|
||||
if (initSegment) {
|
||||
mResource = new SourceBufferResource(NS_LITERAL_CSTRING("video/mp4"));
|
||||
@ -431,7 +428,7 @@ public:
|
||||
// consumers of ParseStartAndEndTimestamps to add their timestamp offset
|
||||
// manually. This allows the ContainerParser to be shared across different
|
||||
// timestampOffsets.
|
||||
mParser = new mp4_demuxer::MoofParser(mStream, 0, /* aIsAudio = */ false, &mMonitor);
|
||||
mParser = new mp4_demuxer::MoofParser(mStream, 0, /* aIsAudio = */ false);
|
||||
mInitData = new MediaByteBuffer();
|
||||
} else if (!mStream || !mParser) {
|
||||
return false;
|
||||
@ -495,7 +492,6 @@ public:
|
||||
private:
|
||||
RefPtr<MP4Stream> mStream;
|
||||
nsAutoPtr<mp4_demuxer::MoofParser> mParser;
|
||||
Monitor mMonitor;
|
||||
};
|
||||
#endif // MOZ_FMP4
|
||||
|
||||
|
@ -236,13 +236,11 @@ SampleIterator::GetNextKeyframeTime()
|
||||
Index::Index(const nsTArray<Indice>& aIndex,
|
||||
Stream* aSource,
|
||||
uint32_t aTrackId,
|
||||
bool aIsAudio,
|
||||
Monitor* aMonitor)
|
||||
bool aIsAudio)
|
||||
: mSource(aSource)
|
||||
, mMonitor(aMonitor)
|
||||
{
|
||||
if (aIndex.IsEmpty()) {
|
||||
mMoofParser = new MoofParser(aSource, aTrackId, aIsAudio, aMonitor);
|
||||
mMoofParser = new MoofParser(aSource, aTrackId, aIsAudio);
|
||||
} else {
|
||||
if (!mIndex.SetCapacity(aIndex.Length(), fallible)) {
|
||||
// OOM.
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "media/stagefright/MediaSource.h"
|
||||
#include "media/stagefright/MetaData.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mp4_demuxer/MoofParser.h"
|
||||
#include "mp4_demuxer/MP4Metadata.h"
|
||||
@ -333,20 +332,14 @@ MP4Metadata::GetTrackNumber(mozilla::TrackID aTrackID)
|
||||
/*static*/ bool
|
||||
MP4Metadata::HasCompleteMetadata(Stream* aSource)
|
||||
{
|
||||
// The MoofParser requires a monitor, but we don't need one here.
|
||||
mozilla::Monitor monitor("MP4Metadata::HasCompleteMetadata");
|
||||
mozilla::MonitorAutoLock mon(monitor);
|
||||
auto parser = mozilla::MakeUnique<MoofParser>(aSource, 0, false, &monitor);
|
||||
auto parser = mozilla::MakeUnique<MoofParser>(aSource, 0, false);
|
||||
return parser->HasMetadata();
|
||||
}
|
||||
|
||||
/*static*/ already_AddRefed<mozilla::MediaByteBuffer>
|
||||
MP4Metadata::Metadata(Stream* aSource)
|
||||
{
|
||||
// The MoofParser requires a monitor, but we don't need one here.
|
||||
mozilla::Monitor monitor("MP4Metadata::HasCompleteMetadata");
|
||||
mozilla::MonitorAutoLock mon(monitor);
|
||||
auto parser = mozilla::MakeUnique<MoofParser>(aSource, 0, false, &monitor);
|
||||
auto parser = mozilla::MakeUnique<MoofParser>(aSource, 0, false);
|
||||
return parser->Metadata();
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "MediaData.h"
|
||||
#include "MediaResource.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mp4_demuxer/Interval.h"
|
||||
#include "mp4_demuxer/Stream.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
@ -57,8 +56,7 @@ public:
|
||||
Index(const nsTArray<Indice>& aIndex,
|
||||
Stream* aSource,
|
||||
uint32_t aTrackId,
|
||||
bool aIsAudio,
|
||||
mozilla::Monitor* aMonitor);
|
||||
bool aIsAudio);
|
||||
|
||||
void UpdateMoofIndex(const mozilla::MediaByteRangeSet& aByteRanges);
|
||||
Microseconds GetEndCompositionIfBuffered(
|
||||
@ -77,7 +75,6 @@ private:
|
||||
Stream* mSource;
|
||||
FallibleTArray<Sample> mIndex;
|
||||
nsAutoPtr<MoofParser> mMoofParser;
|
||||
mozilla::Monitor* mMonitor;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#ifndef MOOF_PARSER_H_
|
||||
#define MOOF_PARSER_H_
|
||||
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mp4_demuxer/Atom.h"
|
||||
#include "mp4_demuxer/AtomType.h"
|
||||
#include "mp4_demuxer/SinfParser.h"
|
||||
@ -14,7 +13,6 @@
|
||||
#include "MediaResource.h"
|
||||
|
||||
namespace mp4_demuxer {
|
||||
using mozilla::Monitor;
|
||||
typedef int64_t Microseconds;
|
||||
|
||||
class Box;
|
||||
@ -201,11 +199,10 @@ private:
|
||||
class MoofParser
|
||||
{
|
||||
public:
|
||||
MoofParser(Stream* aSource, uint32_t aTrackId, bool aIsAudio, Monitor* aMonitor)
|
||||
MoofParser(Stream* aSource, uint32_t aTrackId, bool aIsAudio)
|
||||
: mSource(aSource)
|
||||
, mOffset(0)
|
||||
, mTrex(aTrackId)
|
||||
, mMonitor(aMonitor)
|
||||
, mIsAudio(aIsAudio)
|
||||
{
|
||||
// Setting the mTrex.mTrackId to 0 is a nasty work around for calculating
|
||||
@ -244,8 +241,7 @@ public:
|
||||
Tfdt mTfdt;
|
||||
Edts mEdts;
|
||||
Sinf mSinf;
|
||||
Monitor* mMonitor;
|
||||
nsTArray<Moof>& Moofs() { mMonitor->AssertCurrentThreadOwns(); return mMoofs; }
|
||||
nsTArray<Moof>& Moofs() { return mMoofs; }
|
||||
private:
|
||||
void ScanForMetadata(mozilla::MediaByteRange& aFtyp,
|
||||
mozilla::MediaByteRange& aMoov);
|
||||
|
@ -96,9 +96,7 @@ TEST(stagefright_MoofParser, EmptyStream)
|
||||
{
|
||||
RefPtr<Stream> stream = new TestStream(nullptr, 0);
|
||||
|
||||
Monitor monitor("MP4Metadata::gtest");
|
||||
MonitorAutoLock mon(monitor);
|
||||
MoofParser parser(stream, 0, false, &monitor);
|
||||
MoofParser parser(stream, 0, false);
|
||||
EXPECT_EQ(0u, parser.mOffset);
|
||||
EXPECT_TRUE(parser.ReachedEnd());
|
||||
|
||||
@ -285,9 +283,7 @@ TEST(stagefright_MoofParser, test_case_mp4)
|
||||
ASSERT_FALSE(buffer.IsEmpty());
|
||||
RefPtr<Stream> stream = new TestStream(buffer.Elements(), buffer.Length());
|
||||
|
||||
Monitor monitor("MP4Metadata::HasCompleteMetadata");
|
||||
MonitorAutoLock mon(monitor);
|
||||
MoofParser parser(stream, 0, false, &monitor);
|
||||
MoofParser parser(stream, 0, false);
|
||||
EXPECT_EQ(0u, parser.mOffset);
|
||||
EXPECT_FALSE(parser.ReachedEnd());
|
||||
|
||||
@ -315,8 +311,6 @@ TEST(stagefright_MoofParser, test_case_mp4_subsets)
|
||||
nsTArray<uint8_t> buffer = ReadTestFile(testFiles[test].mFilename);
|
||||
ASSERT_FALSE(buffer.IsEmpty());
|
||||
ASSERT_LE(step, buffer.Length());
|
||||
Monitor monitor("MP4Metadata::HasCompleteMetadata");
|
||||
MonitorAutoLock mon(monitor);
|
||||
// Just exercizing the parser starting at different points through the file,
|
||||
// making sure it doesn't crash.
|
||||
// No checks because results would differ for each position.
|
||||
@ -326,7 +320,7 @@ TEST(stagefright_MoofParser, test_case_mp4_subsets)
|
||||
RefPtr<TestStream> stream =
|
||||
new TestStream(buffer.Elements() + offset, size);
|
||||
|
||||
MoofParser parser(stream, 0, false, &monitor);
|
||||
MoofParser parser(stream, 0, false);
|
||||
MediaByteRangeSet byteRanges;
|
||||
EXPECT_FALSE(parser.RebuildFragmentedIndex(byteRanges));
|
||||
parser.GetCompositionRange(byteRanges);
|
||||
|
Loading…
Reference in New Issue
Block a user