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 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 Loading... |
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; |
(...skipping 24 matching lines...) Expand all Loading... |
160 | 166 |
161 base::ThreadChecker thread_checker_; | 167 base::ThreadChecker thread_checker_; |
162 base::WeakPtrFactory<PipelineController> weak_factory_; | 168 base::WeakPtrFactory<PipelineController> weak_factory_; |
163 | 169 |
164 DISALLOW_COPY_AND_ASSIGN(PipelineController); | 170 DISALLOW_COPY_AND_ASSIGN(PipelineController); |
165 }; | 171 }; |
166 | 172 |
167 } // namespace media | 173 } // namespace media |
168 | 174 |
169 #endif // MEDIA_FILTERS_PIPELINE_CONTROLLER_H_ | 175 #endif // MEDIA_FILTERS_PIPELINE_CONTROLLER_H_ |
OLD | NEW |