From 1e0e98a439e788fa1ed3887b763f8cf1016bccea Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Tue, 19 Jun 2012 17:05:05 +0400 Subject: [PATCH] added more audio codec params to codec module --- ngx_rtmp_codec_module.c | 5 +++++ ngx_rtmp_codec_module.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/ngx_rtmp_codec_module.c b/ngx_rtmp_codec_module.c index 1a48b6a..c4dc3ca 100644 --- a/ngx_rtmp_codec_module.c +++ b/ngx_rtmp_codec_module.c @@ -145,6 +145,8 @@ ngx_rtmp_codec_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, uint8_t fmt; ngx_rtmp_header_t ch, lh; ngx_uint_t *version; + static ngx_uint_t sample_rates[] = + { 5512, 11025, 22050, 44100 }; if (h->type != NGX_RTMP_MSG_AUDIO && h->type != NGX_RTMP_MSG_VIDEO) { @@ -165,6 +167,9 @@ ngx_rtmp_codec_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, fmt = in->buf->pos[0]; if (h->type == NGX_RTMP_MSG_AUDIO) { ctx->audio_codec_id = (fmt & 0xf0) >> 4; + ctx->audio_channels = (fmt & 0x01) + 1; + ctx->sample_size = (fmt & 0x02) ? 2 : 1; + ctx->sample_rate = sample_rates[(fmt & 0x0c) >> 2]; } else { ctx->video_codec_id = (fmt & 0x0f); } diff --git a/ngx_rtmp_codec_module.h b/ngx_rtmp_codec_module.h index efd4d8e..59f5554 100644 --- a/ngx_rtmp_codec_module.h +++ b/ngx_rtmp_codec_module.h @@ -55,6 +55,9 @@ typedef struct { ngx_uint_t video_codec_id; ngx_uint_t audio_data_rate; ngx_uint_t audio_codec_id; + 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 */ u_char profile[32]; u_char level[32];