|
| 1 | +From 15553a66a08795ab3bbbcfdc9ad3547911ac763e Mon Sep 17 00:00:00 2001 |
| 2 | +From: Chen Li1 < [email protected]> |
| 3 | +Date: Thu, 31 Oct 2019 15:39:42 +0800 |
| 4 | +Subject: [PATCH] Enable REMB for RID streams |
| 5 | + |
| 6 | +--- |
| 7 | + erizo/src/erizo/MediaStream.cpp | 16 +++++++++++++--- |
| 8 | + erizo/src/erizo/SdpInfo.cpp | 1 + |
| 9 | + erizo/src/erizo/rtp/BandwidthEstimationHandler.cpp | 20 ++++++++++++++------ |
| 10 | + erizo/src/erizo/rtp/BandwidthEstimationHandler.h | 4 ++-- |
| 11 | + erizo/src/erizo/rtp/RtpExtensionProcessor.cpp | 2 +- |
| 12 | + 5 files changed, 31 insertions(+), 12 deletions(-) |
| 13 | + |
| 14 | +diff --git a/erizo/src/erizo/MediaStream.cpp b/erizo/src/erizo/MediaStream.cpp |
| 15 | +index a78b057..4327c6f 100644 |
| 16 | +--- a/erizo/src/erizo/MediaStream.cpp |
| 17 | ++++ b/erizo/src/erizo/MediaStream.cpp |
| 18 | +@@ -21,7 +21,7 @@ |
| 19 | + #include "rtp/RtcpForwarder.h" |
| 20 | + // #include "rtp/RtpSlideShowHandler.h" |
| 21 | + // #include "rtp/RtpTrackMuteHandler.h" |
| 22 | +-// #include "rtp/BandwidthEstimationHandler.h" |
| 23 | ++#include "rtp/BandwidthEstimationHandler.h" |
| 24 | + // #include "rtp/FecReceiverHandler.h" |
| 25 | + #include "rtp/RtcpProcessorHandler.h" |
| 26 | + // #include "rtp/RtpRetransmissionHandler.h" |
| 27 | +@@ -151,6 +151,10 @@ bool MediaStream::setRemoteSdp(std::shared_ptr<SdpInfo> sdp) { |
| 28 | + if (!sending_) { |
| 29 | + return true; |
| 30 | + } |
| 31 | ++ if (!sdp) { |
| 32 | ++ ELOG_WARN("%s message: setting remote SDP nullptr", toLog()); |
| 33 | ++ return true; |
| 34 | ++ } |
| 35 | + remote_sdp_ = std::make_shared<SdpInfo>(*sdp.get()); |
| 36 | + if (remote_sdp_->videoBandwidth != 0) { |
| 37 | + ELOG_DEBUG("%s message: Setting remote BW, maxVideoBW: %u", toLog(), remote_sdp_->videoBandwidth); |
| 38 | +@@ -193,6 +197,10 @@ bool MediaStream::setRemoteSdp(std::shared_ptr<SdpInfo> sdp) { |
| 39 | + rtcp_processor_->addSourceSsrc(new_ssrc); |
| 40 | + }); |
| 41 | + |
| 42 | ++ if (remote_sdp_->rids().size() > 1) { |
| 43 | ++ simulcast_ = true; |
| 44 | ++ } |
| 45 | ++ |
| 46 | + initializePipeline(); |
| 47 | + |
| 48 | + initializeStats(); |
| 49 | +@@ -348,7 +356,7 @@ void MediaStream::initializePipeline() { |
| 50 | + pipeline_->addFront(std::make_shared<PacketReader>(this)); |
| 51 | + pipeline_->addFront(WoogeenHandler(this)); |
| 52 | + |
| 53 | +- pipeline_->addFront(std::make_shared<RtcpProcessorHandler>()); |
| 54 | ++ // pipeline_->addFront(std::make_shared<RtcpProcessorHandler>()); |
| 55 | + // pipeline_->addFront(std::make_shared<FecReceiverHandler>()); |
| 56 | + // pipeline_->addFront(std::make_shared<LayerBitrateCalculationHandler>()); |
| 57 | + // pipeline_->addFront(std::make_shared<QualityFilterHandler>()); |
| 58 | +@@ -357,7 +365,9 @@ void MediaStream::initializePipeline() { |
| 59 | + // pipeline_->addFront(std::make_shared<RtpSlideShowHandler>()); |
| 60 | + // pipeline_->addFront(std::make_shared<RtpPaddingGeneratorHandler>()); |
| 61 | + // pipeline_->addFront(std::make_shared<PliPacerHandler>()); |
| 62 | +- // pipeline_->addFront(std::make_shared<BandwidthEstimationHandler>()); |
| 63 | ++ if (simulcast_ && is_publisher_) { |
| 64 | ++ pipeline_->addFront(std::make_shared<BandwidthEstimationHandler>()); |
| 65 | ++ } |
| 66 | + // pipeline_->addFront(std::make_shared<RtpPaddingRemovalHandler>()); |
| 67 | + // pipeline_->addFront(std::make_shared<RtcpFeedbackGenerationHandler>()); |
| 68 | + // pipeline_->addFront(std::make_shared<RtpRetransmissionHandler>()); |
| 69 | +diff --git a/erizo/src/erizo/SdpInfo.cpp b/erizo/src/erizo/SdpInfo.cpp |
| 70 | +index c4d9ea7..4e13951 100644 |
| 71 | +--- a/erizo/src/erizo/SdpInfo.cpp |
| 72 | ++++ b/erizo/src/erizo/SdpInfo.cpp |
| 73 | +@@ -69,6 +69,7 @@ namespace erizo { |
| 74 | + } |
| 75 | + |
| 76 | + bool SdpInfo::initWithSdp(const std::string& sdp, const std::string& media) { |
| 77 | ++ rids_.clear(); |
| 78 | + return processSdp(sdp, media); |
| 79 | + } |
| 80 | + std::string SdpInfo::addCandidate(const CandidateInfo& info) { |
| 81 | +diff --git a/erizo/src/erizo/rtp/BandwidthEstimationHandler.cpp b/erizo/src/erizo/rtp/BandwidthEstimationHandler.cpp |
| 82 | +index a5a9366..d283ca5 100644 |
| 83 | +--- a/erizo/src/erizo/rtp/BandwidthEstimationHandler.cpp |
| 84 | ++++ b/erizo/src/erizo/rtp/BandwidthEstimationHandler.cpp |
| 85 | +@@ -97,15 +97,15 @@ void BandwidthEstimationHandler::process() { |
| 86 | + }, std::chrono::milliseconds(rbe_->TimeUntilNextProcess())); |
| 87 | + } |
| 88 | + |
| 89 | +-void BandwidthEstimationHandler::updateExtensionMaps(std::array<RTPExtensions, 10> video_map, |
| 90 | +- std::array<RTPExtensions, 10> audio_map) { |
| 91 | ++void BandwidthEstimationHandler::updateExtensionMaps(std::array<RTPExtensions, 20> video_map, |
| 92 | ++ std::array<RTPExtensions, 20> audio_map) { |
| 93 | + updateExtensionMap(true, video_map); |
| 94 | + updateExtensionMap(false, audio_map); |
| 95 | + } |
| 96 | + |
| 97 | +-void BandwidthEstimationHandler::updateExtensionMap(bool is_video, std::array<RTPExtensions, 10> map) { |
| 98 | ++void BandwidthEstimationHandler::updateExtensionMap(bool is_video, std::array<RTPExtensions, 20> map) { |
| 99 | + webrtc::RTPExtensionType type = webrtc::kRtpExtensionNone; |
| 100 | +- for (uint8_t id = 0; id < 10; id++) { |
| 101 | ++ for (uint8_t id = 0; id < 20; id++) { |
| 102 | + RTPExtensions extension = map[id]; |
| 103 | + switch (extension) { |
| 104 | + case RTP_ID: |
| 105 | +@@ -130,6 +130,9 @@ void BandwidthEstimationHandler::updateExtensionMap(bool is_video, std::array<RT |
| 106 | + case PLAYBACK_TIME: |
| 107 | + type = webrtc::kRtpExtensionPlayoutDelay; |
| 108 | + break; |
| 109 | ++ default: |
| 110 | ++ continue; |
| 111 | ++ break; |
| 112 | + } |
| 113 | + if (type == webrtc::kRtpExtensionNone) { |
| 114 | + continue; |
| 115 | +@@ -219,6 +222,11 @@ void BandwidthEstimationHandler::pickEstimator() { |
| 116 | + } |
| 117 | + |
| 118 | + void BandwidthEstimationHandler::sendREMBPacket() { |
| 119 | ++ uint32_t mul = 1; |
| 120 | ++ auto remoteSdp = stream_->getRemoteSdpInfo(); |
| 121 | ++ if (remoteSdp && !remoteSdp->rids().empty()) { |
| 122 | ++ mul = (1 << remoteSdp->rids().size()) - 1; |
| 123 | ++ } |
| 124 | + remb_packet_.setPacketType(RTCP_PS_Feedback_PT); |
| 125 | + remb_packet_.setBlockCount(RTCP_AFB); |
| 126 | + memcpy(&remb_packet_.report.rembPacket.uniqueid, "REMB", 4); |
| 127 | +@@ -229,12 +237,12 @@ void BandwidthEstimationHandler::sendREMBPacket() { |
| 128 | + remb_packet_.setLength(5); |
| 129 | + uint32_t capped_bitrate = max_video_bw_ > 0 ? std::min(max_video_bw_, bitrate_) : bitrate_; |
| 130 | + ELOG_DEBUG("Bitrates min(%u,%u) = %u", bitrate_, max_video_bw_, capped_bitrate); |
| 131 | +- remb_packet_.setREMBBitRate(capped_bitrate); |
| 132 | ++ remb_packet_.setREMBBitRate(bitrate_ * mul); |
| 133 | + remb_packet_.setREMBNumSSRC(1); |
| 134 | + remb_packet_.setREMBFeedSSRC(0, stream_->getVideoSourceSSRC()); |
| 135 | + int remb_length = (remb_packet_.getLength() + 1) * 4; |
| 136 | + if (active_) { |
| 137 | +- ELOG_DEBUG("BWE Estimation is %d", last_send_bitrate_); |
| 138 | ++ ELOG_DEBUG("BWE Estimation is %d", bitrate_ * mul); |
| 139 | + getContext()->fireWrite(std::make_shared<DataPacket>(0, |
| 140 | + reinterpret_cast<char*>(&remb_packet_), remb_length, OTHER_PACKET)); |
| 141 | + } |
| 142 | +diff --git a/erizo/src/erizo/rtp/BandwidthEstimationHandler.h b/erizo/src/erizo/rtp/BandwidthEstimationHandler.h |
| 143 | +index c851ab1..166d799 100644 |
| 144 | +--- a/erizo/src/erizo/rtp/BandwidthEstimationHandler.h |
| 145 | ++++ b/erizo/src/erizo/rtp/BandwidthEstimationHandler.h |
| 146 | +@@ -55,7 +55,7 @@ class BandwidthEstimationHandler: public Handler, public RemoteBitrateObserver, |
| 147 | + void write(Context *ctx, std::shared_ptr<DataPacket> packet) override; |
| 148 | + void notifyUpdate() override; |
| 149 | + |
| 150 | +- void updateExtensionMaps(std::array<RTPExtensions, 10> video_map, std::array<RTPExtensions, 10> audio_map); |
| 151 | ++ void updateExtensionMaps(std::array<RTPExtensions, 20> video_map, std::array<RTPExtensions, 20> audio_map); |
| 152 | + |
| 153 | + private: |
| 154 | + void process(); |
| 155 | +@@ -65,7 +65,7 @@ class BandwidthEstimationHandler: public Handler, public RemoteBitrateObserver, |
| 156 | + void pickEstimatorFromHeader(); |
| 157 | + void pickEstimator(); |
| 158 | + |
| 159 | +- void updateExtensionMap(bool video, std::array<RTPExtensions, 10> map); |
| 160 | ++ void updateExtensionMap(bool video, std::array<RTPExtensions, 20> map); |
| 161 | + |
| 162 | + MediaStream *stream_; |
| 163 | + std::shared_ptr<Worker> worker_; |
| 164 | +diff --git a/erizo/src/erizo/rtp/RtpExtensionProcessor.cpp b/erizo/src/erizo/rtp/RtpExtensionProcessor.cpp |
| 165 | +index 5ee860e..6ea37e8 100644 |
| 166 | +--- a/erizo/src/erizo/rtp/RtpExtensionProcessor.cpp |
| 167 | ++++ b/erizo/src/erizo/rtp/RtpExtensionProcessor.cpp |
| 168 | +@@ -153,7 +153,7 @@ uint32_t RtpExtensionProcessor::processRtpExtensions(std::shared_ptr<DataPacket> |
| 169 | + if (extId != 0 && extMap[extId] != 0) { |
| 170 | + switch (extMap[extId]) { |
| 171 | + case ABS_SEND_TIME: |
| 172 | +- processAbsSendTime(extBuffer); |
| 173 | ++ // processAbsSendTime(extBuffer); |
| 174 | + break; |
| 175 | + case VIDEO_ORIENTATION: |
| 176 | + processVideoOrientation(extBuffer); |
| 177 | +-- |
| 178 | +2.7.4 |
| 179 | + |
0 commit comments