mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-15 16:31:07 +02:00
Add amf sender for FCPublish
This commit is contained in:
parent
f29fbc89a4
commit
414053862c
|
@ -586,6 +586,7 @@ ngx_int_t ngx_rtmp_send_sample_access(ngx_rtmp_session_t *s);
|
|||
ngx_int_t ngx_rtmp_send_redirect_status(ngx_rtmp_session_t *s,
|
||||
char *callMethod, char *desc, ngx_str_t to_url);
|
||||
ngx_int_t ngx_rtmp_send_close_method(ngx_rtmp_session_t *s, char *methodName);
|
||||
ngx_int_t ngx_rtmp_send_fcpublish(ngx_rtmp_session_t *s, char *desc);
|
||||
|
||||
|
||||
/* Frame types */
|
||||
|
|
|
@ -1198,15 +1198,31 @@ static ngx_int_t
|
|||
ngx_rtmp_live_on_fcpublish(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
||||
ngx_chain_t *in)
|
||||
{
|
||||
static ngx_rtmp_amf_elt_t out_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
ngx_null_string,
|
||||
"onFCPublish", 0 }
|
||||
};
|
||||
ngx_rtmp_live_app_conf_t *lacf;
|
||||
ngx_rtmp_live_ctx_t *ctx;
|
||||
|
||||
return ngx_rtmp_live_data(s, h, in, out_elts,
|
||||
sizeof(out_elts) / sizeof(out_elts[0]));
|
||||
lacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_live_module);
|
||||
if (lacf == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (!lacf->live || in == NULL || in->buf == NULL) {
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_live_module);
|
||||
if (ctx == NULL || ctx->stream == NULL) {
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
if (ctx->publishing == 0) {
|
||||
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
|
||||
"live: FCPublish from non-publisher: name=%s, ip=%s", ctx->stream->name, s->addr_text);
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
return ngx_rtmp_send_fcpublish(s, ctx->stream->name);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -733,6 +733,73 @@ ngx_rtmp_send_close_method(ngx_rtmp_session_t *s, char *methodName)
|
|||
}
|
||||
|
||||
|
||||
ngx_chain_t *
|
||||
ngx_rtmp_create_fcpublish(ngx_rtmp_session_t *s, char *desc)
|
||||
{
|
||||
ngx_rtmp_header_t h;
|
||||
static double trans;
|
||||
|
||||
static ngx_rtmp_amf_elt_t out_inf[] = {
|
||||
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
ngx_string("level"),
|
||||
"status", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
ngx_string("code"),
|
||||
"NetStream.Publish.Start", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
ngx_string("description"),
|
||||
NULL, 0 },
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf_elt_t out_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
ngx_null_string,
|
||||
"onFCPublish", 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
ngx_null_string,
|
||||
&trans, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_NULL,
|
||||
ngx_null_string,
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
ngx_null_string,
|
||||
out_inf,
|
||||
sizeof(out_inf) },
|
||||
};
|
||||
|
||||
ngx_log_error(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
"create: fcpublish desc='%s'",
|
||||
desc);
|
||||
|
||||
out_inf[2].data = desc;
|
||||
trans = 0;
|
||||
|
||||
memset(&h, 0, sizeof(h));
|
||||
|
||||
h.type = NGX_RTMP_MSG_AMF_CMD;
|
||||
h.csid = NGX_RTMP_CSID_AMF;
|
||||
h.msid = NGX_RTMP_MSID;
|
||||
|
||||
return ngx_rtmp_create_amf(s, &h, out_elts,
|
||||
sizeof(out_elts) / sizeof(out_elts[0]));
|
||||
}
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_rtmp_send_fcpublish(ngx_rtmp_session_t *s, char *desc)
|
||||
{
|
||||
return ngx_rtmp_send_shared_packet(s,
|
||||
ngx_rtmp_create_fcpublish(s, desc));
|
||||
}
|
||||
|
||||
|
||||
ngx_chain_t *
|
||||
ngx_rtmp_create_sample_access(ngx_rtmp_session_t *s)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue