| 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 <set> | 10 #include <set> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 explicit PipelineImpl(MessageLoop* message_loop); | 65 explicit PipelineImpl(MessageLoop* message_loop); |
| 66 | 66 |
| 67 // Pipeline implementation. | 67 // Pipeline implementation. |
| 68 virtual bool Start(FilterFactory* filter_factory, | 68 virtual bool Start(FilterFactory* filter_factory, |
| 69 const std::string& uri, | 69 const std::string& uri, |
| 70 PipelineCallback* start_callback); | 70 PipelineCallback* start_callback); |
| 71 virtual void Stop(PipelineCallback* stop_callback); | 71 virtual void Stop(PipelineCallback* stop_callback); |
| 72 virtual void Seek(base::TimeDelta time, PipelineCallback* seek_callback); | 72 virtual void Seek(base::TimeDelta time, PipelineCallback* seek_callback); |
| 73 virtual bool IsRunning() const; | 73 virtual bool IsRunning() const; |
| 74 virtual bool IsInitialized() const; | 74 virtual bool IsInitialized() const; |
| 75 virtual bool IsNetworkActive() const; |
| 75 virtual bool IsRendered(const std::string& major_mime_type) const; | 76 virtual bool IsRendered(const std::string& major_mime_type) const; |
| 76 virtual float GetPlaybackRate() const; | 77 virtual float GetPlaybackRate() const; |
| 77 virtual void SetPlaybackRate(float playback_rate); | 78 virtual void SetPlaybackRate(float playback_rate); |
| 78 virtual float GetVolume() const; | 79 virtual float GetVolume() const; |
| 79 virtual void SetVolume(float volume); | 80 virtual void SetVolume(float volume); |
| 80 virtual base::TimeDelta GetCurrentTime() const; | 81 virtual base::TimeDelta GetCurrentTime() const; |
| 81 virtual base::TimeDelta GetBufferedTime() const; | 82 virtual base::TimeDelta GetBufferedTime() const; |
| 82 virtual base::TimeDelta GetDuration() const; | 83 virtual base::TimeDelta GetDuration() const; |
| 83 virtual int64 GetBufferedBytes() const; | 84 virtual int64 GetBufferedBytes() const; |
| 84 virtual int64 GetTotalBytes() const; | 85 virtual int64 GetTotalBytes() const; |
| 85 virtual void GetVideoSize(size_t* width_out, size_t* height_out) const; | 86 virtual void GetVideoSize(size_t* width_out, size_t* height_out) const; |
| 86 virtual bool IsStreaming() const; | 87 virtual bool IsStreaming() const; |
| 87 virtual bool IsLoaded() const; | 88 virtual bool IsLoaded() const; |
| 88 virtual PipelineError GetError() const; | 89 virtual PipelineError GetError() const; |
| 89 | 90 |
| 90 // Sets a permanent callback owned by the pipeline that will be executed when | 91 // Sets a permanent callback owned by the pipeline that will be executed when |
| 91 // the media reaches the end. | 92 // the media reaches the end. |
| 92 virtual void SetPipelineEndedCallback(PipelineCallback* ended_callback); | 93 virtual void SetPipelineEndedCallback(PipelineCallback* ended_callback); |
| 93 | 94 |
| 94 // |error_callback_| will be executed upon an error in the pipeline. If | 95 // |error_callback_| will be executed upon an error in the pipeline. If |
| 95 // |error_callback_| is NULL, it is ignored. The pipeline takes ownership | 96 // |error_callback_| is NULL, it is ignored. The pipeline takes ownership |
| 96 // of |error_callback|. | 97 // of |error_callback|. |
| 97 virtual void SetPipelineErrorCallback(PipelineCallback* error_callback); | 98 virtual void SetPipelineErrorCallback(PipelineCallback* error_callback); |
| 98 | 99 |
| 100 // |network_callback_| will be executed when there's a network event. |
| 101 virtual void SetNetworkEventCallback(PipelineCallback* network_callback); |
| 102 |
| 99 private: | 103 private: |
| 100 // Pipeline states, as described above. | 104 // Pipeline states, as described above. |
| 101 enum State { | 105 enum State { |
| 102 kCreated, | 106 kCreated, |
| 103 kInitDataSource, | 107 kInitDataSource, |
| 104 kInitDemuxer, | 108 kInitDemuxer, |
| 105 kInitAudioDecoder, | 109 kInitAudioDecoder, |
| 106 kInitAudioRenderer, | 110 kInitAudioRenderer, |
| 107 kInitVideoDecoder, | 111 kInitVideoDecoder, |
| 108 kInitVideoRenderer, | 112 kInitVideoRenderer, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 138 virtual void SetError(PipelineError error); | 142 virtual void SetError(PipelineError error); |
| 139 virtual base::TimeDelta GetTime() const; | 143 virtual base::TimeDelta GetTime() const; |
| 140 virtual void SetTime(base::TimeDelta time); | 144 virtual void SetTime(base::TimeDelta time); |
| 141 virtual void SetDuration(base::TimeDelta duration); | 145 virtual void SetDuration(base::TimeDelta duration); |
| 142 virtual void SetBufferedTime(base::TimeDelta buffered_time); | 146 virtual void SetBufferedTime(base::TimeDelta buffered_time); |
| 143 virtual void SetTotalBytes(int64 total_bytes); | 147 virtual void SetTotalBytes(int64 total_bytes); |
| 144 virtual void SetBufferedBytes(int64 buffered_bytes); | 148 virtual void SetBufferedBytes(int64 buffered_bytes); |
| 145 virtual void SetVideoSize(size_t width, size_t height); | 149 virtual void SetVideoSize(size_t width, size_t height); |
| 146 virtual void SetStreaming(bool streamed); | 150 virtual void SetStreaming(bool streamed); |
| 147 virtual void SetLoaded(bool loaded); | 151 virtual void SetLoaded(bool loaded); |
| 152 virtual void SetNetworkActivity(bool network_activity); |
| 148 virtual void NotifyEnded(); | 153 virtual void NotifyEnded(); |
| 149 virtual void BroadcastMessage(FilterMessage message); | 154 virtual void BroadcastMessage(FilterMessage message); |
| 150 | 155 |
| 151 // Method called during initialization to insert a mime type into the | 156 // Method called during initialization to insert a mime type into the |
| 152 // |rendered_mime_types_| set. | 157 // |rendered_mime_types_| set. |
| 153 void InsertRenderedMimeType(const std::string& major_mime_type); | 158 void InsertRenderedMimeType(const std::string& major_mime_type); |
| 154 | 159 |
| 155 // Method called during initialization to determine if we rendered anything. | 160 // Method called during initialization to determine if we rendered anything. |
| 156 bool HasRenderedMimeTypes() const; | 161 bool HasRenderedMimeTypes() const; |
| 157 | 162 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 187 | 192 |
| 188 // Carries out notifying filters that the volume has changed. | 193 // Carries out notifying filters that the volume has changed. |
| 189 void VolumeChangedTask(float volume); | 194 void VolumeChangedTask(float volume); |
| 190 | 195 |
| 191 // Carries out notifying filters that we are seeking to a new timestamp. | 196 // Carries out notifying filters that we are seeking to a new timestamp. |
| 192 void SeekTask(base::TimeDelta time, PipelineCallback* seek_callback); | 197 void SeekTask(base::TimeDelta time, PipelineCallback* seek_callback); |
| 193 | 198 |
| 194 // Carries out handling a notification from a filter that it has ended. | 199 // Carries out handling a notification from a filter that it has ended. |
| 195 void NotifyEndedTask(); | 200 void NotifyEndedTask(); |
| 196 | 201 |
| 202 // Carries out handling a notification of network event. |
| 203 void NotifyNetworkEventTask(); |
| 204 |
| 197 // Carries out message broadcasting on the message loop. | 205 // Carries out message broadcasting on the message loop. |
| 198 void BroadcastMessageTask(FilterMessage message); | 206 void BroadcastMessageTask(FilterMessage message); |
| 199 | 207 |
| 200 // Carries out advancing to the next filter during Play()/Pause()/Seek(). | 208 // Carries out advancing to the next filter during Play()/Pause()/Seek(). |
| 201 void FilterStateTransitionTask(); | 209 void FilterStateTransitionTask(); |
| 202 | 210 |
| 203 // Internal methods used in the implementation of the pipeline thread. All | 211 // Internal methods used in the implementation of the pipeline thread. All |
| 204 // of these methods are only called on the pipeline thread. | 212 // of these methods are only called on the pipeline thread. |
| 205 | 213 |
| 206 // The following template functions make use of the fact that media filter | 214 // The following template functions make use of the fact that media filter |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 size_t video_height_; | 300 size_t video_height_; |
| 293 | 301 |
| 294 // Sets by the filters to indicate whether the data source is a streaming | 302 // Sets by the filters to indicate whether the data source is a streaming |
| 295 // source. | 303 // source. |
| 296 bool streaming_; | 304 bool streaming_; |
| 297 | 305 |
| 298 // Sets by the filters to indicate whether the data source is a fully | 306 // Sets by the filters to indicate whether the data source is a fully |
| 299 // loaded source. | 307 // loaded source. |
| 300 bool loaded_; | 308 bool loaded_; |
| 301 | 309 |
| 310 // Sets by the filters to indicate whether network is active. |
| 311 bool network_activity_; |
| 312 |
| 302 // Current volume level (from 0.0f to 1.0f). This value is set immediately | 313 // Current volume level (from 0.0f to 1.0f). This value is set immediately |
| 303 // via SetVolume() and a task is dispatched on the message loop to notify the | 314 // via SetVolume() and a task is dispatched on the message loop to notify the |
| 304 // filters. | 315 // filters. |
| 305 float volume_; | 316 float volume_; |
| 306 | 317 |
| 307 // Current playback rate (>= 0.0f). This value is set immediately via | 318 // Current playback rate (>= 0.0f). This value is set immediately via |
| 308 // SetPlaybackRate() and a task is dispatched on the message loop to notify | 319 // SetPlaybackRate() and a task is dispatched on the message loop to notify |
| 309 // the filters. | 320 // the filters. |
| 310 float playback_rate_; | 321 float playback_rate_; |
| 311 | 322 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 scoped_refptr<FilterFactory> filter_factory_; | 360 scoped_refptr<FilterFactory> filter_factory_; |
| 350 | 361 |
| 351 // URL for the data source as passed in by Start(). | 362 // URL for the data source as passed in by Start(). |
| 352 std::string url_; | 363 std::string url_; |
| 353 | 364 |
| 354 // Callbacks for various pipeline operations. | 365 // Callbacks for various pipeline operations. |
| 355 scoped_ptr<PipelineCallback> seek_callback_; | 366 scoped_ptr<PipelineCallback> seek_callback_; |
| 356 scoped_ptr<PipelineCallback> stop_callback_; | 367 scoped_ptr<PipelineCallback> stop_callback_; |
| 357 scoped_ptr<PipelineCallback> ended_callback_; | 368 scoped_ptr<PipelineCallback> ended_callback_; |
| 358 scoped_ptr<PipelineCallback> error_callback_; | 369 scoped_ptr<PipelineCallback> error_callback_; |
| 370 scoped_ptr<PipelineCallback> network_callback_; |
| 359 | 371 |
| 360 // Vector of our filters and map maintaining the relationship between the | 372 // Vector of our filters and map maintaining the relationship between the |
| 361 // FilterType and the filter itself. | 373 // FilterType and the filter itself. |
| 362 typedef std::vector<scoped_refptr<MediaFilter> > FilterVector; | 374 typedef std::vector<scoped_refptr<MediaFilter> > FilterVector; |
| 363 FilterVector filters_; | 375 FilterVector filters_; |
| 364 | 376 |
| 365 typedef std::map<FilterType, scoped_refptr<MediaFilter> > FilterTypeMap; | 377 typedef std::map<FilterType, scoped_refptr<MediaFilter> > FilterTypeMap; |
| 366 FilterTypeMap filter_types_; | 378 FilterTypeMap filter_types_; |
| 367 | 379 |
| 368 // Vector of threads owned by the pipeline and being used by filters. | 380 // Vector of threads owned by the pipeline and being used by filters. |
| 369 typedef std::vector<base::Thread*> FilterThreadVector; | 381 typedef std::vector<base::Thread*> FilterThreadVector; |
| 370 FilterThreadVector filter_threads_; | 382 FilterThreadVector filter_threads_; |
| 371 | 383 |
| 372 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); | 384 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); |
| 373 }; | 385 }; |
| 374 | 386 |
| 375 } // namespace media | 387 } // namespace media |
| 376 | 388 |
| 377 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ | 389 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ |
| OLD | NEW |