Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine_unittest.cc

Issue 2516993002: Pass SdpAudioFormat through Channel, without converting to CodecInst (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 void SetSink(Sink* sink) override {} 100 void SetSink(Sink* sink) override {}
101 }; 101 };
102 102
103 class WebRtcVoiceEngineTestFake : public testing::Test { 103 class WebRtcVoiceEngineTestFake : public testing::Test {
104 public: 104 public:
105 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {} 105 WebRtcVoiceEngineTestFake() : WebRtcVoiceEngineTestFake("") {}
106 106
107 explicit WebRtcVoiceEngineTestFake(const char* field_trials) 107 explicit WebRtcVoiceEngineTestFake(const char* field_trials)
108 : call_(webrtc::Call::Config(&event_log_)), voe_(&apm_), 108 : call_(webrtc::Call::Config(&event_log_)), voe_(&apm_),
109 override_field_trials_(field_trials) { 109 override_field_trials_(field_trials) {
110 auto factory = webrtc::MockAudioDecoderFactory::CreateUnusedFactory();
111 EXPECT_CALL(adm_, AddRef()).WillOnce(Return(0)); 110 EXPECT_CALL(adm_, AddRef()).WillOnce(Return(0));
112 EXPECT_CALL(adm_, Release()).WillOnce(Return(0)); 111 EXPECT_CALL(adm_, Release()).WillOnce(Return(0));
113 EXPECT_CALL(adm_, BuiltInAECIsAvailable()).WillOnce(Return(false)); 112 EXPECT_CALL(adm_, BuiltInAECIsAvailable()).WillOnce(Return(false));
114 EXPECT_CALL(adm_, BuiltInAGCIsAvailable()).WillOnce(Return(false)); 113 EXPECT_CALL(adm_, BuiltInAGCIsAvailable()).WillOnce(Return(false));
115 EXPECT_CALL(adm_, BuiltInNSIsAvailable()).WillOnce(Return(false)); 114 EXPECT_CALL(adm_, BuiltInNSIsAvailable()).WillOnce(Return(false));
116 EXPECT_CALL(apm_, ApplyConfig(testing::_)); 115 EXPECT_CALL(apm_, ApplyConfig(testing::_));
117 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); 116 EXPECT_CALL(apm_, SetExtraOptions(testing::_));
118 EXPECT_CALL(apm_, Initialize()).WillOnce(Return(0)); 117 EXPECT_CALL(apm_, Initialize()).WillOnce(Return(0));
119 engine_.reset(new cricket::WebRtcVoiceEngine(&adm_, factory, nullptr, 118 // TODO(kwiberg): We should use a mock AudioDecoderFactory, but a bunch of
120 new FakeVoEWrapper(&voe_))); 119 // the tests here probe the specific set of codecs provided by the builtin
120 // factory. Those tests should probably be moved elsewhere.
the sun 2016/12/15 15:34:13 Yes, good call to not do that in this CL though.
121 engine_.reset(new cricket::WebRtcVoiceEngine(
122 &adm_, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr,
123 new FakeVoEWrapper(&voe_)));
121 send_parameters_.codecs.push_back(kPcmuCodec); 124 send_parameters_.codecs.push_back(kPcmuCodec);
122 recv_parameters_.codecs.push_back(kPcmuCodec); 125 recv_parameters_.codecs.push_back(kPcmuCodec);
123 } 126 }
124 127
125 bool SetupChannel() { 128 bool SetupChannel() {
126 EXPECT_CALL(apm_, ApplyConfig(testing::_)); 129 EXPECT_CALL(apm_, ApplyConfig(testing::_));
127 EXPECT_CALL(apm_, SetExtraOptions(testing::_)); 130 EXPECT_CALL(apm_, SetExtraOptions(testing::_));
128 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(), 131 channel_ = engine_->CreateChannel(&call_, cricket::MediaConfig(),
129 cricket::AudioOptions()); 132 cricket::AudioOptions());
130 return (channel_ != nullptr); 133 return (channel_ != nullptr);
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 EXPECT_STREQ("telephone-event", gcodec.plname); 866 EXPECT_STREQ("telephone-event", gcodec.plname);
864 } 867 }
865 868
866 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) { 869 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsAfterAddingStreams) {
867 EXPECT_TRUE(SetupRecvStream()); 870 EXPECT_TRUE(SetupRecvStream());
868 cricket::AudioRecvParameters parameters; 871 cricket::AudioRecvParameters parameters;
869 parameters.codecs.push_back(kIsacCodec); 872 parameters.codecs.push_back(kIsacCodec);
870 parameters.codecs[0].id = 106; // collide with existing CN 32k 873 parameters.codecs[0].id = 106; // collide with existing CN 32k
871 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 874 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
872 875
873 int channel_num2 = voe_.GetLastChannel(); 876 const auto& dm = GetRecvStreamConfig(kSsrc1).decoder_map;
874 webrtc::CodecInst gcodec; 877 ASSERT_EQ(1, dm.count(106));
875 rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC"); 878 EXPECT_EQ(webrtc::SdpAudioFormat("isac", 16000, 1), dm.at(106));
876 gcodec.plfreq = 16000;
877 gcodec.channels = 1;
878 EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
879 EXPECT_EQ(106, gcodec.pltype);
880 EXPECT_STREQ("ISAC", gcodec.plname);
881 } 879 }
882 880
883 // Test that we can apply the same set of codecs again while playing. 881 // Test that we can apply the same set of codecs again while playing.
884 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) { 882 TEST_F(WebRtcVoiceEngineTestFake, SetRecvCodecsWhilePlaying) {
885 EXPECT_TRUE(SetupRecvStream()); 883 EXPECT_TRUE(SetupRecvStream());
886 cricket::AudioRecvParameters parameters; 884 cricket::AudioRecvParameters parameters;
887 parameters.codecs.push_back(kIsacCodec); 885 parameters.codecs.push_back(kIsacCodec);
888 parameters.codecs.push_back(kCn16000Codec); 886 parameters.codecs.push_back(kCn16000Codec);
889 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); 887 EXPECT_TRUE(channel_->SetRecvParameters(parameters));
890 channel_->SetPlayout(true); 888 channel_->SetPlayout(true);
(...skipping 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after
3623 nullptr, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr); 3621 nullptr, webrtc::CreateBuiltinAudioDecoderFactory(), nullptr);
3624 webrtc::RtcEventLogNullImpl event_log; 3622 webrtc::RtcEventLogNullImpl event_log;
3625 std::unique_ptr<webrtc::Call> call( 3623 std::unique_ptr<webrtc::Call> call(
3626 webrtc::Call::Create(webrtc::Call::Config(&event_log))); 3624 webrtc::Call::Create(webrtc::Call::Config(&event_log)));
3627 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), 3625 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(),
3628 cricket::AudioOptions(), call.get()); 3626 cricket::AudioOptions(), call.get());
3629 cricket::AudioRecvParameters parameters; 3627 cricket::AudioRecvParameters parameters;
3630 parameters.codecs = engine.recv_codecs(); 3628 parameters.codecs = engine.recv_codecs();
3631 EXPECT_TRUE(channel.SetRecvParameters(parameters)); 3629 EXPECT_TRUE(channel.SetRecvParameters(parameters));
3632 } 3630 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698