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

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

Issue 13116: Adding media filters interface definitions. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years 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 | « no previous file | media/base/media.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BASE_FILTERS_H_
6 #define MEDIA_BASE_FILTERS_H_
7
8 #include <limits>
9 #include <string>
10 #include "base/basictypes.h"
11 #include "base/ref_counted.h"
12
13 namespace media {
14
15 template <class BufferType> class AssignableInterface;
16 class BufferInterface;
17 class DecoderInterface;
18 class DemuxerStreamInterface;
19 class MediaFormat;
20 class SchedulerFilterInterface;
21 class VideoFrameInterface;
22 class WritableBufferInterface;
23
24 // Identifies the type of filter implementation. Used in conjunction with some
25 // template wizardry to enforce strongly typed operations. More or less a
26 // knock off of MSVC's __uuidof() operator.
27 enum FilterType {
28 FILTER_DATA_SOURCE,
29 FILTER_DEMUXER,
30 FILTER_AUDIO_DECODER,
31 FILTER_VIDEO_DECODER,
32 FILTER_AUDIO_RENDERER,
33 FILTER_VIDEO_RENDERER,
34 FILTER_MAX
35 };
36
37 // Filters are connected in a strongly typed manner, with downstream filters
38 // always reading data from upstream filters. Upstream filters have no clue
39 // who is actually reading from them, and return the results via OnAssignment
40 // using the AssignableInterface<SomeBufferType> interface:
41 //
42 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer
43 // DataSource <- Demuxer <
44 // DemuxerStream(Audio) <- AudioDecoder <- AudioRenderer
45 //
46 // Upstream -------------------------------------------------------> Downstream
47 // <- Reads flow this way
48 // Buffer assignments flow this way ->
49 //
50 // Every filter maintains a reference to the scheduler, who maintains data
51 // shared between filters (i.e., reference clock value, playback state). The
52 // scheduler is also responsible for scheduling filter tasks (i.e., a read on
53 // a VideoDecoder would result in scheduling a Decode task). Filters can also
54 // use the scheduler to signal errors and shutdown playback.
55
56
57 // NOTE: this isn't a true interface since RefCountedThreadSafe has non-virtual
58 // members, therefore implementors should NOT subclass RefCountedThreadSafe.
59 //
60 // If you do, AddRef/Release will have different outcomes depending on the
61 // current type of the pointer (StreamSampleInterface vs. SomeImplementation)
62 class MediaFilterInterface :
63 public base::RefCountedThreadSafe<MediaFilterInterface> {
64 public:
65 virtual ~MediaFilterInterface() {}
66
67 virtual void SetScheduler(SchedulerFilterInterface* scheduler) = 0;
68 };
69
70 class DataSourceInterface : public MediaFilterInterface {
71 public:
72 static const FilterType kFilterType = FILTER_DATA_SOURCE;
73 static const size_t kReadError = static_cast<size_t>(-1);
74 virtual ~DataSourceInterface() {}
75
76 // Initializes this filter, returns true if successful, false otherwise.
77 virtual bool Initialize(const std::wstring& uri) = 0;
78
79 // Returns the MediaFormat for this filter.
80 virtual const MediaFormat* GetMediaFormat() = 0;
81
82 // Read the given amount of bytes into data, returns the number of bytes read
83 // if successful, kReadError otherwise.
84 virtual size_t Read(char* data, size_t size) = 0;
85
86 // Returns true and the current file position for this file, false if the
87 // file position could not be retrieved.
88 virtual bool GetPosition(int64* position_out) = 0;
89
90 // Returns true if the file position could be set, false otherwise.
91 virtual bool SetPosition(int64 position) = 0;
92
93 // Returns true and the file size, false if the file size could not be
94 // retrieved.
95 virtual bool GetSize(int64* size_out) = 0;
96 };
97
98
99 class DemuxerInterface : public MediaFilterInterface {
100 public:
101 static const FilterType kFilterType = FILTER_DEMUXER;
102 virtual ~DemuxerInterface() {}
103
104 // Initializes this filter, returns true if successful, false otherwise.
105 virtual bool Initialize(DataSourceInterface* data_source) = 0;
106
107 // Returns the number of streams available
108 virtual size_t GetNumberOfStreams() = 0;
109
110 // Returns the stream for the given index, NULL otherwise
111 virtual DemuxerStreamInterface* GetStream(int stream_id) = 0;
112 };
113
114
115 class DemuxerStreamInterface {
116 public:
117 virtual ~DemuxerStreamInterface() {}
118
119 // Returns the MediaFormat for this filter.
120 virtual const MediaFormat* GetMediaFormat() = 0;
121
122 // Schedules a read and takes ownership of the given buffer.
123 virtual void Read(AssignableInterface<BufferInterface>* buffer) = 0;
124 };
125
126
127 class VideoDecoderInterface : public MediaFilterInterface {
128 public:
129 static const FilterType kFilterType = FILTER_VIDEO_DECODER;
130 virtual ~VideoDecoderInterface() {}
131
132 // Initializes this filter, returns true if successful, false otherwise.
133 virtual bool Initialize(DemuxerStreamInterface* demuxer_stream) = 0;
134
135 // Returns the MediaFormat for this filter.
136 virtual const MediaFormat* GetMediaFormat() = 0;
137
138 // Schedules a read and takes ownership of the given buffer.
139 virtual void Read(AssignableInterface<VideoFrameInterface>* video_frame) = 0;
140 };
141
142
143 class AudioDecoderInterface : public MediaFilterInterface {
144 public:
145 static const FilterType kFilterType = FILTER_AUDIO_DECODER;
146 virtual ~AudioDecoderInterface() {}
147
148 // Initializes this filter, returns true if successful, false otherwise.
149 virtual bool Initialize(DemuxerStreamInterface* demuxer_stream) = 0;
150
151 // Returns the MediaFormat for this filter.
152 virtual const MediaFormat* GetMediaFormat() = 0;
153
154 // Schedules a read and takes ownership of the given buffer.
155 virtual void Read(AssignableInterface<BufferInterface>* buffer) = 0;
156 };
157
158
159 class VideoRendererInterface : public MediaFilterInterface {
160 public:
161 static const FilterType kFilterType = FILTER_VIDEO_RENDERER;
162 virtual ~VideoRendererInterface() {}
163
164 // Initializes this filter, returns true if successful, false otherwise.
165 virtual bool Initialize(VideoDecoderInterface* decoder) = 0;
166 };
167
168
169 class AudioRendererInterface : public MediaFilterInterface {
170 public:
171 static const FilterType kFilterType = FILTER_AUDIO_RENDERER;
172 virtual ~AudioRendererInterface() {}
173
174 // Initializes this filter, returns true if successful, false otherwise.
175 virtual bool Initialize(AudioDecoderInterface* decoder) = 0;
176 };
177
178 } // namespace media
179
180 #endif // MEDIA_BASE_FILTERS_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/media.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698