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

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: 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/rtc_video_decoder.h" 9 #include "content/renderer/media/rtc_video_decoder.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 RTCVideoDecoderFactory::RTCVideoDecoderFactory( 13 RTCVideoDecoderFactory::RTCVideoDecoderFactory(
14 const scoped_refptr<media::GpuVideoDecoder::Factories>& gpu_factories) 14 scoped_ptr<base::Thread> vda_thread,
15 : vda_loop_proxy_(gpu_factories->GetMessageLoop()) { 15 const scoped_refptr<content::RendererGpuVideoDecoderFactories>&
16 gpu_factories)
17 : vda_thread_(vda_thread.Pass()), gpu_factories_(gpu_factories) {
16 DVLOG(2) << "RTCVideoDecoderFactory"; 18 DVLOG(2) << "RTCVideoDecoderFactory";
17 // The decoder cannot be created in CreateVideoDecoder because VDA has to be
18 // created on |vda_loop_proxy_|, which can be the child thread. The child
19 // thread is blocked when CreateVideoDecoder runs. This supports only one
20 // VDA-powered <video> tag at a time.
21 // TODO(wuchengli): remove this restriction.
22 // |decoder_| can be null if VDA does not support VP8.
23 decoder_ = RTCVideoDecoder::Create(gpu_factories);
24 } 19 }
25 20
26 RTCVideoDecoderFactory::~RTCVideoDecoderFactory() { 21 RTCVideoDecoderFactory::~RTCVideoDecoderFactory() {
27 DVLOG(2) << "~RTCVideoDecoderFactory"; 22 DVLOG(2) << "~RTCVideoDecoderFactory";
28 if (decoder_) {
29 webrtc::VideoDecoder* decoder = decoder_.release();
30 if (!vda_loop_proxy_->DeleteSoon(FROM_HERE, decoder))
31 delete decoder;
32 }
33 } 23 }
34 24
35 webrtc::VideoDecoder* RTCVideoDecoderFactory::CreateVideoDecoder( 25 webrtc::VideoDecoder* RTCVideoDecoderFactory::CreateVideoDecoder(
36 webrtc::VideoCodecType type) { 26 webrtc::VideoCodecType type) {
37 DVLOG(2) << "CreateVideoDecoder"; 27 DVLOG(2) << "CreateVideoDecoder";
38 // Only VP8 is supported. 28 scoped_ptr<RTCVideoDecoder> decoder =
39 if (type == webrtc::kVideoCodecVP8) 29 RTCVideoDecoder::Create(type, gpu_factories_->Clone());
scherkus (not reviewing) 2013/07/18 00:54:43 can we call RenderThreadImpl::current()->GetGpuFac
wuchengli 2013/07/18 09:42:00 CVD() is called on Chrome_libJingle_WorkerThread a
40 return decoder_.release(); 30 return decoder.release();
41 return NULL;
42 } 31 }
43 32
44 void RTCVideoDecoderFactory::DestroyVideoDecoder( 33 void RTCVideoDecoderFactory::DestroyVideoDecoder(
45 webrtc::VideoDecoder* decoder) { 34 webrtc::VideoDecoder* decoder) {
46 DVLOG(2) << "DestroyVideoDecoder"; 35 DVLOG(2) << "DestroyVideoDecoder";
47 // Save back the decoder because it is the only one. VideoDecoder::Release 36 if (!vda_thread_->message_loop_proxy()->DeleteSoon(FROM_HERE, decoder))
48 // should have been called. 37 delete decoder;
49 decoder->RegisterDecodeCompleteCallback(NULL);
50 decoder_.reset(decoder);
51 } 38 }
52 39
53 } // namespace content 40 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698