mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1156689: Part8. Use new MoofParser::HasMetadata in MP4Metadata. r=kentuckyfriedtakahe
This allows MP4Reader::ReadMetadata() to no be unecessarily blocking on partial init segment.
This commit is contained in:
parent
208ad93cf7
commit
06c5225d25
@ -8,6 +8,7 @@
|
||||
#include "media/stagefright/MediaSource.h"
|
||||
#include "media/stagefright/MetaData.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mp4_demuxer/MoofParser.h"
|
||||
#include "mp4_demuxer/MP4Metadata.h"
|
||||
|
||||
#include <limits>
|
||||
@ -264,4 +265,14 @@ MP4Metadata::GetTrackNumber(mozilla::TrackID aTrackID)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*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);
|
||||
return parser->HasMetadata();
|
||||
}
|
||||
|
||||
} // namespace mp4_demuxer
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
explicit MP4Metadata(Stream* aSource);
|
||||
~MP4Metadata();
|
||||
|
||||
static bool HasCompleteMetadata(Stream* aSource);
|
||||
uint32_t GetNumberTracks(mozilla::TrackInfo::TrackType aType) const;
|
||||
mozilla::UniquePtr<mozilla::TrackInfo> GetTrackInfo(mozilla::TrackInfo::TrackType aType,
|
||||
size_t aTrackNumber) const;
|
||||
|
@ -29,10 +29,14 @@ MP4Demuxer::Init()
|
||||
{
|
||||
mMonitor->AssertCurrentThreadOwns();
|
||||
|
||||
// Check that we have an entire moov before attempting any new reads to make
|
||||
// the retry system work.
|
||||
if (!MP4Metadata::HasCompleteMetadata(mSource)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mMetadata = mozilla::MakeUnique<MP4Metadata>(mSource);
|
||||
|
||||
// Read the number of tracks. If we can't find any, make sure to bail now before
|
||||
// attempting any new reads to make the retry system work.
|
||||
if (!mMetadata->GetNumberTracks(mozilla::TrackInfo::kAudioTrack) &&
|
||||
!mMetadata->GetNumberTracks(mozilla::TrackInfo::kVideoTrack)) {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user