Skip to content

Commit

Permalink
hls: add vod_hls_encryption_output_iv directive (#1514)
Browse files Browse the repository at this point in the history
* hls: add vod_hls_encryption_output_iv variable

* remove complexity just return IV when vod_hls_encryption_output_iv is enabled
  • Loading branch information
nonth authored Mar 18, 2024
1 parent 5b96c97 commit 26f0687
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,13 @@ The parameter value can contain variables.
When enabled, the module will shift back the dts timestamps by the pts delay of the initial frame.
This can help keep the pts timestamps aligned across multiple renditions.

#### vod_hls_encryption_output_iv
* **syntax**: `vod_hls_encryption_output_iv on/off`
* **default**: `off`
* **context**: `http`, `server`, `location`

When enabled, the module outputs the `IV` attribute in returned `#EXT-X-KEY` tags.

### Configuration directives - MSS

#### vod_mss_manifest_file_name_prefix
Expand Down
4 changes: 3 additions & 1 deletion ngx_http_vod_hls.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ ngx_http_vod_hls_init_encryption_params(
}

encryption_params->iv = encryption_params->iv_buf;
encryption_params->return_iv = FALSE;
encryption_params->return_iv = conf->hls.output_iv;

sequence = &submodule_context->media_set.sequences[0];

Expand Down Expand Up @@ -1116,6 +1116,7 @@ ngx_http_vod_hls_create_loc_conf(
conf->align_pts = NGX_CONF_UNSET;
conf->output_id3_timestamps = NGX_CONF_UNSET;
conf->encryption_method = NGX_CONF_UNSET_UINT;
conf->output_iv = NGX_CONF_UNSET;
conf->m3u8_config.output_iframes_playlist = NGX_CONF_UNSET;
conf->m3u8_config.force_unmuxed_segments = NGX_CONF_UNSET;
conf->m3u8_config.container_format = NGX_CONF_UNSET_UINT;
Expand All @@ -1131,6 +1132,7 @@ ngx_http_vod_hls_merge_loc_conf(
ngx_conf_merge_value(conf->absolute_master_urls, prev->absolute_master_urls, 1);
ngx_conf_merge_value(conf->absolute_index_urls, prev->absolute_index_urls, 1);
ngx_conf_merge_value(conf->absolute_iframe_urls, prev->absolute_iframe_urls, 0);
ngx_conf_merge_value(conf->output_iv, prev->output_iv, 0);
ngx_conf_merge_value(conf->m3u8_config.output_iframes_playlist, prev->m3u8_config.output_iframes_playlist, 1);

ngx_conf_merge_str_value(conf->master_file_name_prefix, prev->master_file_name_prefix, "master");
Expand Down
7 changes: 7 additions & 0 deletions ngx_http_vod_hls_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
NGX_HTTP_LOC_CONF_OFFSET,
BASE_OFFSET + offsetof(ngx_http_vod_hls_loc_conf_t, m3u8_config.encryption_key_format_versions),
NULL },

{ ngx_string("vod_hls_encryption_output_iv"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
ngx_conf_set_flag_slot,
NGX_HTTP_LOC_CONF_OFFSET,
BASE_OFFSET + offsetof(ngx_http_vod_hls_loc_conf_t, output_iv),
NULL },
#endif // NGX_HAVE_OPENSSL_EVP

{ ngx_string("vod_hls_container_format"),
Expand Down
1 change: 1 addition & 0 deletions ngx_http_vod_hls_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ typedef struct
ngx_http_complex_value_t* id3_data;
vod_uint_t encryption_method;
ngx_http_complex_value_t* encryption_key_uri;
bool_t output_iv;

// derived fields
m3u8_config_t m3u8_config;
Expand Down

0 comments on commit 26f0687

Please sign in to comment.