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