зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1380545 - remove DispatchKeyNeededEvent from MediaFormatReader.cpp. r=gerald
We will use MediaEventSource to dispatch the 'encrypted' events. MozReview-Commit-ID: KY3nS9OrysI --HG-- extra : rebase_source : 4e1fa125b099567426f5a6ea2c825b77d407b2c4 extra : source : 8413b0625159d85a5814cb3bd748121653735e96
This commit is contained in:
Родитель
42e587bffb
Коммит
9b07417b6b
|
@ -321,6 +321,7 @@ MediaDecoder::Shutdown()
|
|||
mOnPlaybackErrorEvent.Disconnect();
|
||||
mOnDecoderDoctorEvent.Disconnect();
|
||||
mOnMediaNotSeekable.Disconnect();
|
||||
mOnEncrypted.Disconnect();
|
||||
|
||||
mDecoderStateMachine->BeginShutdown()
|
||||
->Then(mAbstractMainThread, __func__, this,
|
||||
|
@ -484,6 +485,9 @@ MediaDecoder::SetStateMachineParameters()
|
|||
mAbstractMainThread, this, &MediaDecoder::OnDecoderDoctorEvent);
|
||||
mOnMediaNotSeekable = mDecoderStateMachine->OnMediaNotSeekable().Connect(
|
||||
mAbstractMainThread, this, &MediaDecoder::OnMediaNotSeekable);
|
||||
|
||||
mOnEncrypted = mReader->OnEncrypted().Connect(
|
||||
mAbstractMainThread, GetOwner(), &MediaDecoderOwner::DispatchEncrypted);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -703,6 +703,7 @@ protected:
|
|||
MediaEventListener mOnPlaybackErrorEvent;
|
||||
MediaEventListener mOnDecoderDoctorEvent;
|
||||
MediaEventListener mOnMediaNotSeekable;
|
||||
MediaEventListener mOnEncrypted;
|
||||
|
||||
protected:
|
||||
// PlaybackRate and pitch preservation status we should start at.
|
||||
|
|
|
@ -275,6 +275,11 @@ public:
|
|||
return mOnTrackWaitingForKey;
|
||||
}
|
||||
|
||||
MediaEventSource<nsTArray<uint8_t>, nsString>& OnEncrypted()
|
||||
{
|
||||
return mOnEncrypted;
|
||||
}
|
||||
|
||||
// Switch the video decoder to NullDecoderModule. It might takes effective
|
||||
// since a few samples later depends on how much demuxed samples are already
|
||||
// queued in the original video decoder.
|
||||
|
@ -337,6 +342,8 @@ protected:
|
|||
// Notify if we are waiting for a decryption key.
|
||||
MediaEventProducer<TrackInfo::TrackType> mOnTrackWaitingForKey;
|
||||
|
||||
MediaEventProducer<nsTArray<uint8_t>, nsString> mOnEncrypted;
|
||||
|
||||
RefPtr<MediaResource> mResource;
|
||||
|
||||
private:
|
||||
|
|
|
@ -1224,35 +1224,6 @@ MediaFormatReader::InitInternal()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
class DispatchKeyNeededEvent : public Runnable
|
||||
{
|
||||
public:
|
||||
DispatchKeyNeededEvent(AbstractMediaDecoder* aDecoder,
|
||||
nsTArray<uint8_t>& aInitData,
|
||||
const nsString& aInitDataType)
|
||||
: Runnable("DispatchKeyNeededEvent")
|
||||
, mDecoder(aDecoder)
|
||||
, mInitData(aInitData)
|
||||
, mInitDataType(aInitDataType)
|
||||
{
|
||||
}
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
// Note: Null check the owner, as the decoder could have been shutdown
|
||||
// since this event was dispatched.
|
||||
MediaDecoderOwner* owner = mDecoder->GetOwner();
|
||||
if (owner) {
|
||||
owner->DispatchEncrypted(mInitData, mInitDataType);
|
||||
}
|
||||
mDecoder = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
private:
|
||||
RefPtr<AbstractMediaDecoder> mDecoder;
|
||||
nsTArray<uint8_t> mInitData;
|
||||
nsString mInitDataType;
|
||||
};
|
||||
|
||||
void
|
||||
MediaFormatReader::SetCDMProxy(CDMProxy* aProxy)
|
||||
{
|
||||
|
@ -1380,13 +1351,11 @@ MediaFormatReader::OnDemuxerInitDone(const MediaResult& aResult)
|
|||
}
|
||||
|
||||
UniquePtr<EncryptionInfo> crypto = mDemuxer->GetCrypto();
|
||||
if (mDecoder && crypto && crypto->IsEncrypted()) {
|
||||
if (crypto && crypto->IsEncrypted()) {
|
||||
// Try and dispatch 'encrypted'. Won't go if ready state still HAVE_NOTHING.
|
||||
for (uint32_t i = 0; i < crypto->mInitDatas.Length(); i++) {
|
||||
nsCOMPtr<nsIRunnable> r =
|
||||
new DispatchKeyNeededEvent(mDecoder, crypto->mInitDatas[i].mInitData,
|
||||
crypto->mInitDatas[i].mType);
|
||||
mDecoder->AbstractMainThread()->Dispatch(r.forget());
|
||||
mOnEncrypted.Notify(crypto->mInitDatas[i].mInitData,
|
||||
crypto->mInitDatas[i].mType);
|
||||
}
|
||||
mInfo.mCrypto = *crypto;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче