fix #103, support all aac sample rate, add detail codec logs.
正在显示
6 个修改的文件
包含
74 行增加
和
14 行删除
@@ -220,12 +220,15 @@ int SrsAvcAacCodec::audio_aac_demux(int8_t* data, int size, SrsCodecSample* samp | @@ -220,12 +220,15 @@ int SrsAvcAacCodec::audio_aac_demux(int8_t* data, int size, SrsCodecSample* samp | ||
220 | 220 | ||
221 | // TODO: FIXME: to support aac he/he-v2, see: ngx_rtmp_codec_parse_aac_header | 221 | // TODO: FIXME: to support aac he/he-v2, see: ngx_rtmp_codec_parse_aac_header |
222 | // @see: https://github.com/winlinvip/nginx-rtmp-module/commit/3a5f9eea78fc8d11e8be922aea9ac349b9dcbfc2 | 222 | // @see: https://github.com/winlinvip/nginx-rtmp-module/commit/3a5f9eea78fc8d11e8be922aea9ac349b9dcbfc2 |
223 | - if (aac_profile > 3) { | 223 | + // |
224 | + // donot force to LC, @see: https://github.com/winlinvip/simple-rtmp-server/issues/81 | ||
225 | + // the source will print the sequence header info. | ||
226 | + //if (aac_profile > 3) { | ||
224 | // Mark all extended profiles as LC | 227 | // Mark all extended profiles as LC |
225 | // to make Android as happy as possible. | 228 | // to make Android as happy as possible. |
226 | // @see: ngx_rtmp_hls_parse_aac_header | 229 | // @see: ngx_rtmp_hls_parse_aac_header |
227 | - aac_profile = 1; | ||
228 | - } | 230 | + //aac_profile = 1; |
231 | + //} | ||
229 | } else if (aac_packet_type == SrsCodecAudioTypeRawData) { | 232 | } else if (aac_packet_type == SrsCodecAudioTypeRawData) { |
230 | // ensure the sequence header demuxed | 233 | // ensure the sequence header demuxed |
231 | if (aac_extra_size <= 0 || !aac_extra_data) { | 234 | if (aac_extra_size <= 0 || !aac_extra_data) { |
@@ -335,10 +338,14 @@ int SrsAvcAacCodec::video_avc_demux(int8_t* data, int size, SrsCodecSample* samp | @@ -335,10 +338,14 @@ int SrsAvcAacCodec::video_avc_demux(int8_t* data, int size, SrsCodecSample* samp | ||
335 | return ret; | 338 | return ret; |
336 | } | 339 | } |
337 | //int8_t configurationVersion = stream->read_1bytes(); | 340 | //int8_t configurationVersion = stream->read_1bytes(); |
341 | + stream->read_1bytes(); | ||
338 | //int8_t AVCProfileIndication = stream->read_1bytes(); | 342 | //int8_t AVCProfileIndication = stream->read_1bytes(); |
343 | + avc_profile = stream->read_1bytes(); | ||
339 | //int8_t profile_compatibility = stream->read_1bytes(); | 344 | //int8_t profile_compatibility = stream->read_1bytes(); |
345 | + stream->read_1bytes(); | ||
340 | //int8_t AVCLevelIndication = stream->read_1bytes(); | 346 | //int8_t AVCLevelIndication = stream->read_1bytes(); |
341 | - stream->skip(4); | 347 | + avc_level = stream->read_1bytes(); |
348 | + | ||
342 | // parse the NALU size. | 349 | // parse the NALU size. |
343 | int8_t lengthSizeMinusOne = stream->read_1bytes(); | 350 | int8_t lengthSizeMinusOne = stream->read_1bytes(); |
344 | lengthSizeMinusOne &= 0x03; | 351 | lengthSizeMinusOne &= 0x03; |
@@ -44,7 +44,8 @@ class SrsStream; | @@ -44,7 +44,8 @@ class SrsStream; | ||
44 | // 3 = 44 kHz = 44100 Hz | 44 | // 3 = 44 kHz = 44100 Hz |
45 | enum SrsCodecAudioSampleRate | 45 | enum SrsCodecAudioSampleRate |
46 | { | 46 | { |
47 | - SrsCodecAudioSampleRateReserved = -1, | 47 | + // set to the max value to reserved, for array map. |
48 | + SrsCodecAudioSampleRateReserved = 4, | ||
48 | 49 | ||
49 | SrsCodecAudioSampleRate5512 = 0, | 50 | SrsCodecAudioSampleRate5512 = 0, |
50 | SrsCodecAudioSampleRate11025 = 1, | 51 | SrsCodecAudioSampleRate11025 = 1, |
@@ -59,7 +60,8 @@ enum SrsCodecAudioSampleRate | @@ -59,7 +60,8 @@ enum SrsCodecAudioSampleRate | ||
59 | // 1 = 16-bit samples | 60 | // 1 = 16-bit samples |
60 | enum SrsCodecAudioSampleSize | 61 | enum SrsCodecAudioSampleSize |
61 | { | 62 | { |
62 | - SrsCodecAudioSampleSizeReserved = -1, | 63 | + // set to the max value to reserved, for array map. |
64 | + SrsCodecAudioSampleSizeReserved = 2, | ||
63 | 65 | ||
64 | SrsCodecAudioSampleSize8bit = 0, | 66 | SrsCodecAudioSampleSize8bit = 0, |
65 | SrsCodecAudioSampleSize16bit = 1, | 67 | SrsCodecAudioSampleSize16bit = 1, |
@@ -70,7 +72,8 @@ enum SrsCodecAudioSampleSize | @@ -70,7 +72,8 @@ enum SrsCodecAudioSampleSize | ||
70 | // 1 = Stereo sound | 72 | // 1 = Stereo sound |
71 | enum SrsCodecAudioSoundType | 73 | enum SrsCodecAudioSoundType |
72 | { | 74 | { |
73 | - SrsCodecAudioSoundTypeReserved = -1, | 75 | + // set to the max value to reserved, for array map. |
76 | + SrsCodecAudioSoundTypeReserved = 2, | ||
74 | 77 | ||
75 | SrsCodecAudioSoundTypeMono = 0, | 78 | SrsCodecAudioSoundTypeMono = 0, |
76 | SrsCodecAudioSoundTypeStereo = 1, | 79 | SrsCodecAudioSoundTypeStereo = 1, |
@@ -1497,8 +1497,8 @@ void SrsHls::hls_mux() | @@ -1497,8 +1497,8 @@ void SrsHls::hls_mux() | ||
1497 | // reportable | 1497 | // reportable |
1498 | if (pithy_print->can_print()) { | 1498 | if (pithy_print->can_print()) { |
1499 | srs_trace("-> "SRS_LOG_ID_HLS | 1499 | srs_trace("-> "SRS_LOG_ID_HLS |
1500 | - " time=%"PRId64", dts=%"PRId64", sequence_no=%d", | ||
1501 | - pithy_print->age(), stream_dts, muxer->sequence_no()); | 1500 | + " time=%"PRId64", dts=%"PRId64"(%"PRId64"ms), sequence_no=%d", |
1501 | + pithy_print->age(), stream_dts, stream_dts / 90, muxer->sequence_no()); | ||
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | pithy_print->elapse(); | 1504 | pithy_print->elapse(); |
@@ -41,6 +41,7 @@ using namespace std; | @@ -41,6 +41,7 @@ using namespace std; | ||
41 | #include <srs_kernel_stream.hpp> | 41 | #include <srs_kernel_stream.hpp> |
42 | #include <srs_app_edge.hpp> | 42 | #include <srs_app_edge.hpp> |
43 | #include <srs_kernel_utility.hpp> | 43 | #include <srs_kernel_utility.hpp> |
44 | +#include <srs_app_avc_aac.hpp> | ||
44 | 45 | ||
45 | #define CONST_MAX_JITTER_MS 500 | 46 | #define CONST_MAX_JITTER_MS 500 |
46 | #define DEFAULT_FRAME_TIME_MS 40 | 47 | #define DEFAULT_FRAME_TIME_MS 40 |
@@ -1072,7 +1073,32 @@ int SrsSource::on_audio(SrsMessage* audio) | @@ -1072,7 +1073,32 @@ int SrsSource::on_audio(SrsMessage* audio) | ||
1072 | if (SrsFlvCodec::audio_is_sequence_header(msg->payload, msg->size)) { | 1073 | if (SrsFlvCodec::audio_is_sequence_header(msg->payload, msg->size)) { |
1073 | srs_freep(cache_sh_audio); | 1074 | srs_freep(cache_sh_audio); |
1074 | cache_sh_audio = msg->copy(); | 1075 | cache_sh_audio = msg->copy(); |
1075 | - srs_trace("got audio sh, size=%d", msg->header.payload_length); | 1076 | + |
1077 | + // parse detail audio codec | ||
1078 | + SrsAvcAacCodec codec; | ||
1079 | + SrsCodecSample sample; | ||
1080 | + if ((ret = codec.audio_aac_demux(msg->payload, msg->size, &sample)) != ERROR_SUCCESS) { | ||
1081 | + srs_error("codec demux audio failed. ret=%d", ret); | ||
1082 | + return ret; | ||
1083 | + } | ||
1084 | + | ||
1085 | + static int flv_sample_rates[] = {5512, 11025, 22050, 44100, 0}; | ||
1086 | + static int flv_sample_sizes[] = {8, 16, 0}; | ||
1087 | + 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, " | ||
1095 | + "codec(%d, profile=%d, %dchannels, %dkbps, %dHZ), " | ||
1096 | + "flv(%dbits, %dchannels, %dHZ)", | ||
1097 | + msg->header.payload_length, codec.audio_codec_id, | ||
1098 | + codec.aac_profile, codec.aac_channels, | ||
1099 | + codec.audio_data_rate / 1000, aac_sample_rates[codec.aac_sample_rate], | ||
1100 | + flv_sample_sizes[sample.sound_size], flv_sound_types[sample.sound_type], | ||
1101 | + flv_sample_rates[sample.sound_rate]); | ||
1076 | return ret; | 1102 | return ret; |
1077 | } | 1103 | } |
1078 | 1104 | ||
@@ -1162,7 +1188,20 @@ int SrsSource::on_video(SrsMessage* video) | @@ -1162,7 +1188,20 @@ int SrsSource::on_video(SrsMessage* video) | ||
1162 | if (SrsFlvCodec::video_is_sequence_header(msg->payload, msg->size)) { | 1188 | if (SrsFlvCodec::video_is_sequence_header(msg->payload, msg->size)) { |
1163 | srs_freep(cache_sh_video); | 1189 | srs_freep(cache_sh_video); |
1164 | cache_sh_video = msg->copy(); | 1190 | cache_sh_video = msg->copy(); |
1165 | - srs_trace("got video sh, size=%d", msg->header.payload_length); | 1191 | + |
1192 | + // parse detail audio codec | ||
1193 | + SrsAvcAacCodec codec; | ||
1194 | + SrsCodecSample sample; | ||
1195 | + if ((ret = codec.video_avc_demux(msg->payload, msg->size, &sample)) != ERROR_SUCCESS) { | ||
1196 | + srs_error("codec demux video failed. ret=%d", ret); | ||
1197 | + return ret; | ||
1198 | + } | ||
1199 | + | ||
1200 | + srs_trace("%dB video sh, " | ||
1201 | + "codec(%d, profile=%d, level=%d, %dx%d, %dkbps, %dfps, %ds)", | ||
1202 | + msg->header.payload_length, codec.video_codec_id, | ||
1203 | + codec.avc_profile, codec.avc_level, codec.width, codec.height, | ||
1204 | + codec.video_data_rate / 1000, codec.frame_rate, codec.duration); | ||
1166 | return ret; | 1205 | return ret; |
1167 | } | 1206 | } |
1168 | 1207 |
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
31 | // current release version | 31 | // current release version |
32 | #define VERSION_MAJOR "0" | 32 | #define VERSION_MAJOR "0" |
33 | #define VERSION_MINOR "9" | 33 | #define VERSION_MINOR "9" |
34 | -#define VERSION_REVISION "150" | 34 | +#define VERSION_REVISION "151" |
35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION | 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION |
36 | // server info. | 36 | // server info. |
37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
@@ -36,7 +36,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -36,7 +36,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
36 | // 1 = AAC raw | 36 | // 1 = AAC raw |
37 | enum SrsCodecAudioType | 37 | enum SrsCodecAudioType |
38 | { | 38 | { |
39 | - SrsCodecAudioTypeReserved = -1, | 39 | + // set to the max value to reserved, for array map. |
40 | + SrsCodecAudioTypeReserved = 2, | ||
41 | + | ||
40 | SrsCodecAudioTypeSequenceHeader = 0, | 42 | SrsCodecAudioTypeSequenceHeader = 0, |
41 | SrsCodecAudioTypeRawData = 1, | 43 | SrsCodecAudioTypeRawData = 1, |
42 | }; | 44 | }; |
@@ -51,7 +53,9 @@ enum SrsCodecAudioType | @@ -51,7 +53,9 @@ enum SrsCodecAudioType | ||
51 | // 5 = video info/command frame | 53 | // 5 = video info/command frame |
52 | enum SrsCodecVideoAVCFrame | 54 | enum SrsCodecVideoAVCFrame |
53 | { | 55 | { |
56 | + // set to the max value to reserved, for array map. | ||
54 | SrsCodecVideoAVCFrameReserved = 0, | 57 | SrsCodecVideoAVCFrameReserved = 0, |
58 | + SrsCodecVideoAVCFrameReserved1 = 6, | ||
55 | 59 | ||
56 | SrsCodecVideoAVCFrameKeyFrame = 1, | 60 | SrsCodecVideoAVCFrameKeyFrame = 1, |
57 | SrsCodecVideoAVCFrameInterFrame = 2, | 61 | SrsCodecVideoAVCFrameInterFrame = 2, |
@@ -68,7 +72,8 @@ enum SrsCodecVideoAVCFrame | @@ -68,7 +72,8 @@ enum SrsCodecVideoAVCFrame | ||
68 | // not required or supported) | 72 | // not required or supported) |
69 | enum SrsCodecVideoAVCType | 73 | enum SrsCodecVideoAVCType |
70 | { | 74 | { |
71 | - SrsCodecVideoAVCTypeReserved = -1, | 75 | + // set to the max value to reserved, for array map. |
76 | + SrsCodecVideoAVCTypeReserved = 3, | ||
72 | 77 | ||
73 | SrsCodecVideoAVCTypeSequenceHeader = 0, | 78 | SrsCodecVideoAVCTypeSequenceHeader = 0, |
74 | SrsCodecVideoAVCTypeNALU = 1, | 79 | SrsCodecVideoAVCTypeNALU = 1, |
@@ -86,7 +91,10 @@ enum SrsCodecVideoAVCType | @@ -86,7 +91,10 @@ enum SrsCodecVideoAVCType | ||
86 | // 7 = AVC | 91 | // 7 = AVC |
87 | enum SrsCodecVideo | 92 | enum SrsCodecVideo |
88 | { | 93 | { |
94 | + // set to the max value to reserved, for array map. | ||
89 | SrsCodecVideoReserved = 0, | 95 | SrsCodecVideoReserved = 0, |
96 | + SrsCodecVideoReserved1 = 1, | ||
97 | + SrsCodecVideoReserved2 = 8, | ||
90 | 98 | ||
91 | SrsCodecVideoSorensonH263 = 2, | 99 | SrsCodecVideoSorensonH263 = 2, |
92 | SrsCodecVideoScreenVideo = 3, | 100 | SrsCodecVideoScreenVideo = 3, |
@@ -117,6 +125,9 @@ enum SrsCodecVideo | @@ -117,6 +125,9 @@ enum SrsCodecVideo | ||
117 | // Speex is supported in Flash Player 10 and higher. | 125 | // Speex is supported in Flash Player 10 and higher. |
118 | enum SrsCodecAudio | 126 | enum SrsCodecAudio |
119 | { | 127 | { |
128 | + // set to the max value to reserved, for array map. | ||
129 | + SrsCodecAudioReserved1 = 16, | ||
130 | + | ||
120 | SrsCodecAudioLinearPCMPlatformEndian = 0, | 131 | SrsCodecAudioLinearPCMPlatformEndian = 0, |
121 | SrsCodecAudioADPCM = 1, | 132 | SrsCodecAudioADPCM = 1, |
122 | SrsCodecAudioMP3 = 2, | 133 | SrsCodecAudioMP3 = 2, |
-
请 注册 或 登录 后发表评论