From 384c8677ea022ffbcea2cf3db2ce63fc09655fb4 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 1 Apr 2023 23:48:57 +0800 Subject: [PATCH] =?UTF-8?q?startSendRtp=E6=8E=A5=E5=8F=A3=E5=9C=A8?= =?UTF-8?q?=E5=8F=91=E9=80=81ps=E6=97=B6=E6=94=AF=E6=8C=81=E5=8F=AA?= =?UTF-8?q?=E5=8F=91=E9=80=81=E9=9F=B3=E9=A2=91:=20#2217?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtp/RtpSender.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Rtp/RtpSender.cpp b/src/Rtp/RtpSender.cpp index 39a0e907..de840633 100644 --- a/src/Rtp/RtpSender.cpp +++ b/src/Rtp/RtpSender.cpp @@ -246,6 +246,10 @@ void RtpSender::onConnect(){ } bool RtpSender::addTrack(const Track::Ptr &track){ + if (_args.only_audio && track->getTrackType() == TrackVideo) { + // 如果只发送音频则忽略视频 + return false; + } return _interface->addTrack(track); } @@ -265,6 +269,10 @@ void RtpSender::flush() { //此函数在其他线程执行 bool RtpSender::inputFrame(const Frame::Ptr &frame) { + if (_args.only_audio && frame->getTrackType() == TrackVideo) { + // 如果只发送音频则忽略视频 + return false; + } //连接成功后才做实质操作(节省cpu资源) return _is_connect ? _interface->inputFrame(frame) : false; }