- Remove use of VoERTP_RTCP::SetLocalSSRC() for receive streams; recreate them instead.

- Remove VoERTP_RTCP from VoEWrapper and FakeWebRtcVoiceEngine.

BUG=webrtc:4690

Review-Url: https://codereview.webrtc.org/2072783002
Cr-Commit-Position: refs/heads/master@{#13174}
This commit is contained in:
solenberg 2016-06-16 13:07:33 -07:00 committed by Commit bot
parent 3abb764400
commit 4a0f7b508d
4 changed files with 35 additions and 71 deletions

View File

@ -121,7 +121,7 @@ class FakeAudioProcessing : public webrtc::AudioProcessing {
class FakeWebRtcVoiceEngine
: public webrtc::VoEAudioProcessing,
public webrtc::VoEBase, public webrtc::VoECodec,
public webrtc::VoEHardware, public webrtc::VoERTP_RTCP,
public webrtc::VoEHardware,
public webrtc::VoEVolumeControl {
public:
struct Channel {
@ -136,7 +136,6 @@ class FakeWebRtcVoiceEngine
bool opus_dtx = false;
int cn8_type = 13;
int cn16_type = 105;
uint32_t send_ssrc = 0;
int associate_send_channel = -1;
std::vector<webrtc::CodecInst> recv_codecs;
webrtc::CodecInst send_codec;
@ -156,9 +155,6 @@ class FakeWebRtcVoiceEngine
bool IsInited() const { return inited_; }
int GetLastChannel() const { return last_channel_; }
int GetNumChannels() const { return static_cast<int>(channels_.size()); }
uint32_t GetLocalSSRC(int channel) {
return channels_[channel]->send_ssrc;
}
bool GetPlayout(int channel) {
return channels_[channel]->playout;
}
@ -434,43 +430,6 @@ class FakeWebRtcVoiceEngine
WEBRTC_STUB(EnableBuiltInNS, (bool enable));
bool BuiltInNSIsAvailable() const override { return false; }
// webrtc::VoERTP_RTCP
WEBRTC_FUNC(SetLocalSSRC, (int channel, unsigned int ssrc)) {
WEBRTC_CHECK_CHANNEL(channel);
channels_[channel]->send_ssrc = ssrc;
return 0;
}
WEBRTC_STUB(GetLocalSSRC, (int channel, unsigned int& ssrc));
WEBRTC_STUB(GetRemoteSSRC, (int channel, unsigned int& ssrc));
WEBRTC_STUB(SetSendAudioLevelIndicationStatus, (int channel, bool enable,
unsigned char id));
WEBRTC_STUB(SetReceiveAudioLevelIndicationStatus, (int channel, bool enable,
unsigned char id));
WEBRTC_STUB(SetSendAbsoluteSenderTimeStatus, (int channel, bool enable,
unsigned char id));
WEBRTC_STUB(SetReceiveAbsoluteSenderTimeStatus, (int channel, bool enable,
unsigned char id));
WEBRTC_STUB(SetRTCPStatus, (int channel, bool enable));
WEBRTC_STUB(GetRTCPStatus, (int channel, bool& enabled));
WEBRTC_STUB(SetRTCP_CNAME, (int channel, const char cname[256]));
WEBRTC_STUB(GetRTCP_CNAME, (int channel, char cname[256]));
WEBRTC_STUB(GetRemoteRTCP_CNAME, (int channel, char* cname));
WEBRTC_STUB(GetRemoteRTCPData, (int channel, unsigned int& NTPHigh,
unsigned int& NTPLow,
unsigned int& timestamp,
unsigned int& playoutTimestamp,
unsigned int* jitter,
unsigned short* fractionLost));
WEBRTC_STUB(GetRemoteRTCPReportBlocks,
(int channel, std::vector<webrtc::ReportBlock>* receive_blocks));
WEBRTC_STUB(GetRTPStatistics, (int channel, unsigned int& averageJitterMs,
unsigned int& maxJitterMs,
unsigned int& discardedPackets));
WEBRTC_STUB(GetRTCPStatistics, (int channel, webrtc::CallStatistics& stats));
WEBRTC_STUB(SetREDStatus, (int channel, bool enable, int redPayloadtype));
WEBRTC_STUB(GetREDStatus, (int channel, bool& enable, int& redPayloadtype));
WEBRTC_STUB(SetNACKStatus, (int channel, bool enable, int maxNoPackets));
// webrtc::VoEVolumeControl
WEBRTC_STUB(SetSpeakerVolume, (unsigned int));
WEBRTC_STUB(GetSpeakerVolume, (unsigned int&));

View File

@ -23,7 +23,6 @@
#include "webrtc/voice_engine/include/voe_codec.h"
#include "webrtc/voice_engine/include/voe_errors.h"
#include "webrtc/voice_engine/include/voe_hardware.h"
#include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
#include "webrtc/voice_engine/include/voe_volume_control.h"
namespace cricket {
@ -75,21 +74,19 @@ class VoEWrapper {
public:
VoEWrapper()
: engine_(webrtc::VoiceEngine::Create()), processing_(engine_),
base_(engine_), codec_(engine_), hw_(engine_), rtp_(engine_),
base_(engine_), codec_(engine_), hw_(engine_),
volume_(engine_) {
}
VoEWrapper(webrtc::VoEAudioProcessing* processing,
webrtc::VoEBase* base,
webrtc::VoECodec* codec,
webrtc::VoEHardware* hw,
webrtc::VoERTP_RTCP* rtp,
webrtc::VoEVolumeControl* volume)
: engine_(NULL),
processing_(processing),
base_(base),
codec_(codec),
hw_(hw),
rtp_(rtp),
volume_(volume) {
}
~VoEWrapper() {}
@ -98,7 +95,6 @@ class VoEWrapper {
webrtc::VoEBase* base() const { return base_.get(); }
webrtc::VoECodec* codec() const { return codec_.get(); }
webrtc::VoEHardware* hw() const { return hw_.get(); }
webrtc::VoERTP_RTCP* rtp() const { return rtp_.get(); }
webrtc::VoEVolumeControl* volume() const { return volume_.get(); }
int error() { return base_->LastError(); }
@ -108,7 +104,6 @@ class VoEWrapper {
scoped_voe_ptr<webrtc::VoEBase> base_;
scoped_voe_ptr<webrtc::VoECodec> codec_;
scoped_voe_ptr<webrtc::VoEHardware> hw_;
scoped_voe_ptr<webrtc::VoERTP_RTCP> rtp_;
scoped_voe_ptr<webrtc::VoEVolumeControl> volume_;
};
} // namespace cricket

View File

@ -1285,12 +1285,14 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
RTC_DCHECK_GE(ch, 0);
RTC_DCHECK(call);
config_.rtp.remote_ssrc = remote_ssrc;
config_.rtp.local_ssrc = local_ssrc;
config_.rtcp_send_transport = rtcp_send_transport;
config_.voe_channel_id = ch;
config_.sync_group = sync_group;
config_.decoder_factory = decoder_factory;
RecreateAudioReceiveStream(use_transport_cc, use_nack, extensions);
RecreateAudioReceiveStream(local_ssrc,
use_transport_cc,
use_nack,
extensions);
}
~WebRtcAudioReceiveStream() {
@ -1298,21 +1300,31 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
call_->DestroyAudioReceiveStream(stream_);
}
void RecreateAudioReceiveStream(
const std::vector<webrtc::RtpExtension>& extensions) {
void RecreateAudioReceiveStream(uint32_t local_ssrc) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
RecreateAudioReceiveStream(config_.rtp.transport_cc,
RecreateAudioReceiveStream(local_ssrc,
config_.rtp.transport_cc,
config_.rtp.nack.rtp_history_ms != 0,
extensions);
config_.rtp.extensions);
}
void RecreateAudioReceiveStream(bool use_transport_cc, bool use_nack) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
RecreateAudioReceiveStream(use_transport_cc,
RecreateAudioReceiveStream(config_.rtp.local_ssrc,
use_transport_cc,
use_nack,
config_.rtp.extensions);
}
void RecreateAudioReceiveStream(
const std::vector<webrtc::RtpExtension>& extensions) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
RecreateAudioReceiveStream(config_.rtp.local_ssrc,
config_.rtp.transport_cc,
config_.rtp.nack.rtp_history_ms != 0,
extensions);
}
webrtc::AudioReceiveStream::Stats GetStats() const {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
RTC_DCHECK(stream_);
@ -1331,6 +1343,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
private:
void RecreateAudioReceiveStream(
uint32_t local_ssrc,
bool use_transport_cc,
bool use_nack,
const std::vector<webrtc::RtpExtension>& extensions) {
@ -1339,6 +1352,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
call_->DestroyAudioReceiveStream(stream_);
stream_ = nullptr;
}
config_.rtp.local_ssrc = local_ssrc;
config_.rtp.transport_cc = use_transport_cc;
config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0;
config_.rtp.extensions = extensions;
@ -2022,17 +2036,16 @@ bool WebRtcVoiceMediaChannel::AddSendStream(const StreamParams& sp) {
return false;
}
// At this point the channel's local SSRC has been updated. If the channel is
// the first send channel make sure that all the receive channels are updated
// with the same SSRC in order to send receiver reports.
// At this point the stream's local SSRC has been updated. If it is the first
// send stream, make sure that all the receive streams are updated with the
// same SSRC in order to send receiver reports.
if (send_streams_.size() == 1) {
receiver_reports_ssrc_ = ssrc;
for (const auto& stream : recv_streams_) {
int recv_channel = stream.second->channel();
if (engine()->voe()->rtp()->SetLocalSSRC(recv_channel, ssrc) != 0) {
LOG_RTCERR2(SetLocalSSRC, recv_channel, ssrc);
return false;
}
for (const auto& kv : recv_streams_) {
// TODO(solenberg): Allow applications to set the RTCP SSRC of receive
// streams instead, so we can avoid recreating the streams here.
kv.second->RecreateAudioReceiveStream(ssrc);
int recv_channel = kv.second->channel();
engine()->voe()->base()->AssociateSendChannel(recv_channel, channel);
LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel
<< " is associated with channel #" << channel << ".";

View File

@ -59,7 +59,6 @@ class FakeVoEWrapper : public cricket::VoEWrapper {
engine, // base
engine, // codec
engine, // hw
engine, // rtp
engine) { // volume
}
};
@ -2508,13 +2507,11 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) {
// receive channel is created before the send channel.
TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) {
EXPECT_TRUE(SetupChannel());
EXPECT_TRUE(AddRecvStream(1));
int receive_channel_num = voe_.GetLastChannel();
EXPECT_TRUE(AddRecvStream(kSsrc2));
EXPECT_TRUE(channel_->AddSendStream(
cricket::StreamParams::CreateLegacy(1234)));
EXPECT_TRUE(call_.GetAudioSendStream(1234));
EXPECT_EQ(1234U, voe_.GetLocalSSRC(receive_channel_num));
cricket::StreamParams::CreateLegacy(kSsrc1)));
EXPECT_TRUE(call_.GetAudioSendStream(kSsrc1));
EXPECT_EQ(kSsrc1, GetRecvStreamConfig(kSsrc2).rtp.local_ssrc);
}
// Test that we can properly receive packets.