Skip to content

Commit

Permalink
fix: minor update to exported C interface for decryption
Browse files Browse the repository at this point in the history
  • Loading branch information
lee.fordyce committed Apr 16, 2024
1 parent 85350b5 commit f3f020b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/packager/live_packager_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ typedef struct LivePackagerConfig {
int64_t timed_text_decode_time;

/// Decryption parameters
bool enable_decryption;
uint8_t decryption_key[KEY_SIZE];
uint8_t decryption_key_id[KEY_ID_SIZE];
} LivePackagerConfig_t;
Expand Down
13 changes: 9 additions & 4 deletions packager/live_packager_export.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ LivePackager_t livepackager_new(LivePackagerConfig_t cfg) {
.segment_number = cfg.segment_number,
.m2ts_offset_ms = cfg.m2ts_offset_ms,
.timed_text_decode_time = cfg.timed_text_decode_time,
.decryption_key =
std::vector(cfg.decryption_key, cfg.decryption_key + KEY_SIZE),
.decryption_key_id = std::vector(cfg.decryption_key_id,
cfg.decryption_key_id + KEY_ID_SIZE),
.decryption_key = {},
.decryption_key_id = {},
};

if (cfg.protection_scheme != ENCRYPTION_SCHEME_NONE) {
Expand All @@ -31,6 +29,13 @@ LivePackager_t livepackager_new(LivePackagerConfig_t cfg) {
converted.key_id = std::vector(cfg.key_id, cfg.key_id + KEY_ID_SIZE);
}

if (cfg.enable_decryption) {
converted.decryption_key =
std::vector(cfg.decryption_key, cfg.decryption_key + KEY_SIZE);
converted.decryption_key_id =
std::vector(cfg.decryption_key_id, cfg.decryption_key_id + KEY_ID_SIZE);
}

return new (std::nothrow)
LivePackager_instance_s{std::make_unique<shaka::LivePackager>(converted)};
}
Expand Down

0 comments on commit f3f020b

Please sign in to comment.