Skip to content

Commit

Permalink
sync base repo (#2)
Browse files Browse the repository at this point in the history
* [fix] fixed a crash bug resulted from 'reload'

* [fix] fixed 'proxy protocol not working' bug.

* [fix] fixed a typo.

* [fix] fixed an endian bug in mp4 vod.

* [fix] worked around the buggy option `-map` in FFmpeg.

* [fix] refactored (winshining#245) and fixed a compilation error on Mac.
  • Loading branch information
Executor-Cheng authored Nov 2, 2023
1 parent a5c3cf3 commit 2c55897
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions ngx_rtmp_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ ngx_rtmp_prepare_message(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,

hsize = hdrsize[fmt];

(void) nbufs;
ngx_log_debug8(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
"RTMP prep %s (%d) fmt=%d csid=%uD timestamp=%uD "
"mlen=%uD msid=%uD nbufs=%d",
Expand Down
28 changes: 28 additions & 0 deletions ngx_rtmp_receive.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ ngx_rtmp_amf_message_handler(ngx_rtmp_session_t *s,
ngx_rtmp_core_main_conf_t *cmcf;
ngx_array_t *ch;
ngx_rtmp_handler_pt *ph;
ngx_chain_t *cl;
ngx_int_t amf_len;
size_t len, n;

static u_char func[128];
Expand Down Expand Up @@ -393,6 +395,32 @@ ngx_rtmp_amf_message_handler(ngx_rtmp_session_t *s,

cmcf = ngx_rtmp_get_module_main_conf(s, ngx_rtmp_core_module);

/*
* work around the buggy option `-map` in FFmpeg, see:
* https://trac.ffmpeg.org/ticket/10565
*/
if (in->buf->pos[0] == NGX_RTMP_AMF_NUMBER) {
cl = in;
amf_len = 0;

while (cl) {
amf_len += cl->buf->last - cl->buf->pos;
/* type: 1B, number payload: 8B */
if (amf_len >= 9) {
break;
}

cl = cl->next;
}

if (amf_len < 9) {
ngx_log_error(NGX_LOG_WARN, s->connection->log, 0,
"AMF malformed: type=%d, length=%D, ignored",
NGX_RTMP_AMF_NUMBER, amf_len);
return NGX_OK;
}
}

/* read AMF func name & transaction id */
ngx_memzero(&act, sizeof(act));
act.link = in;
Expand Down

0 comments on commit 2c55897

Please sign in to comment.