示例#1
0
static ngx_int_t
ngx_rtmp_play_close_stream(ngx_rtmp_session_t *s, ngx_rtmp_close_stream_t *v)
{
    ngx_rtmp_play_ctx_t            *ctx;

    ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_play_module);

    if (ctx == NULL) {
        goto next;
    }

    ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
                   "play: close_stream");

    ngx_rtmp_play_stop(s);

    ngx_rtmp_play_done(s);

    if (ctx->file.fd != NGX_INVALID_FILE) {
        ngx_close_file(ctx->file.fd);
        ctx->file.fd = NGX_INVALID_FILE;
    }

next:
    return next_close_stream(s, v);
}
示例#2
0
static ngx_int_t
ngx_rtmp_play_start(ngx_rtmp_session_t *s, double timestamp)
{
    ngx_rtmp_play_ctx_t            *ctx;
    ngx_uint_t                      ts;

    ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_play_module);

    if (ctx == NULL) {
        return NGX_ERROR;
    }

    ngx_rtmp_play_stop(s);

    ts = (timestamp > 0 ? (ngx_uint_t) timestamp : 0);

    ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
                   "play: start timestamp=%ui", ts);

    if (ctx->fmt && ctx->fmt->start &&
        ctx->fmt->start(s, &ctx->file, ts) != NGX_OK)
    {
        return NGX_ERROR;
    }

    ngx_post_event((&ctx->send_evt), &ngx_posted_events);

    return NGX_OK;
}
static ngx_int_t
ngx_rtmp_play_pause(ngx_rtmp_session_t *s, ngx_rtmp_pause_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;
    }

    ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
                  "play: pause=%i timestamp=%i",
                   (ngx_int_t) v->pause, (ngx_int_t) v->position);

    if (v->pause) {
        ngx_rtmp_play_stop(s);
    } else {
        ngx_rtmp_play_start(s, v->position);
    }

next:
    return next_pause(s, v);
}
static ngx_int_t
ngx_rtmp_play_start(ngx_rtmp_session_t *s, ngx_int_t timestamp)
{
    ngx_rtmp_play_ctx_t            *ctx;

    ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_play_module);
    if (ctx == NULL) {
        return NGX_OK;
    }

    ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
                  "play: start timestamp=%i", timestamp);

    ngx_rtmp_play_stop(s);

    ctx->start_timestamp = timestamp;
    ctx->offset = -1;
    ctx->msg_mask = 0;

    ngx_post_event((&ctx->write_evt), &ngx_posted_events)

    return NGX_OK;
}