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

Side by Side Diff: voice_engine/voe_codec_unittest.cc

Issue 3019433002: Remove VoECodec (Closed)
Patch Set: rebase Created 3 years, 3 months 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
« no previous file with comments | « voice_engine/voe_codec_impl.cc ('k') | voice_engine/voice_engine_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2012 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 <memory>
12
13 #include "voice_engine/include/voe_codec.h"
14
15 #include "modules/audio_device/include/fake_audio_device.h"
16 #include "modules/audio_processing/include/audio_processing.h"
17 #include "test/gtest.h"
18 #include "voice_engine/include/voe_base.h"
19 #include "voice_engine/voice_engine_defines.h"
20
21 namespace webrtc {
22 namespace voe {
23 namespace {
24
25 TEST(VoECodecInst, TestCompareCodecInstances) {
26 CodecInst codec1, codec2;
27 memset(&codec1, 0, sizeof(CodecInst));
28 memset(&codec2, 0, sizeof(CodecInst));
29
30 codec1.pltype = 101;
31 strncpy(codec1.plname, "isac", 4);
32 codec1.plfreq = 8000;
33 codec1.pacsize = 110;
34 codec1.channels = 1;
35 codec1.rate = 8000;
36 memcpy(&codec2, &codec1, sizeof(CodecInst));
37 // Compare two codecs now.
38 EXPECT_TRUE(codec1 == codec2);
39 EXPECT_FALSE(codec1 != codec2);
40
41 // Changing pltype.
42 codec2.pltype = 102;
43 EXPECT_FALSE(codec1 == codec2);
44 EXPECT_TRUE(codec1 != codec2);
45
46 // Reset to codec2 to codec1 state.
47 memcpy(&codec2, &codec1, sizeof(CodecInst));
48 // payload name should be case insensitive.
49 strncpy(codec2.plname, "ISAC", 4);
50 EXPECT_TRUE(codec1 == codec2);
51
52 // Test modifying the |plfreq|
53 codec2.plfreq = 16000;
54 EXPECT_FALSE(codec1 == codec2);
55
56 // Reset to codec2 to codec1 state.
57 memcpy(&codec2, &codec1, sizeof(CodecInst));
58 // Test modifying the |pacsize|.
59 codec2.pacsize = 440;
60 EXPECT_FALSE(codec1 == codec2);
61
62 // Reset to codec2 to codec1 state.
63 memcpy(&codec2, &codec1, sizeof(CodecInst));
64 // Test modifying the |channels|.
65 codec2.channels = 2;
66 EXPECT_FALSE(codec1 == codec2);
67
68 // Reset to codec2 to codec1 state.
69 memcpy(&codec2, &codec1, sizeof(CodecInst));
70 // Test modifying the |rate|.
71 codec2.rate = 0;
72 EXPECT_FALSE(codec1 == codec2);
73 }
74
75 // This is a regression test for
76 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6020
77 // The Opus DTX setting was being forgotten after unrelated VoE calls.
78 TEST(VoECodecInst, RememberOpusDtxAfterSettingChange) {
79 VoiceEngine* voe(VoiceEngine::Create());
80 VoEBase* base(VoEBase::GetInterface(voe));
81 VoECodec* voe_codec(VoECodec::GetInterface(voe));
82 std::unique_ptr<FakeAudioDeviceModule> adm(new FakeAudioDeviceModule);
83 std::unique_ptr<AudioProcessing> apm(AudioProcessing::Create());
84
85 base->Init(adm.get(), apm.get());
86
87 CodecInst codec = {111, "opus", 48000, 960, 1, 32000};
88
89 int channel = base->CreateChannel();
90
91 bool DTX = false;
92
93 EXPECT_EQ(0, voe_codec->SetSendCodec(channel, codec));
94 EXPECT_EQ(0, voe_codec->SetOpusDtx(channel, true));
95 EXPECT_EQ(0, voe_codec->SetFECStatus(channel, true));
96 EXPECT_EQ(0, voe_codec->GetOpusDtxStatus(channel, &DTX));
97 EXPECT_TRUE(DTX);
98
99 base->DeleteChannel(channel);
100 base->Terminate();
101 base->Release();
102 voe_codec->Release();
103 VoiceEngine::Delete(voe);
104 }
105
106 } // namespace
107 } // namespace voe
108 } // namespace webrtc
OLDNEW
« no previous file with comments | « voice_engine/voe_codec_impl.cc ('k') | voice_engine/voice_engine_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698