OLD | NEW |
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 Loading... |
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 BeforeResumeCB = base::Callback<void()>; |
| 45 using ResumedCB = base::Callback<void()>; |
44 | 46 |
45 // Construct a PipelineController wrapping |pipeline_|. |pipeline_| must | 47 // Construct a PipelineController wrapping |pipeline_|. |pipeline_| must |
46 // outlive the resulting PipelineController. The callbacks are: | 48 // outlive the resulting PipelineController. The callbacks are: |
47 // - |renderer_factory_cb| is called by PipelineController to create new | 49 // - |renderer_factory_cb| is called by PipelineController to create new |
48 // renderers when starting and resuming. | 50 // renderers when starting and resuming. |
49 // - |seeked_cb| is called upon reaching a stable state if a seek occured. | 51 // - |seeked_cb| is called upon reaching a stable state if a seek occured. |
50 // - |suspended_cb| is called immediately after suspendeding. | 52 // - |suspended_cb| is called immediately after suspending. |
| 53 // - |before_resume_cb| is called immediately before resuming. |
| 54 // - |resumed_cb| is called immediately after resuming. |
51 // - |error_cb| is called if any operation on |pipeline_| does not result | 55 // - |error_cb| is called if any operation on |pipeline_| does not result |
52 // in PIPELINE_OK or its error callback is called. | 56 // in PIPELINE_OK or its error callback is called. |
53 PipelineController(Pipeline* pipeline, | 57 PipelineController(Pipeline* pipeline, |
54 const RendererFactoryCB& renderer_factory_cb, | 58 const RendererFactoryCB& renderer_factory_cb, |
55 const SeekedCB& seeked_cb, | 59 const SeekedCB& seeked_cb, |
56 const SuspendedCB& suspended_cb, | 60 const SuspendedCB& suspended_cb, |
| 61 const BeforeResumeCB& before_resume_cb, |
| 62 const ResumedCB& resumed_cb, |
57 const PipelineStatusCB& error_cb); | 63 const PipelineStatusCB& error_cb); |
58 ~PipelineController(); | 64 ~PipelineController(); |
59 | 65 |
60 // Start |pipeline_|. |demuxer| will be retained and StartWaitingForSeek()/ | 66 // Start |pipeline_|. |demuxer| will be retained and StartWaitingForSeek()/ |
61 // CancelPendingSeek() will be issued to it as necessary. | 67 // CancelPendingSeek() will be issued to it as necessary. |
62 // | 68 // |
63 // When |is_streaming| is true, Resume() will always start at the | 69 // When |is_streaming| is true, Resume() will always start at the |
64 // beginning of the stream, rather than attempting to seek to the current | 70 // beginning of the stream, rather than attempting to seek to the current |
65 // time. | 71 // time. |
66 // | 72 // |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 RendererFactoryCB renderer_factory_cb_; | 122 RendererFactoryCB renderer_factory_cb_; |
117 | 123 |
118 // Called after seeks (which includes Start()) upon reaching a stable state. | 124 // Called after seeks (which includes Start()) upon reaching a stable state. |
119 // Multiple seeks result in only one callback if no stable state occurs | 125 // Multiple seeks result in only one callback if no stable state occurs |
120 // between them. | 126 // between them. |
121 SeekedCB seeked_cb_; | 127 SeekedCB seeked_cb_; |
122 | 128 |
123 // Called immediately when |pipeline_| completes a suspend operation. | 129 // Called immediately when |pipeline_| completes a suspend operation. |
124 SuspendedCB suspended_cb_; | 130 SuspendedCB suspended_cb_; |
125 | 131 |
| 132 // Called immediately before |pipeline_| starts a resume operation. |
| 133 ResumedCB before_resume_cb_; |
| 134 |
| 135 // Called immediately when |pipeline_| completes a resume operation. |
| 136 ResumedCB resumed_cb_; |
| 137 |
126 // Called immediately when any operation on |pipeline_| results in an error. | 138 // Called immediately when any operation on |pipeline_| results in an error. |
127 PipelineStatusCB error_cb_; | 139 PipelineStatusCB error_cb_; |
128 | 140 |
129 // State for handling StartWaitingForSeek()/CancelPendingSeek(). | 141 // State for handling StartWaitingForSeek()/CancelPendingSeek(). |
130 Demuxer* demuxer_ = nullptr; | 142 Demuxer* demuxer_ = nullptr; |
131 bool waiting_for_seek_ = false; | 143 bool waiting_for_seek_ = false; |
132 | 144 |
133 // When true, Resume() will start at time zero instead of seeking to the | 145 // When true, Resume() will start at time zero instead of seeking to the |
134 // current time. | 146 // current time. |
135 bool is_streaming_ = false; | 147 bool is_streaming_ = false; |
(...skipping 24 matching lines...) Expand all Loading... |
160 | 172 |
161 base::ThreadChecker thread_checker_; | 173 base::ThreadChecker thread_checker_; |
162 base::WeakPtrFactory<PipelineController> weak_factory_; | 174 base::WeakPtrFactory<PipelineController> weak_factory_; |
163 | 175 |
164 DISALLOW_COPY_AND_ASSIGN(PipelineController); | 176 DISALLOW_COPY_AND_ASSIGN(PipelineController); |
165 }; | 177 }; |
166 | 178 |
167 } // namespace media | 179 } // namespace media |
168 | 180 |
169 #endif // MEDIA_FILTERS_PIPELINE_CONTROLLER_H_ | 181 #endif // MEDIA_FILTERS_PIPELINE_CONTROLLER_H_ |
OLD | NEW |