static ngx_int_t ngx_rtmp_play_seek(ngx_rtmp_session_t *s, ngx_rtmp_seek_t *v) { ngx_rtmp_play_ctx_t *ctx; ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_play_module); if (ctx == NULL || ctx->file.fd == NGX_INVALID_FILE) { goto next; } if (ngx_rtmp_send_stream_eof(s, NGX_RTMP_MSID) != NGX_OK) { return NGX_ERROR; } ngx_rtmp_play_do_seek(s, v->offset); if (ngx_rtmp_send_status(s, "NetStream.Seek.Notify", "status", "Seeking") != NGX_OK) { return NGX_ERROR; } if (ngx_rtmp_send_stream_begin(s, NGX_RTMP_MSID) != NGX_OK) { return NGX_ERROR; } next: return next_seek(s, v); }
static ngx_int_t ngx_rtmp_play_open(ngx_rtmp_session_t *s, double start) { ngx_rtmp_play_ctx_t *ctx; ngx_event_t *e; ngx_uint_t timestamp; ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_play_module); if (ctx->file.fd == NGX_INVALID_FILE) { return NGX_ERROR; } if (ngx_rtmp_send_stream_begin(s, NGX_RTMP_MSID) != NGX_OK) { return NGX_ERROR; } if (ngx_rtmp_send_status(s, "NetStream.Play.Start", "status", "Start video on demand") != NGX_OK) { return NGX_ERROR; } if (ngx_rtmp_play_join(s) != NGX_OK) { return NGX_ERROR; } e = &ctx->send_evt; e->data = s; e->handler = ngx_rtmp_play_send; e->log = s->connection->log; ngx_rtmp_send_recorded(s, 1); if (ngx_rtmp_send_sample_access(s) != NGX_OK) { return NGX_ERROR; } if (ngx_rtmp_play_do_init(s) != NGX_OK) { return NGX_ERROR; } timestamp = ctx->post_seek != NGX_CONF_UNSET_UINT ? ctx->post_seek : (start < 0 ? 0 : (ngx_uint_t) start); if (ngx_rtmp_play_do_seek(s, timestamp) != NGX_OK) { return NGX_ERROR; } if (ngx_rtmp_play_do_start(s) != NGX_OK) { return NGX_ERROR; } ctx->opened = 1; return NGX_OK; }
static ngx_int_t ngx_rtmp_play_open(ngx_rtmp_session_t *s, double start) { ngx_rtmp_play_ctx_t *ctx; ngx_event_t *e; ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_play_module); if (ctx->file.fd == NGX_INVALID_FILE) { return NGX_ERROR; } if (ngx_rtmp_send_stream_begin(s, NGX_RTMP_MSID) != NGX_OK) { return NGX_ERROR; } if (ngx_rtmp_send_status(s, "NetStream.Play.Start", "status", "Start video on demand") != NGX_OK) { return NGX_ERROR; } e = &ctx->send_evt; e->data = s; e->handler = ngx_rtmp_play_send; e->log = s->connection->log; ngx_rtmp_send_recorded(s, 1); if (ngx_rtmp_play_do_init(s) != NGX_OK) { return NGX_ERROR; } if (ngx_rtmp_play_do_seek(s, start < 0 ? 0 : start) != NGX_OK) { return NGX_ERROR; } if (ngx_rtmp_play_do_start(s) != NGX_OK) { return NGX_ERROR; } return NGX_OK; }
static ngx_int_t ngx_rtmp_play_seek(ngx_rtmp_session_t *s, ngx_rtmp_seek_t *v) { ngx_rtmp_play_ctx_t *ctx; ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_play_module); if (ctx == NULL || ctx->file.fd == NGX_INVALID_FILE) { goto next; } if (!ctx->opened) { ctx->post_seek = (ngx_uint_t) v->offset; ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, "play: post seek=%ui", ctx->post_seek); goto next; } if (ngx_rtmp_send_stream_eof(s, NGX_RTMP_MSID) != NGX_OK) { return NGX_ERROR; } ngx_rtmp_play_do_seek(s, (ngx_uint_t) v->offset); if (ngx_rtmp_send_status(s, "NetStream.Seek.Notify", "status", "Seeking") != NGX_OK) { return NGX_ERROR; } if (ngx_rtmp_send_stream_begin(s, NGX_RTMP_MSID) != NGX_OK) { return NGX_ERROR; } next: return next_seek(s, v); }