Index: webrtc/audio/audio_send_stream_unittest.cc |
diff --git a/webrtc/audio/audio_send_stream_unittest.cc b/webrtc/audio/audio_send_stream_unittest.cc |
index 9ae0a879990db1e859426b389783691ac67fa0e0..9532e6bd6a571d1d6a60f030f6da9380e61247f9 100644 |
--- a/webrtc/audio/audio_send_stream_unittest.cc |
+++ b/webrtc/audio/audio_send_stream_unittest.cc |
@@ -16,6 +16,7 @@ |
#include "webrtc/audio/conversion.h" |
#include "webrtc/base/task_queue.h" |
#include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" |
+#include "webrtc/modules/audio_coding/codecs/builtin_audio_encoder_factory.h" |
#include "webrtc/modules/audio_mixer/audio_mixer_impl.h" |
#include "webrtc/modules/audio_processing/include/mock_audio_processing.h" |
#include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
@@ -55,6 +56,8 @@ const int kTelephoneEventPayloadFrequency = 65432; |
const int kTelephoneEventCode = 45; |
const int kTelephoneEventDuration = 6789; |
const CodecInst kIsacCodec = {103, "isac", 16000, 320, 1, 32000}; |
+const int kIsacPayloadType = 103; |
+const SdpAudioFormat kIsacFormat = {"isac", 16000, 1}; |
class MockLimitObserver : public BitrateAllocator::LimitObserver { |
public: |
@@ -112,7 +115,8 @@ struct ConfigHelper { |
} |
// Use ISAC as default codec so as to prevent unnecessary |voice_engine_| |
// calls from the default ctor behavior. |
- stream_config_.send_codec_spec.codec_inst = kIsacCodec; |
+ stream_config_.send_codec_spec.payload_type = kIsacPayloadType; |
+ stream_config_.send_codec_spec.format.format = kIsacFormat; |
stream_config_.min_bitrate_bps = 10000; |
stream_config_.max_bitrate_bps = 65000; |
} |
@@ -175,10 +179,11 @@ struct ConfigHelper { |
EXPECT_CALL(*channel_proxy_, SetCodecFECStatus(false)) |
.WillOnce(Return(true)); |
EXPECT_CALL(*channel_proxy_, DisableAudioNetworkAdaptor()); |
- // Let |GetSendCodec| return false for the first time to indicate that no |
- // send codec has been set. |
- EXPECT_CALL(*channel_proxy_, GetSendCodec(_)).WillOnce(Return(false)); |
- EXPECT_CALL(*channel_proxy_, SetSendCodec(_)).WillOnce(Return(true)); |
+ EXPECT_CALL(*channel_proxy_, SetSendFormat(_, _, _)).WillOnce(Return(true)); |
+ // These should no longer be called. |
+ EXPECT_CALL(*channel_proxy_, GetSendCodec(_)) |
+ .Times(0); |
kwiberg-webrtc
2017/02/21 23:35:03
Won't clang-format remove this line break?
|
+ EXPECT_CALL(*channel_proxy_, SetSendCodec(_)).Times(0); |
} |
RtcpRttStats* rtcp_rtt_stats() { return &rtcp_rtt_stats_; } |
@@ -263,14 +268,12 @@ TEST(AudioSendStreamTest, ConfigToString) { |
config.max_bitrate_bps = 34000; |
config.send_codec_spec.nack_enabled = true; |
config.send_codec_spec.transport_cc_enabled = false; |
- config.send_codec_spec.enable_codec_fec = true; |
- config.send_codec_spec.enable_opus_dtx = false; |
- config.send_codec_spec.opus_max_playback_rate = 32000; |
config.send_codec_spec.cng_payload_type = 42; |
config.send_codec_spec.cng_plfreq = 56; |
- config.send_codec_spec.min_ptime_ms = 20; |
- config.send_codec_spec.max_ptime_ms = 60; |
- config.send_codec_spec.codec_inst = kIsacCodec; |
+ config.send_codec_spec.payload_type = kIsacPayloadType; |
+ config.send_codec_spec.format.format = kIsacFormat; |
+ // TODO(ossu): Maybe mock this? |
+ config.encoder_factory = CreateBuiltinAudioEncoderFactory(); |
config.rtp.extensions.push_back( |
RtpExtension(RtpExtension::kAudioLevelUri, kAudioLevelId)); |
EXPECT_EQ( |
@@ -279,10 +282,9 @@ TEST(AudioSendStreamTest, ConfigToString) { |
"{rtp_history_ms: 0}, c_name: foo_name}, send_transport: nullptr, " |
"voe_channel_id: 1, min_bitrate_bps: 12000, max_bitrate_bps: 34000, " |
"send_codec_spec: {nack_enabled: true, transport_cc_enabled: false, " |
- "enable_codec_fec: true, enable_opus_dtx: false, opus_max_playback_rate: " |
- "32000, cng_payload_type: 42, cng_plfreq: 56, min_ptime: 20, max_ptime: " |
- "60, codec_inst: {pltype: 103, plname: \"isac\", plfreq: 16000, pacsize: " |
- "320, channels: 1, rate: 32000}}}", |
+ "cng_payload_type: 42, cng_plfreq: 56, payload_type: 103, " |
+ "format: {name: isac, clockrate_hz: 16000, num_channels: 1, " |
+ "parameters: {}}}}", |
config.ToString()); |
} |
@@ -385,28 +387,12 @@ TEST(AudioSendStreamTest, GetStatsTypingNoiseDetected) { |
TEST(AudioSendStreamTest, SendCodecAppliesConfigParams) { |
ConfigHelper helper(false); |
auto stream_config = helper.config(); |
- const CodecInst kOpusCodec = {111, "opus", 48000, 960, 2, 64000}; |
- stream_config.send_codec_spec.codec_inst = kOpusCodec; |
- stream_config.send_codec_spec.enable_codec_fec = true; |
- stream_config.send_codec_spec.enable_opus_dtx = true; |
- stream_config.send_codec_spec.opus_max_playback_rate = 12345; |
+ const webrtc::SdpAudioFormat kOpusFormat = {"opus", 48000, 2}; |
kwiberg-webrtc
2017/02/21 23:35:03
Too bad we can't make this constexpr. Remind me to
|
+ stream_config.send_codec_spec.format.format = kOpusFormat; |
stream_config.send_codec_spec.cng_plfreq = 16000; |
stream_config.send_codec_spec.cng_payload_type = 105; |
- stream_config.send_codec_spec.min_ptime_ms = 10; |
- stream_config.send_codec_spec.max_ptime_ms = 60; |
stream_config.audio_network_adaptor_config = |
rtc::Optional<std::string>("abced"); |
- EXPECT_CALL(*helper.channel_proxy(), SetCodecFECStatus(true)) |
- .WillOnce(Return(true)); |
- EXPECT_CALL( |
- *helper.channel_proxy(), |
- SetOpusDtx(stream_config.send_codec_spec.enable_opus_dtx)) |
- .WillOnce(Return(true)); |
- EXPECT_CALL( |
- *helper.channel_proxy(), |
- SetOpusMaxPlaybackRate( |
- stream_config.send_codec_spec.opus_max_playback_rate)) |
- .WillOnce(Return(true)); |
EXPECT_CALL(*helper.channel_proxy(), |
SetSendCNPayloadType( |
stream_config.send_codec_spec.cng_payload_type, |
@@ -414,10 +400,6 @@ TEST(AudioSendStreamTest, SendCodecAppliesConfigParams) { |
.WillOnce(Return(true)); |
EXPECT_CALL( |
*helper.channel_proxy(), |
- SetReceiverFrameLengthRange(stream_config.send_codec_spec.min_ptime_ms, |
- stream_config.send_codec_spec.max_ptime_ms)); |
- EXPECT_CALL( |
- *helper.channel_proxy(), |
EnableAudioNetworkAdaptor(*stream_config.audio_network_adaptor_config)); |
internal::AudioSendStream send_stream( |
stream_config, helper.audio_state(), helper.worker_queue(), |
@@ -430,8 +412,9 @@ TEST(AudioSendStreamTest, SendCodecAppliesConfigParams) { |
TEST(AudioSendStreamTest, SendCodecCanApplyVad) { |
ConfigHelper helper(false); |
auto stream_config = helper.config(); |
- const CodecInst kG722Codec = {9, "g722", 8000, 160, 1, 16000}; |
- stream_config.send_codec_spec.codec_inst = kG722Codec; |
+ stream_config.send_codec_spec.payload_type = 9; |
+ stream_config.send_codec_spec.format.format = {"g722", 8000, 1}; |
+ stream_config.send_codec_spec.format.info = {16000, 1, 64000}; |
stream_config.send_codec_spec.cng_plfreq = 8000; |
stream_config.send_codec_spec.cng_payload_type = 105; |
EXPECT_CALL(*helper.channel_proxy(), SetVADStatus(true)) |