DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
key_source.h
1 // Copyright 2014 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_BASE_KEY_SOURCE_H_
8 #define MEDIA_BASE_KEY_SOURCE_H_
9 
10 #include <string>
11 #include <vector>
12 
13 #include "packager/media/base/protection_system_specific_info.h"
14 #include "packager/media/base/status.h"
15 
16 namespace shaka {
17 namespace media {
18 
19 struct EncryptionKey {
20  EncryptionKey();
21  ~EncryptionKey();
22 
23  std::vector<ProtectionSystemSpecificInfo> key_system_info;
24  std::vector<uint8_t> key_id;
25  std::vector<uint8_t> key;
26  std::vector<uint8_t> iv;
27 };
28 
30 class KeySource {
31  public:
32  enum TrackType {
33  TRACK_TYPE_UNKNOWN = 0,
34  TRACK_TYPE_SD = 1,
35  TRACK_TYPE_HD = 2,
36  TRACK_TYPE_UHD1 = 3,
37  TRACK_TYPE_UHD2 = 4,
38  TRACK_TYPE_AUDIO = 5,
39  TRACK_TYPE_UNSPECIFIED = 6,
40  NUM_VALID_TRACK_TYPES = 6
41  };
42 
43  KeySource();
44  virtual ~KeySource();
45 
49  virtual Status FetchKeys(const std::vector<uint8_t>& pssh_box) = 0;
50 
54  virtual Status FetchKeys(
55  const std::vector<std::vector<uint8_t>>& key_ids) = 0;
56 
61  virtual Status FetchKeys(uint32_t asset_id) = 0;
62 
68  virtual Status GetKey(TrackType track_type, EncryptionKey* key) = 0;
69 
75  virtual Status GetKey(const std::vector<uint8_t>& key_id,
76  EncryptionKey* key) = 0;
77 
85  virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index,
86  TrackType track_type,
87  EncryptionKey* key) = 0;
88 
90  static TrackType GetTrackTypeFromString(const std::string& track_type_string);
91 
93  static std::string TrackTypeToString(TrackType track_type);
94 
95  private:
96  DISALLOW_COPY_AND_ASSIGN(KeySource);
97 };
98 
99 } // namespace media
100 } // namespace shaka
101 
102 #endif // MEDIA_BASE_KEY_SOURCE_H_
virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index, TrackType track_type, EncryptionKey *key)=0
virtual Status GetKey(TrackType track_type, EncryptionKey *key)=0
static std::string TrackTypeToString(TrackType track_type)
Convert TrackType to string.
Definition: key_source.cc:37
virtual Status FetchKeys(const std::vector< uint8_t > &pssh_box)=0
static TrackType GetTrackTypeFromString(const std::string &track_type_string)
Convert string representation of track type to enum representation.
Definition: key_source.cc:19
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:30