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/compiler_specific.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "media/cdm/api/content_decryption_module.h" | 12 #include "media/cdm/api/content_decryption_module.h" |
12 | 13 |
| 14 #if !defined(USE_PPAPI_CDM_ADAPTER) |
| 15 #include "base/memory/ref_counted.h" |
| 16 #include "media/base/media_export.h" |
| 17 #include "ui/gfx/geometry/size.h" |
| 18 #define MEDIA_CDM_EXPORT MEDIA_EXPORT |
| 19 #else |
| 20 #define MEDIA_CDM_EXPORT |
| 21 #endif |
| 22 |
13 namespace media { | 23 namespace media { |
14 | 24 |
| 25 class VideoFrame; |
| 26 |
15 class DecryptedBlockImpl : public cdm::DecryptedBlock { | 27 class DecryptedBlockImpl : public cdm::DecryptedBlock { |
16 public: | 28 public: |
17 DecryptedBlockImpl(); | 29 DecryptedBlockImpl(); |
18 ~DecryptedBlockImpl() final; | 30 ~DecryptedBlockImpl() final; |
19 | 31 |
20 // cdm::DecryptedBlock implementation. | 32 // cdm::DecryptedBlock implementation. |
21 void SetDecryptedBuffer(cdm::Buffer* buffer) final; | 33 void SetDecryptedBuffer(cdm::Buffer* buffer) final; |
22 cdm::Buffer* DecryptedBuffer() final; | 34 cdm::Buffer* DecryptedBuffer() final; |
23 void SetTimestamp(int64_t timestamp) final; | 35 void SetTimestamp(int64_t timestamp) final; |
24 int64_t Timestamp() const final; | 36 int64_t Timestamp() const final; |
25 | 37 |
26 private: | 38 private: |
27 cdm::Buffer* buffer_; | 39 cdm::Buffer* buffer_; |
28 int64_t timestamp_; | 40 int64_t timestamp_; |
29 | 41 |
30 DISALLOW_COPY_AND_ASSIGN(DecryptedBlockImpl); | 42 DISALLOW_COPY_AND_ASSIGN(DecryptedBlockImpl); |
31 }; | 43 }; |
32 | 44 |
33 class VideoFrameImpl : public cdm::VideoFrame { | 45 class MEDIA_CDM_EXPORT VideoFrameImpl |
| 46 : NON_EXPORTED_BASE(public cdm::VideoFrame) { |
34 public: | 47 public: |
35 VideoFrameImpl(); | 48 VideoFrameImpl(); |
36 ~VideoFrameImpl() final; | 49 ~VideoFrameImpl() override; |
37 | 50 |
38 // cdm::VideoFrame implementation. | 51 // cdm::VideoFrame implementation. |
39 void SetFormat(cdm::VideoFormat format) final; | 52 void SetFormat(cdm::VideoFormat format) final; |
40 cdm::VideoFormat Format() const final; | 53 cdm::VideoFormat Format() const final; |
41 void SetSize(cdm::Size size) final; | 54 void SetSize(cdm::Size size) final; |
42 cdm::Size Size() const final; | 55 cdm::Size Size() const final; |
43 void SetFrameBuffer(cdm::Buffer* frame_buffer) final; | 56 void SetFrameBuffer(cdm::Buffer* frame_buffer) final; |
44 cdm::Buffer* FrameBuffer() final; | 57 cdm::Buffer* FrameBuffer() final; |
45 void SetPlaneOffset(cdm::VideoFrame::VideoPlane plane, uint32_t offset) final; | 58 void SetPlaneOffset(cdm::VideoFrame::VideoPlane plane, uint32_t offset) final; |
46 uint32_t PlaneOffset(VideoPlane plane) final; | 59 uint32_t PlaneOffset(VideoPlane plane) final; |
47 void SetStride(VideoPlane plane, uint32_t stride) final; | 60 void SetStride(VideoPlane plane, uint32_t stride) final; |
48 uint32_t Stride(VideoPlane plane) final; | 61 uint32_t Stride(VideoPlane plane) final; |
49 void SetTimestamp(int64_t timestamp) final; | 62 void SetTimestamp(int64_t timestamp) final; |
50 int64_t Timestamp() const final; | 63 int64_t Timestamp() const final; |
51 | 64 |
52 private: | 65 #if !defined(USE_PPAPI_CDM_ADAPTER) |
| 66 // Create a media::VideoFrame based on the data contained in this object. |
| 67 // |natural_size| is the visible portion of the video frame, and is |
| 68 // provided separately as it comes from the configuration, not the CDM. |
| 69 // The returned object will own |frame_buffer_| and will be responsible for |
| 70 // calling Destroy() on it when the data is no longer needed. |
| 71 // Preconditions: |
| 72 // - |this| needs to be properly initialized. |
| 73 // Postconditions: |
| 74 // - |frame_buffer_| will be NULL (now owned by returned media::VideoFrame). |
| 75 virtual scoped_refptr<media::VideoFrame> TransformToVideoFrame( |
| 76 gfx::Size natural_size) = 0; |
| 77 #endif |
| 78 |
| 79 protected: |
53 // The video buffer format. | 80 // The video buffer format. |
54 cdm::VideoFormat format_; | 81 cdm::VideoFormat format_; |
55 | 82 |
56 // Width and height of the video frame. | 83 // Width and height of the video frame. |
57 cdm::Size size_; | 84 cdm::Size size_; |
58 | 85 |
59 // The video frame buffer. | 86 // The video frame buffer. |
60 cdm::Buffer* frame_buffer_; | 87 cdm::Buffer* frame_buffer_; |
61 | 88 |
62 // Array of data pointers to each plane in the video frame buffer. | 89 // Array of data pointers to each plane in the video frame buffer. |
63 uint32_t plane_offsets_[kMaxPlanes]; | 90 uint32_t plane_offsets_[kMaxPlanes]; |
64 | 91 |
65 // Array of strides for each plane, typically greater or equal to the width | 92 // 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 | 93 // of the surface divided by the horizontal sampling period. Note that |
67 // strides can be negative. | 94 // strides can be negative. |
68 uint32_t strides_[kMaxPlanes]; | 95 uint32_t strides_[kMaxPlanes]; |
69 | 96 |
70 // Presentation timestamp in microseconds. | 97 // Presentation timestamp in microseconds. |
71 int64_t timestamp_; | 98 int64_t timestamp_; |
72 | 99 |
| 100 private: |
73 DISALLOW_COPY_AND_ASSIGN(VideoFrameImpl); | 101 DISALLOW_COPY_AND_ASSIGN(VideoFrameImpl); |
74 }; | 102 }; |
75 | 103 |
76 class AudioFramesImpl : public cdm::AudioFrames { | 104 class AudioFramesImpl : public cdm::AudioFrames { |
77 public: | 105 public: |
78 AudioFramesImpl(); | 106 AudioFramesImpl(); |
79 ~AudioFramesImpl() final; | 107 ~AudioFramesImpl() final; |
80 | 108 |
81 // cdm::AudioFrames implementation. | 109 // cdm::AudioFrames implementation. |
82 void SetFrameBuffer(cdm::Buffer* buffer) final; | 110 void SetFrameBuffer(cdm::Buffer* buffer) final; |
83 cdm::Buffer* FrameBuffer() final; | 111 cdm::Buffer* FrameBuffer() final; |
84 void SetFormat(cdm::AudioFormat format) final; | 112 void SetFormat(cdm::AudioFormat format) final; |
85 cdm::AudioFormat Format() const final; | 113 cdm::AudioFormat Format() const final; |
86 | 114 |
87 cdm::Buffer* PassFrameBuffer(); | 115 cdm::Buffer* PassFrameBuffer(); |
88 | 116 |
89 private: | 117 private: |
90 cdm::Buffer* buffer_; | 118 cdm::Buffer* buffer_; |
91 cdm::AudioFormat format_; | 119 cdm::AudioFormat format_; |
92 | 120 |
93 DISALLOW_COPY_AND_ASSIGN(AudioFramesImpl); | 121 DISALLOW_COPY_AND_ASSIGN(AudioFramesImpl); |
94 }; | 122 }; |
95 | 123 |
96 } // namespace media | 124 } // namespace media |
97 | 125 |
98 #endif // MEDIA_CDM_CDM_HELPERS_H_ | 126 #endif // MEDIA_CDM_CDM_HELPERS_H_ |
OLD | NEW |