| 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> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 static bool IsValidConfig(Format format, const gfx::Size& coded_size, | 79 static bool IsValidConfig(Format format, const gfx::Size& coded_size, |
| 80 const gfx::Rect& visible_rect, | 80 const gfx::Rect& visible_rect, |
| 81 const gfx::Size& natural_size); | 81 const gfx::Size& natural_size); |
| 82 | 82 |
| 83 // CB to write pixels from the texture backing this frame into the | 83 // CB to write pixels from the texture backing this frame into the |
| 84 // |const SkBitmap&| parameter. | 84 // |const SkBitmap&| parameter. |
| 85 typedef base::Callback<void(const SkBitmap&)> ReadPixelsCB; | 85 typedef base::Callback<void(const SkBitmap&)> ReadPixelsCB; |
| 86 | 86 |
| 87 // CB to be called on the mailbox backing this frame when the frame is | 87 // CB to be called on the mailbox backing this frame when the frame is |
| 88 // destroyed. | 88 // destroyed. |
| 89 typedef base::Callback<void(const std::vector<uint32>&)> ReleaseMailboxCB; | 89 typedef base::Callback<void(uint32)> ReleaseMailboxCB; |
| 90 | 90 |
| 91 // Wraps a native texture of the given parameters with a VideoFrame. The | 91 // Wraps a native texture of the given parameters with a VideoFrame. The |
| 92 // backing of the VideoFrame is held in the mailbox held by |mailbox_holder|, | 92 // backing of the VideoFrame is held in the mailbox held by |mailbox_holder|, |
| 93 // and |mailbox_holder_release_cb| will be called with |mailbox_holder| as the | 93 // and |mailbox_holder_release_cb| will be called with |mailbox_holder| as the |
| 94 // argument when the VideoFrame is to be destroyed. | 94 // argument when the VideoFrame is to be destroyed. |
| 95 // |read_pixels_cb| may be used to do (slow!) readbacks from the | 95 // |read_pixels_cb| may be used to do (slow!) readbacks from the |
| 96 // texture to main memory. | 96 // texture to main memory. |
| 97 static scoped_refptr<VideoFrame> WrapNativeTexture( | 97 static scoped_refptr<VideoFrame> WrapNativeTexture( |
| 98 scoped_ptr<gpu::MailboxHolder> mailbox_holder, | 98 scoped_ptr<gpu::MailboxHolder> mailbox_holder, |
| 99 const ReleaseMailboxCB& mailbox_holder_release_cb, | 99 const ReleaseMailboxCB& mailbox_holder_release_cb, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // Returns true if this VideoFrame represents the end of the stream. | 254 // Returns true if this VideoFrame represents the end of the stream. |
| 255 bool end_of_stream() const { return end_of_stream_; } | 255 bool end_of_stream() const { return end_of_stream_; } |
| 256 | 256 |
| 257 base::TimeDelta timestamp() const { | 257 base::TimeDelta timestamp() const { |
| 258 return timestamp_; | 258 return timestamp_; |
| 259 } | 259 } |
| 260 void set_timestamp(const base::TimeDelta& timestamp) { | 260 void set_timestamp(const base::TimeDelta& timestamp) { |
| 261 timestamp_ = timestamp; | 261 timestamp_ = timestamp; |
| 262 } | 262 } |
| 263 | 263 |
| 264 // Append |sync_point| into |release_sync_points_| which will be passed to | 264 class SyncPointClient { |
| 265 // the video decoder when |mailbox_holder_release_cb_| is called so that | 265 public: |
| 266 // the video decoder waits for the sync points before reusing the mailbox. | 266 SyncPointClient() {} |
| 267 // Multiple clients can append multiple sync points on one frame. | 267 virtual uint32 InsertSyncPoint() = 0; |
| 268 virtual void WaitSyncPoint(uint32 sync_point) = 0; |
| 269 |
| 270 protected: |
| 271 virtual ~SyncPointClient() {} |
| 272 |
| 273 DISALLOW_COPY_AND_ASSIGN(SyncPointClient); |
| 274 }; |
| 275 // It uses |client| to insert a new sync point and potentially waits on a |
| 276 // older sync point. The final sync point will be used to release this |
| 277 // VideoFrame. |
| 268 // This method is thread safe. Both blink and compositor threads can call it. | 278 // This method is thread safe. Both blink and compositor threads can call it. |
| 269 void AppendReleaseSyncPoint(uint32 sync_point); | 279 void UpdateReleaseSyncPoint(SyncPointClient* client); |
| 270 | 280 |
| 271 // Used to keep a running hash of seen frames. Expects an initialized MD5 | 281 // Used to keep a running hash of seen frames. Expects an initialized MD5 |
| 272 // context. Calls MD5Update with the context and the contents of the frame. | 282 // context. Calls MD5Update with the context and the contents of the frame. |
| 273 void HashFrameForTesting(base::MD5Context* context); | 283 void HashFrameForTesting(base::MD5Context* context); |
| 274 | 284 |
| 275 private: | 285 private: |
| 276 friend class base::RefCountedThreadSafe<VideoFrame>; | 286 friend class base::RefCountedThreadSafe<VideoFrame>; |
| 277 // Clients must use the static CreateFrame() method to create a new frame. | 287 // Clients must use the static CreateFrame() method to create a new frame. |
| 278 VideoFrame(Format format, | 288 VideoFrame(Format format, |
| 279 const gfx::Size& coded_size, | 289 const gfx::Size& coded_size, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 // Dmabufs for each plane, if this frame is wrapping memory | 338 // Dmabufs for each plane, if this frame is wrapping memory |
| 329 // acquired via dmabuf. | 339 // acquired via dmabuf. |
| 330 base::ScopedFD dmabuf_fds_[kMaxPlanes]; | 340 base::ScopedFD dmabuf_fds_[kMaxPlanes]; |
| 331 #endif | 341 #endif |
| 332 | 342 |
| 333 base::Closure no_longer_needed_cb_; | 343 base::Closure no_longer_needed_cb_; |
| 334 | 344 |
| 335 base::TimeDelta timestamp_; | 345 base::TimeDelta timestamp_; |
| 336 | 346 |
| 337 base::Lock release_sync_point_lock_; | 347 base::Lock release_sync_point_lock_; |
| 338 std::vector<uint32> release_sync_points_; | 348 uint32 release_sync_point_; |
| 339 | 349 |
| 340 const bool end_of_stream_; | 350 const bool end_of_stream_; |
| 341 | 351 |
| 342 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 352 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
| 343 }; | 353 }; |
| 344 | 354 |
| 345 } // namespace media | 355 } // namespace media |
| 346 | 356 |
| 347 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 357 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
| OLD | NEW |