| 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 28 matching lines...) Expand all Loading... |
| 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 | 44 |
| 45 // Construct a PipelineController wrapping |pipeline_|. |pipeline_| must | 45 // Construct a PipelineController wrapping |pipeline_|. |pipeline_| must |
| 46 // outlive the resulting PipelineController. The callbacks are: | 46 // outlive the resulting PipelineController. The callbacks are: |
| 47 // - |renderer_factory_cb| is called by PipelineController to create new | 47 // - |renderer_factory_cb| is called by PipelineController to create new |
| 48 // renderers when starting and resuming. | 48 // renderers when starting and resuming. |
| 49 // - |start_done_cb| is called when the pipeline has finished the async |
| 50 // start operation either successfully or unsuccessfully. |
| 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 suspendeding. |
| 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, |
| 57 const PipelineStatusCB& start_done_cb, |
| 55 const SeekedCB& seeked_cb, | 58 const SeekedCB& seeked_cb, |
| 56 const SuspendedCB& suspended_cb, | 59 const SuspendedCB& suspended_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 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 111 |
| 109 // PipelineStaus callback that also carries the target state. | 112 // PipelineStaus callback that also carries the target state. |
| 110 void OnPipelineStatus(State state, PipelineStatus pipeline_status); | 113 void OnPipelineStatus(State state, PipelineStatus pipeline_status); |
| 111 | 114 |
| 112 // The Pipeline we are managing state for. | 115 // The Pipeline we are managing state for. |
| 113 Pipeline* pipeline_ = nullptr; | 116 Pipeline* pipeline_ = nullptr; |
| 114 | 117 |
| 115 // Factory for Renderers, used for Start() and Resume(). | 118 // Factory for Renderers, used for Start() and Resume(). |
| 116 RendererFactoryCB renderer_factory_cb_; | 119 RendererFactoryCB renderer_factory_cb_; |
| 117 | 120 |
| 121 // Called when Pipeline::Start is completed. |
| 122 PipelineStatusCB start_done_cb_; |
| 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 |
| 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_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |