Track explicit (MSE) duration separately

This commit is contained in:
trav90
2017-07-02 04:25:07 -05:00
committed by Roy Tam
parent 30a4725667
commit cf3312970e
6 changed files with 37 additions and 15 deletions
+15 -1
View File
@@ -210,6 +210,8 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
mDurationSet(false),
mNetworkDuration(mTaskQueue, NullableTimeUnit(),
"MediaDecoderStateMachine::mNetworkDuration (Mirror)"),
mExplicitDuration(mTaskQueue, Maybe<double>(),
"MediaDecoderStateMachine::mExplicitDuration (Mirror)"),
mPlayState(mTaskQueue, MediaDecoder::PLAY_STATE_LOADING,
"MediaDecoderStateMachine::mPlayState (Mirror)"),
mNextPlayState(mTaskQueue, MediaDecoder::PLAY_STATE_PAUSED,
@@ -308,6 +310,7 @@ MediaDecoderStateMachine::InitializationTask()
// Connect mirrors.
mNetworkDuration.Connect(mDecoder->CanonicalNetworkDuration());
mExplicitDuration.Connect(mDecoder->CanonicalExplicitDuration());
mPlayState.Connect(mDecoder->CanonicalPlayState());
mNextPlayState.Connect(mDecoder->CanonicalNextPlayState());
mLogicallySeeking.Connect(mDecoder->CanonicalLogicallySeeking());
@@ -322,6 +325,7 @@ MediaDecoderStateMachine::InitializationTask()
mWatchManager.Watch(mLogicalPlaybackRate, &MediaDecoderStateMachine::LogicalPlaybackRateChanged);
mWatchManager.Watch(mPreservesPitch, &MediaDecoderStateMachine::PreservesPitchChanged);
mWatchManager.Watch(mNetworkDuration, &MediaDecoderStateMachine::RecomputeDuration);
mWatchManager.Watch(mExplicitDuration, &MediaDecoderStateMachine::RecomputeDuration);
mWatchManager.Watch(mPlayState, &MediaDecoderStateMachine::PlayStateChanged);
mWatchManager.Watch(mLogicallySeeking, &MediaDecoderStateMachine::LogicallySeekingChanged);
}
@@ -1420,7 +1424,16 @@ void MediaDecoderStateMachine::RecomputeDuration()
MOZ_ASSERT(OnTaskQueue());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
if (mInfo.mMetadataDuration.isSome()) {
if (mExplicitDuration.Ref().isSome()) {
double d = mExplicitDuration.Ref().ref();
if (IsNaN(d)) {
// We have an explicit duration (which means that we shouldn't look at
// any other duration sources), but the duration isn't ready yet.
return;
}
TimeUnit duration = TimeUnit::FromSeconds(d);
SetDuration(duration.ToMicroseconds());
} else if (mInfo.mMetadataDuration.isSome()) {
SetDuration(mInfo.mMetadataDuration.ref().ToMicroseconds());
} else if (mInfo.mMetadataEndTime.isSome() && mStartTime >= 0) {
SetDuration((mInfo.mMetadataEndTime.ref() - TimeUnit::FromMicroseconds(mStartTime)).ToMicroseconds());
@@ -2542,6 +2555,7 @@ MediaDecoderStateMachine::FinishShutdown()
// Disconnect canonicals and mirrors before shutting down our task queue.
mNetworkDuration.DisconnectIfConnected();
mExplicitDuration.DisconnectIfConnected();
mPlayState.DisconnectIfConnected();
mNextPlayState.DisconnectIfConnected();
mLogicallySeeking.DisconnectIfConnected();