Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: chromecast/media/cma/ipc_streamer/av_streamer_proxy.h

Issue 2300993003: CmaRenderer is dead. Long live MojoRenderer. (Closed)
Patch Set: update OWNERS file Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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_AV_STREAMER_PROXY_H_
6 #define CHROMECAST_MEDIA_CMA_IPC_STREAMER_AV_STREAMER_PROXY_H_
7
8 #include <list>
9 #include <memory>
10
11 #include "base/callback.h"
12 #include "base/macros.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"
17
18 namespace chromecast {
19 namespace media {
20 class CodedFrameProvider;
21 class DecoderBufferBase;
22 class MediaMessageFifo;
23
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();
30
31 // AvStreamerProxy gets frames and audio/video config
32 // from the |frame_provider| and feed them into the |fifo|.
33 void SetCodedFrameProvider(
34 std::unique_ptr<CodedFrameProvider> frame_provider);
35 void SetMediaMessageFifo(std::unique_ptr<MediaMessageFifo> fifo);
36
37 // Starts fetching A/V buffers.
38 void Start();
39
40 // Stops fetching A/V buffers and flush the pending buffers,
41 // invoking |flush_cb| when done.
42 void StopAndFlush(const base::Closure& flush_cb);
43
44 // Event invoked when some data have been read from the fifo.
45 // This means some data can now possibly be written into the fifo.
46 void OnFifoReadEvent();
47
48 private:
49 void RequestBufferIfNeeded();
50
51 void OnNewBuffer(const scoped_refptr<DecoderBufferBase>& buffer,
52 const ::media::AudioDecoderConfig& audio_config,
53 const ::media::VideoDecoderConfig& video_config);
54
55 void ProcessPendingData();
56
57 bool SendAudioDecoderConfig(const ::media::AudioDecoderConfig& config);
58 bool SendVideoDecoderConfig(const ::media::VideoDecoderConfig& config);
59 bool SendBuffer(const scoped_refptr<DecoderBufferBase>& buffer);
60
61 void OnStopAndFlushDone();
62
63 base::ThreadChecker thread_checker_;
64
65 std::unique_ptr<CodedFrameProvider> frame_provider_;
66
67 // Fifo used to convey A/V configs and buffers.
68 std::unique_ptr<MediaMessageFifo> fifo_;
69
70 // State.
71 bool is_running_;
72
73 // Indicates if there is a pending request to the coded frame provider.
74 bool pending_read_;
75
76 // Pending config & buffer.
77 // |pending_av_data_| is set as long as one of the pending audio/video
78 // config or buffer is valid.
79 bool pending_av_data_;
80 ::media::AudioDecoderConfig pending_audio_config_;
81 ::media::VideoDecoderConfig pending_video_config_;
82 scoped_refptr<DecoderBufferBase> pending_buffer_;
83
84 // List of pending callbacks in StopAndFlush
85 std::list<base::Closure> pending_stop_flush_cb_list_;
86
87 base::WeakPtr<AvStreamerProxy> weak_this_;
88 base::WeakPtrFactory<AvStreamerProxy> weak_factory_;
89
90 DISALLOW_COPY_AND_ASSIGN(AvStreamerProxy);
91 };
92
93 } // namespace media
94 } // namespace chromecast
95
96 #endif // CHROMECAST_MEDIA_CMA_IPC_STREAMER_AV_STREAMER_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698