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 04018b47e3c25ba98b29cc934a69e3741d12f0a3..e621735dbccb87041048d589e5b8533d3e92e078 100644 |
--- a/content/renderer/media/rtc_video_decoder_factory.cc |
+++ b/content/renderer/media/rtc_video_decoder_factory.cc |
@@ -6,49 +6,38 @@ |
#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" |
#include "media/filters/gpu_video_decoder_factories.h" |
namespace content { |
RTCVideoDecoderFactory::RTCVideoDecoderFactory( |
- const scoped_refptr<media::GpuVideoDecoderFactories>& 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 |