simple_cdm_buffer.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_CDM_SIMPLE_CDM_BUFFER_H_
  5. #define MEDIA_CDM_SIMPLE_CDM_BUFFER_H_
  6. #include <stddef.h>
  7. #include <stdint.h>
  8. #include <vector>
  9. #include "media/cdm/api/content_decryption_module.h"
  10. namespace media {
  11. // cdm::Buffer implementation that provides access to memory. This is a simple
  12. // implementation that stores the data in a std::vector<uint8_t>.
  13. class SimpleCdmBuffer final : public cdm::Buffer {
  14. public:
  15. static SimpleCdmBuffer* Create(size_t capacity);
  16. SimpleCdmBuffer(const SimpleCdmBuffer&) = delete;
  17. SimpleCdmBuffer& operator=(const SimpleCdmBuffer&) = delete;
  18. // cdm::Buffer implementation.
  19. void Destroy() override;
  20. uint32_t Capacity() const override;
  21. uint8_t* Data() override;
  22. void SetSize(uint32_t size) override;
  23. uint32_t Size() const override;
  24. private:
  25. explicit SimpleCdmBuffer(uint32_t capacity);
  26. ~SimpleCdmBuffer() override;
  27. std::vector<uint8_t> buffer_;
  28. uint32_t size_;
  29. };
  30. } // namespace media
  31. #endif // MEDIA_CDM_SIMPLE_CDM_BUFFER_H_