From 9a26ba9f8a3024eda94cd7fe19d985bdbe14d214 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 1 Apr 2021 20:14:07 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dandroid=E4=B8=8B=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/Process.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/Process.cpp b/server/Process.cpp index fab4c515..9a75ee58 100644 --- a/server/Process.cpp +++ b/server/Process.cpp @@ -108,10 +108,17 @@ void Process::run(const string &cmd, const string &log_file_tmp) { } fprintf(stderr, "\r\n\r\n#### pid=%d,cmd=%s #####\r\n\r\n", getpid(), cmd.data()); +#ifndef ANDROID //关闭父进程继承的fd for (int i = 3; i < getdtablesize(); i++) { ::close(i); } +#else + //关闭父进程继承的fd + for (int i = 3; i < 1024; i++) { + ::close(i); + } +#endif auto params = split(cmd, " "); // memory leak in child process, it's ok. From 5539050f0696f4be68f578ee3b13e6afec44af24 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 1 Apr 2021 21:44:10 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/media-server | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdpart/media-server b/3rdpart/media-server index c12a2cdb..ec171caa 160000 --- a/3rdpart/media-server +++ b/3rdpart/media-server @@ -1 +1 @@ -Subproject commit c12a2cdb8040e1cb1cedd8718ada27017eccb80e +Subproject commit ec171caa4b28db0f6ea47bca2c0c9530f345698a From 075756c4c614a3ef07d4bc68670f02463eb96a46 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 1 Apr 2021 21:46:02 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=8F=90=E5=8D=87=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=80=A7=EF=BC=9A#789?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/AAC.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Extension/AAC.cpp b/src/Extension/AAC.cpp index d29ccc59..72c3fb3e 100644 --- a/src/Extension/AAC.cpp +++ b/src/Extension/AAC.cpp @@ -205,7 +205,7 @@ public: if (bitrate) { _printer << "b=AS:" << bitrate << "\r\n"; } - _printer << "a=rtpmap:" << payload_type << " MPEG4-GENERIC/" << sample_rate << "/" << channels << "\r\n"; + _printer << "a=rtpmap:" << payload_type << " mpeg4-generic/" << sample_rate << "/" << channels << "\r\n"; string configStr; char buf[4] = {0}; From d2fec801c98c71c73170d664e565cd93cb154a80 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 1 Apr 2021 21:56:21 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E4=B8=8D=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E7=9A=84rtmp=E6=8E=A8=E6=B5=81=E5=99=A8=EF=BC=9A#764?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtmp/RtmpSession.cpp | 15 +++++---------- src/Rtmp/RtmpSession.h | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Rtmp/RtmpSession.cpp b/src/Rtmp/RtmpSession.cpp index 61c844a1..7187226d 100644 --- a/src/Rtmp/RtmpSession.cpp +++ b/src/Rtmp/RtmpSession.cpp @@ -415,17 +415,11 @@ void RtmpSession::onCmd_pause(AMFDecoder &dec) { } void RtmpSession::setMetaData(AMFDecoder &dec) { - if (!_publisher_src) { - throw std::runtime_error("not a publisher"); - } std::string type = dec.load(); if (type != "onMetaData") { throw std::runtime_error("can only set metadata"); } - auto metadata = dec.load(); -// dumpMetadata(metadata); - _publisher_src->setMetaData(metadata); - _set_meta_data = true; + _publisher_metadata = dec.load(); } void RtmpSession::onProcessCmd(AMFDecoder &dec) { @@ -478,7 +472,8 @@ void RtmpSession::onRtmpChunk(RtmpPacket::Ptr packet) { case MSG_AUDIO: case MSG_VIDEO: { if (!_publisher_src) { - throw std::runtime_error("Not a rtmp publisher!"); + WarnL << "Not a rtmp publisher!"; + return; } GET_CONFIG(bool, rtmp_modify_stamp, Rtmp::kModifyStamp); if (rtmp_modify_stamp) { @@ -487,9 +482,9 @@ void RtmpSession::onRtmpChunk(RtmpPacket::Ptr packet) { chunk_data.time_stamp = (uint32_t)dts_out; } - if (!_set_meta_data && !chunk_data.isCfgFrame()) { + if (!_set_meta_data) { _set_meta_data = true; - _publisher_src->setMetaData(TitleMeta().getMetadata()); + _publisher_src->setMetaData(_publisher_metadata ? _publisher_metadata : TitleMeta().getMetadata()); } _publisher_src->onWrite(std::move(packet)); break; diff --git a/src/Rtmp/RtmpSession.h b/src/Rtmp/RtmpSession.h index 0939ee80..02f2d623 100644 --- a/src/Rtmp/RtmpSession.h +++ b/src/Rtmp/RtmpSession.h @@ -98,8 +98,8 @@ private: //数据接收超时计时器 Ticker _ticker; MediaInfo _media_info; - std::weak_ptr _player_src; + AMFValue _publisher_metadata; std::shared_ptr _publisher_src; RtmpMediaSource::RingType::RingReader::Ptr _ring_reader; }; From 2434470fb89b89c3588221fda378cb9ca27beb3f Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 1 Apr 2021 22:20:29 +0800 Subject: [PATCH 5/6] =?UTF-8?q?G711=E5=BC=BA=E5=88=B6=E8=A7=84=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/G711.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Extension/G711.h b/src/Extension/G711.h index bcf5f677..550acbc4 100644 --- a/src/Extension/G711.h +++ b/src/Extension/G711.h @@ -22,7 +22,7 @@ namespace mediakit{ class G711Track : public AudioTrackImp{ public: using Ptr = std::shared_ptr; - G711Track(CodecId codecId,int sample_rate, int channels, int sample_bit) : AudioTrackImp(codecId,sample_rate,channels,sample_bit){} + G711Track(CodecId codecId, int sample_rate, int channels, int sample_bit) : AudioTrackImp(codecId, 8000, 1, 16) {} private: Sdp::Ptr getSdp() override; From a328520c9ca05b59ef303d6259efb3d86234ca98 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 1 Apr 2021 22:24:35 +0800 Subject: [PATCH 6/6] buf fixed --- src/Rtp/RtpProcess.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Rtp/RtpProcess.cpp b/src/Rtp/RtpProcess.cpp index 5c888a19..a50a8ecb 100644 --- a/src/Rtp/RtpProcess.cpp +++ b/src/Rtp/RtpProcess.cpp @@ -145,6 +145,9 @@ bool RtpProcess::alive() { void RtpProcess::setStopCheckRtp(bool is_check){ _stop_rtp_check = is_check; + if (!is_check) { + _last_frame_time.resetTime(); + } } void RtpProcess::onDetach() {