| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include "voice_engine/channel_proxy.h" | |
| 12 #include "voice_engine/test/auto_test/fixtures/after_initialization_fixture.h" | |
| 13 #include "voice_engine/voice_engine_impl.h" | |
| 14 | |
| 15 class CodecBeforeStreamingTest : public AfterInitializationFixture { | |
| 16 protected: | |
| 17 void SetUp() { | |
| 18 memset(&codec_instance_, 0, sizeof(codec_instance_)); | |
| 19 codec_instance_.channels = 1; | |
| 20 codec_instance_.plfreq = 16000; | |
| 21 codec_instance_.pacsize = 480; | |
| 22 | |
| 23 channel_ = voe_base_->CreateChannel(); | |
| 24 static_cast<webrtc::VoiceEngineImpl*>(voice_engine_) | |
| 25 ->GetChannelProxy(channel_) | |
| 26 ->RegisterLegacyReceiveCodecs(); | |
| 27 } | |
| 28 | |
| 29 void TearDown() { | |
| 30 voe_base_->DeleteChannel(channel_); | |
| 31 } | |
| 32 | |
| 33 webrtc::CodecInst codec_instance_; | |
| 34 int channel_; | |
| 35 }; | |
| 36 | |
| 37 // TODO(phoglund): add test which verifies default pltypes for various codecs. | |
| 38 | |
| 39 TEST_F(CodecBeforeStreamingTest, GetRecPayloadTypeFailsForInvalidCodecName) { | |
| 40 strcpy(codec_instance_.plname, "SomeInvalidCodecName"); | |
| 41 | |
| 42 // Should fail since the codec name is invalid. | |
| 43 EXPECT_NE(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); | |
| 44 } | |
| 45 | |
| 46 TEST_F(CodecBeforeStreamingTest, GetRecPayloadTypeRecognizesISAC) { | |
| 47 strcpy(codec_instance_.plname, "iSAC"); | |
| 48 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); | |
| 49 strcpy(codec_instance_.plname, "ISAC"); | |
| 50 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); | |
| 51 } | |
| 52 | |
| 53 TEST_F(CodecBeforeStreamingTest, SetRecPayloadTypeCanChangeISACPayloadType) { | |
| 54 strcpy(codec_instance_.plname, "ISAC"); | |
| 55 codec_instance_.rate = 32000; | |
| 56 | |
| 57 codec_instance_.pltype = 123; | |
| 58 EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance_)); | |
| 59 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); | |
| 60 EXPECT_EQ(123, codec_instance_.pltype); | |
| 61 | |
| 62 codec_instance_.pltype = 104; | |
| 63 EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance_)); | |
| 64 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); | |
| 65 | |
| 66 EXPECT_EQ(104, codec_instance_.pltype); | |
| 67 } | |
| 68 | |
| 69 TEST_F(CodecBeforeStreamingTest, SetRecPayloadTypeCanChangeILBCPayloadType) { | |
| 70 strcpy(codec_instance_.plname, "iLBC"); | |
| 71 codec_instance_.plfreq = 8000; | |
| 72 codec_instance_.pacsize = 240; | |
| 73 codec_instance_.rate = 13300; | |
| 74 | |
| 75 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); | |
| 76 int original_pltype = codec_instance_.pltype; | |
| 77 codec_instance_.pltype = 123; | |
| 78 EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance_)); | |
| 79 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); | |
| 80 | |
| 81 EXPECT_EQ(123, codec_instance_.pltype); | |
| 82 | |
| 83 codec_instance_.pltype = original_pltype; | |
| 84 EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance_)); | |
| 85 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); | |
| 86 | |
| 87 EXPECT_EQ(original_pltype, codec_instance_.pltype); | |
| 88 } | |
| OLD | NEW |