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

Side by Side 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: rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/rtc_video_decoder_factory.h" 5 #include "content/renderer/media/rtc_video_decoder_factory.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "content/renderer/media/renderer_gpu_video_decoder_factories.h"
9 #include "content/renderer/media/rtc_video_decoder.h" 10 #include "content/renderer/media/rtc_video_decoder.h"
10 #include "media/filters/gpu_video_decoder_factories.h" 11 #include "media/filters/gpu_video_decoder_factories.h"
11 12
12 namespace content { 13 namespace content {
13 14
14 RTCVideoDecoderFactory::RTCVideoDecoderFactory( 15 RTCVideoDecoderFactory::RTCVideoDecoderFactory(
15 const scoped_refptr<media::GpuVideoDecoderFactories>& gpu_factories) 16 const scoped_refptr<RendererGpuVideoDecoderFactories>& gpu_factories)
16 : vda_loop_proxy_(gpu_factories->GetMessageLoop()) { 17 : gpu_factories_(gpu_factories) {
17 DVLOG(2) << "RTCVideoDecoderFactory"; 18 DVLOG(2) << "RTCVideoDecoderFactory";
18 // The decoder cannot be created in CreateVideoDecoder because VDA has to be
19 // created on |vda_loop_proxy_|, which can be the child thread. The child
20 // thread is blocked when CreateVideoDecoder runs. This supports only one
21 // VDA-powered <video> tag at a time.
22 // TODO(wuchengli): remove this restriction.
23 // |decoder_| can be null if VDA does not support VP8.
24 decoder_ = RTCVideoDecoder::Create(gpu_factories);
25 } 19 }
26 20
27 RTCVideoDecoderFactory::~RTCVideoDecoderFactory() { 21 RTCVideoDecoderFactory::~RTCVideoDecoderFactory() {
28 DVLOG(2) << "~RTCVideoDecoderFactory"; 22 DVLOG(2) << "~RTCVideoDecoderFactory";
29 if (decoder_) {
30 webrtc::VideoDecoder* decoder = decoder_.release();
31 if (!vda_loop_proxy_->DeleteSoon(FROM_HERE, decoder))
32 delete decoder;
33 }
34 } 23 }
35 24
36 webrtc::VideoDecoder* RTCVideoDecoderFactory::CreateVideoDecoder( 25 webrtc::VideoDecoder* RTCVideoDecoderFactory::CreateVideoDecoder(
37 webrtc::VideoCodecType type) { 26 webrtc::VideoCodecType type) {
38 DVLOG(2) << "CreateVideoDecoder"; 27 DVLOG(2) << "CreateVideoDecoder";
39 // Only VP8 is supported. 28 // RendererGpuVideoDecoderFactories is not thread safe. It cannot be shared
40 if (type == webrtc::kVideoCodecVP8) 29 // by different decoders. This method runs on Chrome_libJingle_WorkerThread
41 return decoder_.release(); 30 // and the child thread is blocked while this runs. We cannot create new gpu
42 return NULL; 31 // factories here. Clone one instead.
32 scoped_ptr<RTCVideoDecoder> decoder =
33 RTCVideoDecoder::Create(type, gpu_factories_->Clone());
34 return decoder.release();
43 } 35 }
44 36
45 void RTCVideoDecoderFactory::DestroyVideoDecoder( 37 void RTCVideoDecoderFactory::DestroyVideoDecoder(
46 webrtc::VideoDecoder* decoder) { 38 webrtc::VideoDecoder* decoder) {
47 DVLOG(2) << "DestroyVideoDecoder"; 39 DVLOG(2) << "DestroyVideoDecoder";
48 // Save back the decoder because it is the only one. VideoDecoder::Release 40 gpu_factories_->GetMessageLoop()->DeleteSoon(FROM_HERE, decoder);
49 // should have been called.
50 decoder->RegisterDecodeCompleteCallback(NULL);
51 decoder_.reset(decoder);
52 } 41 }
53 42
54 } // namespace content 43 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_video_decoder_factory.h ('k') | content/renderer/media/rtc_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698