From f3f020bb693dfae0bbb23ea36ef2f7529280c3a1 Mon Sep 17 00:00:00 2001 From: "lee.fordyce" Date: Tue, 16 Apr 2024 13:58:48 -0600 Subject: [PATCH] fix: minor update to exported C interface for decryption --- include/packager/live_packager_export.h | 1 + packager/live_packager_export.cc | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/packager/live_packager_export.h b/include/packager/live_packager_export.h index f92c92ad81..a2d978b847 100644 --- a/include/packager/live_packager_export.h +++ b/include/packager/live_packager_export.h @@ -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; diff --git a/packager/live_packager_export.cc b/packager/live_packager_export.cc index 7459062acc..cd62af3815 100644 --- a/packager/live_packager_export.cc +++ b/packager/live_packager_export.cc @@ -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) { @@ -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(converted)}; }