OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 TEST(FrameCombiner, CombiningZeroFramesShouldProduceSilence) { | 88 TEST(FrameCombiner, CombiningZeroFramesShouldProduceSilence) { |
89 FrameCombiner combiner(false); | 89 FrameCombiner combiner(false); |
90 for (const int rate : {8000, 10000, 11000, 32000, 44100}) { | 90 for (const int rate : {8000, 10000, 11000, 32000, 44100}) { |
91 for (const int number_of_channels : {1, 2}) { | 91 for (const int number_of_channels : {1, 2}) { |
92 SCOPED_TRACE(ProduceDebugText(rate, number_of_channels, 0)); | 92 SCOPED_TRACE(ProduceDebugText(rate, number_of_channels, 0)); |
93 | 93 |
94 const std::vector<AudioFrame*> frames_to_combine; | 94 const std::vector<AudioFrame*> frames_to_combine; |
95 combiner.Combine(frames_to_combine, number_of_channels, rate, | 95 combiner.Combine(frames_to_combine, number_of_channels, rate, |
96 &audio_frame_for_mixing); | 96 &audio_frame_for_mixing); |
97 | 97 |
| 98 const int16_t* audio_frame_for_mixing_data = |
| 99 audio_frame_for_mixing.data(); |
98 const std::vector<int16_t> mixed_data( | 100 const std::vector<int16_t> mixed_data( |
99 audio_frame_for_mixing.data_, | 101 audio_frame_for_mixing_data, |
100 audio_frame_for_mixing.data_ + number_of_channels * rate / 100); | 102 audio_frame_for_mixing_data + number_of_channels * rate / 100); |
101 | 103 |
102 const std::vector<int16_t> expected(number_of_channels * rate / 100, 0); | 104 const std::vector<int16_t> expected(number_of_channels * rate / 100, 0); |
103 EXPECT_EQ(mixed_data, expected); | 105 EXPECT_EQ(mixed_data, expected); |
104 } | 106 } |
105 } | 107 } |
106 } | 108 } |
107 | 109 |
108 TEST(FrameCombiner, CombiningOneFrameShouldNotChangeFrame) { | 110 TEST(FrameCombiner, CombiningOneFrameShouldNotChangeFrame) { |
109 FrameCombiner combiner(false); | 111 FrameCombiner combiner(false); |
110 for (const int rate : {8000, 10000, 11000, 32000, 44100}) { | 112 for (const int rate : {8000, 10000, 11000, 32000, 44100}) { |
111 for (const int number_of_channels : {1, 2}) { | 113 for (const int number_of_channels : {1, 2}) { |
112 SCOPED_TRACE(ProduceDebugText(rate, number_of_channels, 1)); | 114 SCOPED_TRACE(ProduceDebugText(rate, number_of_channels, 1)); |
113 | 115 |
114 SetUpFrames(rate, number_of_channels); | 116 SetUpFrames(rate, number_of_channels); |
115 std::iota(frame1.data_, frame1.data_ + number_of_channels * rate / 100, | 117 int16_t* frame1_data = frame1.mutable_data(); |
116 0); | 118 std::iota(frame1_data, frame1_data + number_of_channels * rate / 100, 0); |
117 const std::vector<AudioFrame*> frames_to_combine = {&frame1}; | 119 const std::vector<AudioFrame*> frames_to_combine = {&frame1}; |
118 combiner.Combine(frames_to_combine, number_of_channels, rate, | 120 combiner.Combine(frames_to_combine, number_of_channels, rate, |
119 &audio_frame_for_mixing); | 121 &audio_frame_for_mixing); |
120 | 122 |
| 123 const int16_t* audio_frame_for_mixing_data = |
| 124 audio_frame_for_mixing.data(); |
121 const std::vector<int16_t> mixed_data( | 125 const std::vector<int16_t> mixed_data( |
122 audio_frame_for_mixing.data_, | 126 audio_frame_for_mixing_data, |
123 audio_frame_for_mixing.data_ + number_of_channels * rate / 100); | 127 audio_frame_for_mixing_data + number_of_channels * rate / 100); |
124 | 128 |
125 std::vector<int16_t> expected(number_of_channels * rate / 100); | 129 std::vector<int16_t> expected(number_of_channels * rate / 100); |
126 std::iota(expected.begin(), expected.end(), 0); | 130 std::iota(expected.begin(), expected.end(), 0); |
127 EXPECT_EQ(mixed_data, expected); | 131 EXPECT_EQ(mixed_data, expected); |
128 } | 132 } |
129 } | 133 } |
130 } | 134 } |
131 | 135 |
132 } // namespace webrtc | 136 } // namespace webrtc |
OLD | NEW |