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

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

Issue 1830913005: Convert WMPI state management to level-triggered. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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<scoped_ptr<Renderer>(void)>; 41 using RendererFactoryCB = base::Callback<scoped_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()>;
45 44
46 // Construct a PipelineController wrapping |pipeline_|. |pipeline_| must 45 // Construct a PipelineController wrapping |pipeline_|. |pipeline_| must
47 // outlive the resulting PipelineController. The callbacks are: 46 // outlive the resulting PipelineController. The callbacks are:
48 // - |renderer_factory_cb| is called by PipelineController to create new 47 // - |renderer_factory_cb| is called by PipelineController to create new
49 // renderers when starting and resuming. 48 // renderers when starting and resuming.
50 // - |seeked_cb| is called upon reaching a stable state if a seek occured. 49 // - |seeked_cb| is called upon reaching a stable state if a seek occured.
51 // - |suspended_cb| is called immediately after suspendeding. 50 // - |suspended_cb| is called immediately after suspendeding.
52 // - |resumed_cb| is called immediately after resuming.
53 // - |error_cb| is called if any operation on |pipeline_| does not result 51 // - |error_cb| is called if any operation on |pipeline_| does not result
54 // in PIPELINE_OK or its error callback is called. 52 // in PIPELINE_OK or its error callback is called.
55 PipelineController(Pipeline* pipeline, 53 PipelineController(Pipeline* pipeline,
56 const RendererFactoryCB& renderer_factory_cb, 54 const RendererFactoryCB& renderer_factory_cb,
57 const SeekedCB& seeked_cb, 55 const SeekedCB& seeked_cb,
58 const SuspendedCB& suspended_cb, 56 const SuspendedCB& suspended_cb,
59 const ResumedCB& resumed_cb,
60 const PipelineStatusCB& error_cb); 57 const PipelineStatusCB& error_cb);
61 ~PipelineController(); 58 ~PipelineController();
62 59
63 // Start |pipeline_|. |demuxer| will be retained and StartWaitingForSeek()/ 60 // Start |pipeline_|. |demuxer| will be retained and StartWaitingForSeek()/
64 // CancelPendingSeek() will be issued to it as necessary. 61 // CancelPendingSeek() will be issued to it as necessary.
65 // 62 //
66 // When |is_streaming| is true, Resume() will always start at the 63 // When |is_streaming| is true, Resume() will always start at the
67 // beginning of the stream, rather than attempting to seek to the current 64 // beginning of the stream, rather than attempting to seek to the current
68 // time. 65 // time.
69 // 66 //
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 RendererFactoryCB renderer_factory_cb_; 118 RendererFactoryCB renderer_factory_cb_;
122 119
123 // Called after seeks (which includes Start()) upon reaching a stable state. 120 // Called after seeks (which includes Start()) upon reaching a stable state.
124 // Multiple seeks result in only one callback if no stable state occurs 121 // Multiple seeks result in only one callback if no stable state occurs
125 // between them. 122 // between them.
126 SeekedCB seeked_cb_; 123 SeekedCB seeked_cb_;
127 124
128 // Called immediately when |pipeline_| completes a suspend operation. 125 // Called immediately when |pipeline_| completes a suspend operation.
129 SuspendedCB suspended_cb_; 126 SuspendedCB suspended_cb_;
130 127
131 // Called immediately when |pipeline_| completes a resume operation.
132 ResumedCB resumed_cb_;
133
134 // Called immediately when any operation on |pipeline_| results in an error. 128 // Called immediately when any operation on |pipeline_| results in an error.
135 PipelineStatusCB error_cb_; 129 PipelineStatusCB error_cb_;
136 130
137 // State for handling StartWaitingForSeek()/CancelPendingSeek(). 131 // State for handling StartWaitingForSeek()/CancelPendingSeek().
138 Demuxer* demuxer_ = nullptr; 132 Demuxer* demuxer_ = nullptr;
139 bool waiting_for_seek_ = false; 133 bool waiting_for_seek_ = false;
140 134
141 // When true, Resume() will start at time zero instead of seeking to the 135 // When true, Resume() will start at time zero instead of seeking to the
142 // current time. 136 // current time.
143 bool is_streaming_ = false; 137 bool is_streaming_ = false;
144 138
145 // When true, seeking to the current time may be elided. 139 // When true, seeking to the current time may be elided.
146 bool is_static_ = true; 140 bool is_static_ = true;
147 141
148 // Tracks the current state of |pipeline_|. 142 // Tracks the current state of |pipeline_|.
149 State state_ = State::CREATED; 143 State state_ = State::CREATED;
150 144
151 // Indicates that a seek has occurred. When set, a seeked callback will be 145 // Indicates that a seek has occurred. When set, a seeked callback will be
152 // issued at the next stable state. 146 // issued at the next stable state.
153 bool pending_seeked_cb_ = false; 147 bool pending_seeked_cb_ = false;
154 148
155 // Indicates that time has been changed by a seek, which will be reported at 149 // Indicates that time has been changed by a seek, which will be reported at
156 // the next seeked callback. 150 // the next seeked callback.
157 bool pending_time_updated_ = false; 151 bool pending_time_updated_ = false;
158 152
159 // Indicates that the |pipeline_| was suspended, and therefore that a resumed
160 // callback should be issued the next time we enter State::PLAYING.
161 bool pending_resumed_cb_ = false;
162
163 // The target time of the active seek; valid while SEEKING or RESUMING. 153 // The target time of the active seek; valid while SEEKING or RESUMING.
164 base::TimeDelta seek_time_; 154 base::TimeDelta seek_time_;
165 155
166 // Target state which we will work to achieve. |pending_seek_time_| is only 156 // Target state which we will work to achieve. |pending_seek_time_| is only
167 // valid when |pending_seek_| is true. 157 // valid when |pending_seek_| is true.
168 bool pending_seek_ = false; 158 bool pending_seek_ = false;
169 base::TimeDelta pending_seek_time_; 159 base::TimeDelta pending_seek_time_;
170 bool pending_suspend_ = false; 160 bool pending_suspend_ = false;
171 bool pending_resume_ = false; 161 bool pending_resume_ = false;
172 162
173 base::ThreadChecker thread_checker_; 163 base::ThreadChecker thread_checker_;
174 base::WeakPtrFactory<PipelineController> weak_factory_; 164 base::WeakPtrFactory<PipelineController> weak_factory_;
175 165
176 DISALLOW_COPY_AND_ASSIGN(PipelineController); 166 DISALLOW_COPY_AND_ASSIGN(PipelineController);
177 }; 167 };
178 168
179 } // namespace media 169 } // namespace media
180 170
181 #endif // MEDIA_FILTERS_PIPELINE_CONTROLLER_H_ 171 #endif // MEDIA_FILTERS_PIPELINE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698