Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: media/cdm/cdm_helpers.h

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

Powered by Google App Engine
This is Rietveld 408576698