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

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

Issue 312803002: Android media: VideoFrame should not store so many sync points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits Created 6 years, 5 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
« no previous file with comments | « content/renderer/media/webmediaplayer_impl.cc ('k') | media/base/video_frame.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector>
9
10 #include "base/callback.h" 8 #include "base/callback.h"
11 #include "base/md5.h" 9 #include "base/md5.h"
12 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
13 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
14 #include "media/base/buffers.h" 12 #include "media/base/buffers.h"
15 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
16 #include "ui/gfx/size.h" 14 #include "ui/gfx/size.h"
17 15
18 class SkBitmap; 16 class SkBitmap;
19 17
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 static bool IsValidConfig(Format format, const gfx::Size& coded_size, 77 static bool IsValidConfig(Format format, const gfx::Size& coded_size,
80 const gfx::Rect& visible_rect, 78 const gfx::Rect& visible_rect,
81 const gfx::Size& natural_size); 79 const gfx::Size& natural_size);
82 80
83 // CB to write pixels from the texture backing this frame into the 81 // CB to write pixels from the texture backing this frame into the
84 // |const SkBitmap&| parameter. 82 // |const SkBitmap&| parameter.
85 typedef base::Callback<void(const SkBitmap&)> ReadPixelsCB; 83 typedef base::Callback<void(const SkBitmap&)> ReadPixelsCB;
86 84
87 // CB to be called on the mailbox backing this frame when the frame is 85 // CB to be called on the mailbox backing this frame when the frame is
88 // destroyed. 86 // destroyed.
89 typedef base::Callback<void(const std::vector<uint32>&)> ReleaseMailboxCB; 87 typedef base::Callback<void(uint32)> ReleaseMailboxCB;
90 88
91 // Wraps a native texture of the given parameters with a VideoFrame. The 89 // 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|, 90 // 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 91 // and |mailbox_holder_release_cb| will be called with |mailbox_holder| as the
94 // argument when the VideoFrame is to be destroyed. 92 // argument when the VideoFrame is to be destroyed.
95 // |read_pixels_cb| may be used to do (slow!) readbacks from the 93 // |read_pixels_cb| may be used to do (slow!) readbacks from the
96 // texture to main memory. 94 // texture to main memory.
97 static scoped_refptr<VideoFrame> WrapNativeTexture( 95 static scoped_refptr<VideoFrame> WrapNativeTexture(
98 scoped_ptr<gpu::MailboxHolder> mailbox_holder, 96 scoped_ptr<gpu::MailboxHolder> mailbox_holder,
99 const ReleaseMailboxCB& mailbox_holder_release_cb, 97 const ReleaseMailboxCB& mailbox_holder_release_cb,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // The image data is only accessible via dmabuf fds, which are usually passed 134 // The image data is only accessible via dmabuf fds, which are usually passed
137 // directly to a hardware device and/or to another process, or can also be 135 // directly to a hardware device and/or to another process, or can also be
138 // mapped via mmap() for CPU access. 136 // mapped via mmap() for CPU access.
139 // When the frame is destroyed, |no_longer_needed_cb.Run()| will be called. 137 // When the frame is destroyed, |no_longer_needed_cb.Run()| will be called.
140 // Returns NULL on failure. 138 // Returns NULL on failure.
141 static scoped_refptr<VideoFrame> WrapExternalDmabufs( 139 static scoped_refptr<VideoFrame> WrapExternalDmabufs(
142 Format format, 140 Format format,
143 const gfx::Size& coded_size, 141 const gfx::Size& coded_size,
144 const gfx::Rect& visible_rect, 142 const gfx::Rect& visible_rect,
145 const gfx::Size& natural_size, 143 const gfx::Size& natural_size,
146 const std::vector<int> dmabuf_fds, 144 const std::vector<int> dmabuf_fds,
xhwang 2014/07/14 15:40:31 keep include <vector> for this
147 base::TimeDelta timestamp, 145 base::TimeDelta timestamp,
148 const base::Closure& no_longer_needed_cb); 146 const base::Closure& no_longer_needed_cb);
149 #endif 147 #endif
150 148
151 // Wraps external YUV data of the given parameters with a VideoFrame. 149 // Wraps external YUV data of the given parameters with a VideoFrame.
152 // The returned VideoFrame does not own the data passed in. When the frame 150 // The returned VideoFrame does not own the data passed in. When the frame
153 // is destroyed |no_longer_needed_cb.Run()| will be called. 151 // is destroyed |no_longer_needed_cb.Run()| will be called.
154 // TODO(sheu): merge this into WrapExternalSharedMemory(). 152 // TODO(sheu): merge this into WrapExternalSharedMemory().
155 // http://crbug.com/270217 153 // http://crbug.com/270217
156 static scoped_refptr<VideoFrame> WrapExternalYuvData( 154 static scoped_refptr<VideoFrame> WrapExternalYuvData(
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // Returns true if this VideoFrame represents the end of the stream. 247 // Returns true if this VideoFrame represents the end of the stream.
250 bool end_of_stream() const { return end_of_stream_; } 248 bool end_of_stream() const { return end_of_stream_; }
251 249
252 base::TimeDelta timestamp() const { 250 base::TimeDelta timestamp() const {
253 return timestamp_; 251 return timestamp_;
254 } 252 }
255 void set_timestamp(const base::TimeDelta& timestamp) { 253 void set_timestamp(const base::TimeDelta& timestamp) {
256 timestamp_ = timestamp; 254 timestamp_ = timestamp;
257 } 255 }
258 256
259 // Append |sync_point| into |release_sync_points_| which will be passed to 257 class SyncPointClient {
260 // the video decoder when |mailbox_holder_release_cb_| is called so that 258 public:
261 // the video decoder waits for the sync points before reusing the mailbox. 259 SyncPointClient() {}
262 // Multiple clients can append multiple sync points on one frame. 260 virtual uint32 InsertSyncPoint() = 0;
261 virtual void WaitSyncPoint(uint32 sync_point) = 0;
262
263 protected:
264 virtual ~SyncPointClient() {}
265
266 DISALLOW_COPY_AND_ASSIGN(SyncPointClient);
267 };
268 // It uses |client| to insert a new sync point and potentially waits on a
269 // older sync point. The final sync point will be used to release this
270 // VideoFrame.
263 // This method is thread safe. Both blink and compositor threads can call it. 271 // This method is thread safe. Both blink and compositor threads can call it.
264 void AppendReleaseSyncPoint(uint32 sync_point); 272 void UpdateReleaseSyncPoint(SyncPointClient* client);
265 273
266 // Used to keep a running hash of seen frames. Expects an initialized MD5 274 // Used to keep a running hash of seen frames. Expects an initialized MD5
267 // context. Calls MD5Update with the context and the contents of the frame. 275 // context. Calls MD5Update with the context and the contents of the frame.
268 void HashFrameForTesting(base::MD5Context* context); 276 void HashFrameForTesting(base::MD5Context* context);
269 277
270 private: 278 private:
271 friend class base::RefCountedThreadSafe<VideoFrame>; 279 friend class base::RefCountedThreadSafe<VideoFrame>;
272 // Clients must use the static CreateFrame() method to create a new frame. 280 // Clients must use the static CreateFrame() method to create a new frame.
273 VideoFrame(Format format, 281 VideoFrame(Format format,
274 const gfx::Size& coded_size, 282 const gfx::Size& coded_size,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // Dmabufs for each plane, if this frame is wrapping memory 331 // Dmabufs for each plane, if this frame is wrapping memory
324 // acquired via dmabuf. 332 // acquired via dmabuf.
325 base::ScopedFD dmabuf_fds_[kMaxPlanes]; 333 base::ScopedFD dmabuf_fds_[kMaxPlanes];
326 #endif 334 #endif
327 335
328 base::Closure no_longer_needed_cb_; 336 base::Closure no_longer_needed_cb_;
329 337
330 base::TimeDelta timestamp_; 338 base::TimeDelta timestamp_;
331 339
332 base::Lock release_sync_point_lock_; 340 base::Lock release_sync_point_lock_;
333 std::vector<uint32> release_sync_points_; 341 uint32 release_sync_point_;
334 342
335 const bool end_of_stream_; 343 const bool end_of_stream_;
336 344
337 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame); 345 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoFrame);
338 }; 346 };
339 347
340 } // namespace media 348 } // namespace media
341 349
342 #endif // MEDIA_BASE_VIDEO_FRAME_H_ 350 #endif // MEDIA_BASE_VIDEO_FRAME_H_
OLDNEW
« no previous file with comments | « content/renderer/media/webmediaplayer_impl.cc ('k') | media/base/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698