| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 // 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 factory containing the filters they want the pipeline to | 6 // provide a filter factory 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_ |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/task.h" | 14 #include "base/task.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "media/base/factory.h" | 16 #include "media/base/factory.h" |
| 17 | 17 |
| 18 namespace media { | 18 namespace media { |
| 19 | 19 |
| 20 // Error definitions for pipeline. | 20 // Error definitions for pipeline. All codes indicate an error except: |
| 21 // PIPELINE_OK indicates the pipeline is running normally. |
| 22 // PIPELINE_STOPPING is used internally when Pipeline::Stop() is called. |
| 21 enum PipelineError { | 23 enum PipelineError { |
| 22 PIPELINE_OK, | 24 PIPELINE_OK, |
| 25 PIPELINE_STOPPING, |
| 26 PIPELINE_ERROR_URL_NOT_FOUND, |
| 23 PIPELINE_ERROR_NETWORK, | 27 PIPELINE_ERROR_NETWORK, |
| 24 PIPELINE_ERROR_DECODE, | 28 PIPELINE_ERROR_DECODE, |
| 25 PIPELINE_ERROR_ABORT, | 29 PIPELINE_ERROR_ABORT, |
| 26 PIPELINE_ERROR_INITIALIZATION_FAILED, | 30 PIPELINE_ERROR_INITIALIZATION_FAILED, |
| 27 PIPELINE_STOPPING | 31 PIPELINE_ERROR_REQUIRED_FILTER_MISSING, |
| 32 PIPELINE_ERROR_OUT_OF_MEMORY, |
| 33 PIPELINE_ERROR_COULD_NOT_RENDER, |
| 34 PIPELINE_ERROR_READ |
| 28 }; | 35 }; |
| 29 | 36 |
| 30 // Base class for Pipeline class which allows for read-only access to members. | 37 // Base class for Pipeline class which allows for read-only access to members. |
| 31 // Filters are allowed to access the PipelineStatus interface but are not given | 38 // Filters are allowed to access the PipelineStatus interface but are not given |
| 32 // access to the client Pipeline methods. | 39 // access to the client Pipeline methods. |
| 33 class PipelineStatus { | 40 class PipelineStatus { |
| 34 public: | 41 public: |
| 35 // Returns the current initialization state of the pipeline. Clients can | 42 // Returns the current initialization state of the pipeline. Clients can |
| 36 // examine this to determine if it is acceptable to call SetRate/SetVolume/ | 43 // examine this to determine if it is acceptable to call SetRate/SetVolume/ |
| 37 // Seek after calling Start on the pipeline. Note that this will be | 44 // Seek after calling Start on the pipeline. Note that this will be |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // progresses from 0 to the end of the media. Becuase this method provides | 90 // progresses from 0 to the end of the media. Becuase this method provides |
| 84 // an estimated time, it is possible that subsequent calls to this method will | 91 // an estimated time, it is possible that subsequent calls to this method will |
| 85 // actually progress backwards slightly, so callers must not assume that this | 92 // actually progress backwards slightly, so callers must not assume that this |
| 86 // method will always return times larger than the last one. | 93 // method will always return times larger than the last one. |
| 87 virtual base::TimeDelta GetInterpolatedTime() const = 0; | 94 virtual base::TimeDelta GetInterpolatedTime() const = 0; |
| 88 | 95 |
| 89 // Gets the current error status for the pipeline. If the pipeline is | 96 // Gets the current error status for the pipeline. If the pipeline is |
| 90 // operating correctly, this will return OK. | 97 // operating correctly, this will return OK. |
| 91 virtual PipelineError GetError() const = 0; | 98 virtual PipelineError GetError() const = 0; |
| 92 | 99 |
| 100 // If the |major_mime_type| exists in the pipeline and is being rendered, this |
| 101 // method will return true. Types are defined in media/base/media_foramt.h. |
| 102 // For example, to determine if a pipeline contains video: |
| 103 // bool has_video = pipeline->IsRendered(mime_type::kMajorTypeVideo); |
| 104 virtual bool IsRendered(const std::string& major_mime_type) const = 0; |
| 105 |
| 93 protected: | 106 protected: |
| 94 virtual ~PipelineStatus() {} | 107 virtual ~PipelineStatus() {} |
| 95 }; | 108 }; |
| 96 | 109 |
| 97 | 110 |
| 98 class Pipeline : public PipelineStatus { | 111 class Pipeline : public PipelineStatus { |
| 99 public: | 112 public: |
| 100 // Build a pipeline to render the given URI using the given filter factory to | 113 // Build a pipeline to render the given URI using the given filter factory to |
| 101 // construct a filter chain. Returns true if successful, false otherwise | 114 // construct a filter chain. Returns true if successful, false otherwise |
| 102 // (i.e., pipeline already started). Note that a return value of true | 115 // (i.e., pipeline already started). Note that a return value of true |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // This method must be called only after initialization has completed. | 166 // This method must be called only after initialization has completed. |
| 154 virtual void SetVolume(float volume) = 0; | 167 virtual void SetVolume(float volume) = 0; |
| 155 | 168 |
| 156 protected: | 169 protected: |
| 157 virtual ~Pipeline() {} | 170 virtual ~Pipeline() {} |
| 158 }; | 171 }; |
| 159 | 172 |
| 160 } // namespace media | 173 } // namespace media |
| 161 | 174 |
| 162 #endif // MEDIA_BASE_PIPELINE_H_ | 175 #endif // MEDIA_BASE_PIPELINE_H_ |
| OLD | NEW |