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 "webrtc/voice_engine/test/auto_test/fixtures/after_initialization_fixture.h" 12 13class CodecBeforeStreamingTest : public AfterInitializationFixture { 14 protected: 15 void SetUp() { 16 memset(&codec_instance_, 0, sizeof(codec_instance_)); 17 codec_instance_.channels = 1; 18 codec_instance_.plfreq = 16000; 19 codec_instance_.pacsize = 480; 20 21 channel_ = voe_base_->CreateChannel(); 22 } 23 24 void TearDown() { 25 voe_base_->DeleteChannel(channel_); 26 } 27 28 webrtc::CodecInst codec_instance_; 29 int channel_; 30}; 31 32// TODO(phoglund): add test which verifies default pltypes for various codecs. 33 34TEST_F(CodecBeforeStreamingTest, GetRecPayloadTypeFailsForInvalidCodecName) { 35 strcpy(codec_instance_.plname, "SomeInvalidCodecName"); 36 37 // Should fail since the codec name is invalid. 38 EXPECT_NE(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); 39} 40 41TEST_F(CodecBeforeStreamingTest, GetRecPayloadTypeRecognizesISAC) { 42 strcpy(codec_instance_.plname, "iSAC"); 43 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); 44 strcpy(codec_instance_.plname, "ISAC"); 45 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); 46} 47 48TEST_F(CodecBeforeStreamingTest, SetRecPayloadTypeCanChangeISACPayloadType) { 49 strcpy(codec_instance_.plname, "ISAC"); 50 51 codec_instance_.pltype = 123; 52 EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance_)); 53 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); 54 EXPECT_EQ(123, codec_instance_.pltype); 55 56 codec_instance_.pltype = 104; 57 EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance_)); 58 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); 59 60 EXPECT_EQ(104, codec_instance_.pltype); 61} 62 63TEST_F(CodecBeforeStreamingTest, SetRecPayloadTypeCanChangeILBCPayloadType) { 64 strcpy(codec_instance_.plname, "iLBC"); 65 codec_instance_.plfreq = 8000; 66 codec_instance_.pacsize = 240; 67 codec_instance_.rate = 13300; 68 69 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); 70 int original_pltype = codec_instance_.pltype; 71 codec_instance_.pltype = 123; 72 EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance_)); 73 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); 74 75 EXPECT_EQ(123, codec_instance_.pltype); 76 77 codec_instance_.pltype = original_pltype; 78 EXPECT_EQ(0, voe_codec_->SetRecPayloadType(channel_, codec_instance_)); 79 EXPECT_EQ(0, voe_codec_->GetRecPayloadType(channel_, codec_instance_)); 80 81 EXPECT_EQ(original_pltype, codec_instance_.pltype); 82} 83