[MediaRouter] Update MR-2-Extension's PostMessage to return boolean.
[chromium-blink-merge.git] / chromecast / media / cma / ipc_streamer / coded_frame_provider_host.h
blob738cc8bd7691524dda39e09f197f49ff37185426
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.
5 #ifndef CHROMECAST_MEDIA_CMA_IPC_STREAMER_CODED_FRAME_PROVIDER_HOST_H_
6 #define CHROMECAST_MEDIA_CMA_IPC_STREAMER_CODED_FRAME_PROVIDER_HOST_H_
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"
15 namespace chromecast {
16 namespace media {
17 class MediaMessageFifo;
19 // CodedFrameProviderHost is a frame provider that gets the frames
20 // from a media message fifo.
21 class 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 ~CodedFrameProviderHost() override;
30 // CodedFrameProvider implementation.
31 void Read(const ReadCB& read_cb) override;
32 void Flush(const base::Closure& flush_cb) override;
34 // Invoked when some data has been written into the fifo.
35 void OnFifoWriteEvent();
36 base::Closure GetFifoWriteEventCb();
38 private:
39 void ReadMessages();
41 base::ThreadChecker thread_checker_;
43 // Fifo holding the frames.
44 scoped_ptr<MediaMessageFifo> fifo_;
46 ReadCB read_cb_;
48 // Audio/video configuration for the next A/V buffer.
49 ::media::AudioDecoderConfig audio_config_;
50 ::media::VideoDecoderConfig video_config_;
52 base::WeakPtr<CodedFrameProviderHost> weak_this_;
53 base::WeakPtrFactory<CodedFrameProviderHost> weak_factory_;
55 DISALLOW_COPY_AND_ASSIGN(CodedFrameProviderHost);
58 } // namespace media
59 } // namespace chromecast
61 #endif // CHROMECAST_MEDIA_CMA_IPC_STREAMER_CODED_FRAME_PROVIDER_HOST_H_