[-]
[+]
|
Changed |
nginx.spec
|
|
[-]
[+]
|
Changed |
nginx-rtmp-module-0.9.1.tar.bz2/TODO
^
|
@@ -1,20 +1,16 @@
-- improve session epoch variable
-
-- exec_init
+- multiple tracks in vod/mp4
-- improve drop engine to restart at key frame
+- HLS problem on publish restart
-- access log
-- rooms (+force pull)
+- improve session epoch variable
-- auto_push for pull
+- exec_init
- fix auto-pushing to cache manager
- HDS
-
- DNS round-robin url
- multiple streams per connection
|
[-]
[+]
|
Changed |
nginx-rtmp-module-0.9.1.tar.bz2/hls/ngx_rtmp_hls_module.c
^
|
@@ -94,6 +94,7 @@
ngx_msec_t sync;
ngx_msec_t playlen;
size_t nfrags;
+ ngx_flag_t continuous;
ngx_rtmp_hls_ctx_t **ctx;
ngx_uint_t nbuckets;
ngx_str_t path;
@@ -144,6 +145,12 @@
offsetof(ngx_rtmp_hls_app_conf_t, sync),
NULL },
+ { ngx_string("hls_continuous"),
+ NGX_RTMP_MAIN_CONF|NGX_RTMP_SRV_CONF|NGX_RTMP_APP_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_flag_slot,
+ NGX_RTMP_APP_CONF_OFFSET,
+ offsetof(ngx_rtmp_hls_app_conf_t, continuous),
+ NULL },
ngx_null_command
};
@@ -802,6 +809,71 @@
}
+static void
+ngx_rtmp_hls_restore_frag(ngx_rtmp_session_t *s)
+{
+ ngx_rtmp_hls_ctx_t *ctx;
+ ngx_file_t file;
+ ngx_file_info_t fi;
+ ssize_t ret;
+ u_char *p, *last;
+ u_char buffer[sizeof("-.ts\r\n") +
+ NGX_OFF_T_LEN];
+
+ /* try to restore frag from previously stored playlist */
+
+ ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_hls_module);
+
+ ngx_memzero(&file, sizeof(file));
+
+ file.log = s->connection->log;
+
+ file.fd = ngx_open_file(ctx->playlist.data, NGX_FILE_RDONLY, NGX_FILE_OPEN,
+ 0);
+ if (file.fd == NGX_INVALID_FILE) {
+ return;
+ }
+
+ if (ngx_fd_info(file.fd, &fi)) {
+ goto done;
+ }
+
+ ret = ngx_read_file(&file, buffer, sizeof(buffer),
+ fi.st_size > (off_t) sizeof(buffer) ?
+ fi.st_size - sizeof(buffer) : 0);
+ if (ret <= 0) {
+ goto done;
+ }
+
+ /* last line example:
+ * mystream-14.ts\r\n */
+
+ if (ret < (ssize_t) sizeof(".ts\r\n")) {
+ goto done;
+ }
+
+ ret -= (sizeof(".ts\r\n") - 1);
+
+ last = buffer + ret;
+ p = last;
+ while (p > buffer && *(p - 1) != '-') {
+ --p;
+ }
+
+ if (p == buffer) {
+ goto done;
+ }
+
+ ctx->frag = ngx_atoi(p, (size_t) (last - p)) + 1;
+
+ ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
+ "hls: restored frag=%i", ctx->frag);
+
+done:
+ ngx_close_file(file.fd);
+}
+
+
static ngx_int_t
ngx_rtmp_hls_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
{
@@ -872,6 +944,10 @@
"hls: playlist='%V' playlist_bak='%V' stream_pattern='%V'",
&ctx->playlist, &ctx->playlist_bak, &ctx->stream);
+ if (hacf->continuous) {
+ ngx_rtmp_hls_restore_frag(s);
+ }
+
/* schedule restart event */
ctx->publishing = 1;
ctx->frag_start = ngx_current_msec - hacf->fraglen - 1;
@@ -1170,6 +1246,7 @@
conf->muxdelay = NGX_CONF_UNSET;
conf->sync = NGX_CONF_UNSET;
conf->playlen = NGX_CONF_UNSET;
+ conf->continuous = NGX_CONF_UNSET;
conf->nbuckets = 1024;
return conf;
@@ -1185,9 +1262,10 @@
ngx_conf_merge_value(conf->hls, prev->hls, 0);
ngx_conf_merge_msec_value(conf->fraglen, prev->fraglen, 5000);
ngx_conf_merge_msec_value(conf->muxdelay, prev->muxdelay, 700);
- ngx_conf_merge_msec_value(conf->sync, prev->sync, 0);
+ ngx_conf_merge_msec_value(conf->sync, prev->sync, 300);
ngx_conf_merge_msec_value(conf->playlen, prev->playlen, 30000);
ngx_conf_merge_str_value(conf->path, prev->path, "");
+ ngx_conf_merge_value(conf->continuous, prev->continuous, 0);
conf->ctx = ngx_pcalloc(cf->pool,
sizeof(ngx_rtmp_hls_ctx_t *) * conf->nbuckets);
if (conf->ctx == NULL) {
|
[-]
[+]
|
Changed |
nginx-rtmp-module-0.9.1.tar.bz2/ngx_rtmp_cmd_module.c
^
|
@@ -134,8 +134,8 @@
ngx_rtmp_core_srv_conf_t *cscf;
ngx_rtmp_core_app_conf_t **cacfp;
ngx_uint_t n;
- size_t len;
ngx_rtmp_header_t h;
+ u_char *p;
static double trans;
static double capabilities = NGX_RTMP_CAPABILITIES;
@@ -229,16 +229,19 @@
#undef NGX_RTMP_SET_STRPAR
+ p = ngx_strlchr(s->app.data, s->app.data + s->app.len, '?');
+ if (p) {
+ s->app.len = (p - s->app.data);
+ }
+
s->acodecs = v->acodecs;
s->vcodecs = v->vcodecs;
/* find application & set app_conf */
- len = ngx_strlen(v->app);
-
cacfp = cscf->applications.elts;
for(n = 0; n < cscf->applications.nelts; ++n, ++cacfp) {
- if ((*cacfp)->name.len == len
- && !ngx_strncmp((*cacfp)->name.data, v->app, len))
+ if ((*cacfp)->name.len == s->app.len &&
+ ngx_strncmp((*cacfp)->name.data, s->app.data, s->app.len) == 0)
{
/* found app! */
s->app_conf = (*cacfp)->app_conf;
@@ -248,7 +251,7 @@
if (s->app_conf == NULL) {
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
- "connect: application not found: '%s'", v->app);
+ "connect: application not found: '%V'", &s->app);
return NGX_ERROR;
}
|
[-]
[+]
|
Changed |
nginx-rtmp-module-0.9.1.tar.bz2/ngx_rtmp_record_module.c
^
|
@@ -89,6 +89,14 @@
offsetof(ngx_rtmp_record_app_conf_t, unique),
NULL },
+ { ngx_string("record_lock"),
+ NGX_RTMP_MAIN_CONF|NGX_RTMP_SRV_CONF|NGX_RTMP_APP_CONF|
+ NGX_RTMP_REC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_flag_slot,
+ NGX_RTMP_APP_CONF_OFFSET,
+ offsetof(ngx_rtmp_record_app_conf_t, lock_file),
+ NULL },
+
{ ngx_string("record_max_size"),
NGX_RTMP_MAIN_CONF|NGX_RTMP_SRV_CONF|NGX_RTMP_APP_CONF|
NGX_RTMP_REC_CONF|NGX_CONF_TAKE1,
@@ -176,6 +184,7 @@
racf->max_frames = NGX_CONF_UNSET;
racf->interval = NGX_CONF_UNSET;
racf->unique = NGX_CONF_UNSET;
+ racf->lock_file = NGX_CONF_UNSET;
racf->notify = NGX_CONF_UNSET;
racf->url = NGX_CONF_UNSET_PTR;
@@ -199,6 +208,7 @@
ngx_conf_merge_size_value(conf->max_size, prev->max_size, 0);
ngx_conf_merge_size_value(conf->max_frames, prev->max_frames, 0);
ngx_conf_merge_value(conf->unique, prev->unique, 0);
+ ngx_conf_merge_value(conf->lock_file, prev->lock_file, 0);
ngx_conf_merge_value(conf->notify, prev->notify, 0);
ngx_conf_merge_msec_value(conf->interval, prev->interval,
(ngx_msec_t) NGX_CONF_UNSET);
@@ -448,6 +458,14 @@
return NGX_OK;
}
+ if (rracf->lock_file) {
+ err = ngx_lock_fd(rctx->file.fd);
+ if (err) {
+ ngx_log_error(NGX_LOG_CRIT, s->connection->log, err,
+ "record: %V lock failed", &rracf->id);
+ }
+ }
+
ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"record: %V opened '%V'", &rracf->id, &path);
|
[-]
[+]
|
Changed |
nginx-rtmp-module-0.9.1.tar.bz2/ngx_rtmp_record_module.h
^
|
@@ -26,6 +26,7 @@
ngx_msec_t interval;
ngx_str_t suffix;
ngx_flag_t unique;
+ ngx_flag_t lock_file;
ngx_flag_t notify;
ngx_url_t *url;
|