coded_frame_provider_host.h revision 1320f92c476a1ad9d19dba2a48c72b75566198e9
1// Copyright 2014 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 CHROMECAST_MEDIA_CMA_IPC_STREAMER_CODED_FRAME_PROVIDER_HOST_H_ 6#define CHROMECAST_MEDIA_CMA_IPC_STREAMER_CODED_FRAME_PROVIDER_HOST_H_ 7 8#include "base/callback.h" 9#include "base/memory/weak_ptr.h" 10#include "base/threading/thread_checker.h" 11#include "chromecast/media/cma/base/coded_frame_provider.h" 12#include "media/base/audio_decoder_config.h" 13#include "media/base/video_decoder_config.h" 14 15namespace chromecast { 16namespace media { 17class MediaMessageFifo; 18 19// CodedFrameProviderHost is a frame provider that gets the frames 20// from a media message fifo. 21class CodedFrameProviderHost : public CodedFrameProvider { 22 public: 23 // Note: if the media message fifo is located into shared memory, 24 // the caller must make sure the shared memory segment is valid 25 // during the whole lifetime of this object. 26 explicit CodedFrameProviderHost( 27 scoped_ptr<MediaMessageFifo> media_message_fifo); 28 virtual ~CodedFrameProviderHost(); 29 30 // CodedFrameProvider implementation. 31 virtual void Read(const ReadCB& read_cb) OVERRIDE; 32 virtual void Flush(const base::Closure& flush_cb) OVERRIDE; 33 34 // Invoked when some data has been written into the fifo. 35 void OnFifoWriteEvent(); 36 base::Closure GetFifoWriteEventCb(); 37 38 private: 39 void ReadMessages(); 40 41 base::ThreadChecker thread_checker_; 42 43 // Fifo holding the frames. 44 scoped_ptr<MediaMessageFifo> fifo_; 45 46 ReadCB read_cb_; 47 48 // Audio/video configuration for the next A/V buffer. 49 ::media::AudioDecoderConfig audio_config_; 50 ::media::VideoDecoderConfig video_config_; 51 52 base::WeakPtrFactory<CodedFrameProviderHost> weak_factory_; 53 base::WeakPtr<CodedFrameProviderHost> weak_this_; 54 55 DISALLOW_COPY_AND_ASSIGN(CodedFrameProviderHost); 56}; 57 58} // namespace media 59} // namespace chromecast 60 61#endif // CHROMECAST_MEDIA_CMA_IPC_STREAMER_CODED_FRAME_PROVIDER_HOST_H_ 62