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

Side by Side Diff: webrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc

Issue 2695243005: Injectable audio encoders: BuiltinAudioEncoderFactory (Closed)
Patch Set: Fix build problems on Windows, Android and downstream. Created 3 years, 8 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
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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
11 #include <stdio.h> 11 #include <stdio.h>
12 #include <string.h> 12 #include <string.h>
13 #include <memory> 13 #include <memory>
14 #include <vector> 14 #include <vector>
15 15
16 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" 16 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h"
17 #include "webrtc/base/criticalsection.h" 17 #include "webrtc/base/criticalsection.h"
18 #include "webrtc/base/md5digest.h" 18 #include "webrtc/base/md5digest.h"
19 #include "webrtc/base/platform_thread.h" 19 #include "webrtc/base/platform_thread.h"
20 #include "webrtc/base/thread_annotations.h" 20 #include "webrtc/base/thread_annotations.h"
21 #include "webrtc/modules/audio_coding/acm2/acm_receive_test.h" 21 #include "webrtc/modules/audio_coding/acm2/acm_receive_test.h"
22 #include "webrtc/modules/audio_coding/acm2/acm_send_test.h" 22 #include "webrtc/modules/audio_coding/acm2/acm_send_test.h"
23 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" 23 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
24 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" 24 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h"
25 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" 25 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
26 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h" 26 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h"
27 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa c.h" 27 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa c.h"
28 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" 28 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h"
29 #include "webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h"
29 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" 30 #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
30 #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" 31 #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
31 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" 32 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h"
32 #include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h" 33 #include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h"
33 #include "webrtc/modules/audio_coding/neteq/tools/audio_checksum.h" 34 #include "webrtc/modules/audio_coding/neteq/tools/audio_checksum.h"
34 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" 35 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h"
35 #include "webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h" 36 #include "webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h"
36 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" 37 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h"
37 #include "webrtc/modules/audio_coding/neteq/tools/output_audio_file.h" 38 #include "webrtc/modules/audio_coding/neteq/tools/output_audio_file.h"
38 #include "webrtc/modules/audio_coding/neteq/tools/output_wav_file.h" 39 #include "webrtc/modules/audio_coding/neteq/tools/output_wav_file.h"
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 std::unique_ptr<test::AcmSendTestOldApi> send_test_; 1260 std::unique_ptr<test::AcmSendTestOldApi> send_test_;
1260 std::unique_ptr<test::InputAudioFile> audio_source_; 1261 std::unique_ptr<test::InputAudioFile> audio_source_;
1261 uint32_t frame_size_rtp_timestamps_; 1262 uint32_t frame_size_rtp_timestamps_;
1262 int packet_count_; 1263 int packet_count_;
1263 uint8_t payload_type_; 1264 uint8_t payload_type_;
1264 uint16_t last_sequence_number_; 1265 uint16_t last_sequence_number_;
1265 uint32_t last_timestamp_; 1266 uint32_t last_timestamp_;
1266 rtc::Md5Digest payload_checksum_; 1267 rtc::Md5Digest payload_checksum_;
1267 }; 1268 };
1268 1269
1270 class AcmSenderBitExactnessNewApi : public AcmSenderBitExactnessOldApi {};
1271
1269 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) 1272 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
1270 TEST_F(AcmSenderBitExactnessOldApi, IsacWb30ms) { 1273 TEST_F(AcmSenderBitExactnessOldApi, IsacWb30ms) {
1271 ASSERT_NO_FATAL_FAILURE(SetUpTest("ISAC", 16000, 1, 103, 480, 480)); 1274 ASSERT_NO_FATAL_FAILURE(SetUpTest("ISAC", 16000, 1, 103, 480, 480));
1272 Run(AcmReceiverBitExactnessOldApi::PlatformChecksum( 1275 Run(AcmReceiverBitExactnessOldApi::PlatformChecksum(
1273 "0b58f9eeee43d5891f5f6c75e77984a3", 1276 "0b58f9eeee43d5891f5f6c75e77984a3",
1274 "c7e5bdadfa2871df95639fcc297cf23d", 1277 "c7e5bdadfa2871df95639fcc297cf23d",
1275 "0499ca260390769b3172136faad925b9", 1278 "0499ca260390769b3172136faad925b9",
1276 "866abf524acd2807efbe65e133c23f95"), 1279 "866abf524acd2807efbe65e133c23f95"),
1277 AcmReceiverBitExactnessOldApi::PlatformChecksum( 1280 AcmReceiverBitExactnessOldApi::PlatformChecksum(
1278 "3c79f16f34218271f3dca4e2b1dfe1bb", 1281 "3c79f16f34218271f3dca4e2b1dfe1bb",
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 AcmReceiverBitExactnessOldApi::PlatformChecksum( 1456 AcmReceiverBitExactnessOldApi::PlatformChecksum(
1454 "66516152eeaa1e650ad94ff85f668dac", 1457 "66516152eeaa1e650ad94ff85f668dac",
1455 "66516152eeaa1e650ad94ff85f668dac", "android_arm32_payload", 1458 "66516152eeaa1e650ad94ff85f668dac", "android_arm32_payload",
1456 "android_arm64_payload"), 1459 "android_arm64_payload"),
1457 50, test::AcmReceiveTestOldApi::kStereoOutput); 1460 50, test::AcmReceiveTestOldApi::kStereoOutput);
1458 } 1461 }
1459 #endif 1462 #endif
1460 1463
1461 #if WEBRTC_OPUS_SUPPORT_120MS_PTIME 1464 #if WEBRTC_OPUS_SUPPORT_120MS_PTIME
1462 #define MAYBE_Opus_stereo_20ms DISABLED_Opus_stereo_20ms 1465 #define MAYBE_Opus_stereo_20ms DISABLED_Opus_stereo_20ms
1466 #define MAYBE_OpusFromFormat_stereo_20ms DISABLED_OpusFromFormat_stereo_20ms
1463 #else 1467 #else
1464 #define MAYBE_Opus_stereo_20ms Opus_stereo_20ms 1468 #define MAYBE_Opus_stereo_20ms Opus_stereo_20ms
1469 #define MAYBE_OpusFromFormat_stereo_20ms OpusFromFormat_stereo_20ms
1465 #endif 1470 #endif
1466 TEST_F(AcmSenderBitExactnessOldApi, MAYBE_Opus_stereo_20ms) { 1471 TEST_F(AcmSenderBitExactnessOldApi, MAYBE_Opus_stereo_20ms) {
1467 ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 2, 120, 960, 960)); 1472 ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 2, 120, 960, 960));
1468 Run(AcmReceiverBitExactnessOldApi::PlatformChecksum( 1473 Run(AcmReceiverBitExactnessOldApi::PlatformChecksum(
1469 "855041f2490b887302bce9d544731849", 1474 "855041f2490b887302bce9d544731849",
1470 "855041f2490b887302bce9d544731849", 1475 "855041f2490b887302bce9d544731849",
1471 "9692eede45638eb425e0daf9c75b5c7a", 1476 "9692eede45638eb425e0daf9c75b5c7a",
1472 "86d3552bb3492247f965cdd0e88a1c82"), 1477 "86d3552bb3492247f965cdd0e88a1c82"),
1473 AcmReceiverBitExactnessOldApi::PlatformChecksum( 1478 AcmReceiverBitExactnessOldApi::PlatformChecksum(
1474 "d781cce1ab986b618d0da87226cdde30", 1479 "d781cce1ab986b618d0da87226cdde30",
1475 "d781cce1ab986b618d0da87226cdde30", 1480 "d781cce1ab986b618d0da87226cdde30",
1476 "8d6782b905c3230d4b0e3e83e1fc3439", 1481 "8d6782b905c3230d4b0e3e83e1fc3439",
1477 "798347a685fac7d0c2d8f748ffe66881"), 1482 "798347a685fac7d0c2d8f748ffe66881"),
1478 50, test::AcmReceiveTestOldApi::kStereoOutput); 1483 50, test::AcmReceiveTestOldApi::kStereoOutput);
1479 } 1484 }
1480 1485
1486 TEST_F(AcmSenderBitExactnessNewApi, MAYBE_OpusFromFormat_stereo_20ms) {
1487 const SdpAudioFormat kOpusFormat("opus", 48000, 2, {{"stereo", "1"}});
1488 AudioEncoderOpus encoder(120, kOpusFormat);
1489 ASSERT_NO_FATAL_FAILURE(SetUpTestExternalEncoder(&encoder, 120));
1490 Run(AcmReceiverBitExactnessOldApi::PlatformChecksum(
1491 "855041f2490b887302bce9d544731849",
1492 "855041f2490b887302bce9d544731849",
1493 "9692eede45638eb425e0daf9c75b5c7a",
1494 "86d3552bb3492247f965cdd0e88a1c82"),
1495 AcmReceiverBitExactnessOldApi::PlatformChecksum(
1496 "d781cce1ab986b618d0da87226cdde30",
1497 "d781cce1ab986b618d0da87226cdde30",
1498 "8d6782b905c3230d4b0e3e83e1fc3439",
1499 "798347a685fac7d0c2d8f748ffe66881"),
1500 50, test::AcmReceiveTestOldApi::kStereoOutput);
1501 }
1502
1481 #if WEBRTC_OPUS_SUPPORT_120MS_PTIME 1503 #if WEBRTC_OPUS_SUPPORT_120MS_PTIME
1482 #define MAYBE_Opus_stereo_20ms_voip DISABLED_Opus_stereo_20ms_voip 1504 #define MAYBE_Opus_stereo_20ms_voip DISABLED_Opus_stereo_20ms_voip
1505 #define MAYBE_OpusFromFormat_stereo_20ms_voip \
1506 DISABLED_OpusFromFormat_stereo_20ms_voip
1483 #else 1507 #else
1484 #define MAYBE_Opus_stereo_20ms_voip Opus_stereo_20ms_voip 1508 #define MAYBE_Opus_stereo_20ms_voip Opus_stereo_20ms_voip
1509 #define MAYBE_OpusFromFormat_stereo_20ms_voip OpusFromFormat_stereo_20ms_voip
1485 #endif 1510 #endif
1486 TEST_F(AcmSenderBitExactnessOldApi, MAYBE_Opus_stereo_20ms_voip) { 1511 TEST_F(AcmSenderBitExactnessOldApi, MAYBE_Opus_stereo_20ms_voip) {
1487 ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 2, 120, 960, 960)); 1512 ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 2, 120, 960, 960));
1488 // If not set, default will be kAudio in case of stereo. 1513 // If not set, default will be kAudio in case of stereo.
1489 EXPECT_EQ(0, send_test_->acm()->SetOpusApplication(kVoip)); 1514 EXPECT_EQ(0, send_test_->acm()->SetOpusApplication(kVoip));
1490 Run(AcmReceiverBitExactnessOldApi::PlatformChecksum( 1515 Run(AcmReceiverBitExactnessOldApi::PlatformChecksum(
1491 "9b9e12bc3cc793740966e11cbfa8b35b", 1516 "9b9e12bc3cc793740966e11cbfa8b35b",
1492 "9b9e12bc3cc793740966e11cbfa8b35b", 1517 "9b9e12bc3cc793740966e11cbfa8b35b",
1493 "0de6249018fdd316c21086db84e10610", 1518 "0de6249018fdd316c21086db84e10610",
1494 "9c4cb69db77b85841a5f8225bb8f508b"), 1519 "9c4cb69db77b85841a5f8225bb8f508b"),
1495 AcmReceiverBitExactnessOldApi::PlatformChecksum( 1520 AcmReceiverBitExactnessOldApi::PlatformChecksum(
1496 "c7340b1189652ab6b5e80dade7390cb4", 1521 "c7340b1189652ab6b5e80dade7390cb4",
1497 "c7340b1189652ab6b5e80dade7390cb4", 1522 "c7340b1189652ab6b5e80dade7390cb4",
1498 "95612864c954ee63e28cc6eebad56626", 1523 "95612864c954ee63e28cc6eebad56626",
1499 "ae33ea2e43407cf9ebdabbbd6ca912a3"), 1524 "ae33ea2e43407cf9ebdabbbd6ca912a3"),
1500 50, test::AcmReceiveTestOldApi::kStereoOutput); 1525 50, test::AcmReceiveTestOldApi::kStereoOutput);
1501 } 1526 }
1502 1527
1528 TEST_F(AcmSenderBitExactnessNewApi, MAYBE_OpusFromFormat_stereo_20ms_voip) {
1529 const SdpAudioFormat kOpusFormat("opus", 48000, 2, {{"stereo", "1"}});
1530 AudioEncoderOpus encoder(120, kOpusFormat);
1531 ASSERT_NO_FATAL_FAILURE(SetUpTestExternalEncoder(&encoder, 120));
1532 // If not set, default will be kAudio in case of stereo.
1533 EXPECT_EQ(0, send_test_->acm()->SetOpusApplication(kVoip));
1534 Run(AcmReceiverBitExactnessOldApi::PlatformChecksum(
1535 "9b9e12bc3cc793740966e11cbfa8b35b",
1536 "9b9e12bc3cc793740966e11cbfa8b35b",
1537 "0de6249018fdd316c21086db84e10610",
1538 "9c4cb69db77b85841a5f8225bb8f508b"),
1539 AcmReceiverBitExactnessOldApi::PlatformChecksum(
1540 "c7340b1189652ab6b5e80dade7390cb4",
1541 "c7340b1189652ab6b5e80dade7390cb4",
1542 "95612864c954ee63e28cc6eebad56626",
1543 "ae33ea2e43407cf9ebdabbbd6ca912a3"),
1544 50, test::AcmReceiveTestOldApi::kStereoOutput);
1545 }
1546
1503 // This test is for verifying the SetBitRate function. The bitrate is changed at 1547 // This test is for verifying the SetBitRate function. The bitrate is changed at
1504 // the beginning, and the number of generated bytes are checked. 1548 // the beginning, and the number of generated bytes are checked.
1505 class AcmSetBitRateOldApi : public ::testing::Test { 1549 class AcmSetBitRateTest : public ::testing::Test {
1506 protected: 1550 protected:
1507 static const int kTestDurationMs = 1000; 1551 static const int kTestDurationMs = 1000;
1508 1552
1509 // Sets up the test::AcmSendTest object. Returns true on success, otherwise 1553 // Sets up the test::AcmSendTest object. Returns true on success, otherwise
1510 // false. 1554 // false.
1511 bool SetUpSender() { 1555 bool SetUpSender() {
1512 const std::string input_file_name = 1556 const std::string input_file_name =
1513 webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); 1557 webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
1514 // Note that |audio_source_| will loop forever. The test duration is set 1558 // Note that |audio_source_| will loop forever. The test duration is set
1515 // explicitly by |kTestDurationMs|. 1559 // explicitly by |kTestDurationMs|.
1516 audio_source_.reset(new test::InputAudioFile(input_file_name)); 1560 audio_source_.reset(new test::InputAudioFile(input_file_name));
1517 static const int kSourceRateHz = 32000; 1561 static const int kSourceRateHz = 32000;
1518 send_test_.reset(new test::AcmSendTestOldApi( 1562 send_test_.reset(new test::AcmSendTestOldApi(
1519 audio_source_.get(), kSourceRateHz, kTestDurationMs)); 1563 audio_source_.get(), kSourceRateHz, kTestDurationMs));
1520 return send_test_.get(); 1564 return send_test_.get();
1521 } 1565 }
1522 1566
1523 // Registers a send codec in the test::AcmSendTest object. Returns true on 1567 // Registers a send codec in the test::AcmSendTest object. Returns true on
1524 // success, false on failure. 1568 // success, false on failure.
1525 virtual bool RegisterSendCodec(const char* payload_name, 1569 virtual bool RegisterSendCodec(const char* payload_name,
1526 int sampling_freq_hz, 1570 int sampling_freq_hz,
1527 int channels, 1571 int channels,
1528 int payload_type, 1572 int payload_type,
1529 int frame_size_samples, 1573 int frame_size_samples,
1530 int frame_size_rtp_timestamps) { 1574 int frame_size_rtp_timestamps) {
1531 return send_test_->RegisterCodec(payload_name, sampling_freq_hz, channels, 1575 return send_test_->RegisterCodec(payload_name, sampling_freq_hz, channels,
1532 payload_type, frame_size_samples); 1576 payload_type, frame_size_samples);
1533 } 1577 }
1534 1578
1535 // Runs the test. SetUpSender() and RegisterSendCodec() must have been called 1579 bool RegisterExternalSendCodec(AudioEncoder* external_speech_encoder,
1536 // before calling this method. 1580 int payload_type) {
1537 void Run(int target_bitrate_bps, int expected_total_bits) { 1581 return send_test_->RegisterExternalCodec(external_speech_encoder);
1538 ASSERT_TRUE(send_test_->acm()); 1582 }
1539 send_test_->acm()->SetBitRate(target_bitrate_bps); 1583
1584 void RunInner(int expected_total_bits) {
1540 int nr_bytes = 0; 1585 int nr_bytes = 0;
1541 while (std::unique_ptr<test::Packet> next_packet = 1586 while (std::unique_ptr<test::Packet> next_packet =
1542 send_test_->NextPacket()) { 1587 send_test_->NextPacket()) {
1543 nr_bytes += next_packet->payload_length_bytes(); 1588 nr_bytes += next_packet->payload_length_bytes();
1544 } 1589 }
1545 EXPECT_EQ(expected_total_bits, nr_bytes * 8); 1590 EXPECT_EQ(expected_total_bits, nr_bytes * 8);
1546 } 1591 }
1547 1592
1548 void SetUpTest(const char* codec_name, 1593 void SetUpTest(const char* codec_name,
1549 int codec_sample_rate_hz, 1594 int codec_sample_rate_hz,
1550 int channels, 1595 int channels,
1551 int payload_type, 1596 int payload_type,
1552 int codec_frame_size_samples, 1597 int codec_frame_size_samples,
1553 int codec_frame_size_rtp_timestamps) { 1598 int codec_frame_size_rtp_timestamps) {
1554 ASSERT_TRUE(SetUpSender()); 1599 ASSERT_TRUE(SetUpSender());
1555 ASSERT_TRUE(RegisterSendCodec(codec_name, codec_sample_rate_hz, channels, 1600 ASSERT_TRUE(RegisterSendCodec(codec_name, codec_sample_rate_hz, channels,
1556 payload_type, codec_frame_size_samples, 1601 payload_type, codec_frame_size_samples,
1557 codec_frame_size_rtp_timestamps)); 1602 codec_frame_size_rtp_timestamps));
1558 } 1603 }
1559 1604
1560 std::unique_ptr<test::AcmSendTestOldApi> send_test_; 1605 std::unique_ptr<test::AcmSendTestOldApi> send_test_;
1561 std::unique_ptr<test::InputAudioFile> audio_source_; 1606 std::unique_ptr<test::InputAudioFile> audio_source_;
1562 }; 1607 };
1563 1608
1609 class AcmSetBitRateOldApi : public AcmSetBitRateTest {
1610 protected:
1611 // Runs the test. SetUpSender() must have been called and a codec must be set
1612 // up before calling this method.
1613 void Run(int target_bitrate_bps, int expected_total_bits) {
1614 ASSERT_TRUE(send_test_->acm());
1615 send_test_->acm()->SetBitRate(target_bitrate_bps);
1616 RunInner(expected_total_bits);
1617 }
1618 };
1619
1620 class AcmSetBitRateNewApi : public AcmSetBitRateTest {
1621 protected:
1622 // Runs the test. SetUpSender() must have been called and a codec must be set
1623 // up before calling this method.
1624 void Run(int expected_total_bits) { RunInner(expected_total_bits); }
1625 };
1626
1564 #if WEBRTC_OPUS_SUPPORT_120MS_PTIME 1627 #if WEBRTC_OPUS_SUPPORT_120MS_PTIME
1565 #define MAYBE_Opus_48khz_20ms_10kbps DISABLED_Opus_48khz_20ms_10kbps 1628 #define MAYBE_Opus_48khz_20ms_10kbps DISABLED_Opus_48khz_20ms_10kbps
1629 #define MAYBE_OpusFromFormat_48khz_20ms_10kbps \
1630 DISABLED_OpusFromFormat_48khz_20ms_10kbps
1566 #else 1631 #else
1567 #define MAYBE_Opus_48khz_20ms_10kbps Opus_48khz_20ms_10kbps 1632 #define MAYBE_Opus_48khz_20ms_10kbps Opus_48khz_20ms_10kbps
1633 #define MAYBE_OpusFromFormat_48khz_20ms_10kbps OpusFromFormat_48khz_20ms_10kbps
1568 #endif 1634 #endif
1569 TEST_F(AcmSetBitRateOldApi, MAYBE_Opus_48khz_20ms_10kbps) { 1635 TEST_F(AcmSetBitRateOldApi, MAYBE_Opus_48khz_20ms_10kbps) {
1570 ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960)); 1636 ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960));
1571 #if defined(WEBRTC_ANDROID) 1637 #if defined(WEBRTC_ANDROID)
1572 Run(10000, 9288); 1638 Run(10000, 9288);
1573 #else 1639 #else
1574 Run(10000, 9024); 1640 Run(10000, 9024);
1575 #endif // WEBRTC_ANDROID 1641 #endif // WEBRTC_ANDROID
1576 } 1642 }
1577 1643
1644 TEST_F(AcmSetBitRateNewApi, MAYBE_OpusFromFormat_48khz_20ms_10kbps) {
1645 AudioEncoderOpus encoder(
1646 107, SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "10000"}}));
1647 ASSERT_TRUE(SetUpSender());
1648 ASSERT_TRUE(RegisterExternalSendCodec(&encoder, 107));
1649 #if defined(WEBRTC_ANDROID)
1650 RunInner(9288);
1651 #else
1652 RunInner(9024);
1653 #endif // WEBRTC_ANDROID
1654 }
1655
1578 #if WEBRTC_OPUS_SUPPORT_120MS_PTIME 1656 #if WEBRTC_OPUS_SUPPORT_120MS_PTIME
1579 #define MAYBE_Opus_48khz_20ms_50kbps DISABLED_Opus_48khz_20ms_50kbps 1657 #define MAYBE_Opus_48khz_20ms_50kbps DISABLED_Opus_48khz_20ms_50kbps
1658 #define MAYBE_OpusFromFormat_48khz_20ms_50kbps \
1659 DISABLED_OpusFromFormat_48khz_20ms_50kbps
1580 #else 1660 #else
1581 #define MAYBE_Opus_48khz_20ms_50kbps Opus_48khz_20ms_50kbps 1661 #define MAYBE_Opus_48khz_20ms_50kbps Opus_48khz_20ms_50kbps
1662 #define MAYBE_OpusFromFormat_48khz_20ms_50kbps OpusFromFormat_48khz_20ms_50kbps
1582 #endif 1663 #endif
1583 TEST_F(AcmSetBitRateOldApi, MAYBE_Opus_48khz_20ms_50kbps) { 1664 TEST_F(AcmSetBitRateOldApi, MAYBE_Opus_48khz_20ms_50kbps) {
1584 ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960)); 1665 ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960));
1585 #if defined(WEBRTC_ANDROID) 1666 #if defined(WEBRTC_ANDROID)
1586 Run(50000, 47960); 1667 Run(50000, 47960);
1587 #else 1668 #else
1588 Run(50000, 49544); 1669 Run(50000, 49544);
1589 #endif // WEBRTC_ANDROID 1670 #endif // WEBRTC_ANDROID
1590 } 1671 }
1591 1672
1673 TEST_F(AcmSetBitRateNewApi, MAYBE_OpusFromFormat_48khz_20ms_50kbps) {
1674 AudioEncoderOpus encoder(
1675 107, SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "50000"}}));
1676 ASSERT_TRUE(SetUpSender());
1677 ASSERT_TRUE(RegisterExternalSendCodec(&encoder, 107));
1678 #if defined(WEBRTC_ANDROID)
1679 RunInner(47960);
1680 #else
1681 RunInner(49544);
1682 #endif // WEBRTC_ANDROID
1683 }
1684
1592 // The result on the Android platforms is inconsistent for this test case. 1685 // The result on the Android platforms is inconsistent for this test case.
1593 // On android_rel the result is different from android and android arm64 rel. 1686 // On android_rel the result is different from android and android arm64 rel.
1594 #if defined(WEBRTC_ANDROID) || WEBRTC_OPUS_SUPPORT_120MS_PTIME 1687 #if defined(WEBRTC_ANDROID) || WEBRTC_OPUS_SUPPORT_120MS_PTIME
1595 #define MAYBE_Opus_48khz_20ms_100kbps DISABLED_Opus_48khz_20ms_100kbps 1688 #define MAYBE_Opus_48khz_20ms_100kbps DISABLED_Opus_48khz_20ms_100kbps
1689 #define MAYBE_OpusFromFormat_48khz_20ms_100kbps \
1690 DISABLED_OpusFromFormat_48khz_20ms_100kbps
1596 #else 1691 #else
1597 #define MAYBE_Opus_48khz_20ms_100kbps Opus_48khz_20ms_100kbps 1692 #define MAYBE_Opus_48khz_20ms_100kbps Opus_48khz_20ms_100kbps
1693 #define MAYBE_OpusFromFormat_48khz_20ms_100kbps \
1694 OpusFromFormat_48khz_20ms_100kbps
1598 #endif 1695 #endif
1599 TEST_F(AcmSetBitRateOldApi, MAYBE_Opus_48khz_20ms_100kbps) { 1696 TEST_F(AcmSetBitRateOldApi, MAYBE_Opus_48khz_20ms_100kbps) {
1600 ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960)); 1697 ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960));
1601 Run(100000, 100888); 1698 Run(100000, 100888);
1602 } 1699 }
1603 1700
1701 TEST_F(AcmSetBitRateNewApi, MAYBE_OpusFromFormat_48khz_20ms_100kbps) {
1702 AudioEncoderOpus encoder(
1703 107, SdpAudioFormat("opus", 48000, 2, {{"maxaveragebitrate", "100000"}}));
1704 ASSERT_TRUE(SetUpSender());
1705 ASSERT_TRUE(RegisterExternalSendCodec(&encoder, 107));
1706 RunInner(100888);
1707 }
1708
1604 // These next 2 tests ensure that the SetBitRate function has no effect on PCM 1709 // These next 2 tests ensure that the SetBitRate function has no effect on PCM
1605 TEST_F(AcmSetBitRateOldApi, Pcm16_8khz_10ms_8kbps) { 1710 TEST_F(AcmSetBitRateOldApi, Pcm16_8khz_10ms_8kbps) {
1606 ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80)); 1711 ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80));
1607 Run(8000, 128000); 1712 Run(8000, 128000);
1608 } 1713 }
1609 1714
1610 TEST_F(AcmSetBitRateOldApi, Pcm16_8khz_10ms_32kbps) { 1715 TEST_F(AcmSetBitRateOldApi, Pcm16_8khz_10ms_32kbps) {
1611 ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80)); 1716 ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80));
1612 Run(32000, 128000); 1717 Run(32000, 128000);
1613 } 1718 }
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 Run(16000, 8000, 1000); 1981 Run(16000, 8000, 1000);
1877 } 1982 }
1878 1983
1879 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { 1984 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) {
1880 Run(8000, 16000, 1000); 1985 Run(8000, 16000, 1000);
1881 } 1986 }
1882 1987
1883 #endif 1988 #endif
1884 1989
1885 } // namespace webrtc 1990 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/BUILD.gn ('k') | webrtc/modules/audio_coding/codecs/audio_encoder_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698