зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1380234. P1 - pass KnowsCompositor to MFR through MediaDecoderReaderInit. r=jya
MozReview-Commit-ID: 3krK3meG5jV --HG-- extra : rebase_source : f0a628ab28a527fa7f79ec61672e988cf1def8e7 extra : source : c8c2a6f2506338a8208f3bcf56160c47e6a29000
This commit is contained in:
Родитель
8b68a498ad
Коммит
4ca981216d
|
@ -339,7 +339,7 @@ DecoderTraits::CreateDecoder(MediaDecoderInit& aInit,
|
|||
/* static */
|
||||
MediaDecoderReader*
|
||||
DecoderTraits::CreateReader(const MediaContainerType& aType,
|
||||
const MediaDecoderReaderInit& aInit)
|
||||
MediaDecoderReaderInit& aInit)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MediaDecoderReader* decoderReader = nullptr;
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
// Create a reader for thew given MIME type aType. Returns null
|
||||
// if we were unable to create the reader.
|
||||
static MediaDecoderReader* CreateReader(const MediaContainerType& aType,
|
||||
const MediaDecoderReaderInit& aInit);
|
||||
MediaDecoderReaderInit& aInit);
|
||||
|
||||
// Returns true if MIME type aType is supported in video documents,
|
||||
// or false otherwise. Not all platforms support all MIME types, and
|
||||
|
|
|
@ -1058,19 +1058,23 @@ MediaDecoder::DurationChanged()
|
|||
}
|
||||
}
|
||||
|
||||
already_AddRefed<KnowsCompositor>
|
||||
MediaDecoder::GetCompositor()
|
||||
{
|
||||
MediaDecoderOwner* owner = GetOwner();
|
||||
nsIDocument* ownerDoc = owner ? owner->GetDocument() : nullptr;
|
||||
RefPtr<LayerManager> layerManager =
|
||||
ownerDoc ? nsContentUtils::LayerManagerForDocument(ownerDoc) : nullptr;
|
||||
RefPtr<KnowsCompositor> knows =
|
||||
layerManager ? layerManager->AsShadowForwarder() : nullptr;
|
||||
return knows.forget();
|
||||
}
|
||||
|
||||
void
|
||||
MediaDecoder::NotifyCompositor()
|
||||
{
|
||||
MediaDecoderOwner* owner = GetOwner();
|
||||
NS_ENSURE_TRUE_VOID(owner);
|
||||
|
||||
nsIDocument* ownerDoc = owner->GetDocument();
|
||||
NS_ENSURE_TRUE_VOID(ownerDoc);
|
||||
|
||||
RefPtr<LayerManager> layerManager =
|
||||
nsContentUtils::LayerManagerForDocument(ownerDoc);
|
||||
if (layerManager) {
|
||||
RefPtr<KnowsCompositor> knowsCompositor = layerManager->AsShadowForwarder();
|
||||
RefPtr<KnowsCompositor> knowsCompositor = GetCompositor();
|
||||
if (knowsCompositor) {
|
||||
mCompositorUpdatedEvent.Notify(knowsCompositor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -512,6 +512,8 @@ protected:
|
|||
return mCurrentPosition.Ref();
|
||||
}
|
||||
|
||||
already_AddRefed<layers::KnowsCompositor> GetCompositor();
|
||||
|
||||
// Official duration of the media resource as observed by script.
|
||||
double mDuration;
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
size_t mSize;
|
||||
};
|
||||
|
||||
MediaDecoderReader::MediaDecoderReader(const MediaDecoderReaderInit& aInit)
|
||||
MediaDecoderReader::MediaDecoderReader(MediaDecoderReaderInit& aInit)
|
||||
: mAudioCompactor(mAudioQueue)
|
||||
, mDecoder(aInit.mDecoder)
|
||||
, mTaskQueue(new TaskQueue(
|
||||
|
|
|
@ -67,6 +67,7 @@ struct MOZ_STACK_CLASS MediaDecoderReaderInit
|
|||
AbstractMediaDecoder* const mDecoder;
|
||||
MediaResource* mResource = nullptr;
|
||||
VideoFrameContainer* mVideoFrameContainer = nullptr;
|
||||
already_AddRefed<layers::KnowsCompositor> mKnowsCompositor;
|
||||
|
||||
explicit MediaDecoderReaderInit(AbstractMediaDecoder* aDecoder)
|
||||
: mDecoder(aDecoder)
|
||||
|
@ -110,7 +111,7 @@ public:
|
|||
|
||||
// The caller must ensure that Shutdown() is called before aDecoder is
|
||||
// destroyed.
|
||||
explicit MediaDecoderReader(const MediaDecoderReaderInit& aInit);
|
||||
explicit MediaDecoderReader(MediaDecoderReaderInit& aInit);
|
||||
|
||||
// Initializes the reader, returns NS_OK on success, or NS_ERROR_FAILURE
|
||||
// on failure.
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "AutoTaskQueue.h"
|
||||
#include "Layers.h"
|
||||
#include "MediaData.h"
|
||||
#include "MediaDecoderOwner.h"
|
||||
#include "MediaInfo.h"
|
||||
#include "MediaResource.h"
|
||||
#include "VideoFrameContainer.h"
|
||||
|
@ -22,8 +23,6 @@
|
|||
#include "mozilla/SyncRunnable.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/HTMLMediaElement.h"
|
||||
#include "mozilla/layers/ShadowLayers.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsSize.h"
|
||||
|
@ -1094,7 +1093,7 @@ MediaFormatReader::DemuxerProxy::NotifyDataArrived()
|
|||
});
|
||||
}
|
||||
|
||||
MediaFormatReader::MediaFormatReader(const MediaDecoderReaderInit& aInit,
|
||||
MediaFormatReader::MediaFormatReader(MediaDecoderReaderInit& aInit,
|
||||
MediaDataDemuxer* aDemuxer)
|
||||
: MediaDecoderReader(aInit)
|
||||
, mAudio(this, MediaData::AUDIO_DATA,
|
||||
|
@ -1106,6 +1105,7 @@ MediaFormatReader::MediaFormatReader(const MediaDecoderReaderInit& aInit,
|
|||
, mPendingNotifyDataArrived(false)
|
||||
, mLastReportedNumDecodedFrames(0)
|
||||
, mPreviousDecodedKeyframeTime_us(sNoPreviousDecodedKeyframe)
|
||||
, mKnowsCompositor(aInit.mKnowsCompositor)
|
||||
, mInitDone(false)
|
||||
, mTrackDemuxersMayBlock(false)
|
||||
, mSeekScheduled(false)
|
||||
|
@ -1214,38 +1214,11 @@ MediaFormatReader::TearDownDecoders()
|
|||
return MediaDecoderReader::Shutdown();
|
||||
}
|
||||
|
||||
void
|
||||
MediaFormatReader::InitLayersBackendType()
|
||||
{
|
||||
// Extract the layer manager backend type so that platform decoders
|
||||
// can determine whether it's worthwhile using hardware accelerated
|
||||
// video decoding.
|
||||
if (!mDecoder) {
|
||||
return;
|
||||
}
|
||||
MediaDecoderOwner* owner = mDecoder->GetOwner();
|
||||
if (!owner) {
|
||||
NS_WARNING("MediaFormatReader without a decoder owner, can't get HWAccel");
|
||||
return;
|
||||
}
|
||||
|
||||
dom::HTMLMediaElement* element = owner->GetMediaElement();
|
||||
NS_ENSURE_TRUE_VOID(element);
|
||||
|
||||
RefPtr<LayerManager> layerManager =
|
||||
nsContentUtils::LayerManagerForDocument(element->OwnerDoc());
|
||||
NS_ENSURE_TRUE_VOID(layerManager);
|
||||
|
||||
mKnowsCompositor = layerManager->AsShadowForwarder();
|
||||
}
|
||||
|
||||
nsresult
|
||||
MediaFormatReader::InitInternal()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
|
||||
|
||||
InitLayersBackendType();
|
||||
|
||||
mAudio.mTaskQueue = new TaskQueue(
|
||||
GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER),
|
||||
"MFR::mAudio::mTaskQueue");
|
||||
|
|
|
@ -29,7 +29,7 @@ class MediaFormatReader final : public MediaDecoderReader
|
|||
typedef MozPromise<bool, MediaResult, /* IsExclusive = */ true> NotifyDataArrivedPromise;
|
||||
|
||||
public:
|
||||
MediaFormatReader(const MediaDecoderReaderInit& aInit, MediaDataDemuxer* aDemuxer);
|
||||
MediaFormatReader(MediaDecoderReaderInit& aInit, MediaDataDemuxer* aDemuxer);
|
||||
|
||||
virtual ~MediaFormatReader();
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef mozilla::layers::Image Image;
|
|||
typedef mozilla::layers::PlanarYCbCrImage PlanarYCbCrImage;
|
||||
|
||||
AndroidMediaReader::AndroidMediaReader(const MediaContainerType& aContainerType,
|
||||
const MediaDecoderReaderInit& aInit) :
|
||||
MediaDecoderReaderInit& aInit) :
|
||||
MediaDecoderReader(aInit),
|
||||
mType(aContainerType),
|
||||
mPlugin(nullptr),
|
||||
|
|
|
@ -38,7 +38,7 @@ class AndroidMediaReader : public MediaDecoderReader
|
|||
MozPromiseRequestHolder<MediaDecoderReader::VideoDataPromise> mSeekRequest;
|
||||
public:
|
||||
AndroidMediaReader(const MediaContainerType& aContainerType,
|
||||
const MediaDecoderReaderInit& aInit);
|
||||
MediaDecoderReaderInit& aInit);
|
||||
|
||||
nsresult ResetDecode(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack,
|
||||
TrackInfo::kVideoTrack)) override;
|
||||
|
|
|
@ -34,6 +34,7 @@ MediaDecoderStateMachine* MP4Decoder::CreateStateMachine()
|
|||
{
|
||||
MediaDecoderReaderInit init(this);
|
||||
init.mVideoFrameContainer = GetVideoFrameContainer();
|
||||
init.mKnowsCompositor = GetCompositor();
|
||||
mReader = new MediaFormatReader(init, new MP4Demuxer(mResource));
|
||||
return new MediaDecoderStateMachine(this, mReader);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ HLSDecoder::CreateStateMachine()
|
|||
MOZ_ASSERT(resourceWrapper);
|
||||
MediaDecoderReaderInit init(this);
|
||||
init.mVideoFrameContainer = GetVideoFrameContainer();
|
||||
init.mKnowsCompositor = GetCompositor();
|
||||
mReader =
|
||||
new MediaFormatReader(init, new HLSDemuxer(resourceWrapper->GetPlayerId()));
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ MediaSourceDecoder::CreateStateMachine()
|
|||
mDemuxer = new MediaSourceDemuxer(AbstractMainThread());
|
||||
MediaDecoderReaderInit init(this);
|
||||
init.mVideoFrameContainer = GetVideoFrameContainer();
|
||||
init.mKnowsCompositor = GetCompositor();
|
||||
mReader = new MediaFormatReader(init, mDemuxer);
|
||||
return new MediaDecoderStateMachine(this, mReader);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ MediaDecoderStateMachine* OggDecoder::CreateStateMachine()
|
|||
RefPtr<OggDemuxer> demuxer = new OggDemuxer(mResource);
|
||||
MediaDecoderReaderInit init(this);
|
||||
init.mVideoFrameContainer = GetVideoFrameContainer();
|
||||
init.mKnowsCompositor = GetCompositor();
|
||||
mReader = new MediaFormatReader(init, demuxer);
|
||||
demuxer->SetChainingEvents(&mReader->TimedMetadataProducer(),
|
||||
&mReader->MediaNotSeekableProducer());
|
||||
|
|
|
@ -20,6 +20,7 @@ MediaDecoderStateMachine* WebMDecoder::CreateStateMachine()
|
|||
{
|
||||
MediaDecoderReaderInit init(this);
|
||||
init.mVideoFrameContainer = GetVideoFrameContainer();
|
||||
init.mKnowsCompositor = GetCompositor();
|
||||
mReader = new MediaFormatReader(init, new WebMDemuxer(mResource));
|
||||
return new MediaDecoderStateMachine(this, mReader);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче