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_AUDIO = 3,
37  TRACK_TYPE_UNSPECIFIED = 4,
38  NUM_VALID_TRACK_TYPES = 4
39  };
40 
41  KeySource();
42  virtual ~KeySource();
43 
47  virtual Status FetchKeys(const std::vector<uint8_t>& pssh_box) = 0;
48 
52  virtual Status FetchKeys(
53  const std::vector<std::vector<uint8_t>>& key_ids) = 0;
54 
59  virtual Status FetchKeys(uint32_t asset_id) = 0;
60 
66  virtual Status GetKey(TrackType track_type, EncryptionKey* key) = 0;
67 
73  virtual Status GetKey(const std::vector<uint8_t>& key_id,
74  EncryptionKey* key) = 0;
75 
83  virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index,
84  TrackType track_type,
85  EncryptionKey* key) = 0;
86 
88  static TrackType GetTrackTypeFromString(const std::string& track_type_string);
89 
91  static std::string TrackTypeToString(TrackType track_type);
92 
93  private:
94  DISALLOW_COPY_AND_ASSIGN(KeySource);
95 };
96 
97 } // namespace media
98 } // namespace shaka
99 
100 #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:33
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