123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- // Copyright 2015 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 MEDIA_CDM_CDM_HELPERS_H_
- #define MEDIA_CDM_CDM_HELPERS_H_
- #include <stdint.h>
- #include "base/compiler_specific.h"
- #include "base/memory/raw_ptr.h"
- #include "base/memory/ref_counted.h"
- #include "media/base/media_export.h"
- #include "media/base/video_color_space.h"
- #include "media/cdm/api/content_decryption_module.h"
- #include "ui/gfx/geometry/size.h"
- namespace media {
- class VideoFrame;
- class DecryptedBlockImpl final : public cdm::DecryptedBlock {
- public:
- DecryptedBlockImpl();
- DecryptedBlockImpl(const DecryptedBlockImpl&) = delete;
- DecryptedBlockImpl& operator=(const DecryptedBlockImpl&) = delete;
- ~DecryptedBlockImpl() final;
- // cdm::DecryptedBlock implementation.
- void SetDecryptedBuffer(cdm::Buffer* buffer) final;
- cdm::Buffer* DecryptedBuffer() final;
- void SetTimestamp(int64_t timestamp) final;
- int64_t Timestamp() const final;
- private:
- raw_ptr<cdm::Buffer> buffer_;
- int64_t timestamp_;
- };
- class MEDIA_EXPORT VideoFrameImpl : public cdm::VideoFrame,
- public cdm::VideoFrame_2 {
- public:
- VideoFrameImpl();
- VideoFrameImpl(const VideoFrameImpl&) = delete;
- VideoFrameImpl& operator=(const VideoFrameImpl&) = delete;
- ~VideoFrameImpl() override;
- // cdm::VideoFrame and cdm::VideoFrame_2 common implementation.
- void SetFormat(cdm::VideoFormat format) final;
- cdm::VideoFormat Format() const final;
- void SetSize(cdm::Size size) final;
- cdm::Size Size() const final;
- void SetFrameBuffer(cdm::Buffer* frame_buffer) final;
- cdm::Buffer* FrameBuffer() final;
- void SetPlaneOffset(cdm::VideoPlane plane, uint32_t offset) final;
- uint32_t PlaneOffset(cdm::VideoPlane plane) final;
- void SetStride(cdm::VideoPlane plane, uint32_t stride) final;
- uint32_t Stride(cdm::VideoPlane plane) final;
- void SetTimestamp(int64_t timestamp) final;
- int64_t Timestamp() const final;
- // cdm::VideoFrame_2 specific implementation.
- void SetColorSpace(cdm::ColorSpace color_space) final;
- // Helper functions to get the ColorSpace.
- media::VideoColorSpace MediaColorSpace() const;
- // Create a media::VideoFrame based on the data contained in this object.
- // |natural_size| is the visible portion of the video frame, and is
- // provided separately as it comes from the configuration, not the CDM.
- // The returned object will own |frame_buffer_| and will be responsible for
- // calling Destroy() on it when the data is no longer needed.
- // Preconditions:
- // - |this| needs to be properly initialized.
- // Postconditions:
- // - |frame_buffer_| will be NULL (now owned by returned media::VideoFrame).
- virtual scoped_refptr<media::VideoFrame> TransformToVideoFrame(
- gfx::Size natural_size) = 0;
- protected:
- // The video buffer format.
- cdm::VideoFormat format_;
- cdm::ColorSpace color_space_;
- // Width and height of the video frame.
- cdm::Size size_;
- // The video frame buffer.
- raw_ptr<cdm::Buffer> frame_buffer_;
- // Array of data pointers to each plane in the video frame buffer.
- uint32_t plane_offsets_[cdm::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.
- uint32_t strides_[cdm::kMaxPlanes];
- // Presentation timestamp in microseconds.
- int64_t timestamp_;
- };
- class AudioFramesImpl final : public cdm::AudioFrames {
- public:
- AudioFramesImpl();
- AudioFramesImpl(const AudioFramesImpl&) = delete;
- AudioFramesImpl& operator=(const AudioFramesImpl&) = delete;
- ~AudioFramesImpl() final;
- // cdm::AudioFrames implementation.
- void SetFrameBuffer(cdm::Buffer* buffer) final;
- cdm::Buffer* FrameBuffer() final;
- void SetFormat(cdm::AudioFormat format) final;
- cdm::AudioFormat Format() const final;
- cdm::Buffer* PassFrameBuffer();
- private:
- raw_ptr<cdm::Buffer> buffer_;
- cdm::AudioFormat format_;
- };
- } // namespace media
- #endif // MEDIA_CDM_CDM_HELPERS_H_
|