Index: webkit/media/crypto/ppapi/ffmpeg_cdm_video_frame.h |
diff --git a/webkit/media/crypto/ppapi/ffmpeg_cdm_video_frame.h b/webkit/media/crypto/ppapi/ffmpeg_cdm_video_frame.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6f6c4e029c97c8ff0e93d9911ba46bee011a764c |
--- /dev/null |
+++ b/webkit/media/crypto/ppapi/ffmpeg_cdm_video_frame.h |
@@ -0,0 +1,74 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_VIDEO_FRAME_H_ |
+#define WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_VIDEO_FRAME_H_ |
+ |
+#include "base/basictypes.h" |
+#include "base/compiler_specific.h" |
+#include "webkit/media/crypto/ppapi/content_decryption_module.h" |
+ |
+namespace webkit_media { |
+ |
+// Allocates storage for video frames using cdm::Allocator, and contains all |
+// the information necessary to read and write the video frame data. |
+class FFmpegCdmVideoFrame { |
+ public: |
+ ~FFmpegCdmVideoFrame(); |
+ |
+ // Returns a pointer to FFmpegCdmVideoFrame of the specified |format| and |
+ // |size|. Returns NULL on failure. |
+ static FFmpegCdmVideoFrame* Create(cdm::Allocator* allocator, |
+ cdm::VideoFormat format, |
+ const cdm::Size& size); |
+ |
+ cdm::VideoFormat format() const { return format_; } |
+ cdm::Buffer* frame_buffer() { return frame_buffer_; } |
+ const cdm::Size& size() const { return size_; } |
+ |
+ int32_t plane_offset(cdm::VideoFrame::VideoPlane plane) const; |
+ int32_t stride(cdm::VideoFrame::VideoPlane plane) const; |
+ |
+ // Returns true when |format| and |data_size| can be used to create a valid |
+ // FFmpegCdmVideoFrame. |
+ static bool IsValidConfig(cdm::VideoFormat format, |
+ const cdm::Size& data_size); |
+ |
+ // Transfers ownership of |frame_buffer_| to |target|, and copies all video |
+ // frame meta data stored in FFmpegCdmVideoFrame. |
+ void TransferVideoFrame(cdm::VideoFrame* target); |
xhwang
2012/10/17 18:43:00
nit: s/Transfer/Pass? We use "pass/take" in chrome
Tom Finegan
2012/10/17 19:55:44
Used Pass.
|
+ |
+ private: |
+ // Clients must use the static Create() method to create a new frame. |
+ FFmpegCdmVideoFrame(cdm::VideoFormat format, const cdm::Size& size); |
+ |
+ // Allocates a YUV video frame buffer of type |format_| using |size_|. |
+ // Returns true when the frame buffer is successfully allocated. Returns |
+ // false otherwise. |
+ bool AllocateYuv(cdm::Allocator* allocator); |
+ |
+ // The video buffer format. |
+ cdm::VideoFormat format_; |
+ |
+ // Width and height of the video frame. |
+ cdm::Size size_; |
+ |
+ // The video frame buffer. Owned by FFmpegCdmVideoFrame until |
+ // ReleaseCdmBuffer() is called. |
+ cdm::Buffer* frame_buffer_; |
+ |
+ // Array of data pointers to each plane in the video frame buffer. |
+ int32_t plane_offsets_[cdm::VideoFrame::kMaxPlanes]; |
+ |
+ // Array of strides for each plane, typically greater or equal to the width |
+ // of the surface divided by the horizontal sampling period. Note that |
+ // strides can be negative. |
+ int32_t strides_[cdm::VideoFrame::kMaxPlanes]; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(FFmpegCdmVideoFrame); |
+}; |
+ |
+} // namespace webkit_media |
+ |
+#endif // WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_VIDEO_FRAME_H_ |