cdm_type_conversion.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // Copyright 2018 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_CDM_TYPE_CONVERSION_H_
  5. #define MEDIA_CDM_CDM_TYPE_CONVERSION_H_
  6. #include <vector>
  7. #include "media/base/audio_codecs.h"
  8. #include "media/base/audio_decoder_config.h"
  9. #include "media/base/cdm_key_information.h"
  10. #include "media/base/cdm_promise.h"
  11. #include "media/base/channel_layout.h"
  12. #include "media/base/content_decryption_module.h"
  13. #include "media/base/decoder_buffer.h"
  14. #include "media/base/decrypt_config.h"
  15. #include "media/base/decryptor.h"
  16. #include "media/base/encryption_scheme.h"
  17. #include "media/base/media_export.h"
  18. #include "media/base/sample_format.h"
  19. #include "media/base/video_codecs.h"
  20. #include "media/base/video_color_space.h"
  21. #include "media/base/video_decoder_config.h"
  22. #include "media/base/video_types.h"
  23. #include "media/cdm/api/content_decryption_module.h"
  24. namespace media {
  25. // Color Converters
  26. MEDIA_EXPORT cdm::ColorSpace ToCdmColorSpace(
  27. const VideoColorSpace& color_space);
  28. MEDIA_EXPORT VideoColorSpace
  29. ToMediaColorSpace(const cdm::ColorSpace& color_space);
  30. // CDM Converters
  31. MEDIA_EXPORT cdm::HdcpVersion ToCdmHdcpVersion(HdcpVersion hdcp_version);
  32. MEDIA_EXPORT cdm::SessionType ToCdmSessionType(CdmSessionType session_type);
  33. MEDIA_EXPORT CdmSessionType ToMediaSessionType(cdm::SessionType session_type);
  34. MEDIA_EXPORT cdm::InitDataType ToCdmInitDataType(
  35. EmeInitDataType init_data_type);
  36. MEDIA_EXPORT EmeInitDataType
  37. ToEmeInitDataType(cdm::InitDataType init_data_type);
  38. MEDIA_EXPORT CdmKeyInformation::KeyStatus ToMediaKeyStatus(
  39. cdm::KeyStatus status);
  40. MEDIA_EXPORT cdm::KeyStatus ToCdmKeyStatus(CdmKeyInformation::KeyStatus status);
  41. MEDIA_EXPORT cdm::EncryptionScheme ToCdmEncryptionScheme(
  42. EncryptionScheme scheme);
  43. MEDIA_EXPORT CdmPromise::Exception ToMediaCdmPromiseException(
  44. cdm::Exception exception);
  45. MEDIA_EXPORT cdm::Exception ToCdmException(CdmPromise::Exception exception);
  46. MEDIA_EXPORT CdmMessageType ToMediaMessageType(cdm::MessageType message_type);
  47. MEDIA_EXPORT cdm::MessageType ToCdmMessageType(CdmMessageType message_type);
  48. MEDIA_EXPORT cdm::StreamType ToCdmStreamType(Decryptor::StreamType stream_type);
  49. MEDIA_EXPORT Decryptor::Status ToMediaDecryptorStatus(cdm::Status status);
  50. // Audio Converters
  51. MEDIA_EXPORT cdm::AudioCodec ToCdmAudioCodec(AudioCodec codec);
  52. MEDIA_EXPORT SampleFormat ToMediaSampleFormat(cdm::AudioFormat format);
  53. // Video Converters
  54. MEDIA_EXPORT cdm::VideoCodec ToCdmVideoCodec(VideoCodec codec);
  55. MEDIA_EXPORT VideoCodec ToMediaVideoCodec(cdm::VideoCodec codec);
  56. MEDIA_EXPORT cdm::VideoCodecProfile ToCdmVideoCodecProfile(
  57. VideoCodecProfile profile);
  58. MEDIA_EXPORT VideoCodecProfile
  59. ToMediaVideoCodecProfile(cdm::VideoCodecProfile profile);
  60. MEDIA_EXPORT cdm::VideoFormat ToCdmVideoFormat(VideoPixelFormat format);
  61. MEDIA_EXPORT VideoPixelFormat ToMediaVideoFormat(cdm::VideoFormat format);
  62. // Aggregated Types
  63. // Warning: The returned config contains raw pointers to the extra data in the
  64. // input |config|. Hence, the caller must make sure the input |config| outlives
  65. // the returned config.
  66. MEDIA_EXPORT cdm::AudioDecoderConfig_2 ToCdmAudioDecoderConfig(
  67. const AudioDecoderConfig& config);
  68. // Warning: The returned config contains raw pointers to the extra data in the
  69. // input |config|. Hence, the caller must make sure the input |config| outlives
  70. // the returned config.
  71. MEDIA_EXPORT cdm::VideoDecoderConfig_3 ToCdmVideoDecoderConfig(
  72. const VideoDecoderConfig& config);
  73. // Fill |input_buffer| based on the values in |encrypted|. |subsamples|
  74. // is used to hold some of the data. |input_buffer| will contain pointers
  75. // to data contained in |encrypted| and |subsamples|, so the lifetime of
  76. // |input_buffer| must be <= the lifetime of |encrypted| and |subsamples|.
  77. MEDIA_EXPORT void ToCdmInputBuffer(const DecoderBuffer& encrypted_buffer,
  78. std::vector<cdm::SubsampleEntry>* subsamples,
  79. cdm::InputBuffer_2* input_buffer);
  80. } // namespace media
  81. #endif // MEDIA_CDM_CDM_TYPE_CONVERSION_H_