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

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

Issue 14199002: Send hardware video frames with mailboxes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef MEDIA_BASE_VIDEO_FRAME_H_ 5 #ifndef MEDIA_BASE_VIDEO_FRAME_H_
6 #define MEDIA_BASE_VIDEO_FRAME_H_ 6 #define MEDIA_BASE_VIDEO_FRAME_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/md5.h" 9 #include "base/md5.h"
10 #include "gpu/command_buffer/common/mailbox.h"
10 #include "media/base/buffers.h" 11 #include "media/base/buffers.h"
11 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
12 #include "ui/gfx/size.h" 13 #include "ui/gfx/size.h"
13 14
14 class SkBitmap; 15 class SkBitmap;
15 16
16 namespace media { 17 namespace media {
17 18
18 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> { 19 class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
19 public: 20 public:
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // frame is destroyed |no_longer_needed_cb.Run()| will be called. 79 // frame is destroyed |no_longer_needed_cb.Run()| will be called.
79 // |coded_size| is the width and height of the frame data in pixels. 80 // |coded_size| is the width and height of the frame data in pixels.
80 // |visible_rect| is the visible portion of |coded_size|, after cropping (if 81 // |visible_rect| is the visible portion of |coded_size|, after cropping (if
81 // any) is applied. 82 // any) is applied.
82 // |natural_size| is the width and height of the frame when the frame's aspect 83 // |natural_size| is the width and height of the frame when the frame's aspect
83 // ratio is applied to |visible_rect|. 84 // ratio is applied to |visible_rect|.
84 85
85 // |read_pixels_cb| may be used to do (slow!) readbacks from the 86 // |read_pixels_cb| may be used to do (slow!) readbacks from the
86 // texture to main memory. 87 // texture to main memory.
87 static scoped_refptr<VideoFrame> WrapNativeTexture( 88 static scoped_refptr<VideoFrame> WrapNativeTexture(
88 uint32 texture_id, 89 const gpu::Mailbox& texture_mailbox,
89 uint32 texture_target, 90 uint32 texture_target,
90 const gfx::Size& coded_size, 91 const gfx::Size& coded_size,
91 const gfx::Rect& visible_rect, 92 const gfx::Rect& visible_rect,
92 const gfx::Size& natural_size, 93 const gfx::Size& natural_size,
93 base::TimeDelta timestamp, 94 base::TimeDelta timestamp,
94 const ReadPixelsCB& read_pixels_cb, 95 const ReadPixelsCB& read_pixels_cb,
95 const base::Closure& no_longer_needed_cb); 96 const base::Closure& no_longer_needed_cb);
96 97
97 // Read pixels from the native texture backing |*this| and write 98 // Read pixels from the native texture backing |*this| and write
98 // them to |pixels| as BGRA. |pixels| must point to a buffer at 99 // them to |pixels| as BGRA. |pixels| must point to a buffer at
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // 150 //
150 // As opposed to stride(), row_bytes() refers to the bytes representing 151 // As opposed to stride(), row_bytes() refers to the bytes representing
151 // frame data scanlines (coded_size.width() pixels, without stride padding). 152 // frame data scanlines (coded_size.width() pixels, without stride padding).
152 int row_bytes(size_t plane) const; 153 int row_bytes(size_t plane) const;
153 int rows(size_t plane) const; 154 int rows(size_t plane) const;
154 155
155 // Returns pointer to the buffer for a given plane. The memory is owned by 156 // Returns pointer to the buffer for a given plane. The memory is owned by
156 // VideoFrame object and must not be freed by the caller. 157 // VideoFrame object and must not be freed by the caller.
157 uint8* data(size_t plane) const; 158 uint8* data(size_t plane) const;
158 159
159 // Returns the ID of the native texture wrapped by this frame. Only valid to 160 // Returns the mailbox of the native texture wrapped by this frame. Only
160 // call if this is a NATIVE_TEXTURE frame. 161 // valid to call if this is a NATIVE_TEXTURE frame.
161 uint32 texture_id() const; 162 const gpu::Mailbox& texture_mailbox() const;
162 163
163 // Returns the texture target. Only valid for NATIVE_TEXTURE frames. 164 // Returns the texture target. Only valid for NATIVE_TEXTURE frames.
164 uint32 texture_target() const; 165 uint32 texture_target() const;
165 166
166 // Returns true if this VideoFrame represents the end of the stream. 167 // Returns true if this VideoFrame represents the end of the stream.
167 bool IsEndOfStream() const; 168 bool IsEndOfStream() const;
168 169
169 base::TimeDelta GetTimestamp() const { 170 base::TimeDelta GetTimestamp() const {
170 return timestamp_; 171 return timestamp_;
171 } 172 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 gfx::Size natural_size_; 209 gfx::Size natural_size_;
209 210
210 // Array of strides for each plane, typically greater or equal to the width 211 // Array of strides for each plane, typically greater or equal to the width
211 // of the surface divided by the horizontal sampling period. Note that 212 // of the surface divided by the horizontal sampling period. Note that
212 // strides can be negative. 213 // strides can be negative.
213 int32 strides_[kMaxPlanes]; 214 int32 strides_[kMaxPlanes];
214 215
215 // Array of data pointers to each plane. 216 // Array of data pointers to each plane.
216 uint8* data_[kMaxPlanes]; 217 uint8* data_[kMaxPlanes];
217 218
218 // Native texture ID, if this is a NATIVE_TEXTURE frame. 219 // Native texture mailbox, if this is a NATIVE_TEXTURE frame.
219 uint32 texture_id_; 220 gpu::Mailbox texture_mailbox_;
220 uint32 texture_target_; 221 uint32 texture_target_;
221 ReadPixelsCB read_pixels_cb_; 222 ReadPixelsCB read_pixels_cb_;
222 223
223 base::Closure no_longer_needed_cb_; 224 base::Closure no_longer_needed_cb_;
224 225
225 base::TimeDelta timestamp_; 226 base::TimeDelta timestamp_;
226 227
227 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 228 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
228 }; 229 };
229 230
230 } // namespace media 231 } // namespace media
231 232
232 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 233 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698