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 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/renderer_gpu_video_decoder_factories.h" 10 #include "content/renderer/media/rtc_video_decoder.h" 11 #include "media/filters/gpu_video_decoder_factories.h" 12 13 namespace content { 14 15 RTCVideoDecoderFactory::RTCVideoDecoderFactory( 16 const scoped_refptr<RendererGpuVideoDecoderFactories>& gpu_factories) 17 : gpu_factories_(gpu_factories) { 18 DVLOG(2) << "RTCVideoDecoderFactory"; 19 } 20 21 RTCVideoDecoderFactory::~RTCVideoDecoderFactory() { 22 DVLOG(2) << "~RTCVideoDecoderFactory"; 23 } 24 25 webrtc::VideoDecoder* RTCVideoDecoderFactory::CreateVideoDecoder( 26 webrtc::VideoCodecType type) { 27 DVLOG(2) << "CreateVideoDecoder"; 28 // RendererGpuVideoDecoderFactories is not thread safe. It cannot be shared 29 // by different decoders. This method runs on Chrome_libJingle_WorkerThread 30 // and the child thread is blocked while this runs. We cannot create new gpu 31 // factories here. Clone one instead. 32 scoped_ptr<RTCVideoDecoder> decoder = 33 RTCVideoDecoder::Create(type, gpu_factories_->Clone()); 34 return decoder.release(); 35 } 36 37 void RTCVideoDecoderFactory::DestroyVideoDecoder( 38 webrtc::VideoDecoder* decoder) { 39 DVLOG(2) << "DestroyVideoDecoder"; 40 gpu_factories_->GetMessageLoop()->DeleteSoon(FROM_HERE, decoder); 41 } 42 43 } // namespace content 44