Skip to content

Commit

Permalink
add support for absolute urls in hds
Browse files Browse the repository at this point in the history
add conf var vod_hds_absolute_manifest_urls
  • Loading branch information
erankor committed Oct 31, 2016
1 parent 136875b commit d399e26
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -1284,6 +1284,13 @@ Sets the MPD format, available options are:

### Configuration directives - HDS

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

When enabled the server returns the base URL in the F4M manifest

#### vod_hds_manifest_file_name_prefix
* **syntax**: `vod_hds_manifest_file_name_prefix name`
* **default**: `manifest`
Expand Down
18 changes: 16 additions & 2 deletions ngx_http_vod_hds.c
Expand Up @@ -23,14 +23,26 @@ ngx_http_vod_hds_handle_manifest(
ngx_str_t* response,
ngx_str_t* content_type)
{
ngx_http_vod_loc_conf_t* conf = submodule_context->conf;
ngx_str_t base_url = ngx_null_string;
vod_status_t rc;

if (conf->hds.absolute_manifest_urls)
{
rc = ngx_http_vod_get_base_url(submodule_context->r, conf->base_url, &submodule_context->r->uri, &base_url);
if (rc != NGX_OK)
{
return rc;
}
}

rc = hds_packager_build_manifest(
&submodule_context->request_context,
&submodule_context->conf->hds.manifest_config,
&conf->hds.manifest_config,
&base_url,
&submodule_context->r->uri,
&submodule_context->media_set,
submodule_context->conf->drm_enabled,
conf->drm_enabled,
response);
if (rc != VOD_OK)
{
Expand Down Expand Up @@ -162,6 +174,7 @@ ngx_http_vod_hds_create_loc_conf(
ngx_conf_t *cf,
ngx_http_vod_hds_loc_conf_t *conf)
{
conf->absolute_manifest_urls = NGX_CONF_UNSET;
conf->fragment_config.generate_moof_atom = NGX_CONF_UNSET;
}

Expand All @@ -172,6 +185,7 @@ ngx_http_vod_hds_merge_loc_conf(
ngx_http_vod_hds_loc_conf_t *conf,
ngx_http_vod_hds_loc_conf_t *prev)
{
ngx_conf_merge_value(conf->absolute_manifest_urls, prev->absolute_manifest_urls, 0);
ngx_conf_merge_str_value(conf->manifest_config.fragment_file_name_prefix, prev->manifest_config.fragment_file_name_prefix, "frag");
ngx_conf_merge_str_value(conf->manifest_config.bootstrap_file_name_prefix, prev->manifest_config.bootstrap_file_name_prefix, "bootstrap");
ngx_conf_merge_str_value(conf->manifest_file_name_prefix, prev->manifest_file_name_prefix, "manifest");
Expand Down
7 changes: 7 additions & 0 deletions ngx_http_vod_hds_commands.h
@@ -1,5 +1,12 @@
#define BASE_OFFSET offsetof(ngx_http_vod_loc_conf_t, hds)

{ ngx_string("vod_hds_absolute_manifest_urls"),
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_hds_loc_conf_t, absolute_manifest_urls),
NULL },

{ ngx_string("vod_hds_manifest_file_name_prefix"),
NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_CONF_TAKE1,
ngx_conf_set_str_slot,
Expand Down
1 change: 1 addition & 0 deletions ngx_http_vod_hds_conf.h
Expand Up @@ -9,6 +9,7 @@
// typedefs
typedef struct
{
ngx_flag_t absolute_manifest_urls;
ngx_str_t manifest_file_name_prefix;
hds_manifest_config_t manifest_config;
hds_fragment_config_t fragment_config;
Expand Down
10 changes: 10 additions & 0 deletions vod/hds/hds_manifest.c
Expand Up @@ -12,6 +12,9 @@
" xmlns=\"http://ns.adobe.com/f4m/1.0\">\n" \
" <id>%V</id>\n"

#define HDS_MANIFEST_HEADER_BASE_URL \
" <baseURL>%V</baseURL>\n"

#define HDS_MANIFEST_HEADER_VOD \
" <duration>%uD.%03uD</duration>\n" \
" <streamType>recorded</streamType>\n"
Expand Down Expand Up @@ -354,6 +357,7 @@ vod_status_t
hds_packager_build_manifest(
request_context_t* request_context,
hds_manifest_config_t* conf,
vod_str_t* base_url,
vod_str_t* manifest_id,
media_set_t* media_set,
bool_t drm_enabled,
Expand Down Expand Up @@ -407,6 +411,7 @@ hds_packager_build_manifest(
// calculate the result size
result_size =
sizeof(HDS_MANIFEST_HEADER) - 1 + manifest_id->len +
sizeof(HDS_MANIFEST_HEADER_BASE_URL) - 1 + base_url->len +
sizeof(HDS_MANIFEST_HEADER_LANG) - 1 + LANG_ISO639_2_LEN +
sizeof(HDS_MANIFEST_FOOTER);

Expand Down Expand Up @@ -534,6 +539,11 @@ hds_packager_build_manifest(
// print the manifest header
p = vod_sprintf(result->data, HDS_MANIFEST_HEADER, manifest_id);

if (base_url->len != 0)
{
p = vod_sprintf(p, HDS_MANIFEST_HEADER_BASE_URL, base_url);
}

switch (media_set->type)
{
case MEDIA_SET_VOD:
Expand Down
1 change: 1 addition & 0 deletions vod/hds/hds_manifest.h
Expand Up @@ -22,6 +22,7 @@ vod_status_t hds_packager_build_bootstrap(
vod_status_t hds_packager_build_manifest(
request_context_t* request_context,
hds_manifest_config_t* conf,
vod_str_t* base_url,
vod_str_t* manifest_id,
media_set_t* media_set,
bool_t drm_enabled,
Expand Down

0 comments on commit d399e26

Please sign in to comment.