| 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 23 matching lines...) Expand all Loading... |
| 34 // [ InitXXX (for each filter) ] | 34 // [ InitXXX (for each filter) ] |
| 35 // | | 35 // | |
| 36 // V | 36 // V |
| 37 // [ Seeking (for each filter) ] <----------------------. | 37 // [ Seeking (for each filter) ] <----------------------. |
| 38 // | | | 38 // | | |
| 39 // V | | 39 // V | |
| 40 // [ Starting (for each filter) ] | | 40 // [ Starting (for each filter) ] | |
| 41 // | | | 41 // | | |
| 42 // V Seek() | | 42 // V Seek() | |
| 43 // [ Started ] --------> [ Pausing (for each filter) ] -' | 43 // [ Started ] --------> [ Pausing (for each filter) ] -' |
| 44 // | 44 // | | |
| 45 // | NotifyEnded() Seek() | |
| 46 // `-------------> [ Ended ] ---------------------' |
| 45 // | 47 // |
| 46 // SetError() | 48 // SetError() |
| 47 // [ Any State ] -------------> [ Error ] | 49 // [ Any State ] -------------> [ Error ] |
| 48 // | Stop() | 50 // | Stop() |
| 49 // '--------------------> [ Stopped ] | 51 // '--------------------> [ Stopped ] |
| 50 // | 52 // |
| 51 // Initialization is a series of state transitions from "Created" through each | 53 // Initialization is a series of state transitions from "Created" through each |
| 52 // filter initialization state. When all filter initialization states have | 54 // filter initialization state. When all filter initialization states have |
| 53 // completed, we are implicitly in a "Paused" state. At that point we simulate | 55 // completed, we are implicitly in a "Paused" state. At that point we simulate |
| 54 // a Seek() to the beginning of the media to give filters a chance to preroll. | 56 // a Seek() to the beginning of the media to give filters a chance to preroll. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 77 virtual void SetVolume(float volume); | 79 virtual void SetVolume(float volume); |
| 78 virtual base::TimeDelta GetCurrentTime() const; | 80 virtual base::TimeDelta GetCurrentTime() const; |
| 79 virtual base::TimeDelta GetBufferedTime() const; | 81 virtual base::TimeDelta GetBufferedTime() const; |
| 80 virtual base::TimeDelta GetDuration() const; | 82 virtual base::TimeDelta GetDuration() const; |
| 81 virtual int64 GetBufferedBytes() const; | 83 virtual int64 GetBufferedBytes() const; |
| 82 virtual int64 GetTotalBytes() const; | 84 virtual int64 GetTotalBytes() const; |
| 83 virtual void GetVideoSize(size_t* width_out, size_t* height_out) const; | 85 virtual void GetVideoSize(size_t* width_out, size_t* height_out) const; |
| 84 virtual bool IsStreaming() const; | 86 virtual bool IsStreaming() const; |
| 85 virtual PipelineError GetError() const; | 87 virtual PipelineError GetError() const; |
| 86 | 88 |
| 89 // Sets a permanent callback owned by the pipeline that will be executed when |
| 90 // the media reaches the end. |
| 91 virtual void SetPipelineEndedCallback(PipelineCallback* ended_callback); |
| 92 |
| 87 // |error_callback_| will be executed upon an error in the pipeline. If | 93 // |error_callback_| will be executed upon an error in the pipeline. If |
| 88 // |error_callback_| is NULL, it is ignored. The pipeline takes ownernship | 94 // |error_callback_| is NULL, it is ignored. The pipeline takes ownership |
| 89 // of |error_callback|. | 95 // of |error_callback|. |
| 90 virtual void SetPipelineErrorCallback(PipelineCallback* error_callback); | 96 virtual void SetPipelineErrorCallback(PipelineCallback* error_callback); |
| 91 | 97 |
| 92 private: | 98 private: |
| 93 // Pipeline states, as described above. | 99 // Pipeline states, as described above. |
| 94 enum State { | 100 enum State { |
| 95 kCreated, | 101 kCreated, |
| 96 kInitDataSource, | 102 kInitDataSource, |
| 97 kInitDemuxer, | 103 kInitDemuxer, |
| 98 kInitAudioDecoder, | 104 kInitAudioDecoder, |
| 99 kInitAudioRenderer, | 105 kInitAudioRenderer, |
| 100 kInitVideoDecoder, | 106 kInitVideoDecoder, |
| 101 kInitVideoRenderer, | 107 kInitVideoRenderer, |
| 102 kPausing, | 108 kPausing, |
| 103 kSeeking, | 109 kSeeking, |
| 104 kStarting, | 110 kStarting, |
| 105 kStarted, | 111 kStarted, |
| 112 kEnded, |
| 106 kStopped, | 113 kStopped, |
| 107 kError, | 114 kError, |
| 108 }; | 115 }; |
| 109 | 116 |
| 110 virtual ~PipelineImpl(); | 117 virtual ~PipelineImpl(); |
| 111 | 118 |
| 112 // Reset the state of the pipeline object to the initial state. This method | 119 // Reset the state of the pipeline object to the initial state. This method |
| 113 // is used by the constructor, and the Stop() method. | 120 // is used by the constructor, and the Stop() method. |
| 114 void ResetState(); | 121 void ResetState(); |
| 115 | 122 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 129 // FilterHost implementation. | 136 // FilterHost implementation. |
| 130 virtual void SetError(PipelineError error); | 137 virtual void SetError(PipelineError error); |
| 131 virtual base::TimeDelta GetTime() const; | 138 virtual base::TimeDelta GetTime() const; |
| 132 virtual void SetTime(base::TimeDelta time); | 139 virtual void SetTime(base::TimeDelta time); |
| 133 virtual void SetDuration(base::TimeDelta duration); | 140 virtual void SetDuration(base::TimeDelta duration); |
| 134 virtual void SetBufferedTime(base::TimeDelta buffered_time); | 141 virtual void SetBufferedTime(base::TimeDelta buffered_time); |
| 135 virtual void SetTotalBytes(int64 total_bytes); | 142 virtual void SetTotalBytes(int64 total_bytes); |
| 136 virtual void SetBufferedBytes(int64 buffered_bytes); | 143 virtual void SetBufferedBytes(int64 buffered_bytes); |
| 137 virtual void SetVideoSize(size_t width, size_t height); | 144 virtual void SetVideoSize(size_t width, size_t height); |
| 138 virtual void SetStreaming(bool streamed); | 145 virtual void SetStreaming(bool streamed); |
| 146 virtual void NotifyEnded(); |
| 139 virtual void BroadcastMessage(FilterMessage message); | 147 virtual void BroadcastMessage(FilterMessage message); |
| 140 | 148 |
| 141 // Method called during initialization to insert a mime type into the | 149 // Method called during initialization to insert a mime type into the |
| 142 // |rendered_mime_types_| set. | 150 // |rendered_mime_types_| set. |
| 143 void InsertRenderedMimeType(const std::string& major_mime_type); | 151 void InsertRenderedMimeType(const std::string& major_mime_type); |
| 144 | 152 |
| 145 // Method called during initialization to determine if we rendered anything. | 153 // Method called during initialization to determine if we rendered anything. |
| 146 bool HasRenderedMimeTypes() const; | 154 bool HasRenderedMimeTypes() const; |
| 147 | 155 |
| 148 // Callback executed by filters upon completing initialization. | 156 // Callback executed by filters upon completing initialization. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 174 | 182 |
| 175 // Carries out notifying filters that the playback rate has changed. | 183 // Carries out notifying filters that the playback rate has changed. |
| 176 void PlaybackRateChangedTask(float playback_rate); | 184 void PlaybackRateChangedTask(float playback_rate); |
| 177 | 185 |
| 178 // Carries out notifying filters that the volume has changed. | 186 // Carries out notifying filters that the volume has changed. |
| 179 void VolumeChangedTask(float volume); | 187 void VolumeChangedTask(float volume); |
| 180 | 188 |
| 181 // Carries out notifying filters that we are seeking to a new timestamp. | 189 // Carries out notifying filters that we are seeking to a new timestamp. |
| 182 void SeekTask(base::TimeDelta time, PipelineCallback* seek_callback); | 190 void SeekTask(base::TimeDelta time, PipelineCallback* seek_callback); |
| 183 | 191 |
| 192 // Carries out handling a notification from a filter that it has ended. |
| 193 void NotifyEndedTask(); |
| 194 |
| 184 // Carries out message broadcasting on the message loop. | 195 // Carries out message broadcasting on the message loop. |
| 185 void BroadcastMessageTask(FilterMessage message); | 196 void BroadcastMessageTask(FilterMessage message); |
| 186 | 197 |
| 187 // Carries out advancing to the next filter during Play()/Pause()/Seek(). | 198 // Carries out advancing to the next filter during Play()/Pause()/Seek(). |
| 188 void FilterStateTransitionTask(); | 199 void FilterStateTransitionTask(); |
| 189 | 200 |
| 190 // Internal methods used in the implementation of the pipeline thread. All | 201 // Internal methods used in the implementation of the pipeline thread. All |
| 191 // of these methods are only called on the pipeline thread. | 202 // of these methods are only called on the pipeline thread. |
| 192 | 203 |
| 193 // The following template functions make use of the fact that media filter | 204 // The following template functions make use of the fact that media filter |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 | 336 |
| 326 // Filter factory as passed in by Start(). | 337 // Filter factory as passed in by Start(). |
| 327 scoped_refptr<FilterFactory> filter_factory_; | 338 scoped_refptr<FilterFactory> filter_factory_; |
| 328 | 339 |
| 329 // URL for the data source as passed in by Start(). | 340 // URL for the data source as passed in by Start(). |
| 330 std::string url_; | 341 std::string url_; |
| 331 | 342 |
| 332 // Callbacks for various pipeline operations. | 343 // Callbacks for various pipeline operations. |
| 333 scoped_ptr<PipelineCallback> seek_callback_; | 344 scoped_ptr<PipelineCallback> seek_callback_; |
| 334 scoped_ptr<PipelineCallback> stop_callback_; | 345 scoped_ptr<PipelineCallback> stop_callback_; |
| 346 scoped_ptr<PipelineCallback> ended_callback_; |
| 335 scoped_ptr<PipelineCallback> error_callback_; | 347 scoped_ptr<PipelineCallback> error_callback_; |
| 336 | 348 |
| 337 // Vector of our filters and map maintaining the relationship between the | 349 // Vector of our filters and map maintaining the relationship between the |
| 338 // FilterType and the filter itself. | 350 // FilterType and the filter itself. |
| 339 typedef std::vector<scoped_refptr<MediaFilter> > FilterVector; | 351 typedef std::vector<scoped_refptr<MediaFilter> > FilterVector; |
| 340 FilterVector filters_; | 352 FilterVector filters_; |
| 341 | 353 |
| 342 typedef std::map<FilterType, scoped_refptr<MediaFilter> > FilterTypeMap; | 354 typedef std::map<FilterType, scoped_refptr<MediaFilter> > FilterTypeMap; |
| 343 FilterTypeMap filter_types_; | 355 FilterTypeMap filter_types_; |
| 344 | 356 |
| 345 // Vector of threads owned by the pipeline and being used by filters. | 357 // Vector of threads owned by the pipeline and being used by filters. |
| 346 typedef std::vector<base::Thread*> FilterThreadVector; | 358 typedef std::vector<base::Thread*> FilterThreadVector; |
| 347 FilterThreadVector filter_threads_; | 359 FilterThreadVector filter_threads_; |
| 348 | 360 |
| 349 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); | 361 DISALLOW_COPY_AND_ASSIGN(PipelineImpl); |
| 350 }; | 362 }; |
| 351 | 363 |
| 352 } // namespace media | 364 } // namespace media |
| 353 | 365 |
| 354 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ | 366 #endif // MEDIA_BASE_PIPELINE_IMPL_H_ |
| OLD | NEW |