Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: media/base/pipeline.h

Issue 155338: Implemented injected message loops for PipelineImpl. (Closed)
Patch Set: Merged with git-svn Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/filter_host_impl.cc ('k') | media/base/pipeline_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // TODO(scherkus): consider returning a PipelineError instead of a bool, or 49 // TODO(scherkus): consider returning a PipelineError instead of a bool, or
50 // perhaps a client callback interface. 50 // perhaps a client callback interface.
51 typedef Callback1<bool>::Type PipelineCallback; 51 typedef Callback1<bool>::Type PipelineCallback;
52 52
53 class Pipeline { 53 class Pipeline {
54 public: 54 public:
55 // Build a pipeline to render the given URL using the given filter factory to 55 // Build a pipeline to render the given URL using the given filter factory to
56 // construct a filter chain. Returns true if successful, false otherwise 56 // construct a filter chain. Returns true if successful, false otherwise
57 // (i.e., pipeline already started). Note that a return value of true 57 // (i.e., pipeline already started). Note that a return value of true
58 // only indicates that the initialization process has started successfully. 58 // only indicates that the initialization process has started successfully.
59 // Pipeline initialization is an inherently asynchronous process. Clients 59 // Pipeline initialization is an inherently asynchronous process. Clients can
60 // should not call SetPlaybackRate(), Seek(), or SetVolume() until 60 // either poll the IsInitialized() method (discouraged) or use the
61 // initialization is complete. Clients can either poll the IsInitialized() 61 // |start_callback| as described below.
62 // method (which is discouraged) or use the |start_callback| as described
63 // below.
64 // 62 //
65 // This method is asynchronous and can execute a callback when completed. 63 // This method is asynchronous and can execute a callback when completed.
66 // If the caller provides a |start_callback|, it will be called when the 64 // If the caller provides a |start_callback|, it will be called when the
67 // pipeline initialization completes. If successful, the callback's bool 65 // pipeline initialization completes. If successful, the callback's bool
68 // parameter will be true. If the callback is called with false, then the 66 // parameter will be true. If the callback is called with false, then the
69 // client can use the GetError() method to obtain more information about the 67 // client can use GetError() to obtain more information about the reason
70 // reason initialization failed. The prototype for the client callback is: 68 // initialization failed.
71 // void Client::PipelineInitComplete(bool init_was_successful);
72 //
73 // Note that clients must not call the Stop method from within the
74 // |start_callback|. Other methods, including SetPlaybackRate(), Seek(), and
75 // SetVolume() may be called. The client will be called on a thread owned by
76 // the pipeline class, not on the thread that originally called the Start()
77 // method.
78 virtual bool Start(FilterFactory* filter_factory, 69 virtual bool Start(FilterFactory* filter_factory,
79 const std::string& url, 70 const std::string& url,
80 PipelineCallback* start_callback) = 0; 71 PipelineCallback* start_callback) = 0;
81 72
82 // Stops the pipeline and resets to an uninitialized state. This method 73 // Asynchronously stops the pipeline and resets it to an uninitialized state.
83 // will block the calling thread until the pipeline has been completely 74 // If provided, |stop_callback| will be executed when the pipeline has been
84 // torn down and reset to an uninitialized state. After calling Stop(), it 75 // completely torn down and reset to an uninitialized state. It is acceptable
85 // is acceptable to call Start() again since Stop() leaves the pipeline 76 // to call Start() again once the callback has finished executing.
86 // in a state identical to a newly created pipeline.
87 // 77 //
88 // Stop() must be called before destroying the pipeline. 78 // Stop() must be called before destroying the pipeline. Clients can
79 // determine whether Stop() must be called by checking IsRunning().
89 // 80 //
90 // TODO(scherkus): it shouldn't be acceptable to call Start() again after you 81 // TODO(scherkus): ideally clients would destroy the pipeline after calling
91 // Stop() a pipeline -- it should be destroyed and replaced with a new 82 // Stop() and create a new pipeline as needed.
92 // instance. 83 virtual void Stop(PipelineCallback* stop_callback) = 0;
93 virtual void Stop() = 0;
94 84
95 // Attempt to seek to the position specified by time. |seek_callback| will be 85 // Attempt to seek to the position specified by time. |seek_callback| will be
96 // executed when the all filters in the pipeline have processed the seek. 86 // executed when the all filters in the pipeline have processed the seek.
97 // The callback will return true if the seek was carried out, false otherwise 87 // The callback will return true if the seek was carried out, false otherwise
98 // (i.e., streaming media). 88 // (i.e., streaming media).
99 virtual void Seek(base::TimeDelta time, PipelineCallback* seek_callback) = 0; 89 virtual void Seek(base::TimeDelta time, PipelineCallback* seek_callback) = 0;
100 90
101 // Returns the current initialization state of the pipeline. Note that this 91 // Returns true if the pipeline has been started via Start(). If IsRunning()
102 // will be set to true prior to a executing |init_complete_callback| if 92 // returns true, it is expected that Stop() will be called before destroying
103 // initialization is successful. 93 // the pipeline.
94 virtual bool IsRunning() const = 0;
95
96 // Returns true if the pipeline has been started and fully initialized to a
97 // point where playback controls will be respected. Note that it is possible
98 // for a pipeline to be started but not initialized (i.e., an error occurred).
104 virtual bool IsInitialized() const = 0; 99 virtual bool IsInitialized() const = 0;
105 100
106 // If the |major_mime_type| exists in the pipeline and is being rendered, this 101 // If the |major_mime_type| exists in the pipeline and is being rendered, this
107 // method will return true. Types are defined in media/base/media_foramt.h. 102 // method will return true. Types are defined in media/base/media_foramt.h.
108 // For example, to determine if a pipeline contains video: 103 // For example, to determine if a pipeline contains video:
109 // bool has_video = pipeline->IsRendered(mime_type::kMajorTypeVideo); 104 // bool has_video = pipeline->IsRendered(mime_type::kMajorTypeVideo);
110 virtual bool IsRendered(const std::string& major_mime_type) const = 0; 105 virtual bool IsRendered(const std::string& major_mime_type) const = 0;
111 106
112 // Gets the current playback rate of the pipeline. When the pipeline is 107 // Gets the current playback rate of the pipeline. When the pipeline is
113 // started, the playback rate will be 0.0f. A rate of 1.0f indicates 108 // started, the playback rate will be 0.0f. A rate of 1.0f indicates
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // operating correctly, this will return OK. 155 // operating correctly, this will return OK.
161 virtual PipelineError GetError() const = 0; 156 virtual PipelineError GetError() const = 0;
162 157
163 protected: 158 protected:
164 virtual ~Pipeline() {} 159 virtual ~Pipeline() {}
165 }; 160 };
166 161
167 } // namespace media 162 } // namespace media
168 163
169 #endif // MEDIA_BASE_PIPELINE_H_ 164 #endif // MEDIA_BASE_PIPELINE_H_
OLDNEW
« no previous file with comments | « media/base/filter_host_impl.cc ('k') | media/base/pipeline_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698