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

Side by Side Diff: media/base/pipeline_impl.h

Issue 1904793002: Move Pipeline permanent callbacks into Pipeline::Client interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup 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 (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_BASE_PIPELINE_IMPL_H_ 5 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_
6 #define MEDIA_BASE_PIPELINE_IMPL_H_ 6 #define MEDIA_BASE_PIPELINE_IMPL_H_
7 7
8 #include "base/gtest_prod_util.h" 8 #include "base/gtest_prod_util.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 PipelineImpl(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 78 PipelineImpl(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
79 MediaLog* media_log); 79 MediaLog* media_log);
80 ~PipelineImpl() override; 80 ~PipelineImpl() override;
81 81
82 void SetErrorForTesting(PipelineStatus status); 82 void SetErrorForTesting(PipelineStatus status);
83 bool HasWeakPtrsForTesting() const; 83 bool HasWeakPtrsForTesting() const;
84 84
85 // Pipeline implementation. 85 // Pipeline implementation.
86 void Start(Demuxer* demuxer, 86 void Start(Demuxer* demuxer,
87 scoped_ptr<Renderer> renderer, 87 scoped_ptr<Renderer> renderer,
88 const base::Closure& ended_cb, 88 Client* client,
xhwang 2016/04/25 22:49:45 Document that |client| call be called on any threa
89 const PipelineStatusCB& error_cb, 89 const PipelineStatusCB& seek_cb) override;
90 const PipelineStatusCB& seek_cb,
91 const PipelineMetadataCB& metadata_cb,
92 const BufferingStateCB& buffering_state_cb,
93 const base::Closure& duration_change_cb,
94 const AddTextTrackCB& add_text_track_cb,
95 const base::Closure& waiting_for_decryption_key_cb) override;
96 void Stop(const base::Closure& stop_cb) override; 90 void Stop(const base::Closure& stop_cb) override;
97 void Seek(base::TimeDelta time, const PipelineStatusCB& seek_cb) override; 91 void Seek(base::TimeDelta time, const PipelineStatusCB& seek_cb) override;
98 bool IsRunning() const override; 92 bool IsRunning() const override;
99 double GetPlaybackRate() const override; 93 double GetPlaybackRate() const override;
100 void SetPlaybackRate(double playback_rate) override; 94 void SetPlaybackRate(double playback_rate) override;
101 void Suspend(const PipelineStatusCB& suspend_cb) override; 95 void Suspend(const PipelineStatusCB& suspend_cb) override;
102 void Resume(scoped_ptr<Renderer> renderer, 96 void Resume(scoped_ptr<Renderer> renderer,
103 base::TimeDelta timestamp, 97 base::TimeDelta timestamp,
104 const PipelineStatusCB& seek_cb) override; 98 const PipelineStatusCB& seek_cb) override;
105 float GetVolume() const override; 99 float GetVolume() const override;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 const TextTrackConfig& config) override; 143 const TextTrackConfig& config) override;
150 void RemoveTextStream(DemuxerStream* text_stream) override; 144 void RemoveTextStream(DemuxerStream* text_stream) override;
151 145
152 // Callback executed when a rendering error happened, initiating the teardown 146 // Callback executed when a rendering error happened, initiating the teardown
153 // sequence. 147 // sequence.
154 void OnError(PipelineStatus error); 148 void OnError(PipelineStatus error);
155 149
156 // Callback executed by filters to update statistics. 150 // Callback executed by filters to update statistics.
157 void OnUpdateStatistics(const PipelineStatistics& stats_delta); 151 void OnUpdateStatistics(const PipelineStatistics& stats_delta);
158 152
153 // Callback executed by renderer when waiting for decryption key.
154 void OnWaitingForDecryptionKey();
155
159 // The following "task" methods correspond to the public methods, but these 156 // The following "task" methods correspond to the public methods, but these
160 // methods are run as the result of posting a task to the Pipeline's 157 // methods are run as the result of posting a task to the Pipeline's
161 // task runner. 158 // task runner.
162 void StartTask(); 159 void StartTask();
163 160
164 // Suspends the pipeline, discarding the current renderer. 161 // Suspends the pipeline, discarding the current renderer.
165 void SuspendTask(const PipelineStatusCB& suspend_cb); 162 void SuspendTask(const PipelineStatusCB& suspend_cb);
166 163
167 // Resumes the pipeline with a new renderer, and initializes it with a seek. 164 // Resumes the pipeline with a new renderer, and initializes it with a seek.
168 void ResumeTask(scoped_ptr<Renderer> renderer, 165 void ResumeTask(scoped_ptr<Renderer> renderer,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 288
292 // Temporary callback used for Start(), Seek(), and Resume(). 289 // Temporary callback used for Start(), Seek(), and Resume().
293 PipelineStatusCB seek_cb_; 290 PipelineStatusCB seek_cb_;
294 291
295 // Temporary callback used for Stop(). 292 // Temporary callback used for Stop().
296 base::Closure stop_cb_; 293 base::Closure stop_cb_;
297 294
298 // Temporary callback used for Suspend(). 295 // Temporary callback used for Suspend().
299 PipelineStatusCB suspend_cb_; 296 PipelineStatusCB suspend_cb_;
300 297
301 // Permanent callbacks passed in via Start().
302 base::Closure ended_cb_;
303 PipelineStatusCB error_cb_;
304 PipelineMetadataCB metadata_cb_;
305 BufferingStateCB buffering_state_cb_;
306 base::Closure duration_change_cb_;
307 AddTextTrackCB add_text_track_cb_;
308 base::Closure waiting_for_decryption_key_cb_;
309
310 // Holds the initialized demuxer. Used for seeking. Owned by client. 298 // Holds the initialized demuxer. Used for seeking. Owned by client.
311 Demuxer* demuxer_; 299 Demuxer* demuxer_;
312 300
313 // Holds the initialized renderers. Used for setting the volume, 301 // Holds the initialized renderers. Used for setting the volume,
314 // playback rate, and determining when playback has finished. 302 // playback rate, and determining when playback has finished.
315 scoped_ptr<Renderer> renderer_; 303 scoped_ptr<Renderer> renderer_;
316 scoped_ptr<TextRenderer> text_renderer_; 304 scoped_ptr<TextRenderer> text_renderer_;
317 305
306 // Holds the client passed on Start().
307 Client* client_;
308
318 PipelineStatistics statistics_; 309 PipelineStatistics statistics_;
319 310
320 scoped_ptr<SerialRunner> pending_callbacks_; 311 scoped_ptr<SerialRunner> pending_callbacks_;
321 312
322 // The CdmContext to be used to decrypt (and decode) encrypted stream in this 313 // The CdmContext to be used to decrypt (and decode) encrypted stream in this
323 // pipeline. It is set when SetCdm() succeeds on the renderer (or when 314 // pipeline. It is set when SetCdm() succeeds on the renderer (or when
324 // SetCdm() is called before Start()), after which it is guaranteed to outlive 315 // SetCdm() is called before Start()), after which it is guaranteed to outlive
325 // this pipeline. The saved value will be used to configure new renderers, 316 // this pipeline. The saved value will be used to configure new renderers,
326 // when starting or resuming. 317 // when starting or resuming.
327 CdmContext* cdm_context_; 318 CdmContext* cdm_context_;
328 319
329 base::ThreadChecker thread_checker_; 320 base::ThreadChecker thread_checker_;
330 321
331 // A weak pointer that can be safely copied on the media thread. 322 // A weak pointer that can be safely copied on the media thread.
332 base::WeakPtr<PipelineImpl> weak_this_; 323 base::WeakPtr<PipelineImpl> weak_this_;
333 324
334 // Weak pointers must be created on the main thread, and must be dereferenced 325 // Weak pointers must be created on the main thread, and must be dereferenced
335 // on the media thread. 326 // on the media thread.
336 // 327 //
337 // Declared last so that weak pointers will be invalidated before all other 328 // Declared last so that weak pointers will be invalidated before all other
338 // member variables. 329 // member variables.
339 base::WeakPtrFactory<PipelineImpl> weak_factory_; 330 base::WeakPtrFactory<PipelineImpl> weak_factory_;
340 331
341 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); 332 DISALLOW_COPY_AND_ASSIGN(PipelineImpl);
342 }; 333 };
343 334
344 } // namespace media 335 } // namespace media
345 336
346 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ 337 #endif // MEDIA_BASE_PIPELINE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698