aboutsummaryrefslogtreecommitdiff
path: root/audio/audio_receive_stream_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'audio/audio_receive_stream_unittest.cc')
-rw-r--r--audio/audio_receive_stream_unittest.cc68
1 files changed, 42 insertions, 26 deletions
diff --git a/audio/audio_receive_stream_unittest.cc b/audio/audio_receive_stream_unittest.cc
index 99e3a56e1b..fb5f1cb876 100644
--- a/audio/audio_receive_stream_unittest.cc
+++ b/audio/audio_receive_stream_unittest.cc
@@ -74,7 +74,7 @@ const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest();
struct ConfigHelper {
explicit ConfigHelper(bool use_null_audio_processing)
- : ConfigHelper(new rtc::RefCountedObject<MockAudioMixer>(),
+ : ConfigHelper(rtc::make_ref_counted<MockAudioMixer>(),
use_null_audio_processing) {}
ConfigHelper(rtc::scoped_refptr<MockAudioMixer> audio_mixer,
@@ -87,9 +87,9 @@ struct ConfigHelper {
config.audio_processing =
use_null_audio_processing
? nullptr
- : new rtc::RefCountedObject<NiceMock<MockAudioProcessing>>();
+ : rtc::make_ref_counted<NiceMock<MockAudioProcessing>>();
config.audio_device_module =
- new rtc::RefCountedObject<testing::NiceMock<MockAudioDeviceModule>>();
+ rtc::make_ref_counted<testing::NiceMock<MockAudioDeviceModule>>();
audio_state_ = AudioState::Create(config);
channel_receive_ = new ::testing::StrictMock<MockChannelReceive>();
@@ -104,8 +104,6 @@ struct ConfigHelper {
.WillRepeatedly(Invoke([](const std::map<int, SdpAudioFormat>& codecs) {
EXPECT_THAT(codecs, ::testing::IsEmpty());
}));
- EXPECT_CALL(*channel_receive_, SetDepacketizerToDecoderFrameTransformer(_))
- .Times(1);
EXPECT_CALL(*channel_receive_, SetSourceTracker(_));
stream_config_.rtp.local_ssrc = kLocalSsrc;
@@ -117,15 +115,16 @@ struct ConfigHelper {
RtpExtension::kTransportSequenceNumberUri, kTransportSequenceNumberId));
stream_config_.rtcp_send_transport = &rtcp_send_transport_;
stream_config_.decoder_factory =
- new rtc::RefCountedObject<MockAudioDecoderFactory>;
+ rtc::make_ref_counted<MockAudioDecoderFactory>();
}
std::unique_ptr<internal::AudioReceiveStream> CreateAudioReceiveStream() {
- return std::unique_ptr<internal::AudioReceiveStream>(
- new internal::AudioReceiveStream(
- Clock::GetRealTimeClock(), &rtp_stream_receiver_controller_,
- &packet_router_, stream_config_, audio_state_, &event_log_,
- std::unique_ptr<voe::ChannelReceiveInterface>(channel_receive_)));
+ auto ret = std::make_unique<internal::AudioReceiveStream>(
+ Clock::GetRealTimeClock(), &packet_router_, stream_config_,
+ audio_state_, &event_log_,
+ std::unique_ptr<voe::ChannelReceiveInterface>(channel_receive_));
+ ret->RegisterWithTransport(&rtp_stream_receiver_controller_);
+ return ret;
}
AudioReceiveStream::Config& config() { return stream_config_; }
@@ -199,6 +198,7 @@ TEST(AudioReceiveStreamTest, ConstructDestruct) {
for (bool use_null_audio_processing : {false, true}) {
ConfigHelper helper(use_null_audio_processing);
auto recv_stream = helper.CreateAudioReceiveStream();
+ recv_stream->UnregisterFromTransport();
}
}
@@ -212,6 +212,7 @@ TEST(AudioReceiveStreamTest, ReceiveRtcpPacket) {
ReceivedRTCPPacket(&rtcp_packet[0], rtcp_packet.size()))
.WillOnce(Return());
recv_stream->DeliverRtcp(&rtcp_packet[0], rtcp_packet.size());
+ recv_stream->UnregisterFromTransport();
}
}
@@ -276,6 +277,7 @@ TEST(AudioReceiveStreamTest, GetStats) {
EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_,
stats.capture_start_ntp_time_ms);
EXPECT_EQ(kPlayoutNtpTimestampMs, stats.estimated_playout_ntp_timestamp_ms);
+ recv_stream->UnregisterFromTransport();
}
}
@@ -286,6 +288,7 @@ TEST(AudioReceiveStreamTest, SetGain) {
EXPECT_CALL(*helper.channel_receive(),
SetChannelOutputVolumeScaling(FloatEq(0.765f)));
recv_stream->SetGain(0.765f);
+ recv_stream->UnregisterFromTransport();
}
}
@@ -317,14 +320,9 @@ TEST(AudioReceiveStreamTest, StreamsShouldBeAddedToMixerOnceOnStart) {
// Stop stream before it is being destructed.
recv_stream2->Stop();
- }
-}
-TEST(AudioReceiveStreamTest, ReconfigureWithSameConfig) {
- for (bool use_null_audio_processing : {false, true}) {
- ConfigHelper helper(use_null_audio_processing);
- auto recv_stream = helper.CreateAudioReceiveStream();
- recv_stream->Reconfigure(helper.config());
+ recv_stream1->UnregisterFromTransport();
+ recv_stream2->UnregisterFromTransport();
}
}
@@ -334,20 +332,32 @@ TEST(AudioReceiveStreamTest, ReconfigureWithUpdatedConfig) {
auto recv_stream = helper.CreateAudioReceiveStream();
auto new_config = helper.config();
- new_config.rtp.nack.rtp_history_ms = 300 + 20;
+
new_config.rtp.extensions.clear();
new_config.rtp.extensions.push_back(
RtpExtension(RtpExtension::kAudioLevelUri, kAudioLevelId + 1));
new_config.rtp.extensions.push_back(
RtpExtension(RtpExtension::kTransportSequenceNumberUri,
kTransportSequenceNumberId + 1));
- new_config.decoder_map.emplace(1, SdpAudioFormat("foo", 8000, 1));
MockChannelReceive& channel_receive = *helper.channel_receive();
- EXPECT_CALL(channel_receive, SetNACKStatus(true, 15 + 1)).Times(1);
+
+ // TODO(tommi, nisse): This applies new extensions to the internal config,
+ // but there's nothing that actually verifies that the changes take effect.
+ // In fact Call manages the extensions separately in Call::ReceiveRtpConfig
+ // and changing this config value (there seem to be a few copies), doesn't
+ // affect that logic.
+ recv_stream->ReconfigureForTesting(new_config);
+
+ new_config.decoder_map.emplace(1, SdpAudioFormat("foo", 8000, 1));
EXPECT_CALL(channel_receive, SetReceiveCodecs(new_config.decoder_map));
+ recv_stream->SetDecoderMap(new_config.decoder_map);
+
+ EXPECT_CALL(channel_receive, SetNACKStatus(true, 15 + 1)).Times(1);
+ recv_stream->SetUseTransportCcAndNackHistory(new_config.rtp.transport_cc,
+ 300 + 20);
- recv_stream->Reconfigure(new_config);
+ recv_stream->UnregisterFromTransport();
}
}
@@ -358,17 +368,23 @@ TEST(AudioReceiveStreamTest, ReconfigureWithFrameDecryptor) {
auto new_config_0 = helper.config();
rtc::scoped_refptr<FrameDecryptorInterface> mock_frame_decryptor_0(
- new rtc::RefCountedObject<MockFrameDecryptor>());
+ rtc::make_ref_counted<MockFrameDecryptor>());
new_config_0.frame_decryptor = mock_frame_decryptor_0;
- recv_stream->Reconfigure(new_config_0);
+ // TODO(tommi): While this changes the internal config value, it doesn't
+ // actually change what frame_decryptor is used. WebRtcAudioReceiveStream
+ // recreates the whole instance in order to change this value.
+ // So, it's not clear if changing this post initialization needs to be
+ // supported.
+ recv_stream->ReconfigureForTesting(new_config_0);
auto new_config_1 = helper.config();
rtc::scoped_refptr<FrameDecryptorInterface> mock_frame_decryptor_1(
- new rtc::RefCountedObject<MockFrameDecryptor>());
+ rtc::make_ref_counted<MockFrameDecryptor>());
new_config_1.frame_decryptor = mock_frame_decryptor_1;
new_config_1.crypto_options.sframe.require_frame_encryption = true;
- recv_stream->Reconfigure(new_config_1);
+ recv_stream->ReconfigureForTesting(new_config_1);
+ recv_stream->UnregisterFromTransport();
}
}