From ee66d945e8d1b681bc57d608ffb6091837544269 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 12 Dec 2019 22:25:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0media-server=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/media-server | 2 +- src/Extension/Factory.cpp | 24 ++++++++++-------------- src/Record/MP4Muxer.cpp | 4 ++-- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/3rdpart/media-server b/3rdpart/media-server index 4325386b..8d40dad3 160000 --- a/3rdpart/media-server +++ b/3rdpart/media-server @@ -1 +1 @@ -Subproject commit 4325386be318889b7815cdd86a2e83f05a059c81 +Subproject commit 8d40dad3dbdce171756691d4511aca49fcf2a231 diff --git a/src/Extension/Factory.cpp b/src/Extension/Factory.cpp index 4aad5e9f..cff9a4c0 100644 --- a/src/Extension/Factory.cpp +++ b/src/Extension/Factory.cpp @@ -180,6 +180,9 @@ CodecId Factory::getCodecIdByAmf(const AMFValue &val){ if(str == "mp4a"){ return CodecAAC; } + if(str == "hev1" || str == "hvc1"){ + return CodecH265; + } WarnL << "暂不支持该Amf:" << str; return CodecInvalid; } @@ -187,12 +190,9 @@ CodecId Factory::getCodecIdByAmf(const AMFValue &val){ if (val.type() != AMF_NULL){ auto type_id = val.as_integer(); switch (type_id){ - case 7:{ - return CodecH264; - } - case 10:{ - return CodecAAC; - } + case 7: return CodecH264; + case 10: return CodecAAC; + case 12: return CodecH265; default: WarnL << "暂不支持该Amf:" << type_id; return CodecInvalid; @@ -219,14 +219,10 @@ RtmpCodec::Ptr Factory::getRtmpCodecByTrack(const Track::Ptr &track) { AMFValue Factory::getAmfByCodecId(CodecId codecId) { switch (codecId){ - case CodecAAC:{ - return AMFValue("mp4a"); - } - case CodecH264:{ - return AMFValue("avc1"); - } - default: - return AMFValue(AMF_NULL); + case CodecAAC: return AMFValue("mp4a"); + case CodecH264: return AMFValue("avc1"); + case CodecH265: return AMFValue(12); + default: return AMFValue(AMF_NULL); } } diff --git a/src/Record/MP4Muxer.cpp b/src/Record/MP4Muxer.cpp index 70d6e38c..53bd61ae 100644 --- a/src/Record/MP4Muxer.cpp +++ b/src/Record/MP4Muxer.cpp @@ -152,7 +152,7 @@ void MP4Muxer::addTrack(const Track::Ptr &track) { struct mpeg4_avc_t avc; string sps_pps = string("\x00\x00\x00\x01", 4) + h264_track->getSps() + string("\x00\x00\x00\x01", 4) + h264_track->getPps(); - h264_annexbtomp4(&avc, sps_pps.data(), sps_pps.size(), NULL, 0, NULL); + h264_annexbtomp4(&avc, sps_pps.data(), sps_pps.size(), NULL, 0, NULL, NULL); uint8_t extra_data[1024]; int extra_data_size = mpeg4_avc_decoder_configuration_record_save(&avc, extra_data, sizeof(extra_data)); @@ -186,7 +186,7 @@ void MP4Muxer::addTrack(const Track::Ptr &track) { string vps_sps_pps = string("\x00\x00\x00\x01", 4) + h265_track->getVps() + string("\x00\x00\x00\x01", 4) + h265_track->getSps() + string("\x00\x00\x00\x01", 4) + h265_track->getPps(); - h265_annexbtomp4(&hevc, vps_sps_pps.data(), vps_sps_pps.size(), NULL, 0, NULL); + h265_annexbtomp4(&hevc, vps_sps_pps.data(), vps_sps_pps.size(), NULL, 0, NULL, NULL); uint8_t extra_data[1024]; int extra_data_size = mpeg4_hevc_decoder_configuration_record_save(&hevc, extra_data, sizeof(extra_data));