Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_CDM_CDM_HELPERS_H_ | 5 #ifndef MEDIA_CDM_CDM_HELPERS_H_ |
| 6 #define MEDIA_CDM_CDM_HELPERS_H_ | 6 #define MEDIA_CDM_CDM_HELPERS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "media/cdm/api/content_decryption_module.h" | 11 #include "media/cdm/api/content_decryption_module.h" |
| 12 | 12 |
| 13 #if !defined(USE_PPAPI_CDM_ADAPTER) | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "ui/gfx/geometry/size.h" | |
| 16 #endif | |
| 17 | |
| 13 namespace media { | 18 namespace media { |
| 14 | 19 |
| 20 class VideoFrame; | |
| 21 | |
| 15 class DecryptedBlockImpl : public cdm::DecryptedBlock { | 22 class DecryptedBlockImpl : public cdm::DecryptedBlock { |
| 16 public: | 23 public: |
| 17 DecryptedBlockImpl(); | 24 DecryptedBlockImpl(); |
| 18 ~DecryptedBlockImpl() final; | 25 ~DecryptedBlockImpl() final; |
| 19 | 26 |
| 20 // cdm::DecryptedBlock implementation. | 27 // cdm::DecryptedBlock implementation. |
| 21 void SetDecryptedBuffer(cdm::Buffer* buffer) final; | 28 void SetDecryptedBuffer(cdm::Buffer* buffer) final; |
| 22 cdm::Buffer* DecryptedBuffer() final; | 29 cdm::Buffer* DecryptedBuffer() final; |
| 23 void SetTimestamp(int64_t timestamp) final; | 30 void SetTimestamp(int64_t timestamp) final; |
| 24 int64_t Timestamp() const final; | 31 int64_t Timestamp() const final; |
| 25 | 32 |
| 26 private: | 33 private: |
| 27 cdm::Buffer* buffer_; | 34 cdm::Buffer* buffer_; |
| 28 int64_t timestamp_; | 35 int64_t timestamp_; |
| 29 | 36 |
| 30 DISALLOW_COPY_AND_ASSIGN(DecryptedBlockImpl); | 37 DISALLOW_COPY_AND_ASSIGN(DecryptedBlockImpl); |
| 31 }; | 38 }; |
| 32 | 39 |
| 33 class VideoFrameImpl : public cdm::VideoFrame { | 40 class VideoFrameImpl : public cdm::VideoFrame { |
| 34 public: | 41 public: |
| 35 VideoFrameImpl(); | 42 VideoFrameImpl(); |
| 36 ~VideoFrameImpl() final; | 43 ~VideoFrameImpl() override; |
| 37 | 44 |
| 38 // cdm::VideoFrame implementation. | 45 // cdm::VideoFrame implementation. |
| 39 void SetFormat(cdm::VideoFormat format) final; | 46 void SetFormat(cdm::VideoFormat format) final; |
| 40 cdm::VideoFormat Format() const final; | 47 cdm::VideoFormat Format() const final; |
| 41 void SetSize(cdm::Size size) final; | 48 void SetSize(cdm::Size size) final; |
| 42 cdm::Size Size() const final; | 49 cdm::Size Size() const final; |
| 43 void SetFrameBuffer(cdm::Buffer* frame_buffer) final; | 50 void SetFrameBuffer(cdm::Buffer* frame_buffer) final; |
| 44 cdm::Buffer* FrameBuffer() final; | 51 cdm::Buffer* FrameBuffer() final; |
| 45 void SetPlaneOffset(cdm::VideoFrame::VideoPlane plane, uint32_t offset) final; | 52 void SetPlaneOffset(cdm::VideoFrame::VideoPlane plane, uint32_t offset) final; |
| 46 uint32_t PlaneOffset(VideoPlane plane) final; | 53 uint32_t PlaneOffset(VideoPlane plane) final; |
| 47 void SetStride(VideoPlane plane, uint32_t stride) final; | 54 void SetStride(VideoPlane plane, uint32_t stride) final; |
| 48 uint32_t Stride(VideoPlane plane) final; | 55 uint32_t Stride(VideoPlane plane) final; |
| 49 void SetTimestamp(int64_t timestamp) final; | 56 void SetTimestamp(int64_t timestamp) final; |
| 50 int64_t Timestamp() const final; | 57 int64_t Timestamp() const final; |
| 51 | 58 |
| 52 private: | 59 #if !defined(USE_PPAPI_CDM_ADAPTER) |
| 60 // Create a media::VideoFrame based on the data contained in this object. | |
| 61 // The returned object will own the memory in FrameBuffer and will be | |
|
xhwang
2016/02/12 08:45:30
nit: s/the memory in FrameBuffer/|frame_buffer_| ?
jrummell
2016/02/12 23:14:20
Done.
| |
| 62 // responsible for calling Destroy() on it when the media::VideoFrame no | |
| 63 // longer needs it. After CreateVideoFrame() is called the VideoFrameImpl | |
| 64 // will no longer have a reference to the memory. | |
|
xhwang
2016/02/12 08:45:30
nit: s/the VideoFrameImpl will no longer have a re
jrummell
2016/02/12 23:14:20
Removed the whole sentence since it simply restate
| |
| 65 virtual scoped_refptr<media::VideoFrame> CreateVideoFrame( | |
| 66 gfx::Size natural_size) = 0; | |
|
xhwang
2016/02/12 08:45:30
nit: Actually, this is not a typical "Create" call
jrummell
2016/02/12 23:14:20
Done.
| |
| 67 #endif | |
| 68 | |
| 69 protected: | |
| 53 // The video buffer format. | 70 // The video buffer format. |
| 54 cdm::VideoFormat format_; | 71 cdm::VideoFormat format_; |
| 55 | 72 |
| 56 // Width and height of the video frame. | 73 // Width and height of the video frame. |
| 57 cdm::Size size_; | 74 cdm::Size size_; |
| 58 | 75 |
| 59 // The video frame buffer. | 76 // The video frame buffer. |
| 60 cdm::Buffer* frame_buffer_; | 77 cdm::Buffer* frame_buffer_; |
| 61 | 78 |
| 62 // Array of data pointers to each plane in the video frame buffer. | 79 // Array of data pointers to each plane in the video frame buffer. |
| 63 uint32_t plane_offsets_[kMaxPlanes]; | 80 uint32_t plane_offsets_[kMaxPlanes]; |
| 64 | 81 |
| 65 // Array of strides for each plane, typically greater or equal to the width | 82 // Array of strides for each plane, typically greater or equal to the width |
| 66 // of the surface divided by the horizontal sampling period. Note that | 83 // of the surface divided by the horizontal sampling period. Note that |
| 67 // strides can be negative. | 84 // strides can be negative. |
| 68 uint32_t strides_[kMaxPlanes]; | 85 uint32_t strides_[kMaxPlanes]; |
| 69 | 86 |
| 70 // Presentation timestamp in microseconds. | 87 // Presentation timestamp in microseconds. |
| 71 int64_t timestamp_; | 88 int64_t timestamp_; |
| 72 | 89 |
| 90 private: | |
| 73 DISALLOW_COPY_AND_ASSIGN(VideoFrameImpl); | 91 DISALLOW_COPY_AND_ASSIGN(VideoFrameImpl); |
| 74 }; | 92 }; |
| 75 | 93 |
| 76 class AudioFramesImpl : public cdm::AudioFrames { | 94 class AudioFramesImpl : public cdm::AudioFrames { |
| 77 public: | 95 public: |
| 78 AudioFramesImpl(); | 96 AudioFramesImpl(); |
| 79 ~AudioFramesImpl() final; | 97 ~AudioFramesImpl() final; |
| 80 | 98 |
| 81 // cdm::AudioFrames implementation. | 99 // cdm::AudioFrames implementation. |
| 82 void SetFrameBuffer(cdm::Buffer* buffer) final; | 100 void SetFrameBuffer(cdm::Buffer* buffer) final; |
| 83 cdm::Buffer* FrameBuffer() final; | 101 cdm::Buffer* FrameBuffer() final; |
| 84 void SetFormat(cdm::AudioFormat format) final; | 102 void SetFormat(cdm::AudioFormat format) final; |
| 85 cdm::AudioFormat Format() const final; | 103 cdm::AudioFormat Format() const final; |
| 86 | 104 |
| 87 cdm::Buffer* PassFrameBuffer(); | 105 cdm::Buffer* PassFrameBuffer(); |
| 88 | 106 |
| 89 private: | 107 private: |
| 90 cdm::Buffer* buffer_; | 108 cdm::Buffer* buffer_; |
| 91 cdm::AudioFormat format_; | 109 cdm::AudioFormat format_; |
| 92 | 110 |
| 93 DISALLOW_COPY_AND_ASSIGN(AudioFramesImpl); | 111 DISALLOW_COPY_AND_ASSIGN(AudioFramesImpl); |
| 94 }; | 112 }; |
| 95 | 113 |
| 96 } // namespace media | 114 } // namespace media |
| 97 | 115 |
| 98 #endif // MEDIA_CDM_CDM_HELPERS_H_ | 116 #endif // MEDIA_CDM_CDM_HELPERS_H_ |
| OLD | NEW |