diff options
Diffstat (limited to '')
-rw-r--r-- | dom/media/mediasource/TrackBuffersManager.cpp | 42 | ||||
-rw-r--r-- | dom/media/mediasource/TrackBuffersManager.h | 2 |
2 files changed, 40 insertions, 4 deletions
diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index c87fa239f1..58ba7c250b 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -922,7 +922,11 @@ void TrackBuffersManager::SegmentParserLoop() { if (mNewMediaSegmentStarted) { if (NS_SUCCEEDED(newData) && mLastParsedEndTime.isSome() && start < mLastParsedEndTime.ref()) { - MSE_DEBUG("Re-creating demuxer"); + MSE_DEBUG("Re-creating demuxer, new start (%" PRId64 + ") is smaller than last parsed end time (%" PRId64 ")", + start.ToMicroseconds(), + mLastParsedEndTime->ToMicroseconds()); + mFrameEndTimeBeforeRecreateDemuxer = Some(end); ResetDemuxingState(); return; } @@ -1038,8 +1042,15 @@ void TrackBuffersManager::CreateDemuxerforMIMEType() { if (mType.Type() == MEDIAMIMETYPE(VIDEO_WEBM) || mType.Type() == MEDIAMIMETYPE(AUDIO_WEBM)) { - mInputDemuxer = - new WebMDemuxer(mCurrentInputBuffer, true /* IsMediaSource*/); + if (mFrameEndTimeBeforeRecreateDemuxer) { + MSE_DEBUG( + "CreateDemuxerFromMimeType: " + "mFrameEndTimeBeforeRecreateDemuxer=%" PRId64, + mFrameEndTimeBeforeRecreateDemuxer->ToMicroseconds()); + } + mInputDemuxer = new WebMDemuxer(mCurrentInputBuffer, true, + mFrameEndTimeBeforeRecreateDemuxer); + mFrameEndTimeBeforeRecreateDemuxer.reset(); DDLINKCHILD("demuxer", mInputDemuxer.get()); return; } @@ -1047,6 +1058,7 @@ void TrackBuffersManager::CreateDemuxerforMIMEType() { if (mType.Type() == MEDIAMIMETYPE(VIDEO_MP4) || mType.Type() == MEDIAMIMETYPE(AUDIO_MP4)) { mInputDemuxer = new MP4Demuxer(mCurrentInputBuffer); + mFrameEndTimeBeforeRecreateDemuxer.reset(); DDLINKCHILD("demuxer", mInputDemuxer.get()); return; } @@ -1625,9 +1637,11 @@ void TrackBuffersManager::MaybeDispatchEncryptedEvent( void TrackBuffersManager::OnVideoDemuxCompleted( const RefPtr<MediaTrackDemuxer::SamplesHolder>& aSamples) { mTaskQueueCapability->AssertOnCurrentThread(); - MSE_DEBUG("%zu video samples demuxed", aSamples->GetSamples().Length()); mVideoTracks.mDemuxRequest.Complete(); mVideoTracks.mQueuedSamples.AppendElements(aSamples->GetSamples()); + MSE_DEBUG("%zu video samples demuxed, queued-sz=%zu", + aSamples->GetSamples().Length(), + mVideoTracks.mQueuedSamples.Length()); MaybeDispatchEncryptedEvent(aSamples->GetSamples()); DoDemuxAudio(); @@ -1892,6 +1906,9 @@ void TrackBuffersManager::ProcessFrames(TrackBuffer& aSamples, // coded frame. if (!sample->mKeyframe) { previouslyDroppedSample = nullptr; + SAMPLE_DEBUGV("skipping sample [%" PRId64 ",%" PRId64 "]", + sample->mTime.ToMicroseconds(), + sample->GetEndTime().ToMicroseconds()); continue; } // 2. Set the need random access point flag on track buffer to false. @@ -1971,6 +1988,7 @@ void TrackBuffersManager::ProcessFrames(TrackBuffer& aSamples, // 4. Unset the highest end timestamp on all track buffers. // 5. Set the need random access point flag on all track buffers to // true. + MSE_DEBUG("Resetting append state"); track->ResetAppendState(); } // 6. Jump to the Loop Top step above to restart processing of the current @@ -2553,10 +2571,12 @@ void TrackBuffersManager::RecreateParser(bool aReuseInitData) { mParser = ContainerParser::CreateForMIMEType(mType); DDLINKCHILD("parser", mParser.get()); if (aReuseInitData && mInitData) { + MSE_DEBUG("Using existing init data to reset parser"); TimeUnit start, end; mParser->ParseStartAndEndTimestamps(MediaSpan(mInitData), start, end); mProcessedInput = mInitData->Length(); } else { + MSE_DEBUG("Resetting parser, not reusing init data"); mProcessedInput = 0; } } @@ -2843,12 +2863,20 @@ const MediaRawData* TrackBuffersManager::GetSample(TrackInfo::TrackType aTrack, const TrackBuffer& track = GetTrackBuffer(aTrack); if (aIndex >= track.Length()) { + MSE_DEBUGV( + "Can't get sample due to reaching to the end, index=%u, " + "length=%zu", + aIndex, track.Length()); // reached the end. return nullptr; } if (!(aExpectedDts + aFuzz).IsValid() || !(aExpectedPts + aFuzz).IsValid()) { // Time overflow, it seems like we also reached the end. + MSE_DEBUGV("Can't get sample due to time overflow, expectedPts=%" PRId64 + ", aExpectedDts=%" PRId64 ", fuzz=%" PRId64, + aExpectedPts.ToMicroseconds(), aExpectedPts.ToMicroseconds(), + aFuzz.ToMicroseconds()); return nullptr; } @@ -2859,6 +2887,12 @@ const MediaRawData* TrackBuffersManager::GetSample(TrackInfo::TrackType aTrack, return sample; } + MSE_DEBUGV("Can't get sample due to big gap, sample=%" PRId64 + ", expectedPts=%" PRId64 ", aExpectedDts=%" PRId64 + ", fuzz=%" PRId64, + sample->mTime.ToMicroseconds(), aExpectedPts.ToMicroseconds(), + aExpectedPts.ToMicroseconds(), aFuzz.ToMicroseconds()); + // Gap is too big. End of Stream or Waiting for Data. // TODO, check that we have continuous data based on the sanitized buffered // range instead. diff --git a/dom/media/mediasource/TrackBuffersManager.h b/dom/media/mediasource/TrackBuffersManager.h index c72f2f5453..0e9c857586 100644 --- a/dom/media/mediasource/TrackBuffersManager.h +++ b/dom/media/mediasource/TrackBuffersManager.h @@ -568,6 +568,8 @@ class TrackBuffersManager final // mTaskQueue. However, there's special locking around mTaskQueue, so we keep // both for now. Maybe<EventTargetCapability<TaskQueue>> mTaskQueueCapability; + + Maybe<media::TimeUnit> mFrameEndTimeBeforeRecreateDemuxer; }; } // namespace mozilla |