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
{
17 class MediaMessageFifo
;
19 // CodedFrameProviderHost is a frame provider that gets the frames
20 // from a media message fifo.
21 class CodedFrameProviderHost
: public CodedFrameProvider
{
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();
41 base::ThreadChecker thread_checker_
;
43 // Fifo holding the frames.
44 scoped_ptr
<MediaMessageFifo
> fifo_
;
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
);
59 } // namespace chromecast
61 #endif // CHROMECAST_MEDIA_CMA_IPC_STREAMER_CODED_FRAME_PROVIDER_HOST_H_