mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-20 18:01:08 +02:00
Try to send right amf data
This commit is contained in:
parent
175cc47e3f
commit
41d7b0e988
|
@ -169,6 +169,7 @@ static ngx_int_t
|
|||
ngx_rtmp_bandwidth_detection_on_result(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
|
||||
ngx_chain_t *in)
|
||||
{
|
||||
ngx_rtmp_bandwidth_detection_app_conf_t *acf;
|
||||
ngx_rtmp_bandwidth_detection_ctx_t *ctx;
|
||||
|
||||
static struct {
|
||||
|
@ -195,6 +196,13 @@ ngx_rtmp_bandwidth_detection_on_result(ngx_rtmp_session_t *s, ngx_rtmp_header_t
|
|||
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
"bandwidth_detection: _result");
|
||||
|
||||
acf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_bandwidth_detection_module);
|
||||
if (acf == NULL) {
|
||||
ngx_log_error(NGX_LOG_WARN, s->connection->log, 0,
|
||||
"bandwidth_detection: _result - no app config!");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
ctx = ngx_rtmp_get_module_ctx(s, ngx_rtmp_bandwidth_detection_module);
|
||||
if (ctx == NULL || s->relay) {
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
|
||||
|
@ -215,16 +223,18 @@ ngx_rtmp_bandwidth_detection_on_result(ngx_rtmp_session_t *s, ngx_rtmp_header_t
|
|||
"bandwidth_detection: _result: trans='%f' count='%ui'",
|
||||
v.trans, v.count);
|
||||
|
||||
switch ((ngx_int_t)v.trans) {
|
||||
case NGX_RTMP_BANDWIDTH_DETECTION_BWCHECK_TRANS:
|
||||
return ngx_rtmp_bandwidth_detection_check_result(s);
|
||||
if (acf->auto_sense_bw) {
|
||||
switch ((ngx_int_t)v.trans) {
|
||||
case NGX_RTMP_BANDWIDTH_DETECTION_BWCHECK_TRANS:
|
||||
return ngx_rtmp_bandwidth_detection_check_result(s);
|
||||
|
||||
case NGX_RTMP_BANDWIDTH_DETECTION_BWDONE_TRANS:
|
||||
/* Need to test it. Maybe need to set this before send bwDone. */
|
||||
ctx->active = 0;
|
||||
break;
|
||||
default:
|
||||
return NGX_OK;
|
||||
case NGX_RTMP_BANDWIDTH_DETECTION_BWDONE_TRANS:
|
||||
/* Need to test it. Maybe need to set this before send bwDone. */
|
||||
ctx->active = 0;
|
||||
break;
|
||||
default:
|
||||
return NGX_OK;
|
||||
}
|
||||
}
|
||||
return NGX_OK;
|
||||
}
|
||||
|
|
|
@ -996,14 +996,6 @@ ngx_rtmp_create_bwcheck(ngx_rtmp_session_t *s, u_char *payload, size_t plength)
|
|||
|
||||
static double trans;
|
||||
|
||||
static ngx_rtmp_amf_elt_t out_inf[] = {
|
||||
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
ngx_string("payload"),
|
||||
NULL, 0 },
|
||||
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf_elt_t out_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
|
@ -1014,15 +1006,18 @@ ngx_rtmp_create_bwcheck(ngx_rtmp_session_t *s, u_char *payload, size_t plength)
|
|||
ngx_null_string,
|
||||
&trans, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
{ NGX_RTMP_AMF_NULL,
|
||||
ngx_null_string,
|
||||
out_inf,
|
||||
sizeof(out_inf) },
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
ngx_null_string,
|
||||
NULL, 0 },
|
||||
};
|
||||
|
||||
if (payload != NULL) {
|
||||
out_inf[0].data = payload;
|
||||
out_inf[0].len = plength;
|
||||
out_elts[3].data = payload;
|
||||
out_elts[3].len = plength;
|
||||
}
|
||||
trans = NGX_RTMP_BANDWIDTH_DETECTION_BWCHECK_TRANS;
|
||||
|
||||
|
@ -1053,31 +1048,11 @@ ngx_rtmp_create_bwdone(ngx_rtmp_session_t *s,
|
|||
static double trans;
|
||||
static struct {
|
||||
double kbitDown;
|
||||
ngx_uint_t deltaDown;
|
||||
double deltaDown;
|
||||
double deltaTime;
|
||||
ngx_msec_t latency;
|
||||
double latency;
|
||||
} v;
|
||||
|
||||
static ngx_rtmp_amf_elt_t out_inf[] = {
|
||||
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
ngx_string("kbitDown"),
|
||||
&v.kbitDown, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
ngx_string("deltaDown"),
|
||||
&v.deltaDown, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
ngx_string("deltaTime"),
|
||||
&v.deltaTime, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
ngx_string("latency"),
|
||||
&v.latency, 0 },
|
||||
|
||||
};
|
||||
|
||||
static ngx_rtmp_amf_elt_t out_elts[] = {
|
||||
|
||||
{ NGX_RTMP_AMF_STRING,
|
||||
|
@ -1088,10 +1063,26 @@ ngx_rtmp_create_bwdone(ngx_rtmp_session_t *s,
|
|||
ngx_null_string,
|
||||
&trans, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_OBJECT,
|
||||
{ NGX_RTMP_AMF_NULL,
|
||||
ngx_null_string,
|
||||
out_inf,
|
||||
sizeof(out_inf) },
|
||||
NULL, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
ngx_null_string,
|
||||
&v.kbitDown, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
ngx_null_string,
|
||||
&v.deltaDown, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
ngx_null_string,
|
||||
&v.deltaTime, 0 },
|
||||
|
||||
{ NGX_RTMP_AMF_NUMBER,
|
||||
ngx_null_string,
|
||||
&v.latency, 0 },
|
||||
|
||||
};
|
||||
|
||||
ngx_memzero(&v, sizeof(v));
|
||||
|
|
Loading…
Reference in a new issue