mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-14 16:01:09 +02:00
implemented play2
This commit is contained in:
parent
7e19dce7c4
commit
f53d158432
|
@ -94,7 +94,7 @@ ngx_module_t ngx_rtmp_cmd_module = {
|
|||
};
|
||||
|
||||
|
||||
static void
|
||||
void
|
||||
ngx_rtmp_cmd_fill_args(u_char name[NGX_RTMP_MAX_NAME],
|
||||
u_char args[NGX_RTMP_MAX_ARGS])
|
||||
{
|
||||
|
@ -578,6 +578,68 @@ ngx_rtmp_cmd_play(ngx_rtmp_session_t *s, ngx_rtmp_play_t *v)
|
|||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_rtmp_cmd_play2_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
||||
ngx_chain_t *in)
|
||||
{
|
||||
static u_char old_name[NGX_RTMP_MAX_NAME];
|
||||
static u_char transition[NGX_RTMP_MAX_NAME];
|
||||
static ngx_rtmp_play_t v;
|
||||
static ngx_rtmp_close_stream_t vc;
|
||||
|
||||
static ngx_rtmp_amf_elt_t in_elts[] = {
|
||||
|
||||
/* transaction is always 0 */
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
ngx_null_string,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
ngx_null_string,
|
||||
&v.start, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
ngx_null_string,
|
||||
&old_name, sizeof(old_name) },
|
||||
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
ngx_null_string,
|
||||
&v.name, sizeof(v.name) },
|
||||
|
||||
{ NGX_RTMP_AMF_OPTIONAL | NGX_RTMP_AMF_NUMBER,
|
||||
ngx_null_string,
|
||||
&v.duration, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_OPTIONAL | NGX_RTMP_AMF_STRING,
|
||||
ngx_null_string,
|
||||
&transition, sizeof(transition) }
|
||||
};
|
||||
|
||||
ngx_memzero(&v, sizeof(v));
|
||||
|
||||
if (ngx_rtmp_receive_amf(s, in, in_elts,
|
||||
sizeof(in_elts) / sizeof(in_elts[0])))
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
ngx_rtmp_cmd_fill_args(v.name, v.args);
|
||||
|
||||
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
|
||||
"play2: old_name='%s' name='%s' args='%s' "
|
||||
"start=%i duration=%i transition='%s'",
|
||||
old_name, v.name, v.args, (ngx_int_t) v.start,
|
||||
(ngx_int_t) v.duration, transition);
|
||||
|
||||
ngx_memzero(&vc, sizeof(vc));
|
||||
|
||||
/* close_stream should be synchronous */
|
||||
ngx_rtmp_close_stream(s, &vc);
|
||||
|
||||
return ngx_rtmp_play(s, &v);
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_rtmp_cmd_pause_init(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
||||
ngx_chain_t *in)
|
||||
|
@ -730,6 +792,7 @@ static ngx_rtmp_amf_handler_t ngx_rtmp_cmd_map[] = {
|
|||
{ ngx_string("deleteStream"), ngx_rtmp_cmd_delete_stream_init },
|
||||
{ ngx_string("publish"), ngx_rtmp_cmd_publish_init },
|
||||
{ ngx_string("play"), ngx_rtmp_cmd_play_init },
|
||||
{ ngx_string("play2"), ngx_rtmp_cmd_play2_init },
|
||||
{ ngx_string("seek"), ngx_rtmp_cmd_seek_init },
|
||||
{ ngx_string("pause"), ngx_rtmp_cmd_pause_init },
|
||||
{ ngx_string("pauseraw"), ngx_rtmp_cmd_pause_init },
|
||||
|
|
|
@ -97,6 +97,10 @@ typedef struct {
|
|||
} ngx_rtmp_set_buflen_t;
|
||||
|
||||
|
||||
void ngx_rtmp_cmd_fill_args(u_char name[NGX_RTMP_MAX_NAME],
|
||||
u_char args[NGX_RTMP_MAX_ARGS]);
|
||||
|
||||
|
||||
typedef ngx_int_t (*ngx_rtmp_connect_pt)(ngx_rtmp_session_t *s,
|
||||
ngx_rtmp_connect_t *v);
|
||||
typedef ngx_int_t (*ngx_rtmp_disconnect_pt)(ngx_rtmp_session_t *s);
|
||||
|
|
Loading…
Reference in a new issue