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