From d0d9f70792eb6a969629c26e0996ddec19b15142 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 14 Feb 2017 16:28:38 +0100 Subject: [PATCH] Bug 1338086 - Remove useless else blocks in order to reduce complexity in media/webrtc/signaling/ r=jesup MozReview-Commit-ID: EU5B0cUYp6c --HG-- extra : rebase_source : 82aa967f8abfceb785ef7392b915c992ebc5d9a0 --- .../signaling/src/jsep/JsepSessionImpl.cpp | 10 +--- .../src/media-conduit/AudioConduit.cpp | 55 ++++++++----------- .../src/media-conduit/VideoConduit.cpp | 16 +++--- .../src/mediapipeline/MediaPipelineFilter.cpp | 9 ++- .../WebrtcGlobalInformation.cpp | 6 +- 5 files changed, 41 insertions(+), 55 deletions(-) mode change 100755 => 100644 media/webrtc/signaling/src/media-conduit/AudioConduit.cpp diff --git a/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp b/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp index 7f7ee6f2fc4d..ed1df981e2be 100644 --- a/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp +++ b/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp @@ -2496,11 +2496,8 @@ JsepSessionImpl::GetParsedLocalDescription() const { if (mPendingLocalDescription) { return mPendingLocalDescription.get(); - } else if (mCurrentLocalDescription) { - return mCurrentLocalDescription.get(); } - - return nullptr; + return mCurrentLocalDescription.get(); } mozilla::Sdp* @@ -2508,11 +2505,8 @@ JsepSessionImpl::GetParsedRemoteDescription() const { if (mPendingRemoteDescription) { return mPendingRemoteDescription.get(); - } else if (mCurrentRemoteDescription) { - return mCurrentRemoteDescription.get(); } - - return nullptr; + return mCurrentRemoteDescription.get(); } const Sdp* diff --git a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp old mode 100755 new mode 100644 index 82a445657c37..2e2590121b37 --- a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp @@ -536,19 +536,16 @@ WebrtcAudioConduit::ConfigureRecvMediaCodecs( error = mPtrVoEBase->LastError(); CSFLogError(logTag, "%s SetRecvCodec Failed %d ",__FUNCTION__, error); continue; - } else { - CSFLogDebug(logTag, "%s Successfully Set RecvCodec %s", __FUNCTION__, - codec->mName.c_str()); - //copy this to local database - if(CopyCodecToDB(codec)) - { - success = true; - } else { + } + CSFLogDebug(logTag, "%s Successfully Set RecvCodec %s", __FUNCTION__, + codec->mName.c_str()); + + //copy this to local database + if(!CopyCodecToDB(codec)) { CSFLogError(logTag,"%s Unable to updated Codec Database", __FUNCTION__); return kMediaConduitUnknownError; - } - } + success = true; } //end for @@ -927,23 +924,22 @@ WebrtcAudioConduit::SendRtp(const uint8_t* data, // with the Call API update in the webrtc.org codebase. // The only field in it is the packet_id, which is used when the header // extension for TransportSequenceNumber is being used, which we don't. - (void) options; + (void)options; if(mTransmitterTransport && (mTransmitterTransport->SendRtpPacket(data, len) == NS_OK)) { CSFLogDebug(logTag, "%s Sent RTP Packet ", __FUNCTION__); return true; - } else { - CSFLogError(logTag, "%s RTP Packet Send Failed ", __FUNCTION__); - return false; } + CSFLogError(logTag, "%s RTP Packet Send Failed ", __FUNCTION__); + return false; } // Called on WebRTC Process thread and perhaps others bool WebrtcAudioConduit::SendRtcp(const uint8_t* data, size_t len) { - CSFLogDebug(logTag, "%s : len %lu, first rtcp = %u ", + CSFLogDebug(logTag, "%s : len %lu, first rtcp = %u ", __FUNCTION__, (unsigned long) len, static_cast(data[1])); @@ -958,14 +954,14 @@ WebrtcAudioConduit::SendRtcp(const uint8_t* data, size_t len) // Might be a sender report, might be a receiver report, we don't know. CSFLogDebug(logTag, "%s Sent RTCP Packet ", __FUNCTION__); return true; - } else if(mTransmitterTransport && - (mTransmitterTransport->SendRtcpPacket(data, len) == NS_OK)) { - CSFLogDebug(logTag, "%s Sent RTCP Packet (sender report) ", __FUNCTION__); - return true; - } else { - CSFLogError(logTag, "%s RTCP Packet Send Failed ", __FUNCTION__); - return false; } + if (mTransmitterTransport && + (mTransmitterTransport->SendRtcpPacket(data, len) == NS_OK)) { + CSFLogDebug(logTag, "%s Sent RTCP Packet (sender report) ", __FUNCTION__); + return true; + } + CSFLogError(logTag, "%s RTCP Packet Send Failed ", __FUNCTION__); + return false; } /** @@ -975,7 +971,7 @@ WebrtcAudioConduit::SendRtcp(const uint8_t* data, size_t len) bool WebrtcAudioConduit::CodecConfigToWebRTCCodec(const AudioCodecConfig* codecInfo, webrtc::CodecInst& cinst) - { +{ const unsigned int plNameLength = codecInfo->mName.length(); memset(&cinst, 0, sizeof(webrtc::CodecInst)); if(sizeof(cinst.plname) < plNameLength+1) @@ -996,27 +992,22 @@ WebrtcAudioConduit::CodecConfigToWebRTCCodec(const AudioCodecConfig* codecInfo, } cinst.channels = codecInfo->mChannels; return true; - } +} /** - * Supported Sampling Frequncies. + * Supported Sampling Frequencies. */ bool WebrtcAudioConduit::IsSamplingFreqSupported(int freq) const { - if(GetNum10msSamplesForFrequency(freq)) - { - return true; - } else { - return false; - } + return GetNum10msSamplesForFrequency(freq) != 0; } /* Return block-length of 10 ms audio frame in number of samples */ unsigned int WebrtcAudioConduit::GetNum10msSamplesForFrequency(int samplingFreqHz) const { - switch(samplingFreqHz) + switch (samplingFreqHz) { case 16000: return 160; //160 samples case 32000: return 320; //320 samples diff --git a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp index 74623f270589..5d2e9e9c4049 100755 --- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp @@ -313,12 +313,11 @@ PayloadNameToEncoderType(const std::string& name) { if ("VP8" == name) { return webrtc::VideoEncoder::EncoderType::kVp8; - } else if ("VP9" == name) { + } else if ("VP9" == name) { // NOLINT(readability-else-after-return) return webrtc::VideoEncoder::EncoderType::kVp9; - } else if ("H264" == name) { + } else if ("H264" == name) { // NOLINT(readability-else-after-return) return webrtc::VideoEncoder::EncoderType::kH264; } - return webrtc::VideoEncoder::EncoderType::kUnsupportedCodec; } @@ -382,12 +381,11 @@ PayloadNameToDecoderType(const std::string& name) { if ("VP8" == name) { return webrtc::VideoDecoder::DecoderType::kVp8; - } else if ("VP9" == name) { + } else if ("VP9" == name) { // NOLINT(readability-else-after-return) return webrtc::VideoDecoder::DecoderType::kVp9; - } else if ("H264" == name) { + } else if ("H264" == name) { // NOLINT(readability-else-after-return) return webrtc::VideoDecoder::DecoderType::kH264; } - return webrtc::VideoDecoder::DecoderType::kUnsupportedCodec; } @@ -1887,7 +1885,8 @@ WebrtcVideoConduit::SendRtcp(const uint8_t* packet, size_t length) // Might be a sender report, might be a receiver report, we don't know. CSFLogDebug(logTag, "%s Sent RTCP Packet ", __FUNCTION__); return true; - } else if (mTransmitterTransport && + } + if (mTransmitterTransport && NS_SUCCEEDED(mTransmitterTransport->SendRtcpPacket(packet, length))) { CSFLogDebug(logTag, "%s Sent RTCP Packet (sender report) ", __FUNCTION__); return true; @@ -2014,7 +2013,8 @@ WebrtcVideoConduit::CodecPluginID() { if (mSendCodecPlugin) { return mSendCodecPlugin->PluginID(); - } else if (mRecvCodecPlugin) { + } + if (mRecvCodecPlugin) { return mRecvCodecPlugin->PluginID(); } diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipelineFilter.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipelineFilter.cpp index d3ec6cdec1e0..629084f0734b 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipelineFilter.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipelineFilter.cpp @@ -24,12 +24,11 @@ bool MediaPipelineFilter::Filter(const webrtc::RTPHeader& header, if (correlator == correlator_) { AddRemoteSSRC(header.ssrc); return true; - } else { - // Some other stream; it is possible that an SSRC has moved, so make sure - // we don't have that SSRC in our filter any more. - remote_ssrc_set_.erase(header.ssrc); - return false; } + // Some other stream; it is possible that an SSRC has moved, so make sure + // we don't have that SSRC in our filter any more. + remote_ssrc_set_.erase(header.ssrc); + return false; } if (remote_ssrc_set_.count(header.ssrc)) { diff --git a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp index 3f12ef3c2461..8a5d86b1a038 100644 --- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp +++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp @@ -420,7 +420,8 @@ RunStatsQuery( if (NS_FAILED(rv)) { return rv; - } else if (!stsThread) { + } + if (!stsThread) { return NS_ERROR_FAILURE; } @@ -542,7 +543,8 @@ RunLogQuery(const nsCString& aPattern, if (NS_FAILED(rv)) { return rv; - } else if (!stsThread) { + } + if (!stsThread) { return NS_ERROR_FAILURE; }