Tizen WASM Player
Tizen TV WebAssembly Media Player extension allowing for a low-level elementary media stream playback.
media_key.h
Go to the documentation of this file.
1 // Copyright 2020 Samsung Electronics
2 // TizenTV Emscripten extensions are available under two separate licenses, the
3 // MIT license and the University of Illinois/NCSA Open Source License. Both
4 // these licenses can be found in the LICENSE file.
5 
6 #ifndef INCLUDE_SAMSUNG_WASM_MEDIA_KEY_H_
7 #define INCLUDE_SAMSUNG_WASM_MEDIA_KEY_H_
8 
9 #include <cstdint>
10 #include <functional>
11 #include <string>
12 #include <vector>
13 
14 #include "samsung/wasm/common.h"
15 
16 namespace samsung {
17 namespace wasm {
18 
20 enum class EncryptionMode {
21  kUnknown,
22  kCenc,
23  kCbcs,
24 };
25 
28  kUnknown,
29  kPlayready,
30  kWidevine,
31 };
32 
34 enum class Robustness {
35  kEmpty,
41 };
42 
44 struct DRMConfig {
47 
50 
52  std::string license_server;
53 
55  std::vector<uint8_t> init_data;
56 
58  std::string audio_mime_type;
59 
62 
64  std::string video_mime_type;
65 
68 };
69 
71 class MediaKey final {
72  public:
73  using SetupFinishedCallback = std::function<void(OperationResult, MediaKey)>;
74 
75  MediaKey(const MediaKey&) = delete;
76  MediaKey(MediaKey&& other);
77  MediaKey& operator=(const MediaKey&) = delete;
78  MediaKey& operator=(MediaKey&&);
79  ~MediaKey();
80 
86  bool IsValid() const;
87 
100  static Result<void> SetupEncryption(const DRMConfig& config,
101  SetupFinishedCallback on_finished);
102 
103  private:
104  struct AsyncImpl;
105 
106  explicit MediaKey(int handle);
107 
108  int handle_;
109 
110  // access to handle_
111  friend class ElementaryMediaTrack;
112 };
113 
114 } // namespace wasm
115 } // namespace samsung
116 
117 #endif // INCLUDE_SAMSUNG_WASM_MEDIA_KEY_H_
std::string license_server
URL of license server providing keys required to decrypt media.
Definition: media_key.h:52
Robustness video_robustness
Robustness of video track. Unused if video is not encrypted.
Definition: media_key.h:67
Pattern encryption AESCBC mode.
std::function< void(OperationResult, MediaKey)> SetupFinishedCallback
Definition: media_key.h:73
EncryptionMode encryption_mode
Encryption mode used by content.
Definition: media_key.h:49
Class representing an instance of media keys used to decrypt content.
Definition: media_key.h:71
Full sample encryption AESCTR mode.
ContentDecryptionModule
Lists Content Decryption Modules recognized by WASM Player.
Definition: media_key.h:27
Aggregates all data necessary for setting up decryption.
Definition: media_key.h:44
ContentDecryptionModule cdm
CDM used by content.
Definition: media_key.h:46
std::string audio_mime_type
Mime type of encrypted audio or empty string if audio is not encrypted.
Definition: media_key.h:58
std::string video_mime_type
Mime type of encrypted video or empty string if video is not encrypted.
Definition: media_key.h:64
Robustness audio_robustness
Robustness of audio track. Unused if audio is not encrypted.
Definition: media_key.h:61
Robustness
Lists robustness levels recognized by WASM Player.
Definition: media_key.h:34
std::vector< uint8_t > init_data
Buffer containing DRM-specific initialization data.
Definition: media_key.h:55
EncryptionMode
Lists encryption modes recognized by WASM Player.
Definition: media_key.h:20
Tracks are used to deliver either audio or video frames to WASM Player.