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 
21 enum class EmeInitDataType {
22  UNKNOWN,
24  CENC,
26  WEBM,
28  KEYIDS,
30  WIDEVINE_CLASSIC,
31  MAX = WIDEVINE_CLASSIC
32 };
33 
34 struct EncryptionKey {
35  EncryptionKey();
36  ~EncryptionKey();
37 
38  std::vector<ProtectionSystemSpecificInfo> key_system_info;
39  std::vector<uint8_t> key_id;
40  std::vector<uint8_t> key;
41  std::vector<uint8_t> iv;
42 };
43 
45 class KeySource {
46  public:
47  enum TrackType {
48  TRACK_TYPE_UNKNOWN = 0,
49  TRACK_TYPE_SD = 1,
50  TRACK_TYPE_HD = 2,
51  TRACK_TYPE_UHD1 = 3,
52  TRACK_TYPE_UHD2 = 4,
53  TRACK_TYPE_AUDIO = 5,
54  TRACK_TYPE_UNSPECIFIED = 6,
55  NUM_VALID_TRACK_TYPES = 6
56  };
57 
58  KeySource();
59  virtual ~KeySource();
60 
65  virtual Status FetchKeys(EmeInitDataType init_data_type,
66  const std::vector<uint8_t>& init_data) = 0;
67 
73  virtual Status GetKey(TrackType track_type, EncryptionKey* key) = 0;
74 
80  virtual Status GetKey(const std::vector<uint8_t>& key_id,
81  EncryptionKey* key) = 0;
82 
90  virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index,
91  TrackType track_type,
92  EncryptionKey* key) = 0;
93 
95  static TrackType GetTrackTypeFromString(const std::string& track_type_string);
96 
98  static std::string TrackTypeToString(TrackType track_type);
99 
100  private:
101  DISALLOW_COPY_AND_ASSIGN(KeySource);
102 };
103 
104 } // namespace media
105 } // namespace shaka
106 
107 #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(EmeInitDataType init_data_type, const std::vector< uint8_t > &init_data)=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:45