Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: content/renderer/media/rtc_video_decoder_factory.cc

Issue 19534002: Make RendererGpuVideoDecoderFactories live on arbitrary threads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..cfc03b690bb0b34393f7ca8d1c96e301ceecdb99 100644
--- a/content/renderer/media/rtc_video_decoder_factory.cc
+++ b/content/renderer/media/rtc_video_decoder_factory.cc
@@ -11,43 +11,33 @@
namespace content {
RTCVideoDecoderFactory::RTCVideoDecoderFactory(
+ const scoped_refptr<base::MessageLoopProxy>& vda_loop_proxy,
const scoped_refptr<media::GpuVideoDecoder::Factories>& gpu_factories)
- : vda_loop_proxy_(gpu_factories->GetMessageLoop()) {
+ : 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.
Ami GONE FROM CHROMIUM 2013/07/22 19:46:21 Yay!
wuchengli 2013/07/23 16:29:28 :)
- // |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());
scherkus (not reviewing) 2013/07/22 17:56:40 Considering this is a problem unique to content/ a
wuchengli 2013/07/23 16:29:28 Done. That's what I wasn't sure about in https://c
+ 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))
Ami GONE FROM CHROMIUM 2013/07/22 19:46:21 You might enjoy https://plus.sandbox.google.com/10
wuchengli 2013/07/23 16:29:28 Haha. I copied the anti-pattern from other places.
+ delete decoder;
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698