|
| 1 | +From f02918e6b4ca54eafacb3da057bb519e62a1b8d1 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Chen Li1 < [email protected]> |
| 3 | +Date: Thu, 17 Dec 2020 14:21:31 +0800 |
| 4 | +Subject: [PATCH] Remove unused includes and add checks |
| 5 | + |
| 6 | +--- |
| 7 | + erizo/src/erizo/DtlsTransport.cpp | 30 ++++++++++++++---------------- |
| 8 | + erizo/src/erizo/MediaStream.cpp | 10 ++++++---- |
| 9 | + erizo/src/erizo/WebRtcConnection.cpp | 8 ++++---- |
| 10 | + erizo/src/erizo/dtls/DtlsClient.cpp | 2 +- |
| 11 | + erizo/src/erizo/rtp/QualityManager.cpp | 10 ++++++++++ |
| 12 | + erizo/src/erizo/thread/Scheduler.cpp | 2 +- |
| 13 | + erizo/src/erizo/thread/Worker.cpp | 4 +++- |
| 14 | + 7 files changed, 39 insertions(+), 27 deletions(-) |
| 15 | + |
| 16 | +diff --git a/erizo/src/erizo/DtlsTransport.cpp b/erizo/src/erizo/DtlsTransport.cpp |
| 17 | +index 8a6539e..6387ffe 100644 |
| 18 | +--- a/erizo/src/erizo/DtlsTransport.cpp |
| 19 | ++++ b/erizo/src/erizo/DtlsTransport.cpp |
| 20 | +@@ -49,22 +49,20 @@ void TimeoutChecker::scheduleCheck() { |
| 21 | + |
| 22 | + void TimeoutChecker::scheduleNext() { |
| 23 | + scheduled_task_ = transport_->getWorker()->scheduleFromNow([this]() { |
| 24 | +- if (transport_->getTransportState() == TRANSPORT_READY) { |
| 25 | +- return; |
| 26 | +- } |
| 27 | +- if (transport_ != nullptr) { |
| 28 | +- if (max_checks_-- > 0) { |
| 29 | +- ELOG_DEBUG("Handling dtls timeout, checks left: %d", max_checks_); |
| 30 | +- if (socket_context_) { |
| 31 | +- std::lock_guard<std::mutex> guard(dtls_mutex); |
| 32 | +- socket_context_->handleTimeout(); |
| 33 | +- } |
| 34 | +- scheduleNext(); |
| 35 | +- } else { |
| 36 | +- ELOG_DEBUG("%s message: DTLS timeout", transport_->toLog()); |
| 37 | +- transport_->onHandshakeFailed(socket_context_, "Dtls Timeout on TimeoutChecker"); |
| 38 | +- } |
| 39 | ++ if (!transport_ || transport_->getTransportState() == TRANSPORT_READY) { |
| 40 | ++ return; |
| 41 | ++ } |
| 42 | ++ if (max_checks_-- > 0) { |
| 43 | ++ ELOG_DEBUG("Handling dtls timeout, checks left: %d", max_checks_); |
| 44 | ++ if (socket_context_) { |
| 45 | ++ std::lock_guard<std::mutex> guard(dtls_mutex); |
| 46 | ++ socket_context_->handleTimeout(); |
| 47 | + } |
| 48 | ++ scheduleNext(); |
| 49 | ++ } else { |
| 50 | ++ ELOG_DEBUG("%s message: DTLS timeout", transport_->toLog()); |
| 51 | ++ transport_->onHandshakeFailed(socket_context_, "Dtls Timeout on TimeoutChecker"); |
| 52 | ++ } |
| 53 | + }, std::chrono::seconds(check_seconds_)); |
| 54 | + } |
| 55 | + |
| 56 | +@@ -261,7 +259,7 @@ void DtlsTransport::onDtlsPacket(DtlsSocketContext *ctx, const unsigned char* da |
| 57 | + } |
| 58 | + |
| 59 | + ELOG_DEBUG("%s message: Sending DTLS message, transportName: %s, componentId: %d", |
| 60 | +- toLog(), transport_name.c_str(), packet->comp); |
| 61 | ++ toLog(), transport_name.c_str(), packet ? packet->comp : 0); |
| 62 | + } |
| 63 | + |
| 64 | + void DtlsTransport::writeDtlsPacket(DtlsSocketContext *ctx, packetPtr packet) { |
| 65 | +diff --git a/erizo/src/erizo/MediaStream.cpp b/erizo/src/erizo/MediaStream.cpp |
| 66 | +index 00e046a..465caa4 100644 |
| 67 | +--- a/erizo/src/erizo/MediaStream.cpp |
| 68 | ++++ b/erizo/src/erizo/MediaStream.cpp |
| 69 | +@@ -18,7 +18,7 @@ |
| 70 | + #include "rtp/RtpHeaders.h" |
| 71 | + #include "rtp/RtpVP8Parser.h" |
| 72 | + #include "rtp/RtcpAggregator.h" |
| 73 | +-#include "rtp/RtcpForwarder.h" |
| 74 | ++// #include "rtp/RtcpForwarder.h" |
| 75 | + // #include "rtp/RtpSlideShowHandler.h" |
| 76 | + // #include "rtp/RtpTrackMuteHandler.h" |
| 77 | + // #include "rtp/BandwidthEstimationHandler.h" |
| 78 | +@@ -79,7 +79,7 @@ MediaStream::MediaStream(std::shared_ptr<Worker> worker, |
| 79 | + audio_sink_ssrc_ = std::rand(); |
| 80 | + video_sink_ssrc_ = std::rand(); |
| 81 | + |
| 82 | +- rtcp_processor_ = std::make_shared<RtcpForwarder>(static_cast<MediaSink*>(this), static_cast<MediaSource*>(this)); |
| 83 | ++ rtcp_processor_ = nullptr; |
| 84 | + |
| 85 | + should_send_feedback_ = true; |
| 86 | + slide_show_mode_ = false; |
| 87 | +@@ -158,7 +158,7 @@ bool MediaStream::setRemoteSdp(std::shared_ptr<SdpInfo> sdp) { |
| 88 | + remote_sdp_ = std::make_shared<SdpInfo>(*sdp.get()); |
| 89 | + if (remote_sdp_->videoBandwidth != 0) { |
| 90 | + ELOG_DEBUG("%s message: Setting remote BW, maxVideoBW: %u", toLog(), remote_sdp_->videoBandwidth); |
| 91 | +- this->rtcp_processor_->setMaxVideoBW(remote_sdp_->videoBandwidth*1000); |
| 92 | ++ // this->rtcp_processor_->setMaxVideoBW(remote_sdp_->videoBandwidth*1000); |
| 93 | + } |
| 94 | + |
| 95 | + auto video_ssrc_list_it = remote_sdp_->video_ssrc_map.find(getLabel()); |
| 96 | +@@ -192,10 +192,12 @@ bool MediaStream::setRemoteSdp(std::shared_ptr<SdpInfo> sdp) { |
| 97 | + audio_enabled_ = remote_sdp_->hasAudio; |
| 98 | + video_enabled_ = remote_sdp_->hasVideo; |
| 99 | + |
| 100 | ++ /* |
| 101 | + rtcp_processor_->addSourceSsrc(getAudioSourceSSRC()); |
| 102 | + std::for_each(video_source_ssrc_list_.begin(), video_source_ssrc_list_.end(), [this] (uint32_t new_ssrc){ |
| 103 | + rtcp_processor_->addSourceSsrc(new_ssrc); |
| 104 | + }); |
| 105 | ++ */ |
| 106 | + |
| 107 | + if (remote_sdp_->rids().size() > 1) { |
| 108 | + simulcast_ = true; |
| 109 | +@@ -348,7 +350,7 @@ void MediaStream::initializePipeline() { |
| 110 | + handler_manager_ = std::make_shared<HandlerManager>(shared_from_this()); |
| 111 | + pipeline_->addService(shared_from_this()); |
| 112 | + pipeline_->addService(handler_manager_); |
| 113 | +- pipeline_->addService(rtcp_processor_); |
| 114 | ++ // pipeline_->addService(rtcp_processor_); |
| 115 | + pipeline_->addService(stats_); |
| 116 | + pipeline_->addService(quality_manager_); |
| 117 | + pipeline_->addService(packet_buffer_); |
| 118 | +diff --git a/erizo/src/erizo/WebRtcConnection.cpp b/erizo/src/erizo/WebRtcConnection.cpp |
| 119 | +index 5ff5156..b143811 100644 |
| 120 | +--- a/erizo/src/erizo/WebRtcConnection.cpp |
| 121 | ++++ b/erizo/src/erizo/WebRtcConnection.cpp |
| 122 | +@@ -16,14 +16,14 @@ |
| 123 | + // #include "bandwidth/MaxVideoBWDistributor.h" |
| 124 | + // #include "bandwidth/TargetVideoBWDistributor.h" |
| 125 | + #include "rtp/RtpHeaders.h" |
| 126 | +-#include "rtp/RtpVP8Parser.h" |
| 127 | +-#include "rtp/RtcpAggregator.h" |
| 128 | +-#include "rtp/RtcpForwarder.h" |
| 129 | ++// #include "rtp/RtpVP8Parser.h" |
| 130 | ++// #include "rtp/RtcpAggregator.h" |
| 131 | ++// #include "rtp/RtcpForwarder.h" |
| 132 | + // #include "rtp/RtpSlideShowHandler.h" |
| 133 | + // #include "rtp/RtpTrackMuteHandler.h" |
| 134 | + // #include "rtp/BandwidthEstimationHandler.h" |
| 135 | + // #include "rtp/FecReceiverHandler.h" |
| 136 | +-#include "rtp/RtcpProcessorHandler.h" |
| 137 | ++// #include "rtp/RtcpProcessorHandler.h" |
| 138 | + // #include "rtp/RtpRetransmissionHandler.h" |
| 139 | + // #include "rtp/RtcpFeedbackGenerationHandler.h" |
| 140 | + // #include "rtp/RtpPaddingRemovalHandler.h" |
| 141 | +diff --git a/erizo/src/erizo/dtls/DtlsClient.cpp b/erizo/src/erizo/dtls/DtlsClient.cpp |
| 142 | +index e77bdd1..8bcc2d5 100644 |
| 143 | +--- a/erizo/src/erizo/dtls/DtlsClient.cpp |
| 144 | ++++ b/erizo/src/erizo/dtls/DtlsClient.cpp |
| 145 | +@@ -444,7 +444,7 @@ int createCert(const std::string& pAor, int expireDays, int keyLen, X509*& outCe |
| 146 | + ELOG_DEBUG("SRTP Extension negotiated profile=%s", srtp_profile->name); |
| 147 | + } |
| 148 | + |
| 149 | +- if (receiver != NULL) { |
| 150 | ++ if (receiver != NULL && srtp_profile) { |
| 151 | + receiver->onHandshakeCompleted(this, clientKey, serverKey, srtp_profile->name); |
| 152 | + } |
| 153 | + } else { |
| 154 | +diff --git a/erizo/src/erizo/rtp/QualityManager.cpp b/erizo/src/erizo/rtp/QualityManager.cpp |
| 155 | +index 20fe2d2..60afdee 100644 |
| 156 | +--- a/erizo/src/erizo/rtp/QualityManager.cpp |
| 157 | ++++ b/erizo/src/erizo/rtp/QualityManager.cpp |
| 158 | +@@ -49,6 +49,10 @@ void QualityManager::notifyQualityUpdate() { |
| 159 | + return; |
| 160 | + } |
| 161 | + |
| 162 | ++ if (!getContext()) { |
| 163 | ++ return; |
| 164 | ++ } |
| 165 | ++ |
| 166 | + if (!initialized_) { |
| 167 | + auto pipeline = getContext()->getPipelineShared(); |
| 168 | + if (!pipeline) { |
| 169 | +@@ -129,6 +133,9 @@ void QualityManager::selectLayer(bool try_higher_layers) { |
| 170 | + if (!initialized_ || !stats_->getNode().hasChild("qualityLayers")) { |
| 171 | + return; |
| 172 | + } |
| 173 | ++ if (!getContext() || !getContext()->getPipelineShared()) { |
| 174 | ++ return; |
| 175 | ++ } |
| 176 | + stream_->setSimulcast(true); |
| 177 | + last_quality_check_ = clock_->now(); |
| 178 | + int min_requested_spatial_layer = |
| 179 | +@@ -301,6 +308,9 @@ void QualityManager::setTemporalLayer(int temporal_layer) { |
| 180 | + } |
| 181 | + |
| 182 | + void QualityManager::setPadding(bool enabled) { |
| 183 | ++ if (!getContext() || !getContext()->getPipelineShared()) { |
| 184 | ++ return; |
| 185 | ++ } |
| 186 | + if (padding_enabled_ != enabled) { |
| 187 | + padding_enabled_ = enabled; |
| 188 | + HandlerManager *manager = getContext()->getPipelineShared()->getService<HandlerManager>().get(); |
| 189 | +diff --git a/erizo/src/erizo/thread/Scheduler.cpp b/erizo/src/erizo/thread/Scheduler.cpp |
| 190 | +index a5fba22..f5e8adb 100644 |
| 191 | +--- a/erizo/src/erizo/thread/Scheduler.cpp |
| 192 | ++++ b/erizo/src/erizo/thread/Scheduler.cpp |
| 193 | +@@ -7,7 +7,7 @@ |
| 194 | + |
| 195 | + |
| 196 | + Scheduler::Scheduler(int n_threads_servicing_queue) |
| 197 | +-: n_threads_servicing_queue_(n_threads_servicing_queue), stop_requested_(false), stop_when_empty_(false) { |
| 198 | ++ : task_queue_(), n_threads_servicing_queue_(n_threads_servicing_queue), stop_requested_(false), stop_when_empty_(false) { |
| 199 | + stop_requested_ = false; |
| 200 | + stop_when_empty_ = false; |
| 201 | + for (int index = 0; index < n_threads_servicing_queue; index++) { |
| 202 | +diff --git a/erizo/src/erizo/thread/Worker.cpp b/erizo/src/erizo/thread/Worker.cpp |
| 203 | +index 5fc7983..25b3e56 100644 |
| 204 | +--- a/erizo/src/erizo/thread/Worker.cpp |
| 205 | ++++ b/erizo/src/erizo/thread/Worker.cpp |
| 206 | +@@ -141,7 +141,9 @@ std::shared_ptr<ScheduledTaskReference> SimulatedWorker::scheduleFromNow(Task f, |
| 207 | + |
| 208 | + void SimulatedWorker::executeTasks() { |
| 209 | + for (Task f : tasks_) { |
| 210 | +- f(); |
| 211 | ++ if (f) { |
| 212 | ++ f(); |
| 213 | ++ } |
| 214 | + } |
| 215 | + tasks_.clear(); |
| 216 | + } |
| 217 | +-- |
| 218 | +2.7.4 |
| 219 | + |
0 commit comments