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

Side by Side Diff: media/filters/pipeline_controller.h

Issue 2618883002: [Media, Video] Enable the video track for a new renderer. (Closed)
Patch Set: Added ResumedCB to PipelineController Created 3 years, 11 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_FILTERS_PIPELINE_CONTROLLER_H_ 5 #ifndef MEDIA_FILTERS_PIPELINE_CONTROLLER_H_
6 #define MEDIA_FILTERS_PIPELINE_CONTROLLER_H_ 6 #define MEDIA_FILTERS_PIPELINE_CONTROLLER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 23 matching lines...) Expand all
34 PLAYING, 34 PLAYING,
35 SEEKING, 35 SEEKING,
36 SUSPENDING, 36 SUSPENDING,
37 SUSPENDED, 37 SUSPENDED,
38 RESUMING, 38 RESUMING,
39 }; 39 };
40 40
41 using RendererFactoryCB = base::Callback<std::unique_ptr<Renderer>(void)>; 41 using RendererFactoryCB = base::Callback<std::unique_ptr<Renderer>(void)>;
42 using SeekedCB = base::Callback<void(bool time_updated)>; 42 using SeekedCB = base::Callback<void(bool time_updated)>;
43 using SuspendedCB = base::Callback<void()>; 43 using SuspendedCB = base::Callback<void()>;
44 using ResumedCB = base::Callback<void()>;
44 45
45 // Construct a PipelineController wrapping |pipeline_|. |pipeline_| must 46 // Construct a PipelineController wrapping |pipeline_|. |pipeline_| must
46 // outlive the resulting PipelineController. The callbacks are: 47 // outlive the resulting PipelineController. The callbacks are:
47 // - |renderer_factory_cb| is called by PipelineController to create new 48 // - |renderer_factory_cb| is called by PipelineController to create new
48 // renderers when starting and resuming. 49 // renderers when starting and resuming.
49 // - |seeked_cb| is called upon reaching a stable state if a seek occured. 50 // - |seeked_cb| is called upon reaching a stable state if a seek occured.
50 // - |suspended_cb| is called immediately after suspendeding. 51 // - |suspended_cb| is called immediately after suspending.
52 // - |resumed_cb| is called upon reaching a stable state after resuming.
51 // - |error_cb| is called if any operation on |pipeline_| does not result 53 // - |error_cb| is called if any operation on |pipeline_| does not result
52 // in PIPELINE_OK or its error callback is called. 54 // in PIPELINE_OK or its error callback is called.
53 PipelineController(Pipeline* pipeline, 55 PipelineController(Pipeline* pipeline,
54 const RendererFactoryCB& renderer_factory_cb, 56 const RendererFactoryCB& renderer_factory_cb,
55 const SeekedCB& seeked_cb, 57 const SeekedCB& seeked_cb,
56 const SuspendedCB& suspended_cb, 58 const SuspendedCB& suspended_cb,
59 const ResumedCB& resumed_cb,
57 const PipelineStatusCB& error_cb); 60 const PipelineStatusCB& error_cb);
58 ~PipelineController(); 61 ~PipelineController();
59 62
60 // Start |pipeline_|. |demuxer| will be retained and StartWaitingForSeek()/ 63 // Start |pipeline_|. |demuxer| will be retained and StartWaitingForSeek()/
61 // CancelPendingSeek() will be issued to it as necessary. 64 // CancelPendingSeek() will be issued to it as necessary.
62 // 65 //
63 // When |is_streaming| is true, Resume() will always start at the 66 // When |is_streaming| is true, Resume() will always start at the
64 // beginning of the stream, rather than attempting to seek to the current 67 // beginning of the stream, rather than attempting to seek to the current
65 // time. 68 // time.
66 // 69 //
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 RendererFactoryCB renderer_factory_cb_; 119 RendererFactoryCB renderer_factory_cb_;
117 120
118 // Called after seeks (which includes Start()) upon reaching a stable state. 121 // Called after seeks (which includes Start()) upon reaching a stable state.
119 // Multiple seeks result in only one callback if no stable state occurs 122 // Multiple seeks result in only one callback if no stable state occurs
120 // between them. 123 // between them.
121 SeekedCB seeked_cb_; 124 SeekedCB seeked_cb_;
122 125
123 // Called immediately when |pipeline_| completes a suspend operation. 126 // Called immediately when |pipeline_| completes a suspend operation.
124 SuspendedCB suspended_cb_; 127 SuspendedCB suspended_cb_;
125 128
129 // Called immediately when |pipeline_| completes a resume operation.
130 ResumedCB resumed_cb_;
131
126 // Called immediately when any operation on |pipeline_| results in an error. 132 // Called immediately when any operation on |pipeline_| results in an error.
127 PipelineStatusCB error_cb_; 133 PipelineStatusCB error_cb_;
128 134
129 // State for handling StartWaitingForSeek()/CancelPendingSeek(). 135 // State for handling StartWaitingForSeek()/CancelPendingSeek().
130 Demuxer* demuxer_ = nullptr; 136 Demuxer* demuxer_ = nullptr;
131 bool waiting_for_seek_ = false; 137 bool waiting_for_seek_ = false;
132 138
133 // When true, Resume() will start at time zero instead of seeking to the 139 // When true, Resume() will start at time zero instead of seeking to the
134 // current time. 140 // current time.
135 bool is_streaming_ = false; 141 bool is_streaming_ = false;
136 142
137 // When true, seeking to the current time may be elided. 143 // When true, seeking to the current time may be elided.
138 bool is_static_ = true; 144 bool is_static_ = true;
139 145
140 // Tracks the current state of |pipeline_|. 146 // Tracks the current state of |pipeline_|.
141 State state_ = State::CREATED; 147 State state_ = State::CREATED;
142 148
143 // Indicates that a seek has occurred. When set, a seeked callback will be 149 // Indicates that a seek has occurred. When set, a seeked callback will be
144 // issued at the next stable state. 150 // issued at the next stable state.
145 bool pending_seeked_cb_ = false; 151 bool pending_seeked_cb_ = false;
146 152
153 // Indicates that a resume has occurred. When set, a resumed callback will be
154 // issued at the next stable state.
155 bool pending_resumed_cb_ = false;
156
147 // Indicates that time has been changed by a seek, which will be reported at 157 // Indicates that time has been changed by a seek, which will be reported at
148 // the next seeked callback. 158 // the next seeked callback.
149 bool pending_time_updated_ = false; 159 bool pending_time_updated_ = false;
150 160
151 // The target time of the active seek; valid while SEEKING or RESUMING. 161 // The target time of the active seek; valid while SEEKING or RESUMING.
152 base::TimeDelta seek_time_; 162 base::TimeDelta seek_time_;
153 163
154 // Target state which we will work to achieve. |pending_seek_time_| is only 164 // Target state which we will work to achieve. |pending_seek_time_| is only
155 // valid when |pending_seek_| is true. 165 // valid when |pending_seek_| is true.
156 bool pending_seek_ = false; 166 bool pending_seek_ = false;
157 base::TimeDelta pending_seek_time_; 167 base::TimeDelta pending_seek_time_;
158 bool pending_suspend_ = false; 168 bool pending_suspend_ = false;
159 bool pending_resume_ = false; 169 bool pending_resume_ = false;
160 170
161 base::ThreadChecker thread_checker_; 171 base::ThreadChecker thread_checker_;
162 base::WeakPtrFactory<PipelineController> weak_factory_; 172 base::WeakPtrFactory<PipelineController> weak_factory_;
163 173
164 DISALLOW_COPY_AND_ASSIGN(PipelineController); 174 DISALLOW_COPY_AND_ASSIGN(PipelineController);
165 }; 175 };
166 176
167 } // namespace media 177 } // namespace media
168 178
169 #endif // MEDIA_FILTERS_PIPELINE_CONTROLLER_H_ 179 #endif // MEDIA_FILTERS_PIPELINE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698