| 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" |
| 11 #include "base/macros.h" |
| 11 #include "base/md5.h" | 12 #include "base/md5.h" |
| 12 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
| 13 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 14 #include "gpu/command_buffer/common/mailbox_holder.h" | 15 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 15 #include "media/base/video_frame_metadata.h" | 16 #include "media/base/video_frame_metadata.h" |
| 16 #include "media/base/video_types.h" | 17 #include "media/base/video_types.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
| 18 #include "ui/gfx/geometry/size.h" | 19 #include "ui/gfx/geometry/size.h" |
| 19 #include "ui/gfx/gpu_memory_buffer.h" | 20 #include "ui/gfx/gpu_memory_buffer.h" |
| 20 | 21 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // is, in principle, platform independent, see http://crbug.com/323157 and | 66 // is, in principle, platform independent, see http://crbug.com/323157 and |
| 66 // https://groups.google.com/a/google.com/d/topic/chrome-gpu/eIM1RwarUmk/dis
cussion | 67 // https://groups.google.com/a/google.com/d/topic/chrome-gpu/eIM1RwarUmk/dis
cussion |
| 67 STORAGE_HOLE = 6, | 68 STORAGE_HOLE = 6, |
| 68 #endif | 69 #endif |
| 69 STORAGE_GPU_MEMORY_BUFFERS = 7, | 70 STORAGE_GPU_MEMORY_BUFFERS = 7, |
| 70 STORAGE_LAST = STORAGE_GPU_MEMORY_BUFFERS, | 71 STORAGE_LAST = STORAGE_GPU_MEMORY_BUFFERS, |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 // CB to be called on the mailbox backing this frame when the frame is | 74 // CB to be called on the mailbox backing this frame when the frame is |
| 74 // destroyed. | 75 // destroyed. |
| 75 typedef base::Callback<void(uint32)> ReleaseMailboxCB; | 76 typedef base::Callback<void(const gpu::SyncToken&)> ReleaseMailboxCB; |
| 76 | 77 |
| 77 // Interface representing client operations on a SyncPoint, i.e. insert one in | 78 // Interface representing client operations on a SyncToken, i.e. insert one in |
| 78 // the GPU Command Buffer and wait for it. | 79 // the GPU Command Buffer and wait for it. |
| 79 class SyncPointClient { | 80 class SyncTokenClient { |
| 80 public: | 81 public: |
| 81 SyncPointClient() {} | 82 SyncTokenClient() {} |
| 82 virtual uint32 InsertSyncPoint() = 0; | 83 virtual uint32 InsertSyncPoint() = 0; |
| 83 virtual void WaitSyncPoint(uint32 sync_point) = 0; | 84 virtual void WaitSyncToken(const gpu::SyncToken& sync_token) = 0; |
| 84 | 85 |
| 85 protected: | 86 protected: |
| 86 virtual ~SyncPointClient() {} | 87 virtual ~SyncTokenClient() {} |
| 87 | 88 |
| 88 DISALLOW_COPY_AND_ASSIGN(SyncPointClient); | 89 DISALLOW_COPY_AND_ASSIGN(SyncTokenClient); |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 // Call prior to CreateFrame to ensure validity of frame configuration. Called | 92 // Call prior to CreateFrame to ensure validity of frame configuration. Called |
| 92 // automatically by VideoDecoderConfig::IsValidConfig(). | 93 // automatically by VideoDecoderConfig::IsValidConfig(). |
| 93 static bool IsValidConfig(VideoPixelFormat format, | 94 static bool IsValidConfig(VideoPixelFormat format, |
| 94 StorageType storage_type, | 95 StorageType storage_type, |
| 95 const gfx::Size& coded_size, | 96 const gfx::Size& coded_size, |
| 96 const gfx::Rect& visible_rect, | 97 const gfx::Rect& visible_rect, |
| 97 const gfx::Size& natural_size); | 98 const gfx::Size& natural_size); |
| 98 | 99 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 112 static scoped_refptr<VideoFrame> CreateZeroInitializedFrame( | 113 static scoped_refptr<VideoFrame> CreateZeroInitializedFrame( |
| 113 VideoPixelFormat format, | 114 VideoPixelFormat format, |
| 114 const gfx::Size& coded_size, | 115 const gfx::Size& coded_size, |
| 115 const gfx::Rect& visible_rect, | 116 const gfx::Rect& visible_rect, |
| 116 const gfx::Size& natural_size, | 117 const gfx::Size& natural_size, |
| 117 base::TimeDelta timestamp); | 118 base::TimeDelta timestamp); |
| 118 | 119 |
| 119 // Wraps a native texture of the given parameters with a VideoFrame. | 120 // Wraps a native texture of the given parameters with a VideoFrame. |
| 120 // The backing of the VideoFrame is held in the mailbox held by | 121 // The backing of the VideoFrame is held in the mailbox held by |
| 121 // |mailbox_holder|, and |mailbox_holder_release_cb| will be called with | 122 // |mailbox_holder|, and |mailbox_holder_release_cb| will be called with |
| 122 // a syncpoint as the argument when the VideoFrame is to be destroyed. | 123 // a sync token as the argument when the VideoFrame is to be destroyed. |
| 123 static scoped_refptr<VideoFrame> WrapNativeTexture( | 124 static scoped_refptr<VideoFrame> WrapNativeTexture( |
| 124 VideoPixelFormat format, | 125 VideoPixelFormat format, |
| 125 const gpu::MailboxHolder& mailbox_holder, | 126 const gpu::MailboxHolder& mailbox_holder, |
| 126 const ReleaseMailboxCB& mailbox_holder_release_cb, | 127 const ReleaseMailboxCB& mailbox_holder_release_cb, |
| 127 const gfx::Size& coded_size, | 128 const gfx::Size& coded_size, |
| 128 const gfx::Rect& visible_rect, | 129 const gfx::Rect& visible_rect, |
| 129 const gfx::Size& natural_size, | 130 const gfx::Size& natural_size, |
| 130 base::TimeDelta timestamp); | 131 base::TimeDelta timestamp); |
| 131 | 132 |
| 132 // Wraps a set of native textures representing YUV data with a VideoFrame. | 133 // Wraps a set of native textures representing YUV data with a VideoFrame. |
| 133 // |mailbox_holders_release_cb| will be called with a syncpoint as the | 134 // |mailbox_holders_release_cb| will be called with a sync token as the |
| 134 // argument when the VideoFrame is to be destroyed. | 135 // argument when the VideoFrame is to be destroyed. |
| 135 static scoped_refptr<VideoFrame> WrapYUV420NativeTextures( | 136 static scoped_refptr<VideoFrame> WrapYUV420NativeTextures( |
| 136 const gpu::MailboxHolder& y_mailbox_holder, | 137 const gpu::MailboxHolder& y_mailbox_holder, |
| 137 const gpu::MailboxHolder& u_mailbox_holder, | 138 const gpu::MailboxHolder& u_mailbox_holder, |
| 138 const gpu::MailboxHolder& v_mailbox_holder, | 139 const gpu::MailboxHolder& v_mailbox_holder, |
| 139 const ReleaseMailboxCB& mailbox_holders_release_cb, | 140 const ReleaseMailboxCB& mailbox_holders_release_cb, |
| 140 const gfx::Size& coded_size, | 141 const gfx::Size& coded_size, |
| 141 const gfx::Rect& visible_rect, | 142 const gfx::Rect& visible_rect, |
| 142 const gfx::Size& natural_size, | 143 const gfx::Size& natural_size, |
| 143 base::TimeDelta timestamp); | 144 base::TimeDelta timestamp); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 // See VideoFrameMetadata::REFERENCE_TIME for details. | 395 // See VideoFrameMetadata::REFERENCE_TIME for details. |
| 395 base::TimeDelta timestamp() const { return timestamp_; } | 396 base::TimeDelta timestamp() const { return timestamp_; } |
| 396 void set_timestamp(base::TimeDelta timestamp) { | 397 void set_timestamp(base::TimeDelta timestamp) { |
| 397 timestamp_ = timestamp; | 398 timestamp_ = timestamp; |
| 398 } | 399 } |
| 399 | 400 |
| 400 // It uses |client| to insert a new sync point and potentially waits on a | 401 // It uses |client| to insert a new sync point and potentially waits on a |
| 401 // older sync point. The final sync point will be used to release this | 402 // older sync point. The final sync point will be used to release this |
| 402 // VideoFrame. | 403 // VideoFrame. |
| 403 // This method is thread safe. Both blink and compositor threads can call it. | 404 // This method is thread safe. Both blink and compositor threads can call it. |
| 404 void UpdateReleaseSyncPoint(SyncPointClient* client); | 405 void UpdateReleaseSyncToken(SyncTokenClient* client); |
| 405 | 406 |
| 406 private: | 407 private: |
| 407 friend class base::RefCountedThreadSafe<VideoFrame>; | 408 friend class base::RefCountedThreadSafe<VideoFrame>; |
| 408 | 409 |
| 409 static scoped_refptr<VideoFrame> WrapExternalStorage( | 410 static scoped_refptr<VideoFrame> WrapExternalStorage( |
| 410 VideoPixelFormat format, | 411 VideoPixelFormat format, |
| 411 StorageType storage_type, | 412 StorageType storage_type, |
| 412 const gfx::Size& coded_size, | 413 const gfx::Size& coded_size, |
| 413 const gfx::Rect& visible_rect, | 414 const gfx::Rect& visible_rect, |
| 414 const gfx::Size& natural_size, | 415 const gfx::Size& natural_size, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 | 505 |
| 505 #if defined(OS_MACOSX) | 506 #if defined(OS_MACOSX) |
| 506 // CVPixelBuffer, if this frame is wrapping one. | 507 // CVPixelBuffer, if this frame is wrapping one. |
| 507 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_; | 508 base::ScopedCFTypeRef<CVPixelBufferRef> cv_pixel_buffer_; |
| 508 #endif | 509 #endif |
| 509 | 510 |
| 510 std::vector<base::Closure> done_callbacks_; | 511 std::vector<base::Closure> done_callbacks_; |
| 511 | 512 |
| 512 base::TimeDelta timestamp_; | 513 base::TimeDelta timestamp_; |
| 513 | 514 |
| 514 base::Lock release_sync_point_lock_; | 515 base::Lock release_sync_token_lock_; |
| 515 uint32 release_sync_point_; | 516 gpu::SyncToken release_sync_token_; |
| 516 | 517 |
| 517 VideoFrameMetadata metadata_; | 518 VideoFrameMetadata metadata_; |
| 518 | 519 |
| 519 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); | 520 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); |
| 520 }; | 521 }; |
| 521 | 522 |
| 522 } // namespace media | 523 } // namespace media |
| 523 | 524 |
| 524 #endif // MEDIA_BASE_VIDEO_FRAME_H_ | 525 #endif // MEDIA_BASE_VIDEO_FRAME_H_ |
| OLD | NEW |