Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008-2009 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. | 5 // Implementation of Pipeline. |
| 6 | 6 |
| 7 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_ | 7 #ifndef MEDIA_BASE_PIPELINE_IMPL_H_ |
| 8 #define MEDIA_BASE_PIPELINE_IMPL_H_ | 8 #define MEDIA_BASE_PIPELINE_IMPL_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 // must not be an error. | 66 // must not be an error. |
| 67 bool IsPipelineOk() const; | 67 bool IsPipelineOk() const; |
| 68 | 68 |
| 69 // Methods called by FilterHostImpl to update pipeline state. | 69 // Methods called by FilterHostImpl to update pipeline state. |
| 70 void SetDuration(base::TimeDelta duration); | 70 void SetDuration(base::TimeDelta duration); |
| 71 void SetBufferedTime(base::TimeDelta buffered_time); | 71 void SetBufferedTime(base::TimeDelta buffered_time); |
| 72 void SetTotalBytes(int64 total_bytes); | 72 void SetTotalBytes(int64 total_bytes); |
| 73 void SetBufferedBytes(int64 buffered_bytes); | 73 void SetBufferedBytes(int64 buffered_bytes); |
| 74 void SetVideoSize(size_t width, size_t height); | 74 void SetVideoSize(size_t width, size_t height); |
| 75 void SetTime(base::TimeDelta time); | 75 void SetTime(base::TimeDelta time); |
| 76 void InternalSetPlaybackRate(float rate); | |
| 77 | 76 |
| 78 // Sets the error to the new error code only if the current error state is | 77 // Sets the error to the new error code only if the current error state is |
| 79 // PIPELINE_OK. Returns true if error set, otherwise leaves current error | 78 // PIPELINE_OK. Returns true if error set, otherwise leaves current error |
| 80 // alone, and returns false. | 79 // alone, and returns false. |
| 81 bool InternalSetError(PipelineError error); | 80 bool InternalSetError(PipelineError error); |
| 82 | 81 |
| 83 // Method called by the |pipeline_internal_| to insert a mime type into | 82 // Method called by the |pipeline_internal_| to insert a mime type into |
| 84 // the |rendered_mime_types_| set. | 83 // the |rendered_mime_types_| set. |
| 85 void InsertRenderedMimeType(const std::string& major_mime_type); | 84 void InsertRenderedMimeType(const std::string& major_mime_type); |
| 86 | 85 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 114 | 113 |
| 115 // Lock used to serialize access for getter/setter methods. | 114 // Lock used to serialize access for getter/setter methods. |
| 116 mutable Lock lock_; | 115 mutable Lock lock_; |
| 117 | 116 |
| 118 // Video width and height. Set by a FilterHostImpl object on behalf | 117 // Video width and height. Set by a FilterHostImpl object on behalf |
| 119 // of a filter. The video_size_access_lock_ is used to make sure access | 118 // of a filter. The video_size_access_lock_ is used to make sure access |
| 120 // to the pair of width and height are modified or read in thread safe way. | 119 // to the pair of width and height are modified or read in thread safe way. |
| 121 size_t video_width_; | 120 size_t video_width_; |
| 122 size_t video_height_; | 121 size_t video_height_; |
| 123 | 122 |
| 124 // Current volume level (from 0.0f to 1.0f). The volume reflects the last | 123 // Current volume level (from 0.0f to 1.0f). This value is set immediately |
| 125 // value the audio filter was called with SetVolume, so there will be a short | 124 // via SetVolume() and a task is dispatched on the message loop to notify the |
| 126 // period of time between the client calling SetVolume on the pipeline and | 125 // filters. |
| 127 // this value being updated. Set by the PipelineInternal just prior to | |
| 128 // calling the audio renderer. | |
| 129 float volume_; | 126 float volume_; |
| 130 | 127 |
| 131 // Current playback rate (>= 0.0f). This member reflects the last value | 128 // Current playback rate (>= 0.0f). This value is set immediately via |
| 132 // that the filters in the pipeline were called with, so there will be a short | 129 // SetPlaybackRate() and a task is dispatched on the message loop to notify |
| 133 // period of time between the client calling SetPlaybackRate and this value | 130 // the filters. |
| 134 // being updated. Set by the PipelineInternal just prior to calling filters. | |
| 135 float playback_rate_; | 131 float playback_rate_; |
| 136 | 132 |
| 137 // Current playback time. Set by a FilterHostImpl object on behalf of the | 133 // Current playback time. Set by a FilterHostImpl object on behalf of the |
| 138 // audio renderer filter. | 134 // audio renderer filter. |
| 139 base::TimeDelta time_; | 135 base::TimeDelta time_; |
| 140 | 136 |
| 141 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that | 137 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that |
| 142 // the pipeline is operating correctly. Any other value indicates that the | 138 // the pipeline is operating correctly. Any other value indicates that the |
| 143 // pipeline is stopped or is stopping. Clients can call the Stop method to | 139 // pipeline is stopped or is stopping. Clients can call the Stop method to |
| 144 // reset the pipeline state, and restore this to PIPELINE_OK. | 140 // reset the pipeline state, and restore this to PIPELINE_OK. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 explicit PipelineInternal(PipelineImpl* pipeline, MessageLoop* message_loop); | 176 explicit PipelineInternal(PipelineImpl* pipeline, MessageLoop* message_loop); |
| 181 | 177 |
| 182 // After Start() is called, a task of StartTask() is posted on the pipeline | 178 // After Start() is called, a task of StartTask() is posted on the pipeline |
| 183 // thread to perform initialization. See StartTask() to learn more about | 179 // thread to perform initialization. See StartTask() to learn more about |
| 184 // initialization. | 180 // initialization. |
| 185 void Start(FilterFactory* filter_factory, | 181 void Start(FilterFactory* filter_factory, |
| 186 const std::string& url_media_source, | 182 const std::string& url_media_source, |
| 187 PipelineCallback* start_callback); | 183 PipelineCallback* start_callback); |
| 188 void Stop(PipelineCallback* stop_callback); | 184 void Stop(PipelineCallback* stop_callback); |
| 189 void Seek(base::TimeDelta time, PipelineCallback* seek_callback); | 185 void Seek(base::TimeDelta time, PipelineCallback* seek_callback); |
| 190 void SetPlaybackRate(float rate); | 186 |
| 191 void SetVolume(float volume); | 187 // Notifications that the client has changed the playback rate/volume. |
|
Alpha Left Google
2009/07/11 02:05:36
Notifies?
scherkus (not reviewing)
2009/07/11 02:39:58
Done.
| |
| 188 void PlaybackRateChanged(float playback_rate); | |
| 189 void VolumeChanged(float volume); | |
| 192 | 190 |
| 193 // Methods called by a FilterHostImpl object. These methods may be called | 191 // Methods called by a FilterHostImpl object. These methods may be called |
| 194 // on any thread, either the pipeline's thread or any other. | 192 // on any thread, either the pipeline's thread or any other. |
| 195 | 193 |
| 196 // When a filter calls it's FilterHost, the filter host calls back to the | 194 // When a filter calls it's FilterHost, the filter host calls back to the |
| 197 // pipeline thread. If the pipeline thread is running a nested message loop | 195 // pipeline thread. If the pipeline thread is running a nested message loop |
| 198 // then it will be exited. | 196 // then it will be exited. |
| 199 void InitializationComplete(FilterHostImpl* host); | 197 void InitializationComplete(FilterHostImpl* host); |
| 200 | 198 |
| 201 // Sets the pipeline time and schedules a task to call back to any filters | 199 // Sets the pipeline time and schedules a task to call back to any filters |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 // StopTask() and ErrorTask() are similar but serve different purposes: | 261 // StopTask() and ErrorTask() are similar but serve different purposes: |
| 264 // - Both destroy the filter chain. | 262 // - Both destroy the filter chain. |
| 265 // - Both will execute |start_callback| if the pipeline was initializing. | 263 // - Both will execute |start_callback| if the pipeline was initializing. |
| 266 // - StopTask() resets the pipeline to a fresh state, where as ErrorTask() | 264 // - StopTask() resets the pipeline to a fresh state, where as ErrorTask() |
| 267 // leaves the pipeline as is for client inspection. | 265 // leaves the pipeline as is for client inspection. |
| 268 // - StopTask() can be scheduled by the client calling Stop(), where as | 266 // - StopTask() can be scheduled by the client calling Stop(), where as |
| 269 // ErrorTask() is scheduled as a result of a filter calling Error(). | 267 // ErrorTask() is scheduled as a result of a filter calling Error(). |
| 270 void StopTask(PipelineCallback* stop_callback); | 268 void StopTask(PipelineCallback* stop_callback); |
| 271 void ErrorTask(PipelineError error); | 269 void ErrorTask(PipelineError error); |
| 272 | 270 |
| 273 void SetPlaybackRateTask(float rate); | 271 // Carries out notifying filters that the playback rate/volume has changed, |
| 272 void PlaybackRateChangedTask(float playback_rate); | |
| 273 void VolumeChangedTask(float volume); | |
| 274 | |
| 275 // Carries out notifying filters that we are seeking to a new timestamp. | |
| 274 void SeekTask(base::TimeDelta time, PipelineCallback* seek_callback); | 276 void SeekTask(base::TimeDelta time, PipelineCallback* seek_callback); |
| 275 void SetVolumeTask(float volume); | |
| 276 | 277 |
| 277 // Internal methods used in the implementation of the pipeline thread. All | 278 // Internal methods used in the implementation of the pipeline thread. All |
| 278 // of these methods are only called on the pipeline thread. | 279 // of these methods are only called on the pipeline thread. |
| 279 | 280 |
| 280 // The following template functions make use of the fact that media filter | 281 // The following template functions make use of the fact that media filter |
| 281 // derived interfaces are self-describing in the sense that they all contain | 282 // derived interfaces are self-describing in the sense that they all contain |
| 282 // the static method filter_type() which returns a FilterType enum that | 283 // the static method filter_type() which returns a FilterType enum that |
| 283 // uniquely identifies the filter's interface. In addition, filters that are | 284 // uniquely identifies the filter's interface. In addition, filters that are |
| 284 // specific to audio or video also support a static method major_mime_type() | 285 // specific to audio or video also support a static method major_mime_type() |
| 285 // which returns a string of "audio/" or "video/". | 286 // which returns a string of "audio/" or "video/". |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 | 374 |
| 374 typedef std::vector<base::Thread*> FilterThreadVector; | 375 typedef std::vector<base::Thread*> FilterThreadVector; |
| 375 FilterThreadVector filter_threads_; | 376 FilterThreadVector filter_threads_; |
| 376 | 377 |
| 377 DISALLOW_COPY_AND_ASSIGN(PipelineInternal); | 378 DISALLOW_COPY_AND_ASSIGN(PipelineInternal); |
| 378 }; | 379 }; |
| 379 | 380 |
| 380 } // namespace media | 381 } // namespace media |
| 381 | 382 |
| 382 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ | 383 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ |
| OLD | NEW |