From 09e8c47ee5c58e5e86b09dc1950f8d3f9f24cd9f Mon Sep 17 00:00:00 2001 From: "xians@webrtc.org" Date: Wed, 31 Jul 2013 16:30:19 +0000 Subject: [PATCH] Merge r4374 from stable to trunk. r4374 was mistakenly committed to stable, so this is to re-merge back to trunk. Store the sequence number in StopSend() and resume it in StartSend(). When restarting the microphone device, we call StopSend() first, then StartSend() later. Since we reset sequence number in StopSend(), it sometimes causes libSRTP to complain about packets being replayed. Libjingle work around it by caching the sequence number in WebRtcVoiceEngine.cc, and call SetInitSequenceNumber() to resume the sequence number before StartSend().Store the sequence number in StopSend() and resume it in StartSend(). When restarting the microphone device, we call StopSend() first, then StartSend() later. Since we reset sequence number in StopSend(), it sometimes causes libSRTP to complain about packets being replayed. Libjingle work around it by caching the sequence number in WebRtcVoiceEngine.cc, and call SetInitSequenceNumber() to resume the sequence number before StartSend(). This patch fixes this problem by storing the sequence number in StopSend(), and resume it in StartSend(). So that we can remove the workaround in libjingle. BUG=2102 R=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/1922004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4451 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/voice_engine/channel.cc | 14 ++++++++++++++ webrtc/voice_engine/channel.h | 1 + 2 files changed, 15 insertions(+) diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc index 1a77b7f91..c9f4b8a86 100644 --- a/webrtc/voice_engine/channel.cc +++ b/webrtc/voice_engine/channel.cc @@ -915,6 +915,7 @@ Channel::Channel(int32_t channelId, playout_timestamp_rtp_(0), playout_timestamp_rtcp_(0), _numberOfDiscardedPackets(0), + send_sequence_number_(0), _engineStatisticsPtr(NULL), _outputMixerPtr(NULL), _transmitMixerPtr(NULL), @@ -1400,6 +1401,11 @@ Channel::StartSend() { WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), "Channel::StartSend()"); + // Resume the previous sequence number which was reset by StopSend(). + // This needs to be done before |_sending| is set to true. + if (send_sequence_number_) + SetInitSequenceNumber(send_sequence_number_); + { // A lock is needed because |_sending| can be accessed or modified by // another thread at the same time. @@ -1442,6 +1448,14 @@ Channel::StopSend() _sending = false; } + // Store the sequence number to be able to pick up the same sequence for + // the next StartSend(). This is needed for restarting device, otherwise + // it might cause libSRTP to complain about packets being replayed. + // TODO(xians): Remove this workaround after RtpRtcpModule's refactoring + // CL is landed. See issue + // https://code.google.com/p/webrtc/issues/detail?id=2111 . + send_sequence_number_ = _rtpRtcpModule->SequenceNumber(); + // Reset sending SSRC and sequence number and triggers direct transmission // of RTCP BYE if (_rtpRtcpModule->SetSendingStatus(false) == -1 || diff --git a/webrtc/voice_engine/channel.h b/webrtc/voice_engine/channel.h index 444282f4f..eb08b3533 100644 --- a/webrtc/voice_engine/channel.h +++ b/webrtc/voice_engine/channel.h @@ -490,6 +490,7 @@ private: uint32_t playout_timestamp_rtcp_; uint32_t playout_delay_ms_; uint32_t _numberOfDiscardedPackets; + uint16_t send_sequence_number_; private: // uses