OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 19 matching lines...) Expand all Loading... |
30 EXPECT_CALL(*impl, Die()); | 30 EXPECT_CALL(*impl, Die()); |
31 EXPECT_CALL(*impl, MaxEncodedBytes()) | 31 EXPECT_CALL(*impl, MaxEncodedBytes()) |
32 .WillRepeatedly(Return(kPayloadSize * 2)); | 32 .WillRepeatedly(Return(kPayloadSize * 2)); |
33 EXPECT_CALL(*impl, NumChannels()).WillRepeatedly(Return(1)); | 33 EXPECT_CALL(*impl, NumChannels()).WillRepeatedly(Return(1)); |
34 EXPECT_CALL(*impl, SampleRateHz()).WillRepeatedly(Return(8000)); | 34 EXPECT_CALL(*impl, SampleRateHz()).WillRepeatedly(Return(8000)); |
35 } | 35 } |
36 | 36 |
37 EXPECT_CALL(old_impl, EncodeInternal(_, _, _, _)).WillOnce( | 37 EXPECT_CALL(old_impl, EncodeInternal(_, _, _, _)).WillOnce( |
38 Invoke(MockAudioEncoderDeprecated::CopyEncoding(payload))); | 38 Invoke(MockAudioEncoderDeprecated::CopyEncoding(payload))); |
39 | 39 |
40 EXPECT_CALL(new_impl, EncodeInternal(_, _, _)).WillOnce( | 40 EXPECT_CALL(new_impl, EncodeImpl(_, _, _)).WillOnce( |
41 Invoke(MockAudioEncoder::CopyEncoding(payload))); | 41 Invoke(MockAudioEncoder::CopyEncoding(payload))); |
42 | 42 |
43 int16_t audio[80]; | 43 int16_t audio[80]; |
44 uint8_t output_array[kPayloadSize * 2]; | 44 uint8_t output_array[kPayloadSize * 2]; |
45 rtc::Buffer output_buffer; | 45 rtc::Buffer output_buffer; |
46 | 46 |
47 AudioEncoder* old_encoder = &old_impl; | 47 AudioEncoder* old_encoder = &old_impl; |
48 AudioEncoder* new_encoder = &new_impl; | 48 AudioEncoder* new_encoder = &new_impl; |
49 auto old_info = old_encoder->Encode(0, audio, &output_buffer); | 49 auto old_info = old_encoder->Encode(0, audio, &output_buffer); |
50 auto new_info = new_encoder->DEPRECATED_Encode(0, audio, | 50 auto new_info = new_encoder->DEPRECATED_Encode(0, audio, |
51 kPayloadSize * 2, | 51 kPayloadSize * 2, |
52 output_array); | 52 output_array); |
53 | 53 |
54 EXPECT_EQ(old_info.encoded_bytes, kPayloadSize); | 54 EXPECT_EQ(old_info.encoded_bytes, kPayloadSize); |
55 EXPECT_EQ(new_info.encoded_bytes, kPayloadSize); | 55 EXPECT_EQ(new_info.encoded_bytes, kPayloadSize); |
56 EXPECT_EQ(output_buffer.size(), kPayloadSize); | 56 EXPECT_EQ(output_buffer.size(), kPayloadSize); |
57 | 57 |
58 for (size_t i = 0; i != kPayloadSize; ++i) { | 58 for (size_t i = 0; i != kPayloadSize; ++i) { |
59 EXPECT_EQ(output_buffer.data()[i], payload[i]); | 59 EXPECT_EQ(output_buffer.data()[i], payload[i]); |
60 EXPECT_EQ(output_array[i], payload[i]); | 60 EXPECT_EQ(output_array[i], payload[i]); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 } // namespace webrtc | 64 } // namespace webrtc |
OLD | NEW |