Skip to content

when open meta copy, publish -->A-->B, B stream can't play, fix it #1414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions ngx_rtmp_codec_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define NGX_RTMP_CODEC_META_OFF 0
#define NGX_RTMP_CODEC_META_ON 1
#define NGX_RTMP_CODEC_META_COPY 2

#define NGX_RTMP_CODEC_ONMETADATA_HEAD 13

static void * ngx_rtmp_codec_create_app_conf(ngx_conf_t *cf);
static char * ngx_rtmp_codec_merge_app_conf(ngx_conf_t *cf,
Expand Down Expand Up @@ -890,6 +890,34 @@ ngx_rtmp_codec_meta_data(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
}


static ngx_int_t
ngx_rtmp_codec_meta_data_by_setdataframe(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
ngx_chain_t *in)
{
return ngx_rtmp_codec_meta_data(s, h, in);
}


static ngx_int_t
ngx_rtmp_codec_meta_data_by_onmetadata(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
ngx_chain_t *in)
{
ngx_int_t size = 0;

if (in) {
size = in->buf->pos - in->buf->start;

if (in->buf->last > in->buf->pos
&& size >= NGX_RTMP_CODEC_ONMETADATA_HEAD)
{
in->buf->pos -= NGX_RTMP_CODEC_ONMETADATA_HEAD;
}
}

return ngx_rtmp_codec_meta_data(s, h, in);
}


static void *
ngx_rtmp_codec_create_app_conf(ngx_conf_t *cf)
{
Expand Down Expand Up @@ -942,14 +970,14 @@ ngx_rtmp_codec_postconfiguration(ngx_conf_t *cf)
return NGX_ERROR;
}
ngx_str_set(&ch->name, "@setDataFrame");
ch->handler = ngx_rtmp_codec_meta_data;
ch->handler = ngx_rtmp_codec_meta_data_by_setdataframe;

ch = ngx_array_push(&cmcf->amf);
if (ch == NULL) {
return NGX_ERROR;
}
ngx_str_set(&ch->name, "onMetaData");
ch->handler = ngx_rtmp_codec_meta_data;
ch->handler = ngx_rtmp_codec_meta_data_by_onmetadata;


return NGX_OK;
Expand Down