DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerator
fixed_key_source.h
1 // Copyright 2016 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_FIXED_KEY_SOURCE_H_
8 #define MEDIA_BASE_FIXED_KEY_SOURCE_H_
9 
10 #include <string>
11 #include <vector>
12 
13 #include "packager/base/memory/scoped_ptr.h"
14 #include "packager/media/base/key_source.h"
15 
16 namespace edash_packager {
17 namespace media {
18 
20 class FixedKeySource : public KeySource {
21  public:
22  ~FixedKeySource() override;
23 
26  Status FetchKeys(const std::vector<uint8_t>& pssh_box) override;
27  Status FetchKeys(const std::vector<std::vector<uint8_t>>& key_ids) override;
28  Status FetchKeys(uint32_t asset_id) override;
29 
30  Status GetKey(TrackType track_type, EncryptionKey* key) override;
31  Status GetKey(const std::vector<uint8_t>& key_id,
32  EncryptionKey* key) override;
33  Status GetCryptoPeriodKey(uint32_t crypto_period_index,
34  TrackType track_type,
35  EncryptionKey* key) override;
37 
47  static scoped_ptr<FixedKeySource> CreateFromHexStrings(
48  const std::string& key_id_hex,
49  const std::string& key_hex,
50  const std::string& pssh_boxes_hex,
51  const std::string& iv_hex);
52 
53  protected:
54  // Allow default constructor for mock key sources.
56 
57  private:
58  explicit FixedKeySource(scoped_ptr<EncryptionKey> key);
59 
60  scoped_ptr<EncryptionKey> encryption_key_;
61 
62  DISALLOW_COPY_AND_ASSIGN(FixedKeySource);
63 };
64 
65 } // namespace media
66 } // namespace edash_packager
67 
68 #endif // MEDIA_BASE_FIXED_KEY_SOURCE_H_
Status GetCryptoPeriodKey(uint32_t crypto_period_index, TrackType track_type, EncryptionKey *key) override
A key source that uses fixed keys for encryption.
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:31
static scoped_ptr< FixedKeySource > CreateFromHexStrings(const std::string &key_id_hex, const std::string &key_hex, const std::string &pssh_boxes_hex, const std::string &iv_hex)
Status GetKey(TrackType track_type, EncryptionKey *key) override
Status FetchKeys(const std::vector< uint8_t > &pssh_box) override