Bug 1238906 - part2 : notify audible state from MDSM to ME. r=jwwang

--HG--
extra : transplant_source : %20hs%E8%9EH%9F%2A3%17%0A%1C%B1%E27%097%29%B5%CF
This commit is contained in:
Alastor Wu 2016-01-19 14:21:37 +08:00
Родитель 66cf030d20
Коммит 1958522cf4
8 изменённых файлов: 53 добавлений и 5 удалений

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

@ -2113,7 +2113,8 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
mElementInTreeState(ELEMENT_NOT_INTREE),
mHasUserInteraction(false),
mFirstFrameLoaded(false),
mDefaultPlaybackStartPosition(0.0)
mDefaultPlaybackStartPosition(0.0),
mIsAudioTrackAudible(false)
{
mAudioChannel = AudioChannelService::GetDefaultAudioChannel();
@ -5169,5 +5170,14 @@ HTMLMediaElement::IsCurrentlyPlaying() const
return false;
}
void
HTMLMediaElement::NotifyAudibleStateChanged(bool aAudible)
{
if (mIsAudioTrackAudible != aAudible) {
mIsAudioTrackAudible = aAudible;
// To do ...
}
}
} // namespace dom
} // namespace mozilla

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

@ -397,6 +397,9 @@ public:
// when the connection between Rtsp server and client gets lost.
virtual void ResetConnectionState() final override;
// Called by media decoder when the audible state changed.
virtual void NotifyAudibleStateChanged(bool aAudible) final override;
// XPCOM GetPreload() is OK
void SetPreload(const nsAString& aValue, ErrorResult& aRv)
{
@ -1521,6 +1524,9 @@ private:
// initially be set to zero seconds. This time is used to allow the element to
// be seeked even before the media is loaded.
double mDefaultPlaybackStartPosition;
// True if the audio track is producing audible sound.
bool mIsAudioTrackAudible;
};
} // namespace dom

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

@ -532,6 +532,8 @@ MediaDecoder::MediaDecoder(MediaDecoderOwner* aOwner)
"MediaDecoder::mStateMachineDuration (Mirror)")
, mPlaybackPosition(AbstractThread::MainThread(), 0,
"MediaDecoder::mPlaybackPosition (Mirror)")
, mIsAudioDataAudible(AbstractThread::MainThread(), false,
"MediaDecoder::mIsAudioDataAudible (Mirror)")
, mVolume(AbstractThread::MainThread(), 0.0,
"MediaDecoder::mVolume (Canonical)")
, mPlaybackRate(AbstractThread::MainThread(), 1.0,
@ -592,6 +594,8 @@ MediaDecoder::MediaDecoder(MediaDecoderOwner* aOwner)
// mIgnoreProgressData
mWatchManager.Watch(mLogicallySeeking, &MediaDecoder::SeekingChanged);
mWatchManager.Watch(mIsAudioDataAudible, &MediaDecoder::NotifyAudibleStateChanged);
MediaShutdownManager::Instance().Register(this);
}
@ -623,6 +627,8 @@ MediaDecoder::Shutdown()
mOnSeekingStart.Disconnect();
mOnMediaNotSeekable.Disconnect();
mWatchManager.Unwatch(mIsAudioDataAudible, &MediaDecoder::NotifyAudibleStateChanged);
shutdown = mDecoderStateMachine->BeginShutdown()
->Then(AbstractThread::MainThread(), __func__, this,
&MediaDecoder::FinishShutdown,
@ -1473,6 +1479,7 @@ MediaDecoder::SetStateMachine(MediaDecoderStateMachine* aStateMachine)
mNextFrameStatus.Connect(mDecoderStateMachine->CanonicalNextFrameStatus());
mCurrentPosition.Connect(mDecoderStateMachine->CanonicalCurrentPosition());
mPlaybackPosition.Connect(mDecoderStateMachine->CanonicalPlaybackOffset());
mIsAudioDataAudible.Connect(mDecoderStateMachine->CanonicalIsAudioDataAudible());
} else {
mStateMachineDuration.DisconnectIfConnected();
mBuffered.DisconnectIfConnected();
@ -1480,6 +1487,7 @@ MediaDecoder::SetStateMachine(MediaDecoderStateMachine* aStateMachine)
mNextFrameStatus.DisconnectIfConnected();
mCurrentPosition.DisconnectIfConnected();
mPlaybackPosition.DisconnectIfConnected();
mIsAudioDataAudible.DisconnectIfConnected();
}
}
@ -1831,6 +1839,13 @@ MediaDecoder::NextFrameBufferedStatus()
: MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE;
}
void
MediaDecoder::NotifyAudibleStateChanged()
{
MOZ_ASSERT(!mShuttingDown);
mOwner->NotifyAudibleStateChanged(mIsAudioDataAudible);
}
MediaMemoryTracker::MediaMemoryTracker()
{
}

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

@ -773,6 +773,9 @@ protected:
// start playing back again.
Mirror<int64_t> mPlaybackPosition;
// Used to distiguish whether the audio is producing sound.
Mirror<bool> mIsAudioDataAudible;
// Volume of playback. 0.0 = muted. 1.0 = full volume.
Canonical<double> mVolume;
@ -868,6 +871,9 @@ public:
}
private:
// Notify owner when the audible state changed
void NotifyAudibleStateChanged();
/* Functions called by ResourceCallback */
// A media stream is assumed to be infinite if the metadata doesn't

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

@ -130,6 +130,9 @@ public:
// when the connection between Rtsp server and client gets lost.
virtual void ResetConnectionState() = 0;
// Called by media decoder when the audible state changed
virtual void NotifyAudibleStateChanged(bool aAudible) = 0;
#ifdef MOZ_EME
// Dispatches a "encrypted" event to the HTMLMediaElement, with the
// provided init data. Actual dispatch may be delayed until HAVE_METADATA.

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

@ -241,7 +241,6 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
mOutputStreamManager(new OutputStreamManager()),
mResource(aDecoder->GetResource()),
mAudioOffloading(false),
mIsAudioDataAudible(false),
mSilentDataDuration(0),
mBuffered(mTaskQueue, TimeIntervals(),
"MediaDecoderStateMachine::mBuffered (Mirror)"),
@ -279,7 +278,9 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
mCurrentPosition(mTaskQueue, 0,
"MediaDecoderStateMachine::mCurrentPosition (Canonical)"),
mPlaybackOffset(mTaskQueue, 0,
"MediaDecoderStateMachine::mPlaybackOffset (Canonical)")
"MediaDecoderStateMachine::mPlaybackOffset (Canonical)"),
mIsAudioDataAudible(mTaskQueue, false,
"MediaDecoderStateMachine::mIsAudioDataAudible (Canonical)")
{
MOZ_COUNT_CTOR(MediaDecoderStateMachine);
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
@ -2197,6 +2198,7 @@ MediaDecoderStateMachine::FinishShutdown()
mNextFrameStatus.DisconnectAll();
mCurrentPosition.DisconnectAll();
mPlaybackOffset.DisconnectAll();
mIsAudioDataAudible.DisconnectAll();
// Shut down the watch manager before shutting down our task queue.
mWatchManager.Shutdown();

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

@ -1196,8 +1196,7 @@ private:
// Playback will not start when audio is offloading.
bool mAudioOffloading;
// Used to distiguish continuous silent audio data.
bool mIsAudioDataAudible;
// Duration of the continuous silent data.
uint32_t mSilentDataDuration;
#ifdef MOZ_EME
@ -1268,6 +1267,9 @@ private:
// Current playback position in the stream in bytes.
Canonical<int64_t> mPlaybackOffset;
// Used to distiguish whether the audio is producing sound.
Canonical<bool> mIsAudioDataAudible;
public:
AbstractCanonical<media::TimeIntervals>* CanonicalBuffered() {
return mReader->CanonicalBuffered();
@ -1287,6 +1289,9 @@ public:
AbstractCanonical<int64_t>* CanonicalPlaybackOffset() {
return &mPlaybackOffset;
}
AbstractCanonical<bool>* CanonicalIsAudioDataAudible() {
return &mIsAudioDataAudible;
}
};
} // namespace mozilla

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

@ -47,6 +47,7 @@ public:
return nullptr;
}
virtual void ResetConnectionState() override {}
virtual void NotifyAudibleStateChanged(bool aAudible) override {};
};
}