OLD | NEW |
---|---|
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 <vector> | |
9 | |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/md5.h" | 11 #include "base/md5.h" |
10 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
13 #include "base/synchronization/lock.h" | |
11 #include "media/base/buffers.h" | 14 #include "media/base/buffers.h" |
12 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
13 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
14 | 17 |
15 class SkBitmap; | 18 class SkBitmap; |
16 | 19 |
17 namespace gpu { | 20 namespace gpu { |
18 struct MailboxHolder; | 21 struct MailboxHolder; |
19 } // namespace gpu | 22 } // namespace gpu |
20 | 23 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 static bool IsValidConfig(Format format, const gfx::Size& coded_size, | 81 static bool IsValidConfig(Format format, const gfx::Size& coded_size, |
79 const gfx::Rect& visible_rect, | 82 const gfx::Rect& visible_rect, |
80 const gfx::Size& natural_size); | 83 const gfx::Size& natural_size); |
81 | 84 |
82 // CB to write pixels from the texture backing this frame into the | 85 // CB to write pixels from the texture backing this frame into the |
83 // |const SkBitmap&| parameter. | 86 // |const SkBitmap&| parameter. |
84 typedef base::Callback<void(const SkBitmap&)> ReadPixelsCB; | 87 typedef base::Callback<void(const SkBitmap&)> ReadPixelsCB; |
85 | 88 |
86 // CB to be called on the mailbox backing this frame when the frame is | 89 // CB to be called on the mailbox backing this frame when the frame is |
87 // destroyed. | 90 // destroyed. |
88 typedef base::Callback<void(scoped_ptr<gpu::MailboxHolder>)> ReleaseMailboxCB; | 91 typedef base::Callback<void(const std::vector<uint32>&)> ReleaseMailboxCB; |
Ami GONE FROM CHROMIUM
2014/04/11 20:55:17
FYI this is now a blocker for https://code.google.
| |
89 | 92 |
90 // Wraps a native texture of the given parameters with a VideoFrame. The | 93 // Wraps a native texture of the given parameters with a VideoFrame. The |
91 // backing of the VideoFrame is held in the mailbox held by |mailbox_holder|, | 94 // backing of the VideoFrame is held in the mailbox held by |mailbox_holder|, |
92 // and |mailbox_holder_release_cb| will be called with |mailbox_holder| as the | 95 // and |mailbox_holder_release_cb| will be called with |mailbox_holder| as the |
93 // argument when the VideoFrame is to be destroyed. | 96 // argument when the VideoFrame is to be destroyed. |
94 // |coded_size| is the width and height of the frame data in pixels. | 97 // |coded_size| is the width and height of the frame data in pixels. |
95 // |visible_rect| is the visible portion of |coded_size|, after cropping (if | 98 // |visible_rect| is the visible portion of |coded_size|, after cropping (if |
96 // any) is applied. | 99 // any) is applied. |
97 // |natural_size| is the width and height of the frame when the frame's aspect | 100 // |natural_size| is the width and height of the frame when the frame's aspect |
98 // ratio is applied to |visible_rect|. | 101 // ratio is applied to |visible_rect|. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 // Returns true if this VideoFrame represents the end of the stream. | 221 // Returns true if this VideoFrame represents the end of the stream. |
219 bool end_of_stream() const { return end_of_stream_; } | 222 bool end_of_stream() const { return end_of_stream_; } |
220 | 223 |
221 base::TimeDelta GetTimestamp() const { | 224 base::TimeDelta GetTimestamp() const { |
222 return timestamp_; | 225 return timestamp_; |
223 } | 226 } |
224 void SetTimestamp(const base::TimeDelta& timestamp) { | 227 void SetTimestamp(const base::TimeDelta& timestamp) { |
225 timestamp_ = timestamp; | 228 timestamp_ = timestamp; |
226 } | 229 } |
227 | 230 |
231 // Append |sync_point| into |release_sync_points_| which will be passed to | |
232 // the video decoder when |mailbox_holder_release_cb_| is called so that | |
233 // the video decoder waits for the sync points before reusing the mailbox. | |
234 // Multiple clients can append multiple sync points in one frame. | |
Ami GONE FROM CHROMIUM
2014/04/11 20:55:17
s/in/to/
| |
235 // This method is thread safe. Both blink and compositor threads can call it. | |
236 void AppendReleaseSyncPoint(uint32 sync_point); | |
237 | |
228 // Used to keep a running hash of seen frames. Expects an initialized MD5 | 238 // Used to keep a running hash of seen frames. Expects an initialized MD5 |
229 // context. Calls MD5Update with the context and the contents of the frame. | 239 // context. Calls MD5Update with the context and the contents of the frame. |
230 void HashFrameForTesting(base::MD5Context* context); | 240 void HashFrameForTesting(base::MD5Context* context); |
231 | 241 |
232 private: | 242 private: |
233 friend class base::RefCountedThreadSafe<VideoFrame>; | 243 friend class base::RefCountedThreadSafe<VideoFrame>; |
234 // Clients must use the static CreateFrame() method to create a new frame. | 244 // Clients must use the static CreateFrame() method to create a new frame. |
235 VideoFrame(Format format, | 245 VideoFrame(Format format, |
236 const gfx::Size& coded_size, | 246 const gfx::Size& coded_size, |
237 const gfx::Rect& visible_rect, | 247 const gfx::Rect& visible_rect, |
(...skipping 23 matching lines...) Expand all Loading... | |
261 // Array of strides for each plane, typically greater or equal to the width | 271 // Array of strides for each plane, typically greater or equal to the width |
262 // of the surface divided by the horizontal sampling period. Note that | 272 // of the surface divided by the horizontal sampling period. Note that |
263 // strides can be negative. | 273 // strides can be negative. |
264 int32 strides_[kMaxPlanes]; | 274 int32 strides_[kMaxPlanes]; |
265 | 275 |
266 // Array of data pointers to each plane. | 276 // Array of data pointers to each plane. |
267 uint8* data_[kMaxPlanes]; | 277 uint8* data_[kMaxPlanes]; |
268 | 278 |
269 // Native texture mailbox, if this is a NATIVE_TEXTURE frame. | 279 // Native texture mailbox, if this is a NATIVE_TEXTURE frame. |
270 scoped_ptr<gpu::MailboxHolder> mailbox_holder_; | 280 scoped_ptr<gpu::MailboxHolder> mailbox_holder_; |
281 #ifndef NDEBUG | |
282 uint32 debug_initial_sync_point_; | |
283 #endif | |
271 ReleaseMailboxCB mailbox_holder_release_cb_; | 284 ReleaseMailboxCB mailbox_holder_release_cb_; |
272 ReadPixelsCB read_pixels_cb_; | 285 ReadPixelsCB read_pixels_cb_; |
273 | 286 |
274 // Shared memory handle, if this frame was allocated from shared memory. | 287 // Shared memory handle, if this frame was allocated from shared memory. |
275 base::SharedMemoryHandle shared_memory_handle_; | 288 base::SharedMemoryHandle shared_memory_handle_; |
276 | 289 |
277 base::Closure no_longer_needed_cb_; | 290 base::Closure no_longer_needed_cb_; |
278 | 291 |
279 base::TimeDelta timestamp_; | 292 base::TimeDelta timestamp_; |
280 | 293 |
294 base::Lock release_sync_point_lock_; | |
295 std::vector<uint32> release_sync_points_; | |
296 | |
281 const bool end_of_stream_; | 297 const bool end_of_stream_; |
282 | 298 |
283 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 299 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
284 }; | 300 }; |
285 | 301 |
286 } // namespace media | 302 } // namespace media |
287 | 303 |
288 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 304 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
OLD | NEW |