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 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_FACTORY_TV_H_ 6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_FACTORY_TV_H_ 7 8 #include "base/basictypes.h" 9 #include "base/compiler_specific.h" 10 #include "base/message_loop/message_loop.h" 11 #include "content/common/content_export.h" 12 #include "media/base/demuxer.h" 13 #include "third_party/libjingle/source/talk/media/webrtc/webrtcvideodecoderfactory.h" 14 #include "ui/gfx/size.h" 15 16 namespace webrtc { 17 class VideoDecoder; 18 } 19 20 namespace content { 21 22 class MediaStreamDependencyFactory; 23 class RTCDemuxerStream; 24 class RTCVideoDecoderBridgeTv; 25 26 // A factory object generating |RTCVideoDecoderBridgeTv| objects. This object 27 // also functions as a |media::Demuxer| object to receive encoded streams from 28 // the |RTCVideoDecoderBridgeTv| object (which inherits from 29 // |webrtc::VideoDecoder|). 30 class CONTENT_EXPORT RTCVideoDecoderFactoryTv 31 : NON_EXPORTED_BASE(public cricket::WebRtcVideoDecoderFactory), 32 public media::Demuxer { 33 public: 34 RTCVideoDecoderFactoryTv(); 35 virtual ~RTCVideoDecoderFactoryTv(); 36 37 // cricket::WebRtcVideoDecoderFactory implementation. 38 virtual webrtc::VideoDecoder* CreateVideoDecoder( 39 webrtc::VideoCodecType type) OVERRIDE; 40 virtual void DestroyVideoDecoder(webrtc::VideoDecoder* decoder) OVERRIDE; 41 42 // Acquires and releases the demuxer functionality of this object. Only one 43 // client object can access demuxer functionality at a time. No calls to 44 // |media::Demuxer| implementations should be made without acquiring it first. 45 bool AcquireDemuxer(); 46 void ReleaseDemuxer(); 47 48 // media::Demuxer implementation. 49 virtual void Initialize(media::DemuxerHost* host, 50 const media::PipelineStatusCB& cb) OVERRIDE; 51 virtual media::DemuxerStream* GetStream( 52 media::DemuxerStream::Type type) OVERRIDE; 53 virtual base::TimeDelta GetStartTime() const OVERRIDE; 54 55 // For RTCVideoDecoderBridgeTv to talk to RTCDemuxerStream. 56 void InitializeStream(const gfx::Size& size); 57 void QueueBuffer(scoped_refptr<media::DecoderBuffer> buffer, 58 const gfx::Size& size); 59 60 private: 61 // All private variables are lock protected. 62 base::Lock lock_; 63 scoped_ptr<RTCVideoDecoderBridgeTv> decoder_; 64 65 media::PipelineStatusCB init_cb_; 66 scoped_ptr<RTCDemuxerStream> stream_; 67 68 bool is_acquired_; 69 70 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoderFactoryTv); 71 }; 72 73 } // namespace content 74 75 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_FACTORY_TV_H_ 76