OLD | NEW |
1 // Copyright (c) 2008-2009 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 // Defines various types of timestamped media buffers used for transporting | 5 // Defines various types of timestamped media buffers used for transporting |
6 // data between filters. Every buffer contains a timestamp in microseconds | 6 // data between filters. Every buffer contains a timestamp in microseconds |
7 // describing the relative position of the buffer within the media stream, and | 7 // describing the relative position of the buffer within the media stream, and |
8 // the duration in microseconds for the length of time the buffer will be | 8 // the duration in microseconds for the length of time the buffer will be |
9 // rendered. | 9 // rendered. |
10 // | 10 // |
11 // Timestamps are derived directly from the encoded media file and are commonly | 11 // Timestamps are derived directly from the encoded media file and are commonly |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // to GetBufferSize(). | 115 // to GetBufferSize(). |
116 virtual void SetDataSize(size_t data_size) = 0; | 116 virtual void SetDataSize(size_t data_size) = 0; |
117 | 117 |
118 // Returns the size of the underlying buffer. | 118 // Returns the size of the underlying buffer. |
119 virtual size_t GetBufferSize() const = 0; | 119 virtual size_t GetBufferSize() const = 0; |
120 | 120 |
121 protected: | 121 protected: |
122 virtual ~WritableBuffer() {} | 122 virtual ~WritableBuffer() {} |
123 }; | 123 }; |
124 | 124 |
125 | |
126 struct VideoSurface { | |
127 static const size_t kMaxPlanes = 3; | |
128 | |
129 static const size_t kNumRGBPlanes = 1; | |
130 static const size_t kRGBPlane = 0; | |
131 | |
132 static const size_t kNumYUVPlanes = 3; | |
133 static const size_t kYPlane = 0; | |
134 static const size_t kUPlane = 1; | |
135 static const size_t kVPlane = 2; | |
136 | |
137 // Surface formats roughly based on FOURCC labels, see: | |
138 // http://www.fourcc.org/rgb.php | |
139 // http://www.fourcc.org/yuv.php | |
140 enum Format { | |
141 INVALID, // Invalid format value. Used for error reporting. | |
142 RGB555, // 16bpp RGB packed 5:5:5 | |
143 RGB565, // 16bpp RGB packed 5:6:5 | |
144 RGB24, // 24bpp RGB packed 8:8:8 | |
145 RGB32, // 32bpp RGB packed with extra byte 8:8:8 | |
146 RGBA, // 32bpp RGBA packed 8:8:8:8 | |
147 YV12, // 12bpp YVU planar 1x1 Y, 2x2 VU samples | |
148 YV16, // 16bpp YVU planar 1x1 Y, 2x1 VU samples | |
149 EMPTY, // An empty frame. | |
150 }; | |
151 | |
152 // Surface format. | |
153 Format format; | |
154 | |
155 // Width and height of surface. | |
156 size_t width; | |
157 size_t height; | |
158 | |
159 // Number of planes, typically 1 for packed RGB formats and 3 for planar | |
160 // YUV formats. | |
161 size_t planes; | |
162 | |
163 // Array of strides for each plane, typically greater or equal to the width | |
164 // of the surface divided by the horizontal sampling period. Note that | |
165 // strides can be negative. | |
166 int32 strides[kMaxPlanes]; | |
167 | |
168 // Array of data pointers to each plane. | |
169 uint8* data[kMaxPlanes]; | |
170 }; | |
171 | |
172 | |
173 class VideoFrame : public StreamSample { | |
174 public: | |
175 // Locks the underlying surface and fills out the given VideoSurface and | |
176 // returns true if successful, false otherwise. Any additional calls to Lock | |
177 // will fail. | |
178 virtual bool Lock(VideoSurface* surface) = 0; | |
179 | |
180 // Unlocks the underlying surface, the VideoSurface acquired from Lock is no | |
181 // longer guaranteed to be valid. | |
182 virtual void Unlock() = 0; | |
183 | |
184 virtual bool IsEndOfStream() const = 0; | |
185 }; | |
186 | |
187 } // namespace media | 125 } // namespace media |
188 | 126 |
189 #endif // MEDIA_BASE_BUFFERS_H_ | 127 #endif // MEDIA_BASE_BUFFERS_H_ |
OLD | NEW |