@@ -31,7 +31,7 @@ static ngx_int_t ngx_rtmp_hls_ensure_directory(ngx_rtmp_session_t *s,
3131
3232
3333#define NGX_RTMP_HLS_BUFSIZE (1024*1024)
34- #define NGX_RTMP_HLS_DIR_ACCESS 0744
34+ #define NGX_RTMP_HLS_DEFAULT_DIR_ACCESS 0744
3535
3636
3737typedef struct {
@@ -115,6 +115,8 @@ typedef struct {
115115 ngx_str_t key_path ;
116116 ngx_str_t key_url ;
117117 ngx_uint_t frags_per_key ;
118+ ngx_uint_t dir_access ;
119+ ngx_str_t nested_index_filename ;
118120} ngx_rtmp_hls_app_conf_t ;
119121
120122
@@ -309,6 +311,20 @@ static ngx_command_t ngx_rtmp_hls_commands[] = {
309311 offsetof(ngx_rtmp_hls_app_conf_t , frags_per_key ),
310312 NULL },
311313
314+ { ngx_string ("hls_dir_access" ),
315+ NGX_RTMP_MAIN_CONF |NGX_RTMP_SRV_CONF |NGX_RTMP_APP_CONF |NGX_CONF_TAKE1 ,
316+ ngx_conf_set_num_slot ,
317+ NGX_RTMP_APP_CONF_OFFSET ,
318+ offsetof(ngx_rtmp_hls_app_conf_t , dir_access ),
319+ NULL },
320+
321+ { ngx_string ("hls_nested_index_filename" ),
322+ NGX_RTMP_MAIN_CONF |NGX_RTMP_SRV_CONF |NGX_RTMP_APP_CONF |NGX_CONF_TAKE1 ,
323+ ngx_conf_set_str_slot ,
324+ NGX_RTMP_APP_CONF_OFFSET ,
325+ offsetof(ngx_rtmp_hls_app_conf_t , nested_index_filename ),
326+ NULL },
327+
312328 ngx_null_command
313329};
314330
@@ -450,7 +466,7 @@ ngx_rtmp_hls_write_variant_playlist(ngx_rtmp_session_t *s)
450466 ctx -> name .len - ctx -> var -> suffix .len , ctx -> name .data ,
451467 & var -> suffix );
452468 if (hacf -> nested ) {
453- p = ngx_slprintf (p , last , "%s " , "/index" );
469+ p = ngx_slprintf (p , last , "/%V " , & hacf -> nested_index_filename );
454470 }
455471
456472 p = ngx_slprintf (p , last , "%s" , ".m3u8\n" );
@@ -1202,7 +1218,7 @@ ngx_rtmp_hls_ensure_directory(ngx_rtmp_session_t *s, ngx_str_t *path)
12021218
12031219 /* ENOENT */
12041220
1205- if (ngx_create_dir (zpath , NGX_RTMP_HLS_DIR_ACCESS ) == NGX_FILE_ERROR ) {
1221+ if (ngx_create_dir (zpath , hacf -> dir_access ) == NGX_FILE_ERROR ) {
12061222 ngx_log_error (NGX_LOG_ERR , s -> connection -> log , ngx_errno ,
12071223 "hls: " ngx_create_dir_n " failed on '%V'" , path );
12081224 return NGX_ERROR ;
@@ -1264,7 +1280,7 @@ ngx_rtmp_hls_ensure_directory(ngx_rtmp_session_t *s, ngx_str_t *path)
12641280
12651281 /* NGX_ENOENT */
12661282
1267- if (ngx_create_dir (zpath , NGX_RTMP_HLS_DIR_ACCESS ) == NGX_FILE_ERROR ) {
1283+ if (ngx_create_dir (zpath , hacf -> dir_access ) == NGX_FILE_ERROR ) {
12681284 ngx_log_error (NGX_LOG_ERR , s -> connection -> log , ngx_errno ,
12691285 "hls: " ngx_create_dir_n " failed on '%s'" , zpath );
12701286 return NGX_ERROR ;
@@ -1350,7 +1366,7 @@ ngx_rtmp_hls_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
13501366
13511367 len = hacf -> path .len + 1 + ctx -> name .len + sizeof (".m3u8" );
13521368 if (hacf -> nested ) {
1353- len += sizeof ( "/index" ) - 1 ;
1369+ len += hacf -> nested_index_filename . len + 1 ;
13541370 }
13551371
13561372 ctx -> playlist .data = ngx_palloc (s -> connection -> pool , len );
@@ -1421,10 +1437,10 @@ ngx_rtmp_hls_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
14211437 /* playlist path */
14221438
14231439 if (hacf -> nested ) {
1424- p = ngx_cpymem (p , "/index.m3u8" , sizeof ("/index.m3u8" ) - 1 );
1425- } else {
1426- p = ngx_cpymem (p , ".m3u8" , sizeof (".m3u8" ) - 1 );
1440+ p = ngx_cpymem (p , "/" , sizeof ("/" ) - 1 );
1441+ p = ngx_cpymem (p , hacf -> nested_index_filename .data , hacf -> nested_index_filename .len );
14271442 }
1443+ p = ngx_cpymem (p , ".m3u8" , sizeof (".m3u8" ) - 1 );
14281444
14291445 ctx -> playlist .len = p - ctx -> playlist .data ;
14301446
@@ -2350,6 +2366,7 @@ ngx_rtmp_hls_create_app_conf(ngx_conf_t *cf)
23502366 conf -> granularity = NGX_CONF_UNSET ;
23512367 conf -> keys = NGX_CONF_UNSET ;
23522368 conf -> frags_per_key = NGX_CONF_UNSET_UINT ;
2369+ conf -> dir_access = NGX_CONF_UNSET_UINT ;
23532370
23542371 return conf ;
23552372}
@@ -2388,6 +2405,8 @@ ngx_rtmp_hls_merge_app_conf(ngx_conf_t *cf, void *parent, void *child)
23882405 /*ngx_conf_merge_str_value(conf->key_path, prev->key_path, "");*/
23892406 ngx_conf_merge_str_value (conf -> key_url , prev -> key_url , "" );
23902407 ngx_conf_merge_uint_value (conf -> frags_per_key , prev -> frags_per_key , 0 );
2408+ ngx_conf_merge_uint_value (conf -> dir_access , prev -> dir_access , NGX_RTMP_HLS_DEFAULT_DIR_ACCESS );
2409+ ngx_conf_merge_str_value (conf -> nested_index_filename , prev -> nested_index_filename , "index" );
23912410
23922411 if (conf -> fraglen ) {
23932412 conf -> winfrags = conf -> playlen / conf -> fraglen ;
0 commit comments