| OLD | NEW |
| 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 // The pipeline is the public API clients use for playing back media. Clients | 5 // The pipeline is the public API clients use for playing back media. Clients |
| 6 // provide a filter collection containing the filters they want the pipeline to | 6 // provide a filter collection containing the filters they want the pipeline to |
| 7 // use to render media. | 7 // use to render media. |
| 8 | 8 |
| 9 #ifndef MEDIA_BASE_PIPELINE_H_ | 9 #ifndef MEDIA_BASE_PIPELINE_H_ |
| 10 #define MEDIA_BASE_PIPELINE_H_ | 10 #define MEDIA_BASE_PIPELINE_H_ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 uint32 audio_bytes_decoded; // Should be uint64? | 31 uint32 audio_bytes_decoded; // Should be uint64? |
| 32 uint32 video_bytes_decoded; // Should be uint64? | 32 uint32 video_bytes_decoded; // Should be uint64? |
| 33 uint32 video_frames_decoded; | 33 uint32 video_frames_decoded; |
| 34 uint32 video_frames_dropped; | 34 uint32 video_frames_dropped; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 class FilterCollection; | 37 class FilterCollection; |
| 38 | 38 |
| 39 // Client-provided callbacks for various pipeline operations. Clients should | |
| 40 // inspect the Pipeline for errors. | |
| 41 typedef Callback0::Type PipelineCallback; | |
| 42 | |
| 43 class Pipeline : public base::RefCountedThreadSafe<Pipeline> { | 39 class Pipeline : public base::RefCountedThreadSafe<Pipeline> { |
| 44 public: | 40 public: |
| 45 // Initializes pipeline. Pipeline takes ownership of all callbacks passed | 41 // Initializes pipeline. Pipeline takes ownership of all callbacks passed |
| 46 // into this method. | 42 // into this method. |
| 47 // |ended_callback| will be executed when the media reaches the end. | 43 // |ended_callback| will be executed when the media reaches the end. |
| 48 // |error_callback_| will be executed upon an error in the pipeline. | 44 // |error_callback_| will be executed upon an error in the pipeline. |
| 49 // |network_callback_| will be executed when there's a network event. | 45 // |network_callback_| will be executed when there's a network event. |
| 50 virtual void Init(PipelineCallback* ended_callback, | 46 virtual void Init(PipelineStatusCallback* ended_callback, |
| 51 PipelineCallback* error_callback, | 47 PipelineStatusCallback* error_callback, |
| 52 PipelineCallback* network_callback) = 0; | 48 PipelineStatusCallback* network_callback) = 0; |
| 53 | 49 |
| 54 // Build a pipeline to render the given URL using the given filter collection | 50 // Build a pipeline to render the given URL using the given filter collection |
| 55 // to construct a filter chain. Returns true if successful, false otherwise | 51 // to construct a filter chain. Returns true if successful, false otherwise |
| 56 // (i.e., pipeline already started). Note that a return value of true | 52 // (i.e., pipeline already started). Note that a return value of true |
| 57 // only indicates that the initialization process has started successfully. | 53 // only indicates that the initialization process has started successfully. |
| 58 // Pipeline initialization is an inherently asynchronous process. Clients can | 54 // Pipeline initialization is an inherently asynchronous process. Clients can |
| 59 // either poll the IsInitialized() method (discouraged) or use the | 55 // either poll the IsInitialized() method (discouraged) or use the |
| 60 // |start_callback| as described below. | 56 // |start_callback| as described below. |
| 61 // | 57 // |
| 62 // This method is asynchronous and can execute a callback when completed. | 58 // This method is asynchronous and can execute a callback when completed. |
| 63 // If the caller provides a |start_callback|, it will be called when the | 59 // If the caller provides a |start_callback|, it will be called when the |
| 64 // pipeline initialization completes. Clients are expected to call GetError() | 60 // pipeline initialization completes. |
| 65 // to check whether initialization succeeded. | |
| 66 virtual bool Start(FilterCollection* filter_collection, | 61 virtual bool Start(FilterCollection* filter_collection, |
| 67 const std::string& url, | 62 const std::string& url, |
| 68 PipelineCallback* start_callback) = 0; | 63 PipelineStatusCallback* start_callback) = 0; |
| 69 | 64 |
| 70 // Asynchronously stops the pipeline and resets it to an uninitialized state. | 65 // Asynchronously stops the pipeline and resets it to an uninitialized state. |
| 71 // If provided, |stop_callback| will be executed when the pipeline has been | 66 // If provided, |stop_callback| will be executed when the pipeline has been |
| 72 // completely torn down and reset to an uninitialized state. It is acceptable | 67 // completely torn down and reset to an uninitialized state. It is acceptable |
| 73 // to call Start() again once the callback has finished executing. | 68 // to call Start() again once the callback has finished executing. |
| 74 // | 69 // |
| 75 // Stop() must be called before destroying the pipeline. Clients can | 70 // Stop() must be called before destroying the pipeline. Clients can |
| 76 // determine whether Stop() must be called by checking IsRunning(). | 71 // determine whether Stop() must be called by checking IsRunning(). |
| 77 // | 72 // |
| 78 // TODO(scherkus): ideally clients would destroy the pipeline after calling | 73 // TODO(scherkus): ideally clients would destroy the pipeline after calling |
| 79 // Stop() and create a new pipeline as needed. | 74 // Stop() and create a new pipeline as needed. |
| 80 virtual void Stop(PipelineCallback* stop_callback) = 0; | 75 virtual void Stop(PipelineStatusCallback* stop_callback) = 0; |
| 81 | 76 |
| 82 // Attempt to seek to the position specified by time. |seek_callback| will be | 77 // Attempt to seek to the position specified by time. |seek_callback| will be |
| 83 // executed when the all filters in the pipeline have processed the seek. | 78 // executed when the all filters in the pipeline have processed the seek. |
| 84 // | 79 // |
| 85 // Clients are expected to call GetCurrentTime() to check whether the seek | 80 // Clients are expected to call GetCurrentTime() to check whether the seek |
| 86 // succeeded. | 81 // succeeded. |
| 87 virtual void Seek(base::TimeDelta time, PipelineCallback* seek_callback) = 0; | 82 virtual void Seek(base::TimeDelta time, |
| 83 PipelineStatusCallback* seek_callback) = 0; |
| 88 | 84 |
| 89 // Returns true if the pipeline has been started via Start(). If IsRunning() | 85 // Returns true if the pipeline has been started via Start(). If IsRunning() |
| 90 // returns true, it is expected that Stop() will be called before destroying | 86 // returns true, it is expected that Stop() will be called before destroying |
| 91 // the pipeline. | 87 // the pipeline. |
| 92 virtual bool IsRunning() const = 0; | 88 virtual bool IsRunning() const = 0; |
| 93 | 89 |
| 94 // Returns true if the pipeline has been started and fully initialized to a | 90 // Returns true if the pipeline has been started and fully initialized to a |
| 95 // point where playback controls will be respected. Note that it is possible | 91 // point where playback controls will be respected. Note that it is possible |
| 96 // for a pipeline to be started but not initialized (i.e., an error occurred). | 92 // for a pipeline to be started but not initialized (i.e., an error occurred). |
| 97 virtual bool IsInitialized() const = 0; | 93 virtual bool IsInitialized() const = 0; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 virtual void GetVideoSize(size_t* width_out, size_t* height_out) const = 0; | 149 virtual void GetVideoSize(size_t* width_out, size_t* height_out) const = 0; |
| 154 | 150 |
| 155 // If this method returns true, that means the data source is a streaming | 151 // If this method returns true, that means the data source is a streaming |
| 156 // data source. Seeking may not be possible. | 152 // data source. Seeking may not be possible. |
| 157 virtual bool IsStreaming() const = 0; | 153 virtual bool IsStreaming() const = 0; |
| 158 | 154 |
| 159 // If this method returns true, that means the data source has fully loaded | 155 // If this method returns true, that means the data source has fully loaded |
| 160 // the media and that the network is no longer needed. | 156 // the media and that the network is no longer needed. |
| 161 virtual bool IsLoaded() const = 0; | 157 virtual bool IsLoaded() const = 0; |
| 162 | 158 |
| 163 // Gets the current error status for the pipeline. If the pipeline is | |
| 164 // operating correctly, this will return OK. | |
| 165 virtual PipelineError GetError() const = 0; | |
| 166 | |
| 167 // Gets the current pipeline statistics. | 159 // Gets the current pipeline statistics. |
| 168 virtual PipelineStatistics GetStatistics() const = 0; | 160 virtual PipelineStatistics GetStatistics() const = 0; |
| 169 | 161 |
| 170 protected: | 162 protected: |
| 171 // Only allow ourselves to be deleted by reference counting. | 163 // Only allow ourselves to be deleted by reference counting. |
| 172 friend class base::RefCountedThreadSafe<Pipeline>; | 164 friend class base::RefCountedThreadSafe<Pipeline>; |
| 173 virtual ~Pipeline() {} | 165 virtual ~Pipeline() {} |
| 174 }; | 166 }; |
| 175 | 167 |
| 176 } // namespace media | 168 } // namespace media |
| 177 | 169 |
| 178 #endif // MEDIA_BASE_PIPELINE_H_ | 170 #endif // MEDIA_BASE_PIPELINE_H_ |
| OLD | NEW |