Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/renderer/media/rtc_video_decoder_factory.h" | |
| 6 | |
| 7 #include "base/location.h" | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "content/renderer/media/rtc_video_decoder.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 RTCVideoDecoderFactory::RTCVideoDecoderFactory( | |
| 14 const scoped_refptr<media::GpuVideoDecoder::Factories>& gpu_factories) | |
| 15 : vda_loop_proxy_(gpu_factories->GetMessageLoop()) { | |
| 16 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. | |
|
Ami GONE FROM CHROMIUM
2013/06/18 21:54:29
TODO that this supports only one VDA-powered <vide
wuchengli
2013/06/19 13:01:13
Done.
| |
| 20 scoped_ptr<RTCVideoDecoder> decoder(new RTCVideoDecoder(gpu_factories)); | |
| 21 if (decoder->InitVideoDecodeAccelerator()) { | |
| 22 decoder_.reset(decoder.release()); | |
|
Ami GONE FROM CHROMIUM
2013/06/18 21:54:29
FWIW instead of
new+Init+.release/.reset
you coul
wuchengli
2013/06/19 13:01:13
Sounds good. Done.
| |
| 23 } else { | |
| 24 // VP8 is unsupported. Release the decoder. | |
| 25 vda_loop_proxy_->DeleteSoon(FROM_HERE, decoder.release()); | |
| 26 } | |
| 27 } | |
| 28 | |
| 29 RTCVideoDecoderFactory::~RTCVideoDecoderFactory() { | |
| 30 DVLOG(2) << "~RTCVideoDecoderFactory"; | |
| 31 if (decoder_) | |
| 32 vda_loop_proxy_->DeleteSoon(FROM_HERE, decoder_.release()); | |
| 33 } | |
| 34 | |
| 35 webrtc::VideoDecoder* RTCVideoDecoderFactory::CreateVideoDecoder( | |
| 36 webrtc::VideoCodecType type) { | |
| 37 DVLOG(2) << "CreateVideoDecoder"; | |
| 38 // Only VP8 is supported. | |
| 39 if (type == webrtc::kVideoCodecVP8) | |
| 40 return decoder_.release(); | |
| 41 return NULL; | |
| 42 } | |
| 43 | |
| 44 void RTCVideoDecoderFactory::DestroyVideoDecoder( | |
| 45 webrtc::VideoDecoder* decoder) { | |
| 46 DVLOG(2) << "DestroyVideoDecoder"; | |
| 47 // Save back the decoder because it is the only one. | |
| 48 decoder_.reset(decoder); | |
|
Ami GONE FROM CHROMIUM
2013/06/18 21:54:29
Probably want to do something like VDA::Reset() an
wuchengli
2013/06/19 13:01:13
VDA::Release() should have been called, which does
| |
| 49 } | |
| 50 | |
| 51 } // namespace content | |
| OLD | NEW |