From 2c9141513d511ce51593c0e292cd13b2065aa395 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 26 Apr 2020 09:45:00 +0800 Subject: [PATCH] =?UTF-8?q?ts/ps=E6=94=AF=E6=8C=81G711?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/media-server | 2 +- src/Record/TsMuxer.cpp | 21 +++++++++++------- src/Rtp/RtpProcess.cpp | 50 +++++++++++++++++++++++++----------------- 3 files changed, 44 insertions(+), 29 deletions(-) diff --git a/3rdpart/media-server b/3rdpart/media-server index 24519a59..abc08f61 160000 --- a/3rdpart/media-server +++ b/3rdpart/media-server @@ -1 +1 @@ -Subproject commit 24519a594c2c634b21fbe09fad28d54c4eba0885 +Subproject commit abc08f61bb1250b94d252cfeaea249527912dd3b diff --git a/src/Record/TsMuxer.cpp b/src/Record/TsMuxer.cpp index 9730eeec..79419c74 100644 --- a/src/Record/TsMuxer.cpp +++ b/src/Record/TsMuxer.cpp @@ -28,24 +28,29 @@ void TsMuxer::addTrack(const Track::Ptr &track) { case CodecH264: { _have_video = true; _codec_to_trackid[track->getCodecId()].track_id = mpeg_ts_add_stream(_context, PSI_STREAM_H264, nullptr, 0); - } break; + } + case CodecH265: { _have_video = true; _codec_to_trackid[track->getCodecId()].track_id = mpeg_ts_add_stream(_context, PSI_STREAM_H265, nullptr, 0); - } break; + } + case CodecAAC: { _codec_to_trackid[track->getCodecId()].track_id = mpeg_ts_add_stream(_context, PSI_STREAM_AAC, nullptr, 0); - } break; + } - case CodecG711A: - case CodecG711U: { - //todo 此处未区分G711a和G711u - _codec_to_trackid[track->getCodecId()].track_id = mpeg_ts_add_stream(_context, PSI_STREAM_AUDIO_G711, nullptr, 0); - } + case CodecG711A: { + _codec_to_trackid[track->getCodecId()].track_id = mpeg_ts_add_stream(_context, PSI_STREAM_AUDIO_G711A, nullptr, 0); break; + } + + case CodecG711U: { + _codec_to_trackid[track->getCodecId()].track_id = mpeg_ts_add_stream(_context, PSI_STREAM_AUDIO_G711U, nullptr, 0); + break; + } default: break; diff --git a/src/Rtp/RtpProcess.cpp b/src/Rtp/RtpProcess.cpp index 629fde8b..7c9053e2 100644 --- a/src/Rtp/RtpProcess.cpp +++ b/src/Rtp/RtpProcess.cpp @@ -9,7 +9,7 @@ */ #if defined(ENABLE_RTPPROXY) -#include "mpeg-ps.h" +#include "mpeg-ts-proto.h" #include "RtpProcess.h" #include "Util/File.h" #include "Extension/H265.h" @@ -204,19 +204,29 @@ void RtpProcess::onRtpDecode(const uint8_t *packet, int bytes, uint32_t timestam #define SWITCH_CASE(codec_id) case codec_id : return #codec_id static const char *getCodecName(int codec_id) { switch (codec_id) { - SWITCH_CASE(STREAM_VIDEO_MPEG4); - SWITCH_CASE(STREAM_VIDEO_H264); - SWITCH_CASE(STREAM_VIDEO_H265); - SWITCH_CASE(STREAM_VIDEO_SVAC); - SWITCH_CASE(STREAM_AUDIO_MP3); - SWITCH_CASE(STREAM_AUDIO_AAC); - SWITCH_CASE(STREAM_AUDIO_G711); - SWITCH_CASE(STREAM_AUDIO_G722); - SWITCH_CASE(STREAM_AUDIO_G723); - SWITCH_CASE(STREAM_AUDIO_G729); - SWITCH_CASE(STREAM_AUDIO_SVAC); - default: - return "unknown codec"; + SWITCH_CASE(PSI_STREAM_MPEG1); + SWITCH_CASE(PSI_STREAM_MPEG2); + SWITCH_CASE(PSI_STREAM_AUDIO_MPEG1); + SWITCH_CASE(PSI_STREAM_MP3); + SWITCH_CASE(PSI_STREAM_AAC); + SWITCH_CASE(PSI_STREAM_MPEG4); + SWITCH_CASE(PSI_STREAM_MPEG4_AAC_LATM); + SWITCH_CASE(PSI_STREAM_H264); + SWITCH_CASE(PSI_STREAM_MPEG4_AAC); + SWITCH_CASE(PSI_STREAM_H265); + SWITCH_CASE(PSI_STREAM_AUDIO_AC3); + SWITCH_CASE(PSI_STREAM_AUDIO_EAC3); + SWITCH_CASE(PSI_STREAM_AUDIO_DTS); + SWITCH_CASE(PSI_STREAM_VIDEO_DIRAC); + SWITCH_CASE(PSI_STREAM_VIDEO_VC1); + SWITCH_CASE(PSI_STREAM_VIDEO_SVAC); + SWITCH_CASE(PSI_STREAM_AUDIO_SVAC); + SWITCH_CASE(PSI_STREAM_AUDIO_G711A); + SWITCH_CASE(PSI_STREAM_AUDIO_G711U); + SWITCH_CASE(PSI_STREAM_AUDIO_G722); + SWITCH_CASE(PSI_STREAM_AUDIO_G723); + SWITCH_CASE(PSI_STREAM_AUDIO_G729); + default : return "unknown codec"; } } @@ -226,7 +236,7 @@ void RtpProcess::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d _stamps[codecid].revise(dts,pts,dts,pts,false); switch (codecid) { - case STREAM_VIDEO_H264: { + case PSI_STREAM_H264: { _dts = dts; if (!_codecid_video) { //获取到视频 @@ -251,7 +261,7 @@ void RtpProcess::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d break; } - case STREAM_VIDEO_H265: { + case PSI_STREAM_H265: { _dts = dts; if (!_codecid_video) { //获取到视频 @@ -274,7 +284,7 @@ void RtpProcess::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d break; } - case STREAM_AUDIO_AAC: { + case PSI_STREAM_AAC: { _dts = dts; if (!_codecid_audio) { //获取到音频 @@ -292,10 +302,10 @@ void RtpProcess::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d break; } - case STREAM_AUDIO_G711: { + case PSI_STREAM_AUDIO_G711A: + case PSI_STREAM_AUDIO_G711U: { _dts = dts; - //todo 等待陈大佬更新ts/ps解析库,现在暂时固定为G711A - auto codec = CodecG711A; + auto codec = codecid == PSI_STREAM_AUDIO_G711A ? CodecG711A : CodecG711U; if (!_codecid_audio) { //获取到音频 _codecid_audio = codecid;