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

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

Issue 7484054: Migrate Pipeline & PipelineImpl to PipelineStatusCB. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix CR nits Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « media/base/pipeline.h ('k') | media/base/pipeline_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Implementation of Pipeline & PipelineStatusNotification (an async-to-sync 5 // Implementation of Pipeline & PipelineStatusNotification (an async-to-sync
6 // callback adapter). 6 // callback adapter).
7 7
8 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_ 8 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_
9 #define MEDIA_BASE_PIPELINE_IMPL_H_ 9 #define MEDIA_BASE_PIPELINE_IMPL_H_
10 10
(...skipping 21 matching lines...) Expand all
32 // |Callback()| to the Pipeline method requiring a callback. Then Wait() for 32 // |Callback()| to the Pipeline method requiring a callback. Then Wait() for
33 // the callback to get fired and call status() to see what the callback's 33 // the callback to get fired and call status() to see what the callback's
34 // argument was. This object is for one-time use; call |Callback()| exactly 34 // argument was. This object is for one-time use; call |Callback()| exactly
35 // once. 35 // once.
36 class PipelineStatusNotification { 36 class PipelineStatusNotification {
37 public: 37 public:
38 PipelineStatusNotification(); 38 PipelineStatusNotification();
39 ~PipelineStatusNotification(); 39 ~PipelineStatusNotification();
40 40
41 // See class-level comment for usage. 41 // See class-level comment for usage.
42 media::PipelineStatusCallback* Callback(); 42 PipelineStatusCB Callback();
43 void Notify(media::PipelineStatus status);
44 void Wait(); 43 void Wait();
45 media::PipelineStatus status(); 44 PipelineStatus status();
46 45
47 private: 46 private:
47 void Notify(media::PipelineStatus status);
48
48 base::Lock lock_; 49 base::Lock lock_;
49 base::ConditionVariable cv_; 50 base::ConditionVariable cv_;
50 media::PipelineStatus status_; 51 media::PipelineStatus status_;
51 bool notified_; 52 bool notified_;
52 scoped_ptr<media::PipelineStatusCallback> callback_;
53 53
54 DISALLOW_COPY_AND_ASSIGN(PipelineStatusNotification); 54 DISALLOW_COPY_AND_ASSIGN(PipelineStatusNotification);
55 }; 55 };
56 56
57 // PipelineImpl runs the media pipeline. Filters are created and called on the 57 // PipelineImpl runs the media pipeline. Filters are created and called on the
58 // message loop injected into this object. PipelineImpl works like a state 58 // message loop injected into this object. PipelineImpl works like a state
59 // machine to perform asynchronous initialization, pausing, seeking and playing. 59 // machine to perform asynchronous initialization, pausing, seeking and playing.
60 // 60 //
61 // Here's a state diagram that describes the lifetime of this object. 61 // Here's a state diagram that describes the lifetime of this object.
62 // 62 //
(...skipping 26 matching lines...) Expand all
89 // playing the media. 89 // playing the media.
90 // 90 //
91 // If any error ever happens, this object will transition to the "Error" state 91 // If any error ever happens, this object will transition to the "Error" state
92 // from any state. If Stop() is ever called, this object will transition to 92 // from any state. If Stop() is ever called, this object will transition to
93 // "Stopped" state. 93 // "Stopped" state.
94 class PipelineImpl : public Pipeline, public FilterHost { 94 class PipelineImpl : public Pipeline, public FilterHost {
95 public: 95 public:
96 explicit PipelineImpl(MessageLoop* message_loop); 96 explicit PipelineImpl(MessageLoop* message_loop);
97 97
98 // Pipeline implementation. 98 // Pipeline implementation.
99 virtual void Init(PipelineStatusCallback* ended_callback, 99 virtual void Init(const PipelineStatusCB& ended_callback,
100 PipelineStatusCallback* error_callback, 100 const PipelineStatusCB& error_callback,
101 PipelineStatusCallback* network_callback); 101 const PipelineStatusCB& network_callback);
102 virtual bool Start(FilterCollection* filter_collection, 102 virtual bool Start(FilterCollection* filter_collection,
103 const std::string& uri, 103 const std::string& uri,
104 PipelineStatusCallback* start_callback); 104 const PipelineStatusCB& start_callback);
105 virtual void Stop(PipelineStatusCallback* stop_callback); 105 virtual void Stop(const PipelineStatusCB& stop_callback);
106 virtual void Seek(base::TimeDelta time, 106 virtual void Seek(base::TimeDelta time,
107 PipelineStatusCallback* seek_callback); 107 const PipelineStatusCB& seek_callback);
108 virtual bool IsRunning() const; 108 virtual bool IsRunning() const;
109 virtual bool IsInitialized() const; 109 virtual bool IsInitialized() const;
110 virtual bool IsNetworkActive() const; 110 virtual bool IsNetworkActive() const;
111 virtual bool HasAudio() const; 111 virtual bool HasAudio() const;
112 virtual bool HasVideo() const; 112 virtual bool HasVideo() const;
113 virtual float GetPlaybackRate() const; 113 virtual float GetPlaybackRate() const;
114 virtual void SetPlaybackRate(float playback_rate); 114 virtual void SetPlaybackRate(float playback_rate);
115 virtual float GetVolume() const; 115 virtual float GetVolume() const;
116 virtual void SetVolume(float volume); 116 virtual void SetVolume(float volume);
117 virtual void SetPreload(Preload preload); 117 virtual void SetPreload(Preload preload);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 void OnTeardownStateTransition(); 215 void OnTeardownStateTransition();
216 216
217 // Callback executed by filters to update statistics. 217 // Callback executed by filters to update statistics.
218 void OnUpdateStatistics(const PipelineStatistics& stats); 218 void OnUpdateStatistics(const PipelineStatistics& stats);
219 219
220 // The following "task" methods correspond to the public methods, but these 220 // The following "task" methods correspond to the public methods, but these
221 // methods are run as the result of posting a task to the PipelineInternal's 221 // methods are run as the result of posting a task to the PipelineInternal's
222 // message loop. 222 // message loop.
223 void StartTask(FilterCollection* filter_collection, 223 void StartTask(FilterCollection* filter_collection,
224 const std::string& url, 224 const std::string& url,
225 PipelineStatusCallback* start_callback); 225 const PipelineStatusCB& start_callback);
226 226
227 // InitializeTask() performs initialization in multiple passes. It is executed 227 // InitializeTask() performs initialization in multiple passes. It is executed
228 // as a result of calling Start() or InitializationComplete() that advances 228 // as a result of calling Start() or InitializationComplete() that advances
229 // initialization to the next state. It works as a hub of state transition for 229 // initialization to the next state. It works as a hub of state transition for
230 // initialization. 230 // initialization.
231 void InitializeTask(); 231 void InitializeTask();
232 232
233 // Stops and destroys all filters, placing the pipeline in the kStopped state. 233 // Stops and destroys all filters, placing the pipeline in the kStopped state.
234 void StopTask(PipelineStatusCallback* stop_callback); 234 void StopTask(const PipelineStatusCB& stop_callback);
235 235
236 // Carries out stopping and destroying all filters, placing the pipeline in 236 // Carries out stopping and destroying all filters, placing the pipeline in
237 // the kError state. 237 // the kError state.
238 void ErrorChangedTask(PipelineStatus error); 238 void ErrorChangedTask(PipelineStatus error);
239 239
240 // Carries out notifying filters that the playback rate has changed. 240 // Carries out notifying filters that the playback rate has changed.
241 void PlaybackRateChangedTask(float playback_rate); 241 void PlaybackRateChangedTask(float playback_rate);
242 242
243 // Carries out notifying filters that the volume has changed. 243 // Carries out notifying filters that the volume has changed.
244 void VolumeChangedTask(float volume); 244 void VolumeChangedTask(float volume);
245 245
246 // Returns media preload value. 246 // Returns media preload value.
247 virtual Preload GetPreload() const; 247 virtual Preload GetPreload() const;
248 248
249 // Carries out notifying filters that the preload value has changed. 249 // Carries out notifying filters that the preload value has changed.
250 void PreloadChangedTask(Preload preload); 250 void PreloadChangedTask(Preload preload);
251 251
252 // Carries out notifying filters that we are seeking to a new timestamp. 252 // Carries out notifying filters that we are seeking to a new timestamp.
253 void SeekTask(base::TimeDelta time, PipelineStatusCallback* seek_callback); 253 void SeekTask(base::TimeDelta time, const PipelineStatusCB& seek_callback);
254 254
255 // Carries out handling a notification from a filter that it has ended. 255 // Carries out handling a notification from a filter that it has ended.
256 void NotifyEndedTask(); 256 void NotifyEndedTask();
257 257
258 // Carries out handling a notification of network event. 258 // Carries out handling a notification of network event.
259 void NotifyNetworkEventTask(); 259 void NotifyNetworkEventTask();
260 260
261 // Carries out disabling the audio renderer. 261 // Carries out disabling the audio renderer.
262 void DisableAudioRendererTask(); 262 void DisableAudioRendererTask();
263 263
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // TODO(vrk): This is a hack. 422 // TODO(vrk): This is a hack.
423 base::TimeDelta max_buffered_time_; 423 base::TimeDelta max_buffered_time_;
424 424
425 // Filter collection as passed in by Start(). 425 // Filter collection as passed in by Start().
426 scoped_ptr<FilterCollection> filter_collection_; 426 scoped_ptr<FilterCollection> filter_collection_;
427 427
428 // URL for the data source as passed in by Start(). 428 // URL for the data source as passed in by Start().
429 std::string url_; 429 std::string url_;
430 430
431 // Callbacks for various pipeline operations. 431 // Callbacks for various pipeline operations.
432 scoped_ptr<PipelineStatusCallback> seek_callback_; 432 PipelineStatusCB seek_callback_;
433 scoped_ptr<PipelineStatusCallback> stop_callback_; 433 PipelineStatusCB stop_callback_;
434 scoped_ptr<PipelineStatusCallback> ended_callback_; 434 PipelineStatusCB ended_callback_;
435 scoped_ptr<PipelineStatusCallback> error_callback_; 435 PipelineStatusCB error_callback_;
436 scoped_ptr<PipelineStatusCallback> network_callback_; 436 PipelineStatusCB network_callback_;
437 437
438 // Reference to the filter(s) that constitute the pipeline. 438 // Reference to the filter(s) that constitute the pipeline.
439 scoped_refptr<Filter> pipeline_filter_; 439 scoped_refptr<Filter> pipeline_filter_;
440 440
441 // Renderer references used for setting the volume and determining 441 // Renderer references used for setting the volume and determining
442 // when playback has finished. 442 // when playback has finished.
443 scoped_refptr<AudioRenderer> audio_renderer_; 443 scoped_refptr<AudioRenderer> audio_renderer_;
444 scoped_refptr<VideoRenderer> video_renderer_; 444 scoped_refptr<VideoRenderer> video_renderer_;
445 445
446 // Demuxer reference used for setting the preload value. 446 // Demuxer reference used for setting the preload value.
447 scoped_refptr<Demuxer> demuxer_; 447 scoped_refptr<Demuxer> demuxer_;
448 448
449 // Helper class that stores filter references during pipeline 449 // Helper class that stores filter references during pipeline
450 // initialization. 450 // initialization.
451 class PipelineInitState; 451 class PipelineInitState;
452 scoped_ptr<PipelineInitState> pipeline_init_state_; 452 scoped_ptr<PipelineInitState> pipeline_init_state_;
453 453
454 // Statistics. 454 // Statistics.
455 PipelineStatistics statistics_; 455 PipelineStatistics statistics_;
456 456
457 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime); 457 FRIEND_TEST_ALL_PREFIXES(PipelineImplTest, GetBufferedTime);
458 458
459 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); 459 DISALLOW_COPY_AND_ASSIGN(PipelineImpl);
460 }; 460 };
461 461
462 } // namespace media 462 } // namespace media
463 463
464 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ 464 #endif // MEDIA_BASE_PIPELINE_IMPL_H_
OLDNEW
« no previous file with comments | « media/base/pipeline.h ('k') | media/base/pipeline_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698