diff --git a/trunk/src/app/srs_app_avc_aac.cpp b/trunk/src/app/srs_app_avc_aac.cpp index d68ba0a2c..a05959a73 100644 --- a/trunk/src/app/srs_app_avc_aac.cpp +++ b/trunk/src/app/srs_app_avc_aac.cpp @@ -220,12 +220,15 @@ int SrsAvcAacCodec::audio_aac_demux(int8_t* data, int size, SrsCodecSample* samp // TODO: FIXME: to support aac he/he-v2, see: ngx_rtmp_codec_parse_aac_header // @see: https://github.com/winlinvip/nginx-rtmp-module/commit/3a5f9eea78fc8d11e8be922aea9ac349b9dcbfc2 - if (aac_profile > 3) { + // + // donot force to LC, @see: https://github.com/winlinvip/simple-rtmp-server/issues/81 + // the source will print the sequence header info. + //if (aac_profile > 3) { // Mark all extended profiles as LC // to make Android as happy as possible. // @see: ngx_rtmp_hls_parse_aac_header - aac_profile = 1; - } + //aac_profile = 1; + //} } else if (aac_packet_type == SrsCodecAudioTypeRawData) { // ensure the sequence header demuxed if (aac_extra_size <= 0 || !aac_extra_data) { @@ -335,10 +338,14 @@ int SrsAvcAacCodec::video_avc_demux(int8_t* data, int size, SrsCodecSample* samp return ret; } //int8_t configurationVersion = stream->read_1bytes(); + stream->read_1bytes(); //int8_t AVCProfileIndication = stream->read_1bytes(); + avc_profile = stream->read_1bytes(); //int8_t profile_compatibility = stream->read_1bytes(); + stream->read_1bytes(); //int8_t AVCLevelIndication = stream->read_1bytes(); - stream->skip(4); + avc_level = stream->read_1bytes(); + // parse the NALU size. int8_t lengthSizeMinusOne = stream->read_1bytes(); lengthSizeMinusOne &= 0x03; diff --git a/trunk/src/app/srs_app_avc_aac.hpp b/trunk/src/app/srs_app_avc_aac.hpp index 406aa2988..4e100be10 100644 --- a/trunk/src/app/srs_app_avc_aac.hpp +++ b/trunk/src/app/srs_app_avc_aac.hpp @@ -44,7 +44,8 @@ class SrsStream; // 3 = 44 kHz = 44100 Hz enum SrsCodecAudioSampleRate { - SrsCodecAudioSampleRateReserved = -1, + // set to the max value to reserved, for array map. + SrsCodecAudioSampleRateReserved = 4, SrsCodecAudioSampleRate5512 = 0, SrsCodecAudioSampleRate11025 = 1, @@ -59,7 +60,8 @@ enum SrsCodecAudioSampleRate // 1 = 16-bit samples enum SrsCodecAudioSampleSize { - SrsCodecAudioSampleSizeReserved = -1, + // set to the max value to reserved, for array map. + SrsCodecAudioSampleSizeReserved = 2, SrsCodecAudioSampleSize8bit = 0, SrsCodecAudioSampleSize16bit = 1, @@ -70,7 +72,8 @@ enum SrsCodecAudioSampleSize // 1 = Stereo sound enum SrsCodecAudioSoundType { - SrsCodecAudioSoundTypeReserved = -1, + // set to the max value to reserved, for array map. + SrsCodecAudioSoundTypeReserved = 2, SrsCodecAudioSoundTypeMono = 0, SrsCodecAudioSoundTypeStereo = 1, diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index f79c1213c..d94a7730c 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -1497,8 +1497,8 @@ void SrsHls::hls_mux() // reportable if (pithy_print->can_print()) { srs_trace("-> "SRS_LOG_ID_HLS - " time=%"PRId64", dts=%"PRId64", sequence_no=%d", - pithy_print->age(), stream_dts, muxer->sequence_no()); + " time=%"PRId64", dts=%"PRId64"(%"PRId64"ms), sequence_no=%d", + pithy_print->age(), stream_dts, stream_dts / 90, muxer->sequence_no()); } pithy_print->elapse(); diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 866a5e990..cc630542c 100644 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -41,6 +41,7 @@ using namespace std; #include #include #include +#include #define CONST_MAX_JITTER_MS 500 #define DEFAULT_FRAME_TIME_MS 40 @@ -1072,7 +1073,32 @@ int SrsSource::on_audio(SrsMessage* audio) if (SrsFlvCodec::audio_is_sequence_header(msg->payload, msg->size)) { srs_freep(cache_sh_audio); cache_sh_audio = msg->copy(); - srs_trace("got audio sh, size=%d", msg->header.payload_length); + + // parse detail audio codec + SrsAvcAacCodec codec; + SrsCodecSample sample; + if ((ret = codec.audio_aac_demux(msg->payload, msg->size, &sample)) != ERROR_SUCCESS) { + srs_error("codec demux audio failed. ret=%d", ret); + return ret; + } + + static int flv_sample_rates[] = {5512, 11025, 22050, 44100, 0}; + static int flv_sample_sizes[] = {8, 16, 0}; + static int flv_sound_types[] = {1, 2, 0}; + static int aac_sample_rates[] = { + 96000, 88200, 64000, 48000, + 44100, 32000, 24000, 22050, + 16000, 12000, 11025, 8000, + 7350, 0, 0, 0 + }; + srs_trace("%dB audio sh, " + "codec(%d, profile=%d, %dchannels, %dkbps, %dHZ), " + "flv(%dbits, %dchannels, %dHZ)", + msg->header.payload_length, codec.audio_codec_id, + codec.aac_profile, codec.aac_channels, + codec.audio_data_rate / 1000, aac_sample_rates[codec.aac_sample_rate], + flv_sample_sizes[sample.sound_size], flv_sound_types[sample.sound_type], + flv_sample_rates[sample.sound_rate]); return ret; } @@ -1162,7 +1188,20 @@ int SrsSource::on_video(SrsMessage* video) if (SrsFlvCodec::video_is_sequence_header(msg->payload, msg->size)) { srs_freep(cache_sh_video); cache_sh_video = msg->copy(); - srs_trace("got video sh, size=%d", msg->header.payload_length); + + // parse detail audio codec + SrsAvcAacCodec codec; + SrsCodecSample sample; + if ((ret = codec.video_avc_demux(msg->payload, msg->size, &sample)) != ERROR_SUCCESS) { + srs_error("codec demux video failed. ret=%d", ret); + return ret; + } + + srs_trace("%dB video sh, " + "codec(%d, profile=%d, level=%d, %dx%d, %dkbps, %dfps, %ds)", + msg->header.payload_length, codec.video_codec_id, + codec.avc_profile, codec.avc_level, codec.width, codec.height, + codec.video_data_rate / 1000, codec.frame_rate, codec.duration); return ret; } diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 5aa56aee1..7d4f2a40b 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR "0" #define VERSION_MINOR "9" -#define VERSION_REVISION "150" +#define VERSION_REVISION "151" #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION // server info. #define RTMP_SIG_SRS_KEY "SRS" diff --git a/trunk/src/kernel/srs_kernel_codec.hpp b/trunk/src/kernel/srs_kernel_codec.hpp index 570133644..3783f9dab 100644 --- a/trunk/src/kernel/srs_kernel_codec.hpp +++ b/trunk/src/kernel/srs_kernel_codec.hpp @@ -36,7 +36,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // 1 = AAC raw enum SrsCodecAudioType { - SrsCodecAudioTypeReserved = -1, + // set to the max value to reserved, for array map. + SrsCodecAudioTypeReserved = 2, + SrsCodecAudioTypeSequenceHeader = 0, SrsCodecAudioTypeRawData = 1, }; @@ -51,7 +53,9 @@ enum SrsCodecAudioType // 5 = video info/command frame enum SrsCodecVideoAVCFrame { + // set to the max value to reserved, for array map. SrsCodecVideoAVCFrameReserved = 0, + SrsCodecVideoAVCFrameReserved1 = 6, SrsCodecVideoAVCFrameKeyFrame = 1, SrsCodecVideoAVCFrameInterFrame = 2, @@ -68,7 +72,8 @@ enum SrsCodecVideoAVCFrame // not required or supported) enum SrsCodecVideoAVCType { - SrsCodecVideoAVCTypeReserved = -1, + // set to the max value to reserved, for array map. + SrsCodecVideoAVCTypeReserved = 3, SrsCodecVideoAVCTypeSequenceHeader = 0, SrsCodecVideoAVCTypeNALU = 1, @@ -86,7 +91,10 @@ enum SrsCodecVideoAVCType // 7 = AVC enum SrsCodecVideo { + // set to the max value to reserved, for array map. SrsCodecVideoReserved = 0, + SrsCodecVideoReserved1 = 1, + SrsCodecVideoReserved2 = 8, SrsCodecVideoSorensonH263 = 2, SrsCodecVideoScreenVideo = 3, @@ -117,6 +125,9 @@ enum SrsCodecVideo // Speex is supported in Flash Player 10 and higher. enum SrsCodecAudio { + // set to the max value to reserved, for array map. + SrsCodecAudioReserved1 = 16, + SrsCodecAudioLinearPCMPlatformEndian = 0, SrsCodecAudioADPCM = 1, SrsCodecAudioMP3 = 2,