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

Side by Side Diff: chromecast/media/cma/filters/cma_renderer.h

Issue 750683003: Chromecast: adds media::Renderer implementation for CMA pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 years 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
« no previous file with comments | « no previous file | chromecast/media/cma/filters/cma_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_FILTERS_CMA_RENDERER_H_
6 #define CHROMECAST_MEDIA_CMA_FILTERS_CMA_RENDERER_H_
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/synchronization/lock.h"
12 #include "base/threading/thread_checker.h"
13 #include "base/time/default_tick_clock.h"
14 #include "media/base/buffering_state.h"
15 #include "media/base/renderer.h"
16 #include "ui/gfx/geometry/size.h"
17
18 namespace base {
19 class MessageLoopProxy;
20 }
21
22 namespace media {
23 class DemuxerStreamProvider;
24 class TimeDeltaInterpolator;
25 class VideoFrame;
26 }
27
28 namespace chromecast {
29 namespace media {
30 class AudioPipeline;
31 class BalancedMediaTaskRunnerFactory;
32 class MediaPipeline;
33 class VideoPipeline;
34
35 class CmaRenderer : public ::media::Renderer {
36 public:
37 explicit CmaRenderer(scoped_ptr<MediaPipeline> media_pipeline);
38 ~CmaRenderer() override;
39
40 // ::media::Renderer implementation:
41 void Initialize(
42 ::media::DemuxerStreamProvider* demuxer_stream_provider,
43 const base::Closure& init_cb,
44 const ::media::StatisticsCB& statistics_cb,
45 const ::media::BufferingStateCB& buffering_state_cb,
46 const PaintCB& paint_cb,
47 const base::Closure& ended_cb,
48 const ::media::PipelineStatusCB& error_cb) override;
49 void Flush(const base::Closure& flush_cb) override;
50 void StartPlayingFrom(base::TimeDelta time) override;
51 void SetPlaybackRate(float playback_rate) override;
52 void SetVolume(float volume) override;
53 base::TimeDelta GetMediaTime() override;
54 bool HasAudio() override;
55 bool HasVideo() override;
56 void SetCdm(::media::CdmContext* cdm_context,
57 const ::media::CdmAttachedCB& cdm_attached_cb) override;
58
59 private:
60 enum State {
61 kUninitialized,
62 kPlaying,
63 kFlushed,
64 kError,
65 };
66
67 // Asynchronous initialization sequence. These four methods are invoked in
68 // the order below, with a successful initialization making it to
69 // OnVideoPipelineInitializeDone, regardless of which streams are present.
70 void InitializeAudioPipeline();
71 void OnAudioPipelineInitializeDone(::media::PipelineStatus status);
72 void InitializeVideoPipeline();
73 void OnVideoPipelineInitializeDone(::media::PipelineStatus status);
74
75 // Callbacks for AvPipelineClient.
76 void OnEosReached(bool is_audio);
77 void OnStatisticsUpdated(const ::media::PipelineStatistics& stats);
78 void OnNaturalSizeChanged(const gfx::Size& size);
79
80 // Callbacks for MediaPipelineClient.
81 void OnPlaybackTimeUpdated(base::TimeDelta time,
82 base::TimeDelta max_time,
83 base::TimeTicks capture_time);
84 void OnBufferingNotification(::media::BufferingState state);
85
86 void OnFlushDone(::media::PipelineStatus status);
87 void OnError(::media::PipelineStatus status);
88
89 void FireAllPendingCallbacks();
90
91 // Begin a state transition.
92 // Return true if delayed because of a pending state transition.
93 void BeginStateTransition();
94 void CompleteStateTransition(State new_state);
95
96 base::ThreadChecker thread_checker_;
97
98 scoped_refptr<BalancedMediaTaskRunnerFactory> media_task_runner_factory_;
99 scoped_ptr<MediaPipeline> media_pipeline_;
100 AudioPipeline* audio_pipeline_;
101 VideoPipeline* video_pipeline_;
102
103 ::media::DemuxerStreamProvider* demuxer_stream_provider_;
104
105 // Set of callbacks.
106 PaintCB paint_cb_;
107 base::Closure init_cb_;
108 ::media::StatisticsCB statistics_cb_;
109 base::Closure ended_cb_;
110 ::media::PipelineStatusCB error_cb_;
111 ::media::BufferingStateCB buffering_state_cb_;
112 base::Closure flush_cb_;
113
114 // Renderer state.
115 // Used mostly for checking that transitions are correct.
116 State state_;
117 bool is_pending_transition_;
118
119 bool has_audio_;
120 bool has_video_;
121
122 bool received_audio_eos_;
123 bool received_video_eos_;
124
125 // Data members for helping the creation of the initial video hole frame.
126 gfx::Size initial_natural_size_;
127 bool initial_video_hole_created_;
128
129 // Lock protecting access to |time_interpolator_|.
130 base::Lock time_interpolator_lock_;
131
132 // base::TickClock used by |time_interpolator_|.
133 base::DefaultTickClock default_tick_clock_;
134
135 // Tracks the most recent media time update and provides interpolated values
136 // as playback progresses.
137 scoped_ptr< ::media::TimeDeltaInterpolator> time_interpolator_;
138
139 float playback_rate_;
140
141 base::WeakPtr<CmaRenderer> weak_this_;
142 base::WeakPtrFactory<CmaRenderer> weak_factory_;
143
144 DISALLOW_COPY_AND_ASSIGN(CmaRenderer);
145 };
146
147 } // namespace media
148 } // namespace chromecast
149
150 #endif // CHROMECAST_MEDIA_CMA_FILTERS_CMA_RENDERER_H_
OLDNEW
« no previous file with comments | « no previous file | chromecast/media/cma/filters/cma_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698