From 047b72c192764fff5ad570d49eb28e014e6510b3 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Fri, 29 Nov 2013 12:55:42 +0400 Subject: [PATCH] added h264 profile/compat/level parser and fixed dash avc1 codec string --- dash/ngx_rtmp_dash_module.c | 5 ++++- ngx_rtmp_codec_module.c | 16 +++++++++++++--- ngx_rtmp_codec_module.h | 3 +++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/dash/ngx_rtmp_dash_module.c b/dash/ngx_rtmp_dash_module.c index 5d7cc66..4f9fb45 100644 --- a/dash/ngx_rtmp_dash_module.c +++ b/dash/ngx_rtmp_dash_module.c @@ -281,7 +281,7 @@ ngx_rtmp_dash_write_playlist(ngx_rtmp_session_t *s) " height, codec_ctx->frame_rate, &ctx->name, + codec_ctx->avc_profile, + codec_ctx->avc_compat, + codec_ctx->avc_level, codec_ctx->width, codec_ctx->height, codec_ctx->frame_rate, diff --git a/ngx_rtmp_codec_module.c b/ngx_rtmp_codec_module.c index 457cbfd..c8241e6 100644 --- a/ngx_rtmp_codec_module.c +++ b/ngx_rtmp_codec_module.c @@ -290,14 +290,24 @@ ngx_rtmp_codec_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, } ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "codec: AAC header arrived, sample_rate=%ui", + "codec: aac header arrived, sample_rate=%ui", ctx->aac_sample_rate); } } else { if (ctx->video_codec_id == NGX_RTMP_VIDEO_H264) { header = &ctx->avc_header; - ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "codec: AVC/H264 header arrived"); + + if (in->buf->last - in->buf->pos > 8) { + p = in->buf->pos; + ctx->avc_profile = p[6]; + ctx->avc_compat = p[7]; + ctx->avc_level = p[8]; + } + + ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, + "codec: avc header arrived, " + "profile=%ui, compat=%ui, level=%ui", + ctx->avc_profile, ctx->avc_compat, ctx->avc_level); } } diff --git a/ngx_rtmp_codec_module.h b/ngx_rtmp_codec_module.h index 770a98c..bb3abd6 100644 --- a/ngx_rtmp_codec_module.h +++ b/ngx_rtmp_codec_module.h @@ -59,6 +59,9 @@ typedef struct { ngx_uint_t audio_data_rate; ngx_uint_t audio_codec_id; ngx_uint_t aac_sample_rate; + ngx_uint_t avc_profile; + ngx_uint_t avc_compat; + ngx_uint_t avc_level; ngx_uint_t sample_rate; /* 5512, 11025, 22050, 44100 */ ngx_uint_t sample_size; /* 1=8bit, 2=16bit */ ngx_uint_t audio_channels; /* 1, 2 */