cenc_utils.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_CENC_UTILS_H_
  5. #define MEDIA_CDM_CENC_UTILS_H_
  6. #include <stdint.h>
  7. #include <vector>
  8. #include "media/base/media_export.h"
  9. #include "media/cdm/json_web_key.h"
  10. namespace media {
  11. // Validate that |input| is a set of concatenated 'pssh' boxes and the sizes
  12. // match. Returns true if |input| looks valid, false otherwise.
  13. MEDIA_EXPORT bool ValidatePsshInput(const std::vector<uint8_t>& input);
  14. // Gets the Key Ids from the first 'pssh' box for the Common System ID among one
  15. // or more concatenated 'pssh' boxes. Returns true if a matching box is found
  16. // and it contains 1 or more key IDs. Returns false otherwise.
  17. // Notes:
  18. // 1. If multiple PSSH boxes are found, the "KIDs" of the first matching 'pssh'
  19. // box will be set in |key_ids|.
  20. // 2. Only PSSH boxes are allowed in |input|. Any other boxes in |pssh_boxes|
  21. // will result in false being returned.
  22. MEDIA_EXPORT bool GetKeyIdsForCommonSystemId(
  23. const std::vector<uint8_t>& pssh_boxes,
  24. KeyIdList* key_ids);
  25. // Gets the data field from the first 'pssh' box containing |system_id|.
  26. // Returns true if such a box is found and successfully parsed. Returns false
  27. // otherwise.
  28. // Notes:
  29. // 1. If multiple PSSH boxes are found, the "Data" of the first matching 'pssh'
  30. // box will be set in |pssh_data|.
  31. // 2. Only PSSH boxes are allowed in |input|. Any other boxes in |pssh_boxes|
  32. // will result in false being returned.
  33. MEDIA_EXPORT bool GetPsshData(const std::vector<uint8_t>& input,
  34. const std::vector<uint8_t>& system_id,
  35. std::vector<uint8_t>* pssh_data);
  36. } // namespace media
  37. #endif // MEDIA_CDM_CENC_UTILS_H_