Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a80c106ef080e33d7fe8d53020b1f0dc9a2a4557 |
| --- /dev/null |
| +++ b/content/renderer/media/rtc_video_decoder_factory.cc |
| @@ -0,0 +1,51 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/renderer/media/rtc_video_decoder_factory.h" |
| + |
| +#include "base/location.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "content/renderer/media/rtc_video_decoder.h" |
| + |
| +namespace content { |
| + |
| +RTCVideoDecoderFactory::RTCVideoDecoderFactory( |
| + const scoped_refptr<media::GpuVideoDecoder::Factories>& gpu_factories) |
| + : vda_loop_proxy_(gpu_factories->GetMessageLoop()) { |
| + 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. |
|
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.
|
| + scoped_ptr<RTCVideoDecoder> decoder(new RTCVideoDecoder(gpu_factories)); |
| + if (decoder->InitVideoDecodeAccelerator()) { |
| + 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.
|
| + } else { |
| + // VP8 is unsupported. Release the decoder. |
| + vda_loop_proxy_->DeleteSoon(FROM_HERE, decoder.release()); |
| + } |
| +} |
| + |
| +RTCVideoDecoderFactory::~RTCVideoDecoderFactory() { |
| + DVLOG(2) << "~RTCVideoDecoderFactory"; |
| + if (decoder_) |
| + vda_loop_proxy_->DeleteSoon(FROM_HERE, decoder_.release()); |
| +} |
| + |
| +webrtc::VideoDecoder* RTCVideoDecoderFactory::CreateVideoDecoder( |
| + webrtc::VideoCodecType type) { |
| + DVLOG(2) << "CreateVideoDecoder"; |
| + // Only VP8 is supported. |
| + if (type == webrtc::kVideoCodecVP8) |
| + return decoder_.release(); |
| + return NULL; |
| +} |
| + |
| +void RTCVideoDecoderFactory::DestroyVideoDecoder( |
| + webrtc::VideoDecoder* decoder) { |
| + DVLOG(2) << "DestroyVideoDecoder"; |
| + // Save back the decoder because it is the only one. |
| + 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
|
| +} |
| + |
| +} // namespace content |