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/base/memory/scoped_ptr.h"
14 #include "packager/media/base/protection_system_specific_info.h"
15 #include "packager/media/base/status.h"
16 
17 namespace edash_packager {
18 namespace media {
19 
20 struct EncryptionKey {
21  EncryptionKey();
22  ~EncryptionKey();
23 
24  std::vector<ProtectionSystemSpecificInfo> key_system_info;
25  std::vector<uint8_t> key_id;
26  std::vector<uint8_t> key;
27  std::vector<uint8_t> iv;
28 };
29 
31 class KeySource {
32  public:
33  enum TrackType {
34  TRACK_TYPE_UNKNOWN = 0,
35  TRACK_TYPE_SD = 1,
36  TRACK_TYPE_HD = 2,
37  TRACK_TYPE_AUDIO = 3,
38  TRACK_TYPE_UNSPECIFIED = 4,
39  NUM_VALID_TRACK_TYPES = 4
40  };
41 
42  KeySource();
43  virtual ~KeySource();
44 
48  virtual Status FetchKeys(const std::vector<uint8_t>& pssh_box) = 0;
49 
53  virtual Status FetchKeys(
54  const std::vector<std::vector<uint8_t>>& key_ids) = 0;
55 
60  virtual Status FetchKeys(uint32_t asset_id) = 0;
61 
67  virtual Status GetKey(TrackType track_type, EncryptionKey* key) = 0;
68 
74  virtual Status GetKey(const std::vector<uint8_t>& key_id,
75  EncryptionKey* key) = 0;
76 
84  virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index,
85  TrackType track_type,
86  EncryptionKey* key) = 0;
87 
89  static TrackType GetTrackTypeFromString(const std::string& track_type_string);
90 
92  static std::string TrackTypeToString(TrackType track_type);
93 
94  private:
95  DISALLOW_COPY_AND_ASSIGN(KeySource);
96 };
97 
98 } // namespace media
99 } // namespace edash_packager
100 
101 #endif // MEDIA_BASE_KEY_SOURCE_H_
virtual Status GetKey(TrackType track_type, EncryptionKey *key)=0
virtual Status FetchKeys(const std::vector< uint8_t > &pssh_box)=0
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:31
static TrackType GetTrackTypeFromString(const std::string &track_type_string)
Convert string representation of track type to enum representation.
Definition: key_source.cc:19
virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index, TrackType track_type, EncryptionKey *key)=0
static std::string TrackTypeToString(TrackType track_type)
Convert TrackType to string.
Definition: key_source.cc:33