Skip to content

Commit aee1608

Browse files
committed
[fix] fixed meta parsing bug on edge server when "meta copy;" are set on both origin & edge server.
1 parent 441ac35 commit aee1608

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

LICENSE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ Copyright (c) 2018-2019, plainheart
66
Copyright (c) 2018-2019, HeyJupiter
77
Copyright (c) 2018, han4235, Vladimir Vainer
88
Copyright (c) 2019, ever4Keny
9-
Copyright (c) 2020, spacewander
10-
Copyright (c) 2020, ham3r
9+
Copyright (c) 2020, spacewander, ham3r
1110
All rights reserved.
1211

1312
Redistribution and use in source and binary forms, with or without

ngx_rtmp_codec_module.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,9 +775,11 @@ static ngx_int_t
775775
ngx_rtmp_codec_meta_data(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
776776
ngx_chain_t *in)
777777
{
778+
uint16_t len;
779+
ngx_uint_t skip;
780+
u_char *p;
778781
ngx_rtmp_codec_app_conf_t *cacf;
779782
ngx_rtmp_codec_ctx_t *ctx;
780-
ngx_uint_t skip;
781783

782784
static struct {
783785
double width;
@@ -888,7 +890,23 @@ ngx_rtmp_codec_meta_data(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
888890
* 0 is a valid value for uncompressed audio */
889891
v.audio_codec_id_n = -1;
890892

891-
/* FFmpeg sends a string in front of actal metadata; ignore it */
893+
if (in->buf->last > in->buf->pos
894+
&& in->buf->pos - in->buf->start >= 13
895+
&& in->buf->pos[-13] == NGX_RTMP_AMF_STRING)
896+
{
897+
p = (u_char *) &len;
898+
899+
*p++ = in->buf->pos[-11];
900+
*p++ = in->buf->pos[-12];
901+
902+
if (ngx_strncasecmp(in->buf->pos - 10,
903+
(u_char *) "onMetaData", len) == 0)
904+
{
905+
in->buf->pos -= 13;
906+
}
907+
}
908+
909+
/* FFmpeg sends a string in front of actual metadata; ignore it */
892910
skip = !(in->buf->last > in->buf->pos
893911
&& *in->buf->pos == NGX_RTMP_AMF_STRING);
894912
if (ngx_rtmp_receive_amf(s, in, in_elts + skip,

0 commit comments

Comments
 (0)