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

Side by Side Diff: media/base/filters.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/filter_host_impl.cc ('k') | media/base/media_format.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 // Filters are connected in a strongly typed manner, with downstream filters 5 // Filters are connected in a strongly typed manner, with downstream filters
6 // always reading data from upstream filters. Upstream filters have no clue 6 // always reading data from upstream filters. Upstream filters have no clue
7 // who is actually reading from them, and return the results via OnAssignment 7 // who is actually reading from them, and return the results via OnAssignment
8 // using the AssignableInterface<SomeBufferType> interface: 8 // using the AssignableInterface<SomeBufferType> interface:
9 // 9 //
10 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer 10 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer
(...skipping 11 matching lines...) Expand all
22 // use the scheduler to signal errors and shutdown playback. 22 // use the scheduler to signal errors and shutdown playback.
23 23
24 #ifndef MEDIA_BASE_FILTERS_H_ 24 #ifndef MEDIA_BASE_FILTERS_H_
25 #define MEDIA_BASE_FILTERS_H_ 25 #define MEDIA_BASE_FILTERS_H_
26 26
27 #include <limits> 27 #include <limits>
28 #include <string> 28 #include <string>
29 29
30 #include "base/logging.h" 30 #include "base/logging.h"
31 #include "base/ref_counted.h" 31 #include "base/ref_counted.h"
32 #include "base/time.h"
33 #include "media/base/media_format.h"
32 34
33 namespace media { 35 namespace media {
34 36
35 template <class TBuffer> class Assignable; 37 template <class TBuffer> class Assignable;
36 class Buffer; 38 class Buffer;
37 class Decoder; 39 class Decoder;
38 class DemuxerStream; 40 class DemuxerStream;
39 class FilterHost; 41 class FilterHost;
40 class MediaFormat;
41 class VideoFrame; 42 class VideoFrame;
42 class WritableBuffer; 43 class WritableBuffer;
43 44
44 // Identifies the type of filter implementation. Used in conjunction with some 45 // Identifies the type of filter implementation. Used in conjunction with some
45 // template wizardry to enforce strongly typed operations. More or less a 46 // template wizardry to enforce strongly typed operations. More or less a
46 // knock off of MSVC's __uuidof() operator. 47 // knock off of MSVC's __uuidof() operator.
47 enum FilterType { 48 enum FilterType {
48 FILTER_DATA_SOURCE, 49 FILTER_DATA_SOURCE,
49 FILTER_DEMUXER, 50 FILTER_DEMUXER,
50 FILTER_AUDIO_DECODER, 51 FILTER_AUDIO_DECODER,
(...skipping 20 matching lines...) Expand all
71 // The pipeline is being stopped either as a result of an error or because 72 // The pipeline is being stopped either as a result of an error or because
72 // the client called Stop(). 73 // the client called Stop().
73 virtual void Stop() = 0; 74 virtual void Stop() = 0;
74 75
75 // The pipeline playback rate has been changed. Filters may implement this 76 // The pipeline playback rate has been changed. Filters may implement this
76 // method if they need to respond to this call. 77 // method if they need to respond to this call.
77 virtual void SetPlaybackRate(float playback_rate) {} 78 virtual void SetPlaybackRate(float playback_rate) {}
78 79
79 // The pipeline is being seeked to the specified time. Filters may implement 80 // The pipeline is being seeked to the specified time. Filters may implement
80 // this method if they need to respond to this call. 81 // this method if they need to respond to this call.
81 virtual void Seek(int64 time) {} 82 virtual void Seek(base::TimeDelta time) {}
82 83
83 protected: 84 protected:
84 FilterHost* host_; 85 FilterHost* host_;
85 friend class base::RefCountedThreadSafe<MediaFilter>; 86 friend class base::RefCountedThreadSafe<MediaFilter>;
86 virtual ~MediaFilter() {} 87 virtual ~MediaFilter() {}
87 88
88 private: 89 private:
89 DISALLOW_COPY_AND_ASSIGN(MediaFilter); 90 DISALLOW_COPY_AND_ASSIGN(MediaFilter);
90 }; 91 };
91 92
92 93
93 class DataSource : public MediaFilter { 94 class DataSource : public MediaFilter {
94 public: 95 public:
95 static const FilterType kFilterType = FILTER_DATA_SOURCE; 96 static const FilterType filter_type() {
97 return FILTER_DATA_SOURCE;
98 }
99
96 static const size_t kReadError = static_cast<size_t>(-1); 100 static const size_t kReadError = static_cast<size_t>(-1);
97 101
98 // Initializes this filter, returns true if successful, false otherwise. 102 // Initializes this filter, returns true if successful, false otherwise.
99 virtual bool Initialize(const std::string& uri) = 0; 103 virtual bool Initialize(const std::string& url) = 0;
100 104
101 // Returns the MediaFormat for this filter. 105 // Returns the MediaFormat for this filter.
102 virtual const MediaFormat* GetMediaFormat() = 0; 106 virtual const MediaFormat* GetMediaFormat() = 0;
103 107
104 // Read the given amount of bytes into data, returns the number of bytes read 108 // Read the given amount of bytes into data, returns the number of bytes read
105 // if successful, kReadError otherwise. 109 // if successful, kReadError otherwise.
106 virtual size_t Read(char* data, size_t size) = 0; 110 virtual size_t Read(char* data, size_t size) = 0;
107 111
108 // Returns true and the current file position for this file, false if the 112 // Returns true and the current file position for this file, false if the
109 // file position could not be retrieved. 113 // file position could not be retrieved.
110 virtual bool GetPosition(int64* position_out) = 0; 114 virtual bool GetPosition(int64* position_out) = 0;
111 115
112 // Returns true if the file position could be set, false otherwise. 116 // Returns true if the file position could be set, false otherwise.
113 virtual bool SetPosition(int64 position) = 0; 117 virtual bool SetPosition(int64 position) = 0;
114 118
115 // Returns true and the file size, false if the file size could not be 119 // Returns true and the file size, false if the file size could not be
116 // retrieved. 120 // retrieved.
117 virtual bool GetSize(int64* size_out) = 0; 121 virtual bool GetSize(int64* size_out) = 0;
118 }; 122 };
119 123
120 124
121 class Demuxer : public MediaFilter { 125 class Demuxer : public MediaFilter {
122 public: 126 public:
123 static const FilterType kFilterType = FILTER_DEMUXER; 127 static const FilterType filter_type() {
128 return FILTER_DEMUXER;
129 }
124 130
125 // Initializes this filter, returns true if successful, false otherwise. 131 // Initializes this filter, returns true if successful, false otherwise.
126 virtual bool Initialize(DataSource* data_source) = 0; 132 virtual bool Initialize(DataSource* data_source) = 0;
127 133
128 // Returns the number of streams available 134 // Returns the number of streams available
129 virtual size_t GetNumberOfStreams() = 0; 135 virtual size_t GetNumberOfStreams() = 0;
130 136
131 // Returns the stream for the given index, NULL otherwise 137 // Returns the stream for the given index, NULL otherwise
132 virtual DemuxerStream* GetStream(int stream_id) = 0; 138 virtual DemuxerStream* GetStream(int stream_id) = 0;
133 }; 139 };
134 140
135 141
136 class DemuxerStream { 142 class DemuxerStream {
137 public: 143 public:
138 // Returns the MediaFormat for this filter. 144 // Returns the MediaFormat for this filter.
139 virtual const MediaFormat* GetMediaFormat() = 0; 145 virtual const MediaFormat* GetMediaFormat() = 0;
140 146
141 // Schedules a read and takes ownership of the given buffer. 147 // Schedules a read and takes ownership of the given buffer.
142 virtual void Read(Assignable<Buffer>* buffer) = 0; 148 virtual void Read(Assignable<Buffer>* buffer) = 0;
143 149
144 protected: 150 protected:
145 virtual ~DemuxerStream() = 0; 151 virtual ~DemuxerStream() = 0;
146 }; 152 };
147 153
148 154
149 class VideoDecoder : public MediaFilter { 155 class VideoDecoder : public MediaFilter {
150 public: 156 public:
151 static const FilterType kFilterType = FILTER_VIDEO_DECODER; 157 static const FilterType filter_type() {
158 return FILTER_VIDEO_DECODER;
159 }
160
161 static const char* major_mime_type() {
162 return mime_type::kMajorTypeVideo;
163 }
152 164
153 // Initializes this filter, returns true if successful, false otherwise. 165 // Initializes this filter, returns true if successful, false otherwise.
154 virtual bool Initialize(DemuxerStream* demuxer_stream) = 0; 166 virtual bool Initialize(DemuxerStream* demuxer_stream) = 0;
155 167
156 // Returns the MediaFormat for this filter. 168 // Returns the MediaFormat for this filter.
157 virtual const MediaFormat* GetMediaFormat() = 0; 169 virtual const MediaFormat* GetMediaFormat() = 0;
158 170
159 // Schedules a read and takes ownership of the given buffer. 171 // Schedules a read and takes ownership of the given buffer.
160 virtual void Read(Assignable<VideoFrame>* video_frame) = 0; 172 virtual void Read(Assignable<VideoFrame>* video_frame) = 0;
161 }; 173 };
162 174
163 175
164 class AudioDecoder : public MediaFilter { 176 class AudioDecoder : public MediaFilter {
165 public: 177 public:
166 static const FilterType kFilterType = FILTER_AUDIO_DECODER; 178 static const FilterType filter_type() {
179 return FILTER_AUDIO_DECODER;
180 }
181
182 static const char* major_mime_type() {
183 return mime_type::kMajorTypeAudio;
184 }
167 185
168 // Initializes this filter, returns true if successful, false otherwise. 186 // Initializes this filter, returns true if successful, false otherwise.
169 virtual bool Initialize(DemuxerStream* demuxer_stream) = 0; 187 virtual bool Initialize(DemuxerStream* demuxer_stream) = 0;
170 188
171 // Returns the MediaFormat for this filter. 189 // Returns the MediaFormat for this filter.
172 virtual const MediaFormat* GetMediaFormat() = 0; 190 virtual const MediaFormat* GetMediaFormat() = 0;
173 191
174 // Schedules a read and takes ownership of the given buffer. 192 // Schedules a read and takes ownership of the given buffer.
175 virtual void Read(Assignable<Buffer>* buffer) = 0; 193 virtual void Read(Assignable<Buffer>* buffer) = 0;
176 }; 194 };
177 195
178 196
179 class VideoRenderer : public MediaFilter { 197 class VideoRenderer : public MediaFilter {
180 public: 198 public:
181 static const FilterType kFilterType = FILTER_VIDEO_RENDERER; 199 static const FilterType filter_type() {
200 return FILTER_VIDEO_RENDERER;
201 }
202
203 static const char* major_mime_type() {
204 return mime_type::kMajorTypeVideo;
205 }
182 206
183 // Initializes this filter, returns true if successful, false otherwise. 207 // Initializes this filter, returns true if successful, false otherwise.
184 virtual bool Initialize(VideoDecoder* decoder) = 0; 208 virtual bool Initialize(VideoDecoder* decoder) = 0;
185 }; 209 };
186 210
187 211
188 class AudioRenderer : public MediaFilter { 212 class AudioRenderer : public MediaFilter {
189 public: 213 public:
190 static const FilterType kFilterType = FILTER_AUDIO_RENDERER; 214 static const FilterType filter_type() {
215 return FILTER_AUDIO_RENDERER;
216 }
217
218 static const char* major_mime_type() {
219 return mime_type::kMajorTypeAudio;
220 }
191 221
192 // Initializes this filter, returns true if successful, false otherwise. 222 // Initializes this filter, returns true if successful, false otherwise.
193 virtual bool Initialize(AudioDecoder* decoder) = 0; 223 virtual bool Initialize(AudioDecoder* decoder) = 0;
194 224
195 // Sets the output volume. 225 // Sets the output volume.
196 virtual void SetVolume(float volume) = 0; 226 virtual void SetVolume(float volume) = 0;
197 }; 227 };
198 228
199 } // namespace media 229 } // namespace media
200 230
201 #endif // MEDIA_BASE_FILTERS_H_ 231 #endif // MEDIA_BASE_FILTERS_H_
OLDNEW
« no previous file with comments | « media/base/filter_host_impl.cc ('k') | media/base/media_format.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698