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..18fef4833149b9f68d76b807c242b59b8d999e8c 100644 |
--- a/content/renderer/media/rtc_video_decoder_factory.cc |
+++ b/content/renderer/media/rtc_video_decoder_factory.cc |
@@ -11,43 +11,34 @@ |
namespace content { |
RTCVideoDecoderFactory::RTCVideoDecoderFactory( |
- const scoped_refptr<media::GpuVideoDecoder::Factories>& gpu_factories) |
- : vda_loop_proxy_(gpu_factories->GetMessageLoop()) { |
+ const scoped_refptr<base::MessageLoopProxy>& vda_loop_proxy, |
+ const scoped_refptr<content::RendererGpuVideoDecoderFactories>& |
scherkus (not reviewing)
2013/07/19 18:13:58
don't need content namespace
wuchengli
2013/07/20 06:04:14
Changed to media::GpuVideoDecoder::Factories.
|
+ gpu_factories) |
+ : vda_loop_proxy_(vda_loop_proxy), 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, vda_loop_proxy_, 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); |
+ if (!vda_loop_proxy_->DeleteSoon(FROM_HERE, decoder)) |
+ delete decoder; |
} |
} // namespace content |