Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_VIDEO_FRAME_H_ | |
| 6 #define WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_VIDEO_FRAME_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "webkit/media/crypto/ppapi/content_decryption_module.h" | |
| 11 | |
| 12 namespace webkit_media { | |
| 13 | |
| 14 // Allocates storage for video frames using cdm::Allocator, and contains all | |
| 15 // the information necessary to read and write the video frame data. | |
| 16 class FFmpegCdmVideoFrame { | |
| 17 public: | |
| 18 ~FFmpegCdmVideoFrame(); | |
| 19 | |
| 20 // Returns a pointer to FFmpegCdmVideoFrame of the specified |format| and | |
| 21 // |size|. Returns NULL on failure. | |
| 22 static FFmpegCdmVideoFrame* Create(cdm::Allocator* allocator, | |
| 23 cdm::VideoFormat format, | |
| 24 const cdm::Size& size); | |
| 25 | |
| 26 cdm::VideoFormat format() const { return format_; } | |
| 27 cdm::Buffer* frame_buffer() { return frame_buffer_; } | |
| 28 const cdm::Size& size() const { return size_; } | |
| 29 | |
| 30 int32_t plane_offset(cdm::VideoFrame::VideoPlane plane) const; | |
| 31 int32_t stride(cdm::VideoFrame::VideoPlane plane) const; | |
| 32 | |
| 33 // Returns true when |format| and |data_size| can be used to create a valid | |
| 34 // FFmpegCdmVideoFrame. | |
| 35 static bool IsValidConfig(cdm::VideoFormat format, | |
| 36 const cdm::Size& data_size); | |
| 37 | |
| 38 // Transfers ownership of |frame_buffer_| to |target|, and copies all video | |
| 39 // frame meta data stored in FFmpegCdmVideoFrame. | |
| 40 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.
| |
| 41 | |
| 42 private: | |
| 43 // Clients must use the static Create() method to create a new frame. | |
| 44 FFmpegCdmVideoFrame(cdm::VideoFormat format, const cdm::Size& size); | |
| 45 | |
| 46 // Allocates a YUV video frame buffer of type |format_| using |size_|. | |
| 47 // Returns true when the frame buffer is successfully allocated. Returns | |
| 48 // false otherwise. | |
| 49 bool AllocateYuv(cdm::Allocator* allocator); | |
| 50 | |
| 51 // The video buffer format. | |
| 52 cdm::VideoFormat format_; | |
| 53 | |
| 54 // Width and height of the video frame. | |
| 55 cdm::Size size_; | |
| 56 | |
| 57 // The video frame buffer. Owned by FFmpegCdmVideoFrame until | |
| 58 // ReleaseCdmBuffer() is called. | |
| 59 cdm::Buffer* frame_buffer_; | |
| 60 | |
| 61 // Array of data pointers to each plane in the video frame buffer. | |
| 62 int32_t plane_offsets_[cdm::VideoFrame::kMaxPlanes]; | |
| 63 | |
| 64 // Array of strides for each plane, typically greater or equal to the width | |
| 65 // of the surface divided by the horizontal sampling period. Note that | |
| 66 // strides can be negative. | |
| 67 int32_t strides_[cdm::VideoFrame::kMaxPlanes]; | |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(FFmpegCdmVideoFrame); | |
| 70 }; | |
| 71 | |
| 72 } // namespace webkit_media | |
| 73 | |
| 74 #endif // WEBKIT_MEDIA_CRYPTO_PPAPI_FFMPEG_CDM_VIDEO_FRAME_H_ | |
| OLD | NEW |