正在显示
4 个修改的文件
包含
42 行增加
和
23 行删除
@@ -76,6 +76,22 @@ using namespace std; | @@ -76,6 +76,22 @@ using namespace std; | ||
76 | // in ms, for HLS aac flush the audio | 76 | // in ms, for HLS aac flush the audio |
77 | #define SRS_CONF_DEFAULT_AAC_DELAY 100 | 77 | #define SRS_CONF_DEFAULT_AAC_DELAY 100 |
78 | 78 | ||
79 | +// 0 = 5.5 kHz = 5512 Hz | ||
80 | +// 1 = 11 kHz = 11025 Hz | ||
81 | +// 2 = 22 kHz = 22050 Hz | ||
82 | +// 3 = 44 kHz = 44100 Hz | ||
83 | +int flv_sample_rates[] = {5512, 11025, 22050, 44100}; | ||
84 | + | ||
85 | +// the sample rates in the codec, | ||
86 | +// in the sequence header. | ||
87 | +int aac_sample_rates[] = | ||
88 | +{ | ||
89 | + 96000, 88200, 64000, 48000, | ||
90 | + 44100, 32000, 24000, 22050, | ||
91 | + 16000, 12000, 11025, 8000, | ||
92 | + 7350, 0, 0, 0 | ||
93 | +}; | ||
94 | + | ||
79 | // @see: ngx_rtmp_mpegts_header | 95 | // @see: ngx_rtmp_mpegts_header |
80 | u_int8_t mpegts_header[] = { | 96 | u_int8_t mpegts_header[] = { |
81 | /* TS */ | 97 | /* TS */ |
@@ -377,21 +393,11 @@ SrsHlsAacJitter::~SrsHlsAacJitter() | @@ -377,21 +393,11 @@ SrsHlsAacJitter::~SrsHlsAacJitter() | ||
377 | 393 | ||
378 | int64_t SrsHlsAacJitter::on_buffer_start(int64_t flv_pts, int sample_rate, int aac_sample_rate) | 394 | int64_t SrsHlsAacJitter::on_buffer_start(int64_t flv_pts, int sample_rate, int aac_sample_rate) |
379 | { | 395 | { |
380 | - // 0 = 5.5 kHz = 5512 Hz | ||
381 | - // 1 = 11 kHz = 11025 Hz | ||
382 | - // 2 = 22 kHz = 22050 Hz | ||
383 | - // 3 = 44 kHz = 44100 Hz | ||
384 | - static int flv_sample_rates[] = {5512, 11025, 22050, 44100}; | 396 | + // use sample rate in flv/RTMP. |
385 | int flv_sample_rate = flv_sample_rates[sample_rate & 0x03]; | 397 | int flv_sample_rate = flv_sample_rates[sample_rate & 0x03]; |
386 | 398 | ||
387 | - // reset the sample rate by sequence header | 399 | + // override the sample rate by sequence header |
388 | if (aac_sample_rate != _SRS_AAC_SAMPLE_RATE_UNSET) { | 400 | if (aac_sample_rate != _SRS_AAC_SAMPLE_RATE_UNSET) { |
389 | - static int aac_sample_rates[] = { | ||
390 | - 96000, 88200, 64000, 48000, | ||
391 | - 44100, 32000, 24000, 22050, | ||
392 | - 16000, 12000, 11025, 8000, | ||
393 | - 7350, 0, 0, 0 | ||
394 | - }; | ||
395 | flv_sample_rate = aac_sample_rates[aac_sample_rate]; | 401 | flv_sample_rate = aac_sample_rates[aac_sample_rate]; |
396 | } | 402 | } |
397 | 403 |
@@ -48,6 +48,16 @@ class SrsSource; | @@ -48,6 +48,16 @@ class SrsSource; | ||
48 | class SrsFileWriter; | 48 | class SrsFileWriter; |
49 | 49 | ||
50 | /** | 50 | /** |
51 | +* the flv sample rate map | ||
52 | +*/ | ||
53 | +extern int flv_sample_rates[]; | ||
54 | + | ||
55 | +/** | ||
56 | +* the aac sample rate map | ||
57 | +*/ | ||
58 | +extern int aac_sample_rates[]; | ||
59 | + | ||
60 | +/** | ||
51 | * jitter correct for audio, | 61 | * jitter correct for audio, |
52 | * the sample rate 44100/32000 will lost precise, | 62 | * the sample rate 44100/32000 will lost precise, |
53 | * when mp4/ts(tbn=90000) covert to flv/rtmp(1000), | 63 | * when mp4/ts(tbn=90000) covert to flv/rtmp(1000), |
@@ -1082,15 +1082,8 @@ int SrsSource::on_audio(SrsMessage* audio) | @@ -1082,15 +1082,8 @@ int SrsSource::on_audio(SrsMessage* audio) | ||
1082 | return ret; | 1082 | return ret; |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | - static int flv_sample_rates[] = {5512, 11025, 22050, 44100, 0}; | ||
1086 | static int flv_sample_sizes[] = {8, 16, 0}; | 1085 | static int flv_sample_sizes[] = {8, 16, 0}; |
1087 | static int flv_sound_types[] = {1, 2, 0}; | 1086 | static int flv_sound_types[] = {1, 2, 0}; |
1088 | - static int aac_sample_rates[] = { | ||
1089 | - 96000, 88200, 64000, 48000, | ||
1090 | - 44100, 32000, 24000, 22050, | ||
1091 | - 16000, 12000, 11025, 8000, | ||
1092 | - 7350, 0, 0, 0 | ||
1093 | - }; | ||
1094 | srs_trace("%dB audio sh, " | 1087 | srs_trace("%dB audio sh, " |
1095 | "codec(%d, profile=%d, %dchannels, %dkbps, %dHZ), " | 1088 | "codec(%d, profile=%d, %dchannels, %dkbps, %dHZ), " |
1096 | "flv(%dbits, %dchannels, %dHZ)", | 1089 | "flv(%dbits, %dchannels, %dHZ)", |
@@ -41,11 +41,21 @@ namespace _srs_internal | @@ -41,11 +41,21 @@ namespace _srs_internal | ||
41 | /** | 41 | /** |
42 | * the schema type. | 42 | * the schema type. |
43 | */ | 43 | */ |
44 | - enum srs_schema_type { | ||
45 | - srs_schema0 = 0, // key-digest sequence | ||
46 | - // @remark, FMS requires the schema1(digest-key), or connect failed. | ||
47 | - srs_schema1 = 1, // digest-key sequence | 44 | + enum srs_schema_type |
45 | + { | ||
48 | srs_schema_invalid = 2, | 46 | srs_schema_invalid = 2, |
47 | + | ||
48 | + /** | ||
49 | + * key-digest sequence | ||
50 | + */ | ||
51 | + srs_schema0 = 0, | ||
52 | + | ||
53 | + /** | ||
54 | + * digest-key sequence | ||
55 | + * @remark, FMS requires the schema1(digest-key), or connect failed. | ||
56 | + */ | ||
57 | + // | ||
58 | + srs_schema1 = 1, | ||
49 | }; | 59 | }; |
50 | 60 | ||
51 | /** | 61 | /** |
-
请 注册 或 登录 后发表评论