| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 * | 417 * |
| 418 * In side A we test the APIs which are related to sender Side. | 418 * In side A we test the APIs which are related to sender Side. |
| 419 * | 419 * |
| 420 /*/ | 420 /*/ |
| 421 | 421 |
| 422 void APITest::RunTest(char thread) { | 422 void APITest::RunTest(char thread) { |
| 423 int testNum; | 423 int testNum; |
| 424 { | 424 { |
| 425 WriteLockScoped cs(_apiTestRWLock); | 425 WriteLockScoped cs(_apiTestRWLock); |
| 426 if (thread == 'A') { | 426 if (thread == 'A') { |
| 427 _testNumA = (_testNumB + 1 + (rand() % 4)) % 5; | 427 _testNumA = (_testNumB + 1 + (rand() % 3)) % 4; |
| 428 testNum = _testNumA; | 428 testNum = _testNumA; |
| 429 | 429 |
| 430 _movingDot[_dotPositionA] = ' '; | 430 _movingDot[_dotPositionA] = ' '; |
| 431 if (_dotPositionA == 0) { | 431 if (_dotPositionA == 0) { |
| 432 _dotMoveDirectionA = 1; | 432 _dotMoveDirectionA = 1; |
| 433 } | 433 } |
| 434 if (_dotPositionA == 19) { | 434 if (_dotPositionA == 19) { |
| 435 _dotMoveDirectionA = -1; | 435 _dotMoveDirectionA = -1; |
| 436 } | 436 } |
| 437 _dotPositionA += _dotMoveDirectionA; | 437 _dotPositionA += _dotMoveDirectionA; |
| 438 _movingDot[_dotPositionA] = (_dotMoveDirectionA > 0) ? '>' : '<'; | 438 _movingDot[_dotPositionA] = (_dotMoveDirectionA > 0) ? '>' : '<'; |
| 439 } else { | 439 } else { |
| 440 _testNumB = (_testNumA + 1 + (rand() % 4)) % 5; | 440 _testNumB = (_testNumA + 1 + (rand() % 3)) % 4; |
| 441 testNum = _testNumB; | 441 testNum = _testNumB; |
| 442 | 442 |
| 443 _movingDot[_dotPositionB] = ' '; | 443 _movingDot[_dotPositionB] = ' '; |
| 444 if (_dotPositionB == 20) { | 444 if (_dotPositionB == 20) { |
| 445 _dotMoveDirectionB = 1; | 445 _dotMoveDirectionB = 1; |
| 446 } | 446 } |
| 447 if (_dotPositionB == 39) { | 447 if (_dotPositionB == 39) { |
| 448 _dotMoveDirectionB = -1; | 448 _dotMoveDirectionB = -1; |
| 449 } | 449 } |
| 450 _dotPositionB += _dotMoveDirectionB; | 450 _dotPositionB += _dotMoveDirectionB; |
| 451 _movingDot[_dotPositionB] = (_dotMoveDirectionB > 0) ? '>' : '<'; | 451 _movingDot[_dotPositionB] = (_dotMoveDirectionB > 0) ? '>' : '<'; |
| 452 } | 452 } |
| 453 //fprintf(stderr, "%c: %d \n", thread, testNum); | 453 //fprintf(stderr, "%c: %d \n", thread, testNum); |
| 454 //fflush(stderr); | 454 //fflush(stderr); |
| 455 } | 455 } |
| 456 switch (testNum) { | 456 switch (testNum) { |
| 457 case 0: | 457 case 0: |
| 458 CurrentCodec('A'); | 458 CurrentCodec('A'); |
| 459 ChangeCodec('A'); | 459 ChangeCodec('A'); |
| 460 break; | 460 break; |
| 461 case 1: | 461 case 1: |
| 462 TestPlayout('B'); | |
| 463 break; | |
| 464 case 2: | |
| 465 if (!_randomTest) { | 462 if (!_randomTest) { |
| 466 fprintf(stdout, "\nTesting Delay ...\n"); | 463 fprintf(stdout, "\nTesting Delay ...\n"); |
| 467 } | 464 } |
| 468 TestDelay('A'); | 465 TestDelay('A'); |
| 469 break; | 466 break; |
| 470 case 3: | 467 case 2: |
| 471 TestSendVAD('A'); | 468 TestSendVAD('A'); |
| 472 break; | 469 break; |
| 473 case 4: | 470 case 3: |
| 474 TestRegisteration('A'); | 471 TestRegisteration('A'); |
| 475 break; | 472 break; |
| 476 default: | 473 default: |
| 477 fprintf(stderr, "Wrong Test Number\n"); | 474 fprintf(stderr, "Wrong Test Number\n"); |
| 478 getc(stdin); | 475 getc(stdin); |
| 479 exit(1); | 476 exit(1); |
| 480 } | 477 } |
| 481 } | 478 } |
| 482 | 479 |
| 483 bool APITest::APIRunA() { | 480 bool APITest::APIRunA() { |
| 484 _apiEventA->Wait(50); | 481 _apiEventA->Wait(50); |
| 485 | 482 |
| 486 bool randomTest; | 483 bool randomTest; |
| 487 { | 484 { |
| 488 ReadLockScoped rl(_apiTestRWLock); | 485 ReadLockScoped rl(_apiTestRWLock); |
| 489 randomTest = _randomTest; | 486 randomTest = _randomTest; |
| 490 } | 487 } |
| 491 if (randomTest) { | 488 if (randomTest) { |
| 492 RunTest('A'); | 489 RunTest('A'); |
| 493 } else { | 490 } else { |
| 494 CurrentCodec('A'); | 491 CurrentCodec('A'); |
| 495 ChangeCodec('A'); | 492 ChangeCodec('A'); |
| 496 TestPlayout('B'); | |
| 497 if (_codecCntrA == 0) { | 493 if (_codecCntrA == 0) { |
| 498 fprintf(stdout, "\nTesting Delay ...\n"); | 494 fprintf(stdout, "\nTesting Delay ...\n"); |
| 499 TestDelay('A'); | 495 TestDelay('A'); |
| 500 } | 496 } |
| 501 // VAD TEST | 497 // VAD TEST |
| 502 TestSendVAD('A'); | 498 TestSendVAD('A'); |
| 503 TestRegisteration('A'); | 499 TestRegisteration('A'); |
| 504 } | 500 } |
| 505 return true; | 501 return true; |
| 506 } | 502 } |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 *thereIsDecoder = true; | 911 *thereIsDecoder = true; |
| 916 } | 912 } |
| 917 } | 913 } |
| 918 delete myEvent; | 914 delete myEvent; |
| 919 if (!_randomTest) { | 915 if (!_randomTest) { |
| 920 fprintf(stdout, | 916 fprintf(stdout, |
| 921 "---------------------------------------------------------\n"); | 917 "---------------------------------------------------------\n"); |
| 922 } | 918 } |
| 923 } | 919 } |
| 924 | 920 |
| 925 // Playout Mode, background noise mode. | |
| 926 // Receiver Frequency, playout frequency. | |
| 927 void APITest::TestPlayout(char receiveSide) { | |
| 928 AudioCodingModule* receiveACM; | |
| 929 AudioPlayoutMode* playoutMode = NULL; | |
| 930 switch (receiveSide) { | |
| 931 case 'A': { | |
| 932 receiveACM = _acmA.get(); | |
| 933 playoutMode = &_playoutModeA; | |
| 934 break; | |
| 935 } | |
| 936 case 'B': { | |
| 937 receiveACM = _acmB.get(); | |
| 938 playoutMode = &_playoutModeB; | |
| 939 break; | |
| 940 } | |
| 941 default: | |
| 942 receiveACM = _acmA.get(); | |
| 943 } | |
| 944 | |
| 945 int32_t receiveFreqHz = receiveACM->ReceiveFrequency(); | |
| 946 int32_t playoutFreqHz = receiveACM->PlayoutFrequency(); | |
| 947 | |
| 948 CHECK_ERROR_MT(receiveFreqHz); | |
| 949 CHECK_ERROR_MT(playoutFreqHz); | |
| 950 | |
| 951 | |
| 952 char playoutString[25]; | |
| 953 switch (*playoutMode) { | |
| 954 case voice: { | |
| 955 *playoutMode = fax; | |
| 956 strncpy(playoutString, "FAX", 25); | |
| 957 break; | |
| 958 } | |
| 959 case fax: { | |
| 960 *playoutMode = streaming; | |
| 961 strncpy(playoutString, "Streaming", 25); | |
| 962 break; | |
| 963 } | |
| 964 case streaming: { | |
| 965 *playoutMode = voice; | |
| 966 strncpy(playoutString, "Voice", 25); | |
| 967 break; | |
| 968 } | |
| 969 default: | |
| 970 *playoutMode = voice; | |
| 971 strncpy(playoutString, "Voice", 25); | |
| 972 } | |
| 973 CHECK_ERROR_MT(receiveACM->SetPlayoutMode(*playoutMode)); | |
| 974 playoutString[24] = '\0'; | |
| 975 | |
| 976 if (!_randomTest) { | |
| 977 fprintf(stdout, "\n"); | |
| 978 fprintf(stdout, "In Side %c\n", receiveSide); | |
| 979 fprintf(stdout, "---------------------------------\n"); | |
| 980 fprintf(stdout, "Receive Frequency....... %d Hz\n", receiveFreqHz); | |
| 981 fprintf(stdout, "Playout Frequency....... %d Hz\n", playoutFreqHz); | |
| 982 fprintf(stdout, "Audio Playout Mode...... %s\n", playoutString); | |
| 983 } | |
| 984 } | |
| 985 | |
| 986 void APITest::TestSendVAD(char side) { | 921 void APITest::TestSendVAD(char side) { |
| 987 if (_randomTest) { | 922 if (_randomTest) { |
| 988 return; | 923 return; |
| 989 } | 924 } |
| 990 | 925 |
| 991 bool* vad; | 926 bool* vad; |
| 992 bool* dtx; | 927 bool* dtx; |
| 993 ACMVADMode* mode; | 928 ACMVADMode* mode; |
| 994 Channel* myChannel; | 929 Channel* myChannel; |
| 995 AudioCodingModule* myACM; | 930 AudioCodingModule* myACM; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 CHECK_ERROR_MT(myACM->RegisterSendCodec(myCodec)); | 1108 CHECK_ERROR_MT(myACM->RegisterSendCodec(myCodec)); |
| 1174 myChannel->ResetStats(); | 1109 myChannel->ResetStats(); |
| 1175 { | 1110 { |
| 1176 WriteLockScoped wl(_apiTestRWLock); | 1111 WriteLockScoped wl(_apiTestRWLock); |
| 1177 *thereIsEncoder = true; | 1112 *thereIsEncoder = true; |
| 1178 } | 1113 } |
| 1179 Wait(500); | 1114 Wait(500); |
| 1180 } | 1115 } |
| 1181 | 1116 |
| 1182 } // namespace webrtc | 1117 } // namespace webrtc |
| OLD | NEW |