mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-20 18:01:08 +02:00
added aac-he & aac-hev2 support
This commit is contained in:
parent
18fa7a5016
commit
3a5f9eea78
|
@ -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);
|
ngx_rtmp_bit_read(&br, 16);
|
||||||
|
|
||||||
ctx->aac_profile = (ngx_uint_t) ngx_rtmp_bit_read(&br, 5);
|
ctx->aac_profile = (ngx_uint_t) ngx_rtmp_bit_read(&br, 5);
|
||||||
|
|
||||||
if (ctx->aac_profile == 31) {
|
if (ctx->aac_profile == 31) {
|
||||||
ctx->aac_profile = (ngx_uint_t) ngx_rtmp_bit_read(&br, 6) + 32;
|
ctx->aac_profile = (ngx_uint_t) ngx_rtmp_bit_read(&br, 6) + 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
idx = (ngx_uint_t) ngx_rtmp_bit_read(&br, 4);
|
idx = (ngx_uint_t) ngx_rtmp_bit_read(&br, 4);
|
||||||
|
|
||||||
if (idx == 15) {
|
if (idx == 15) {
|
||||||
ctx->sample_rate = (ngx_uint_t) ngx_rtmp_bit_read(&br, 24);
|
ctx->sample_rate = (ngx_uint_t) ngx_rtmp_bit_read(&br, 24);
|
||||||
} else {
|
} 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);
|
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
|
/* MPEG-4 Audio Specific Config
|
||||||
|
|
||||||
5 bits: object type
|
5 bits: object type
|
||||||
if (object type == 31)
|
if (object type == 31)
|
||||||
6 bits + 32: object type
|
6 bits + 32: object type
|
||||||
--->4 bits: frequency index
|
4 bits: frequency index
|
||||||
if (frequency index == 15)
|
if (frequency index == 15)
|
||||||
24 bits: frequency
|
24 bits: frequency
|
||||||
4 bits: channel configuration
|
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
|
var bits: AOT Specific Config
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,8 @@ typedef struct {
|
||||||
ngx_uint_t audio_codec_id;
|
ngx_uint_t audio_codec_id;
|
||||||
ngx_uint_t aac_profile;
|
ngx_uint_t aac_profile;
|
||||||
ngx_uint_t aac_chan_conf;
|
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_profile;
|
||||||
ngx_uint_t avc_compat;
|
ngx_uint_t avc_compat;
|
||||||
ngx_uint_t avc_level;
|
ngx_uint_t avc_level;
|
||||||
|
|
|
@ -363,16 +363,24 @@ ngx_rtmp_stat_client(ngx_http_request_t *r, ngx_chain_t ***lll,
|
||||||
|
|
||||||
|
|
||||||
static char *
|
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) {
|
switch (p) {
|
||||||
case 1:
|
case 1:
|
||||||
return "Main";
|
return "Main";
|
||||||
case 2:
|
case 2:
|
||||||
|
if (ps) {
|
||||||
|
return "HEv2";
|
||||||
|
}
|
||||||
|
if (sbr) {
|
||||||
|
return "HE";
|
||||||
|
}
|
||||||
return "LC";
|
return "LC";
|
||||||
case 3:
|
case 3:
|
||||||
return "SSR";
|
return "SSR";
|
||||||
case 4:
|
case 4:
|
||||||
return "LTP";
|
return "LTP";
|
||||||
|
case 5:
|
||||||
|
return "SBR";
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -526,7 +534,9 @@ ngx_rtmp_stat_live(ngx_http_request_t *r, ngx_chain_t ***lll,
|
||||||
if (codec->aac_profile) {
|
if (codec->aac_profile) {
|
||||||
NGX_RTMP_STAT_L("<profile>");
|
NGX_RTMP_STAT_L("<profile>");
|
||||||
NGX_RTMP_STAT_CS(
|
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>");
|
NGX_RTMP_STAT_L("</profile>");
|
||||||
}
|
}
|
||||||
if (codec->aac_chan_conf) {
|
if (codec->aac_chan_conf) {
|
||||||
|
|
Loading…
Reference in a new issue