Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / media / base / video_frame.h
index 0696a55..5939c45 100644 (file)
@@ -86,7 +86,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
 
   // CB to be called on the mailbox backing this frame when the frame is
   // destroyed.
-  typedef base::Callback<void(const std::vector<uint32>&)> ReleaseMailboxCB;
+  typedef base::Callback<void(uint32)> ReleaseMailboxCB;
 
   // Wraps a native texture of the given parameters with a VideoFrame.  The
   // backing of the VideoFrame is held in the mailbox held by |mailbox_holder|,
@@ -114,6 +114,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
   // and plane count as given by |format|.  The shared memory handle of the
   // backing allocation, if present, can be passed in with |handle|.  When the
   // frame is destroyed, |no_longer_needed_cb.Run()| will be called.
+  // Returns NULL on failure.
   static scoped_refptr<VideoFrame> WrapExternalPackedMemory(
       Format format,
       const gfx::Size& coded_size,
@@ -136,6 +137,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
   // directly to a hardware device and/or to another process, or can also be
   // mapped via mmap() for CPU access.
   // When the frame is destroyed, |no_longer_needed_cb.Run()| will be called.
+  // Returns NULL on failure.
   static scoped_refptr<VideoFrame> WrapExternalDmabufs(
       Format format,
       const gfx::Size& coded_size,
@@ -187,6 +189,11 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
   // equivalent of RGB(0,0,0).
   static scoped_refptr<VideoFrame> CreateBlackFrame(const gfx::Size& size);
 
+  // Allocates YV12A frame based on |size|, and sets its data to the YUVA
+  // equivalent of RGBA(0,0,0,0).
+  static scoped_refptr<VideoFrame> CreateTransparentFrame(
+      const gfx::Size& size);
+
 #if defined(VIDEO_HOLE)
   // Allocates a hole frame.
   static scoped_refptr<VideoFrame> CreateHoleFrame(const gfx::Size& size);
@@ -254,12 +261,22 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
     timestamp_ = timestamp;
   }
 
-  // Append |sync_point| into |release_sync_points_| which will be passed to
-  // the video decoder when |mailbox_holder_release_cb_| is called so that
-  // the video decoder waits for the sync points before reusing the mailbox.
-  // Multiple clients can append multiple sync points on one frame.
+  class SyncPointClient {
+   public:
+    SyncPointClient() {}
+    virtual uint32 InsertSyncPoint() = 0;
+    virtual void WaitSyncPoint(uint32 sync_point) = 0;
+
+   protected:
+    virtual ~SyncPointClient() {}
+
+    DISALLOW_COPY_AND_ASSIGN(SyncPointClient);
+  };
+  // It uses |client| to insert a new sync point and potentially waits on a
+  // older sync point. The final sync point will be used to release this
+  // VideoFrame.
   // This method is thread safe. Both blink and compositor threads can call it.
-  void AppendReleaseSyncPoint(uint32 sync_point);
+  void UpdateReleaseSyncPoint(SyncPointClient* client);
 
   // Used to keep a running hash of seen frames.  Expects an initialized MD5
   // context.  Calls MD5Update with the context and the contents of the frame.
@@ -328,7 +345,7 @@ class MEDIA_EXPORT VideoFrame : public base::RefCountedThreadSafe<VideoFrame> {
   base::TimeDelta timestamp_;
 
   base::Lock release_sync_point_lock_;
-  std::vector<uint32> release_sync_points_;
+  uint32 release_sync_point_;
 
   const bool end_of_stream_;