| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_ | 
| 11 | 11 | 
| 12 #include <string> | 12 #include <string> | 
| 13 | 13 | 
| 14 #include "base/callback.h" | 14 #include "base/callback.h" | 
| 15 #include "media/base/filters.h" |  | 
| 16 #include "media/base/media_filter_collection.h" |  | 
| 17 | 15 | 
| 18 namespace base { | 16 namespace base { | 
| 19 class TimeDelta; | 17 class TimeDelta; | 
| 20 } | 18 } | 
| 21 | 19 | 
| 22 namespace media { | 20 namespace media { | 
| 23 | 21 | 
| 24 // Error definitions for pipeline.  All codes indicate an error except: | 22 // Error definitions for pipeline.  All codes indicate an error except: | 
| 25 // PIPELINE_OK indicates the pipeline is running normally. | 23 // PIPELINE_OK indicates the pipeline is running normally. | 
| 26 enum PipelineError { | 24 enum PipelineError { | 
| 27   PIPELINE_OK, | 25   PIPELINE_OK, | 
| 28   PIPELINE_ERROR_URL_NOT_FOUND, | 26   PIPELINE_ERROR_URL_NOT_FOUND, | 
| 29   PIPELINE_ERROR_NETWORK, | 27   PIPELINE_ERROR_NETWORK, | 
| 30   PIPELINE_ERROR_DECODE, | 28   PIPELINE_ERROR_DECODE, | 
| 31   PIPELINE_ERROR_ABORT, | 29   PIPELINE_ERROR_ABORT, | 
| 32   PIPELINE_ERROR_INITIALIZATION_FAILED, | 30   PIPELINE_ERROR_INITIALIZATION_FAILED, | 
| 33   PIPELINE_ERROR_REQUIRED_FILTER_MISSING, | 31   PIPELINE_ERROR_REQUIRED_FILTER_MISSING, | 
| 34   PIPELINE_ERROR_OUT_OF_MEMORY, | 32   PIPELINE_ERROR_OUT_OF_MEMORY, | 
| 35   PIPELINE_ERROR_COULD_NOT_RENDER, | 33   PIPELINE_ERROR_COULD_NOT_RENDER, | 
| 36   PIPELINE_ERROR_READ, | 34   PIPELINE_ERROR_READ, | 
| 37   PIPELINE_ERROR_AUDIO_HARDWARE, | 35   PIPELINE_ERROR_AUDIO_HARDWARE, | 
| 38   // Demuxer related errors. | 36   // Demuxer related errors. | 
| 39   DEMUXER_ERROR_COULD_NOT_OPEN, | 37   DEMUXER_ERROR_COULD_NOT_OPEN, | 
| 40   DEMUXER_ERROR_COULD_NOT_PARSE, | 38   DEMUXER_ERROR_COULD_NOT_PARSE, | 
| 41   DEMUXER_ERROR_NO_SUPPORTED_STREAMS, | 39   DEMUXER_ERROR_NO_SUPPORTED_STREAMS, | 
| 42   DEMUXER_ERROR_COULD_NOT_CREATE_THREAD, | 40   DEMUXER_ERROR_COULD_NOT_CREATE_THREAD, | 
| 43 }; | 41 }; | 
| 44 | 42 | 
|  | 43 class FilterCollection; | 
|  | 44 | 
| 45 // Client-provided callbacks for various pipeline operations.  Clients should | 45 // Client-provided callbacks for various pipeline operations.  Clients should | 
| 46 // inspect the Pipeline for errors. | 46 // inspect the Pipeline for errors. | 
| 47 typedef Callback0::Type PipelineCallback; | 47 typedef Callback0::Type PipelineCallback; | 
| 48 | 48 | 
| 49 class Pipeline : public base::RefCountedThreadSafe<Pipeline> { | 49 class Pipeline : public base::RefCountedThreadSafe<Pipeline> { | 
| 50  public: | 50  public: | 
| 51   // Initializes pipeline. Pipeline takes ownership of all callbacks passed | 51   // Initializes pipeline. Pipeline takes ownership of all callbacks passed | 
| 52   // into this method. | 52   // into this method. | 
| 53   // |ended_callback| will be executed when the media reaches the end. | 53   // |ended_callback| will be executed when the media reaches the end. | 
| 54   // |error_callback_| will be executed upon an error in the pipeline. | 54   // |error_callback_| will be executed upon an error in the pipeline. | 
| 55   // |network_callback_| will be executed when there's a network event. | 55   // |network_callback_| will be executed when there's a network event. | 
| 56   virtual void Init(PipelineCallback* ended_callback, | 56   virtual void Init(PipelineCallback* ended_callback, | 
| 57                     PipelineCallback* error_callback, | 57                     PipelineCallback* error_callback, | 
| 58                     PipelineCallback* network_callback) = 0; | 58                     PipelineCallback* network_callback) = 0; | 
| 59 | 59 | 
| 60   // Build a pipeline to render the given URL using the given filter collection | 60   // Build a pipeline to render the given URL using the given filter collection | 
| 61   // to construct a filter chain.  Returns true if successful, false otherwise | 61   // to construct a filter chain.  Returns true if successful, false otherwise | 
| 62   // (i.e., pipeline already started).  Note that a return value of true | 62   // (i.e., pipeline already started).  Note that a return value of true | 
| 63   // only indicates that the initialization process has started successfully. | 63   // only indicates that the initialization process has started successfully. | 
| 64   // Pipeline initialization is an inherently asynchronous process.  Clients can | 64   // Pipeline initialization is an inherently asynchronous process.  Clients can | 
| 65   // either poll the IsInitialized() method (discouraged) or use the | 65   // either poll the IsInitialized() method (discouraged) or use the | 
| 66   // |start_callback| as described below. | 66   // |start_callback| as described below. | 
| 67   // | 67   // | 
| 68   // This method is asynchronous and can execute a callback when completed. | 68   // This method is asynchronous and can execute a callback when completed. | 
| 69   // If the caller provides a |start_callback|, it will be called when the | 69   // If the caller provides a |start_callback|, it will be called when the | 
| 70   // pipeline initialization completes.  Clients are expected to call GetError() | 70   // pipeline initialization completes.  Clients are expected to call GetError() | 
| 71   // to check whether initialization succeeded. | 71   // to check whether initialization succeeded. | 
| 72   virtual bool Start(MediaFilterCollection* filter_collection, | 72   virtual bool Start(FilterCollection* filter_collection, | 
| 73                      const std::string& url, | 73                      const std::string& url, | 
| 74                      PipelineCallback* start_callback) = 0; | 74                      PipelineCallback* start_callback) = 0; | 
| 75 | 75 | 
| 76   // Asynchronously stops the pipeline and resets it to an uninitialized state. | 76   // Asynchronously stops the pipeline and resets it to an uninitialized state. | 
| 77   // If provided, |stop_callback| will be executed when the pipeline has been | 77   // If provided, |stop_callback| will be executed when the pipeline has been | 
| 78   // completely torn down and reset to an uninitialized state.  It is acceptable | 78   // completely torn down and reset to an uninitialized state.  It is acceptable | 
| 79   // to call Start() again once the callback has finished executing. | 79   // to call Start() again once the callback has finished executing. | 
| 80   // | 80   // | 
| 81   // Stop() must be called before destroying the pipeline.  Clients can | 81   // Stop() must be called before destroying the pipeline.  Clients can | 
| 82   // determine whether Stop() must be called by checking IsRunning(). | 82   // determine whether Stop() must be called by checking IsRunning(). | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 172 | 172 | 
| 173  protected: | 173  protected: | 
| 174   // Only allow ourselves to be deleted by reference counting. | 174   // Only allow ourselves to be deleted by reference counting. | 
| 175   friend class base::RefCountedThreadSafe<Pipeline>; | 175   friend class base::RefCountedThreadSafe<Pipeline>; | 
| 176   virtual ~Pipeline() {} | 176   virtual ~Pipeline() {} | 
| 177 }; | 177 }; | 
| 178 | 178 | 
| 179 }  // namespace media | 179 }  // namespace media | 
| 180 | 180 | 
| 181 #endif  // MEDIA_BASE_PIPELINE_H_ | 181 #endif  // MEDIA_BASE_PIPELINE_H_ | 
| OLD | NEW | 
|---|