Example #1
0
static void
ngx_rtmp_handshake_done(ngx_rtmp_session_t *s)
{
    ngx_rtmp_free_handshake_buffers(s);

    ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
            "handshake: done");

    if (ngx_rtmp_fire_event(s, NGX_RTMP_HANDSHAKE_DONE,
                NULL, NULL) != NGX_OK)
    {
        ngx_rtmp_finalize_session(s);
        return;
    }

    ngx_rtmp_cycle(s);
}
static void
ngx_rtmp_close_session_handler(ngx_event_t *e)
{
    ngx_rtmp_session_t                 *s;
    ngx_connection_t                   *c;
    ngx_rtmp_core_srv_conf_t           *cscf;

    s = e->data;
    c = s->connection;

    cscf = ngx_rtmp_get_module_srv_conf(s, ngx_rtmp_core_module);

    ngx_log_debug0(NGX_LOG_DEBUG_RTMP, c->log, 0, "close session");

    if (s) {
        ngx_rtmp_fire_event(s, NGX_RTMP_DISCONNECT, NULL, NULL);

        if (s->ping_evt.timer_set) {
            ngx_del_timer(&s->ping_evt);
        }

        if (s->in_old_pool) {
            ngx_destroy_pool(s->in_old_pool);
        }

        if (s->in_pool) {
            ngx_destroy_pool(s->in_pool);
        }

        ngx_rtmp_free_handshake_buffers(s);

        while (s->out_pos != s->out_last) {
            ngx_rtmp_free_shared_chain(cscf, s->out[s->out_pos++]);
            s->out_pos %= s->out_queue;
        }
    }

    ngx_rtmp_close_connection(c);
}