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

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

Issue 18546: Implementation of Pipeline and FilterHost interfaces. This is a large change... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « media/base/media_format.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) 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 "media/base/factory.h" 16 #include "media/base/factory.h"
16 17
17 namespace media { 18 namespace media {
18 19
19 // Error definitions for pipeline. 20 // Error definitions for pipeline.
20 enum PipelineError { 21 enum PipelineError {
21 PIPELINE_OK, 22 PIPELINE_OK,
22 PIPELINE_ERROR_NETWORK, 23 PIPELINE_ERROR_NETWORK,
23 PIPELINE_ERROR_DECODE, 24 PIPELINE_ERROR_DECODE,
24 PIPELINE_ERROR_ABORT, 25 PIPELINE_ERROR_ABORT,
25 PIPELINE_ERROR_INITIALIZATION_FAILED, 26 PIPELINE_ERROR_INITIALIZATION_FAILED,
26 PIPELINE_STOPPING 27 PIPELINE_STOPPING
27 }; 28 };
28 29
29 // Base class for Pipeline class which allows for read-only access to members. 30 // Base class for Pipeline class which allows for read-only access to members.
30 // Filters are allowed to access the PipelineStatus interface but are not given 31 // Filters are allowed to access the PipelineStatus interface but are not given
31 // access to the client Pipeline methods. 32 // access to the client Pipeline methods.
32 class PipelineStatus { 33 class PipelineStatus {
33 public: 34 public:
34 // Returns the current initialization state of the pipeline. Clients can 35 // Returns the current initialization state of the pipeline. Clients can
35 // examine this to determine if it is acceptable to call SetRate/SetVolume/ 36 // examine this to determine if it is acceptable to call SetRate/SetVolume/
36 // Seek after calling Start on the pipeline. Note that this will be 37 // Seek after calling Start on the pipeline. Note that this will be
37 // set to true prior to a call to the client's |init_complete_callback| if 38 // set to true prior to a call to the client's |init_complete_callback| if
38 // initialization is successful. 39 // initialization is successful.
39 virtual bool IsInitialized() const = 0; 40 virtual bool IsInitialized() const = 0;
40 41
41 // Get the duration of the media in microseconds. If the duration has not 42 // Get the duration of the media in microseconds. If the duration has not
42 // been determined yet, then returns 0. 43 // been determined yet, then returns 0.
43 virtual int64 GetDuration() const = 0; 44 virtual base::TimeDelta GetDuration() const = 0;
44 45
45 // Get the approximate amount of playable data buffered so far in micro- 46 // Get the approximate amount of playable data buffered so far in micro-
46 // seconds. 47 // seconds.
47 virtual int64 GetBufferedTime() const = 0; 48 virtual base::TimeDelta GetBufferedTime() const = 0;
48 49
49 // Get the total size of the media file. If the size has not yet been 50 // Get the total size of the media file. If the size has not yet been
50 // determined or can not be determined, this value is 0. 51 // determined or can not be determined, this value is 0.
51 virtual int64 GetTotalBytes() const = 0; 52 virtual int64 GetTotalBytes() const = 0;
52 53
53 // Get the total number of bytes that are buffered on the client and ready to 54 // Get the total number of bytes that are buffered on the client and ready to
54 // be played. 55 // be played.
55 virtual int64 GetBufferedBytes() const = 0; 56 virtual int64 GetBufferedBytes() const = 0;
56 57
57 // Gets the size of the video output in pixel units. If there is no video 58 // Gets the size of the video output in pixel units. If there is no video
58 // or the video has not been rendered yet, the width and height will be 0. 59 // or the video has not been rendered yet, the width and height will be 0.
59 virtual void GetVideoSize(size_t* width_out, size_t* height_out) const = 0; 60 virtual void GetVideoSize(size_t* width_out, size_t* height_out) const = 0;
60 61
61 // Gets the current volume setting being used by the audio renderer. When 62 // Gets the current volume setting being used by the audio renderer. When
62 // the pipeline is started, this value will be 1.0f. Valid values range 63 // the pipeline is started, this value will be 1.0f. Valid values range
63 // from 0.0f to 1.0f. 64 // from 0.0f to 1.0f.
64 virtual float GetVolume() const = 0; 65 virtual float GetVolume() const = 0;
65 66
66 // Gets the current playback rate of the pipeline. When the pipeline is 67 // Gets the current playback rate of the pipeline. When the pipeline is
67 // started, the playback rate will be 0.0f. A rate of 1.0f indicates 68 // started, the playback rate will be 0.0f. A rate of 1.0f indicates
68 // that the pipeline is rendering the media at the standard rate. Valid 69 // that the pipeline is rendering the media at the standard rate. Valid
69 // values for playback rate are >= 0.0f. 70 // values for playback rate are >= 0.0f.
70 virtual float GetPlaybackRate() const = 0; 71 virtual float GetPlaybackRate() const = 0;
71 72
72 // Gets the current pipeline time in microseconds. For a pipeline "time" 73 // Gets the current pipeline time in microseconds. For a pipeline "time"
73 // progresses from 0 to the end of the media. 74 // progresses from 0 to the end of the media.
74 virtual int64 GetTime() const = 0; 75 virtual base::TimeDelta GetTime() const = 0;
75 76
76 // Gets the current error status for the pipeline. If the pipeline is 77 // Gets the current error status for the pipeline. If the pipeline is
77 // operating correctly, this will return OK. 78 // operating correctly, this will return OK.
78 virtual PipelineError GetError() const = 0; 79 virtual PipelineError GetError() const = 0;
79 80
80 protected: 81 protected:
81 virtual ~PipelineStatus() = 0; 82 virtual ~PipelineStatus() {}
82 }; 83 };
83 84
84 85
85 class Pipeline : public PipelineStatus { 86 class Pipeline : public PipelineStatus {
86 public: 87 public:
87 // Build a pipeline to render the given URI using the given filter factory to 88 // Build a pipeline to render the given URI using the given filter factory to
88 // construct a filter chain. Returns true if successful, false otherwise 89 // construct a filter chain. Returns true if successful, false otherwise
89 // (i.e., pipeline already started). Note that a return value of true 90 // (i.e., pipeline already started). Note that a return value of true
90 // only indicates that the initialization process has started successfully. 91 // only indicates that the initialization process has started successfully.
91 // Pipeline initializaion is an inherently asynchronous process. Clients 92 // Pipeline initializaion is an inherently asynchronous process. Clients
(...skipping 17 matching lines...) Expand all
109 // called the Start method. 110 // called the Start method.
110 virtual bool Start(FilterFactory* filter_factory, 111 virtual bool Start(FilterFactory* filter_factory,
111 const std::string& uri, 112 const std::string& uri,
112 Callback1<bool>::Type* init_complete_callback) = 0; 113 Callback1<bool>::Type* init_complete_callback) = 0;
113 114
114 // Stops the pipeline and resets to an uninitialized state. This method 115 // Stops the pipeline and resets to an uninitialized state. This method
115 // will block the calling thread until the pipeline has been completely 116 // will block the calling thread until the pipeline has been completely
116 // torn down and reset to an uninitialized state. After calling Stop, it 117 // torn down and reset to an uninitialized state. After calling Stop, it
117 // is acceptable to call Start again since Stop leaves the pipeline 118 // is acceptable to call Start again since Stop leaves the pipeline
118 // in a state identical to a newly created pipeline. 119 // in a state identical to a newly created pipeline.
120 // Calling this method is not strictly required because the pipeline
121 // destructor will stop it pipeline if it has not been stopped already.
119 virtual void Stop() = 0; 122 virtual void Stop() = 0;
120 123
121 // Attempt to adjust the playback rate. Returns true if successful, 124 // Attempt to adjust the playback rate. Setting a playback rate of 0.0f pauses
122 // false otherwise. Setting a playback rate of 0.0f pauses all rendering 125 // all rendering of the media. A rate of 1.0f indicates a normal playback
123 // of the media. A rate of 1.0f indicates a normal playback rate. Values 126 // rate. Values for the playback rate must be greater than or equal to 0.0f.
124 // for the playback rate must be greater than or equal to 0.0f.
125 // TODO(ralphl) What about maximum rate? Does HTML5 specify a max? 127 // TODO(ralphl) What about maximum rate? Does HTML5 specify a max?
126 // 128 //
127 // This method must be called only after initialization has completed. 129 // This method must be called only after initialization has completed.
128 virtual bool SetPlaybackRate(float playback_rate) = 0; 130 virtual void SetPlaybackRate(float playback_rate) = 0;
129 131
130 // Attempt to seek to the position in microseconds. Returns true if 132 // Attempt to seek to the position in microseconds.
131 // successful, false otherwise. Playback is paused after the seek completes.
132 // 133 //
133 // This method must be called only after initialization has completed. 134 // This method must be called only after initialization has completed.
134 virtual bool Seek(int64 time) = 0; 135 virtual void Seek(base::TimeDelta time) = 0;
135 136
136 // Attempt to set the volume of the audio renderer. Valid values for volume 137 // Attempt to set the volume of the audio renderer. Valid values for volume
137 // range from 0.0f (muted) to 1.0f (full volume). This value affects all 138 // range from 0.0f (muted) to 1.0f (full volume). This value affects all
138 // channels proportionately for multi-channel audio streams. 139 // channels proportionately for multi-channel audio streams.
139 // 140 //
140 // This method must be called only after initialization has completed. 141 // This method must be called only after initialization has completed.
141 virtual bool SetVolume(float volume) = 0; 142 virtual void SetVolume(float volume) = 0;
143
144 protected:
145 virtual ~Pipeline() {}
142 }; 146 };
143 147
144 } // namespace media 148 } // namespace media
145 149
146 #endif // MEDIA_BASE_PIPELINE_H_ 150 #endif // MEDIA_BASE_PIPELINE_H_
OLDNEW
« no previous file with comments | « media/base/media_format.cc ('k') | media/base/pipeline_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698