| Index: content/renderer/media/rtc_video_decoder_factory.cc
|
| diff --git a/content/renderer/media/rtc_video_decoder_factory.cc b/content/renderer/media/rtc_video_decoder_factory.cc
|
| index 3c6b9ad5ac861ae7351c686c7328e157508d3a8d..609573ae5b9ada31e7ad45ecd1de4921f60f4db7 100644
|
| --- a/content/renderer/media/rtc_video_decoder_factory.cc
|
| +++ b/content/renderer/media/rtc_video_decoder_factory.cc
|
| @@ -6,48 +6,37 @@
|
|
|
| #include "base/location.h"
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "content/renderer/media/renderer_gpu_video_decoder_factories.h"
|
| #include "content/renderer/media/rtc_video_decoder.h"
|
|
|
| namespace content {
|
|
|
| RTCVideoDecoderFactory::RTCVideoDecoderFactory(
|
| - const scoped_refptr<media::GpuVideoDecoder::Factories>& gpu_factories)
|
| - : vda_loop_proxy_(gpu_factories->GetMessageLoop()) {
|
| + const scoped_refptr<RendererGpuVideoDecoderFactories>& gpu_factories)
|
| + : gpu_factories_(gpu_factories) {
|
| DVLOG(2) << "RTCVideoDecoderFactory";
|
| - // The decoder cannot be created in CreateVideoDecoder because VDA has to be
|
| - // created on |vda_loop_proxy_|, which can be the child thread. The child
|
| - // thread is blocked when CreateVideoDecoder runs. This supports only one
|
| - // VDA-powered <video> tag at a time.
|
| - // TODO(wuchengli): remove this restriction.
|
| - // |decoder_| can be null if VDA does not support VP8.
|
| - decoder_ = RTCVideoDecoder::Create(gpu_factories);
|
| }
|
|
|
| RTCVideoDecoderFactory::~RTCVideoDecoderFactory() {
|
| DVLOG(2) << "~RTCVideoDecoderFactory";
|
| - if (decoder_) {
|
| - webrtc::VideoDecoder* decoder = decoder_.release();
|
| - if (!vda_loop_proxy_->DeleteSoon(FROM_HERE, decoder))
|
| - delete decoder;
|
| - }
|
| }
|
|
|
| webrtc::VideoDecoder* RTCVideoDecoderFactory::CreateVideoDecoder(
|
| webrtc::VideoCodecType type) {
|
| DVLOG(2) << "CreateVideoDecoder";
|
| - // Only VP8 is supported.
|
| - if (type == webrtc::kVideoCodecVP8)
|
| - return decoder_.release();
|
| - return NULL;
|
| + // RendererGpuVideoDecoderFactories is not thread safe. It cannot be shared
|
| + // by different decoders. This method runs on Chrome_libJingle_WorkerThread
|
| + // and the child thread is blocked while this runs. We cannot create new gpu
|
| + // factories here. Clone one instead.
|
| + scoped_ptr<RTCVideoDecoder> decoder =
|
| + RTCVideoDecoder::Create(type, gpu_factories_->Clone());
|
| + return decoder.release();
|
| }
|
|
|
| void RTCVideoDecoderFactory::DestroyVideoDecoder(
|
| webrtc::VideoDecoder* decoder) {
|
| DVLOG(2) << "DestroyVideoDecoder";
|
| - // Save back the decoder because it is the only one. VideoDecoder::Release
|
| - // should have been called.
|
| - decoder->RegisterDecodeCompleteCallback(NULL);
|
| - decoder_.reset(decoder);
|
| + gpu_factories_->GetMessageLoop()->DeleteSoon(FROM_HERE, decoder);
|
| }
|
|
|
| } // namespace content
|
|
|