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

Side by Side Diff: webrtc/voice_engine/test/auto_test/standard/external_media_test.cc

Issue 2645033002: Remove VoEExternalMedia interface. (Closed)
Patch Set: bad merge Created 3 years, 10 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
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 "webrtc/base/arraysize.h"
12 #include "webrtc/modules/include/module_common_types.h"
13 #include "webrtc/voice_engine/include/voe_external_media.h"
14 #include "webrtc/voice_engine/test/auto_test/fakes/fake_media_process.h"
15 #include "webrtc/voice_engine/test/auto_test/fixtures/after_streaming_fixture.h"
16
17 class ExternalMediaTest : public AfterStreamingFixture {
18 protected:
19 void TestRegisterExternalMedia(int channel, webrtc::ProcessingTypes type) {
20 FakeMediaProcess fake_media_process;
21 EXPECT_EQ(0, voe_xmedia_->RegisterExternalMediaProcessing(
22 channel, type, fake_media_process));
23 Sleep(2000);
24
25 TEST_LOG("Back to normal.\n");
26 EXPECT_EQ(0, voe_xmedia_->DeRegisterExternalMediaProcessing(
27 channel, type));
28 Sleep(2000);
29 }
30 };
31
32 TEST_F(ExternalMediaTest,
33 ManualRegisterExternalMediaProcessingOnAllChannelsAffectsPlayout) {
34 TEST_LOG("Enabling external media processing: audio should be affected.\n");
35 TestRegisterExternalMedia(-1, webrtc::kPlaybackAllChannelsMixed);
36 }
37
38 TEST_F(ExternalMediaTest,
39 ManualRegisterExternalMediaOnSingleChannelAffectsPlayout) {
40 TEST_LOG("Enabling external media processing: audio should be affected.\n");
41 TestRegisterExternalMedia(channel_, webrtc::kRecordingPerChannel);
42 }
43
44 TEST_F(ExternalMediaTest,
45 ManualRegisterExternalMediaOnAllChannelsMixedAffectsRecording) {
46 SwitchToManualMicrophone();
47 TEST_LOG("Speak and verify your voice is distorted.\n");
48 TestRegisterExternalMedia(-1, webrtc::kRecordingAllChannelsMixed);
49 }
50
51 TEST_F(ExternalMediaTest,
52 ExternalMixingCannotBeChangedDuringPlayback) {
53 EXPECT_EQ(-1, voe_xmedia_->SetExternalMixing(channel_, true));
54 EXPECT_EQ(-1, voe_xmedia_->SetExternalMixing(channel_, false));
55 }
56
57 TEST_F(ExternalMediaTest,
58 ExternalMixingIsRequiredForGetAudioFrame) {
59 webrtc::AudioFrame frame;
60 EXPECT_EQ(-1, voe_xmedia_->GetAudioFrame(channel_, 0, &frame));
61 }
62
63 TEST_F(ExternalMediaTest,
64 ExternalMixingPreventsAndRestoresRegularPlayback) {
65 PausePlaying();
66 ASSERT_EQ(0, voe_xmedia_->SetExternalMixing(channel_, true));
67 TEST_LOG("Verify that no sound is played out.\n");
68 ResumePlaying();
69 Sleep(1000);
70 PausePlaying();
71 ASSERT_EQ(0, voe_xmedia_->SetExternalMixing(channel_, false));
72 ResumePlaying();
73 TEST_LOG("Verify that sound is played out.\n");
74 ResumePlaying();
75 Sleep(1000);
76 }
77
78 TEST_F(ExternalMediaTest,
79 ExternalMixingWorks) {
80 webrtc::AudioFrame frame;
81 PausePlaying();
82 EXPECT_EQ(0, voe_xmedia_->SetExternalMixing(channel_, true));
83 ResumePlaying();
84 EXPECT_EQ(0, voe_xmedia_->GetAudioFrame(channel_, 0, &frame));
85 EXPECT_GT(frame.sample_rate_hz_, 0);
86 EXPECT_GT(frame.samples_per_channel_, 0U);
87 PausePlaying();
88 EXPECT_EQ(0, voe_xmedia_->SetExternalMixing(channel_, false));
89 ResumePlaying();
90 }
91
92 TEST_F(ExternalMediaTest,
93 ExternalMixingResamplesToDesiredFrequency) {
94 const int kValidFrequencies[] = {8000, 16000, 22000, 32000, 48000};
95 webrtc::AudioFrame frame;
96 PausePlaying();
97 EXPECT_EQ(0, voe_xmedia_->SetExternalMixing(channel_, true));
98 ResumePlaying();
99 for (size_t i = 0; i < arraysize(kValidFrequencies); i++) {
100 int f = kValidFrequencies[i];
101 EXPECT_EQ(0, voe_xmedia_->GetAudioFrame(channel_, f, &frame))
102 << "Resampling succeeds for freq=" << f;
103 EXPECT_EQ(f, frame.sample_rate_hz_);
104 EXPECT_EQ(static_cast<size_t>(f / 100), frame.samples_per_channel_);
105 }
106 PausePlaying();
107 EXPECT_EQ(0, voe_xmedia_->SetExternalMixing(channel_, false));
108 ResumePlaying();
109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698