mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-06-13 18:49:32 +02:00
Merge pull request #39 from sergey-dryabzhinsky/dummy-fcpublish-response
Add dummy response for onFCPublish
This commit is contained in:
commit
0d0882b29d
|
@ -586,6 +586,8 @@ 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,
|
ngx_int_t ngx_rtmp_send_redirect_status(ngx_rtmp_session_t *s,
|
||||||
char *callMethod, char *desc, ngx_str_t to_url);
|
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_close_method(ngx_rtmp_session_t *s, char *methodName);
|
||||||
|
ngx_int_t ngx_rtmp_send_fcpublish(ngx_rtmp_session_t *s, char *desc);
|
||||||
|
ngx_int_t ngx_rtmp_send_fcunpublish(ngx_rtmp_session_t *s, char *desc);
|
||||||
|
|
||||||
|
|
||||||
/* Frame types */
|
/* Frame types */
|
||||||
|
|
|
@ -1194,6 +1194,123 @@ ngx_rtmp_live_on_fi(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
||||||
sizeof(out_elts) / sizeof(out_elts[0]));
|
sizeof(out_elts) / sizeof(out_elts[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ngx_int_t
|
||||||
|
ngx_rtmp_live_on_fcpublish(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
||||||
|
ngx_chain_t *in)
|
||||||
|
{
|
||||||
|
|
||||||
|
ngx_rtmp_live_app_conf_t *lacf;
|
||||||
|
ngx_rtmp_live_ctx_t *ctx;
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
double trans;
|
||||||
|
u_char action[128];
|
||||||
|
u_char stream[1024];
|
||||||
|
} v;
|
||||||
|
|
||||||
|
static ngx_rtmp_amf_elt_t in_elts[] = {
|
||||||
|
|
||||||
|
// Already readed
|
||||||
|
/* { NGX_RTMP_AMF_STRING,
|
||||||
|
ngx_null_string,
|
||||||
|
&v.action, sizeof(v.action) },
|
||||||
|
*/
|
||||||
|
{ NGX_RTMP_AMF_NUMBER,
|
||||||
|
ngx_null_string,
|
||||||
|
&v.trans, 0 },
|
||||||
|
|
||||||
|
{ NGX_RTMP_AMF_NULL,
|
||||||
|
ngx_null_string,
|
||||||
|
NULL, 0 },
|
||||||
|
|
||||||
|
{ NGX_RTMP_AMF_STRING,
|
||||||
|
ngx_null_string,
|
||||||
|
&v.stream, sizeof(v.stream) },
|
||||||
|
};
|
||||||
|
|
||||||
|
lacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_live_module);
|
||||||
|
if (lacf == NULL) {
|
||||||
|
ngx_log_error(NGX_LOG_DEBUG, s->connection->log, 0,
|
||||||
|
"live: FCPublish - no live config!");
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lacf->live || in == NULL || in->buf == NULL) {
|
||||||
|
ngx_log_error(NGX_LOG_DEBUG, s->connection->log, 0,
|
||||||
|
"live: FCPublish - no live or no buffer!");
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_memzero(&v, sizeof(v));
|
||||||
|
ngx_rtmp_receive_amf(s, in, in_elts,
|
||||||
|
sizeof(in_elts) / sizeof(in_elts[0]));
|
||||||
|
|
||||||
|
ngx_log_error(NGX_LOG_DEBUG, s->connection->log, 0,
|
||||||
|
"live: onFCPublish: stream='%s'",
|
||||||
|
v.stream);
|
||||||
|
|
||||||
|
return ngx_rtmp_send_fcpublish(s, v.stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_int_t
|
||||||
|
ngx_rtmp_live_on_fcunpublish(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
||||||
|
ngx_chain_t *in)
|
||||||
|
{
|
||||||
|
|
||||||
|
ngx_rtmp_live_app_conf_t *lacf;
|
||||||
|
ngx_rtmp_live_ctx_t *ctx;
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
double trans;
|
||||||
|
u_char action[128];
|
||||||
|
u_char stream[1024];
|
||||||
|
} v;
|
||||||
|
|
||||||
|
static ngx_rtmp_amf_elt_t in_elts[] = {
|
||||||
|
|
||||||
|
// Already readed
|
||||||
|
/* { NGX_RTMP_AMF_STRING,
|
||||||
|
ngx_null_string,
|
||||||
|
&v.action, sizeof(v.action) },
|
||||||
|
*/
|
||||||
|
{ NGX_RTMP_AMF_NUMBER,
|
||||||
|
ngx_null_string,
|
||||||
|
&v.trans, 0 },
|
||||||
|
|
||||||
|
{ NGX_RTMP_AMF_NULL,
|
||||||
|
ngx_null_string,
|
||||||
|
NULL, 0 },
|
||||||
|
|
||||||
|
{ NGX_RTMP_AMF_STRING,
|
||||||
|
ngx_null_string,
|
||||||
|
&v.stream, sizeof(v.stream) },
|
||||||
|
};
|
||||||
|
|
||||||
|
lacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_live_module);
|
||||||
|
if (lacf == NULL) {
|
||||||
|
ngx_log_error(NGX_LOG_DEBUG, s->connection->log, 0,
|
||||||
|
"live: FCUnpublish - no live config!");
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lacf->live || in == NULL || in->buf == NULL) {
|
||||||
|
ngx_log_error(NGX_LOG_DEBUG, s->connection->log, 0,
|
||||||
|
"live: FCUnpublish - no live or no buffer!");
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_memzero(&v, sizeof(v));
|
||||||
|
ngx_rtmp_receive_amf(s, in, in_elts,
|
||||||
|
sizeof(in_elts) / sizeof(in_elts[0]));
|
||||||
|
|
||||||
|
ngx_log_error(NGX_LOG_DEBUG, s->connection->log, 0,
|
||||||
|
"live: onFCUnpublish: stream='%s'",
|
||||||
|
v.stream);
|
||||||
|
|
||||||
|
return ngx_rtmp_send_fcunpublish(s, v.stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_rtmp_live_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
|
ngx_rtmp_live_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
|
||||||
|
@ -1320,5 +1437,13 @@ ngx_rtmp_live_postconfiguration(ngx_conf_t *cf)
|
||||||
ngx_str_set(&ch->name, "onFi");
|
ngx_str_set(&ch->name, "onFi");
|
||||||
ch->handler = ngx_rtmp_live_on_fi;
|
ch->handler = ngx_rtmp_live_on_fi;
|
||||||
|
|
||||||
|
ch = ngx_array_push(&cmcf->amf);
|
||||||
|
ngx_str_set(&ch->name, "FCPublish");
|
||||||
|
ch->handler = ngx_rtmp_live_on_fcpublish;
|
||||||
|
|
||||||
|
ch = ngx_array_push(&cmcf->amf);
|
||||||
|
ngx_str_set(&ch->name, "FCUnpublish");
|
||||||
|
ch->handler = ngx_rtmp_live_on_fcunpublish;
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
136
ngx_rtmp_send.c
136
ngx_rtmp_send.c
|
@ -733,6 +733,142 @@ 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 = 3.0; // magick from ffmpeg
|
||||||
|
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_fcunpublish(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.Unpublish.Success", 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,
|
||||||
|
"onFCUnpublish", 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: fcunpublish desc='%s'",
|
||||||
|
desc);
|
||||||
|
|
||||||
|
out_inf[2].data = desc;
|
||||||
|
// trans = 5.0; // magick from ffmpeg
|
||||||
|
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_fcunpublish(ngx_rtmp_session_t *s, char *desc)
|
||||||
|
{
|
||||||
|
return ngx_rtmp_send_shared_packet(s,
|
||||||
|
ngx_rtmp_create_fcunpublish(s, desc));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ngx_chain_t *
|
ngx_chain_t *
|
||||||
ngx_rtmp_create_sample_access(ngx_rtmp_session_t *s)
|
ngx_rtmp_create_sample_access(ngx_rtmp_session_t *s)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue