added aac-he & aac-hev2 support

This commit is contained in:
Roman Arutyunyan 2013-12-21 09:29:39 +04:00
parent 18fa7a5016
commit 3a5f9eea78
3 changed files with 47 additions and 7 deletions

View file

@ -292,13 +292,11 @@ ngx_rtmp_codec_parse_aac_header(ngx_rtmp_session_t *s, ngx_chain_t *in)
ngx_rtmp_bit_read(&br, 16);
ctx->aac_profile = (ngx_uint_t) ngx_rtmp_bit_read(&br, 5);
if (ctx->aac_profile == 31) {
ctx->aac_profile = (ngx_uint_t) ngx_rtmp_bit_read(&br, 6) + 32;
}
idx = (ngx_uint_t) ngx_rtmp_bit_read(&br, 4);
if (idx == 15) {
ctx->sample_rate = (ngx_uint_t) ngx_rtmp_bit_read(&br, 24);
} else {
@ -307,15 +305,45 @@ ngx_rtmp_codec_parse_aac_header(ngx_rtmp_session_t *s, ngx_chain_t *in)
ctx->aac_chan_conf = (ngx_uint_t) ngx_rtmp_bit_read(&br, 4);
if (ctx->aac_profile == 5 || ctx->aac_profile == 29) {
if (ctx->aac_profile == 29) {
ctx->aac_ps = 1;
}
ctx->aac_sbr = 1;
idx = (ngx_uint_t) ngx_rtmp_bit_read(&br, 4);
if (idx == 15) {
ctx->sample_rate = (ngx_uint_t) ngx_rtmp_bit_read(&br, 24);
} else {
ctx->sample_rate = aac_sample_rates[idx];
}
ctx->aac_profile = (ngx_uint_t) ngx_rtmp_bit_read(&br, 5);
if (ctx->aac_profile == 31) {
ctx->aac_profile = (ngx_uint_t) ngx_rtmp_bit_read(&br, 6) + 32;
}
}
/* MPEG-4 Audio Specific Config
5 bits: object type
if (object type == 31)
6 bits + 32: object type
--->4 bits: frequency index
6 bits + 32: object type
4 bits: frequency index
if (frequency index == 15)
24 bits: frequency
24 bits: frequency
4 bits: channel configuration
if (object_type == 5)
4 bits: frequency index
if (frequency index == 15)
24 bits: frequency
5 bits: object type
if (object type == 31)
6 bits + 32: object type
var bits: AOT Specific Config
*/

View file

@ -60,6 +60,8 @@ typedef struct {
ngx_uint_t audio_codec_id;
ngx_uint_t aac_profile;
ngx_uint_t aac_chan_conf;
ngx_uint_t aac_sbr;
ngx_uint_t aac_ps;
ngx_uint_t avc_profile;
ngx_uint_t avc_compat;
ngx_uint_t avc_level;

View file

@ -363,16 +363,24 @@ ngx_rtmp_stat_client(ngx_http_request_t *r, ngx_chain_t ***lll,
static char *
ngx_rtmp_stat_get_aac_profile(ngx_uint_t p) {
ngx_rtmp_stat_get_aac_profile(ngx_uint_t p, ngx_uint_t sbr, ngx_uint_t ps) {
switch (p) {
case 1:
return "Main";
case 2:
if (ps) {
return "HEv2";
}
if (sbr) {
return "HE";
}
return "LC";
case 3:
return "SSR";
case 4:
return "LTP";
case 5:
return "SBR";
default:
return "";
}
@ -526,7 +534,9 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
if (codec->aac_profile) {
NGX_RTMP_STAT_L("<profile>");
NGX_RTMP_STAT_CS(
ngx_rtmp_stat_get_aac_profile(codec->aac_profile));
ngx_rtmp_stat_get_aac_profile(codec->aac_profile,
codec->aac_sbr,
codec->aac_ps));
NGX_RTMP_STAT_L("</profile>");
}
if (codec->aac_chan_conf) {