Update broken references to image assets
[chromium-blink-merge.git] / chromecast / media / cma / ipc_streamer / av_streamer_proxy.h
blob9d24abc7e0ec8037b2fe5712369df6d81ef364c5
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_AV_STREAMER_PROXY_H_
6 #define CHROMECAST_MEDIA_CMA_IPC_STREAMER_AV_STREAMER_PROXY_H_
8 #include <list>
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/thread_checker.h"
15 #include "media/base/audio_decoder_config.h"
16 #include "media/base/video_decoder_config.h"
18 namespace chromecast {
19 namespace media {
20 class CodedFrameProvider;
21 class DecoderBufferBase;
22 class MediaMessageFifo;
24 // AvStreamerProxy streams audio/video data from a coded frame provider
25 // to a media message fifo.
26 class AvStreamerProxy {
27 public:
28 AvStreamerProxy();
29 ~AvStreamerProxy();
31 // AvStreamerProxy gets frames and audio/video config
32 // from the |frame_provider| and feed them into the |fifo|.
33 void SetCodedFrameProvider(scoped_ptr<CodedFrameProvider> frame_provider);
34 void SetMediaMessageFifo(scoped_ptr<MediaMessageFifo> fifo);
36 // Starts fetching A/V buffers.
37 void Start();
39 // Stops fetching A/V buffers and flush the pending buffers,
40 // invoking |flush_cb| when done.
41 void StopAndFlush(const base::Closure& flush_cb);
43 // Event invoked when some data have been read from the fifo.
44 // This means some data can now possibly be written into the fifo.
45 void OnFifoReadEvent();
47 private:
48 void RequestBufferIfNeeded();
50 void OnNewBuffer(const scoped_refptr<DecoderBufferBase>& buffer,
51 const ::media::AudioDecoderConfig& audio_config,
52 const ::media::VideoDecoderConfig& video_config);
54 void ProcessPendingData();
56 bool SendAudioDecoderConfig(const ::media::AudioDecoderConfig& config);
57 bool SendVideoDecoderConfig(const ::media::VideoDecoderConfig& config);
58 bool SendBuffer(const scoped_refptr<DecoderBufferBase>& buffer);
60 void OnStopAndFlushDone();
62 base::ThreadChecker thread_checker_;
64 scoped_ptr<CodedFrameProvider> frame_provider_;
66 // Fifo used to convey A/V configs and buffers.
67 scoped_ptr<MediaMessageFifo> fifo_;
69 // State.
70 bool is_running_;
72 // Indicates if there is a pending request to the coded frame provider.
73 bool pending_read_;
75 // Pending config & buffer.
76 // |pending_av_data_| is set as long as one of the pending audio/video
77 // config or buffer is valid.
78 bool pending_av_data_;
79 ::media::AudioDecoderConfig pending_audio_config_;
80 ::media::VideoDecoderConfig pending_video_config_;
81 scoped_refptr<DecoderBufferBase> pending_buffer_;
83 // List of pending callbacks in StopAndFlush
84 std::list<base::Closure> pending_stop_flush_cb_list_;
86 base::WeakPtr<AvStreamerProxy> weak_this_;
87 base::WeakPtrFactory<AvStreamerProxy> weak_factory_;
89 DISALLOW_COPY_AND_ASSIGN(AvStreamerProxy);
92 } // namespace media
93 } // namespace chromecast
95 #endif // CHROMECAST_MEDIA_CMA_IPC_STREAMER_AV_STREAMER_PROXY_H_