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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 } | 659 } |
660 | 660 |
661 // Set Min delay, get delay, playout timestamp | 661 // Set Min delay, get delay, playout timestamp |
662 void APITest::TestDelay(char side) { | 662 void APITest::TestDelay(char side) { |
663 AudioCodingModule* myACM; | 663 AudioCodingModule* myACM; |
664 Channel* myChannel; | 664 Channel* myChannel; |
665 int32_t* myMinDelay; | 665 int32_t* myMinDelay; |
666 EventTimerWrapper* myEvent = EventTimerWrapper::Create(); | 666 EventTimerWrapper* myEvent = EventTimerWrapper::Create(); |
667 | 667 |
668 uint32_t inTimestamp = 0; | 668 uint32_t inTimestamp = 0; |
669 uint32_t outTimestamp = 0; | |
670 double estimDelay = 0; | 669 double estimDelay = 0; |
671 | 670 |
672 double averageEstimDelay = 0; | 671 double averageEstimDelay = 0; |
673 double averageDelay = 0; | 672 double averageDelay = 0; |
674 | 673 |
675 CircularBuffer estimDelayCB(100); | 674 CircularBuffer estimDelayCB(100); |
676 estimDelayCB.SetArithMean(true); | 675 estimDelayCB.SetArithMean(true); |
677 | 676 |
678 if (side == 'A') { | 677 if (side == 'A') { |
679 myACM = _acmA.get(); | 678 myACM = _acmA.get(); |
680 myChannel = _channel_B2A; | 679 myChannel = _channel_B2A; |
681 myMinDelay = &_minDelayA; | 680 myMinDelay = &_minDelayA; |
682 } else { | 681 } else { |
683 myACM = _acmB.get(); | 682 myACM = _acmB.get(); |
684 myChannel = _channel_A2B; | 683 myChannel = _channel_A2B; |
685 myMinDelay = &_minDelayB; | 684 myMinDelay = &_minDelayB; |
686 } | 685 } |
687 | 686 |
688 CHECK_ERROR_MT(myACM->SetMinimumPlayoutDelay(*myMinDelay)); | 687 CHECK_ERROR_MT(myACM->SetMinimumPlayoutDelay(*myMinDelay)); |
689 | 688 |
690 inTimestamp = myChannel->LastInTimestamp(); | 689 inTimestamp = myChannel->LastInTimestamp(); |
691 CHECK_ERROR_MT(myACM->PlayoutTimestamp(&outTimestamp)); | 690 rtc::Optional<uint32_t> outTimestamp = myACM->PlayoutTimestamp(); |
| 691 CHECK_ERROR_MT(outTimestamp ? 0 : -1); |
692 | 692 |
693 if (!_randomTest) { | 693 if (!_randomTest) { |
694 myEvent->StartTimer(true, 30); | 694 myEvent->StartTimer(true, 30); |
695 int n = 0; | 695 int n = 0; |
696 int settlePoint = 5000; | 696 int settlePoint = 5000; |
697 while (n < settlePoint + 400) { | 697 while (n < settlePoint + 400) { |
698 myEvent->Wait(1000); | 698 myEvent->Wait(1000); |
699 | 699 |
700 inTimestamp = myChannel->LastInTimestamp(); | 700 inTimestamp = myChannel->LastInTimestamp(); |
701 CHECK_ERROR_MT(myACM->PlayoutTimestamp(&outTimestamp)); | 701 outTimestamp = myACM->PlayoutTimestamp(); |
| 702 CHECK_ERROR_MT(outTimestamp ? 0 : -1); |
702 | 703 |
703 //std::cout << outTimestamp << std::endl << std::flush; | 704 //std::cout << outTimestamp << std::endl << std::flush; |
704 estimDelay = (double) ((uint32_t)(inTimestamp - outTimestamp)) | 705 estimDelay = (double)((uint32_t)(inTimestamp - *outTimestamp)) / |
705 / ((double) myACM->ReceiveFrequency() / 1000.0); | 706 ((double)myACM->ReceiveFrequency() / 1000.0); |
706 | 707 |
707 estimDelayCB.Update(estimDelay); | 708 estimDelayCB.Update(estimDelay); |
708 | 709 |
709 estimDelayCB.ArithMean(averageEstimDelay); | 710 estimDelayCB.ArithMean(averageEstimDelay); |
710 //printf("\n %6.1f \n", estimDelay); | 711 //printf("\n %6.1f \n", estimDelay); |
711 //std::cout << " " << std::flush; | 712 //std::cout << " " << std::flush; |
712 | 713 |
713 if (_verbose) { | 714 if (_verbose) { |
714 fprintf(stdout, | 715 fprintf(stdout, |
715 "\rExpected: %4d, retreived: %6.1f, measured: %6.1f", | 716 "\rExpected: %4d, retreived: %6.1f, measured: %6.1f", |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 CHECK_ERROR_MT(myACM->RegisterSendCodec(myCodec)); | 1096 CHECK_ERROR_MT(myACM->RegisterSendCodec(myCodec)); |
1096 myChannel->ResetStats(); | 1097 myChannel->ResetStats(); |
1097 { | 1098 { |
1098 WriteLockScoped wl(_apiTestRWLock); | 1099 WriteLockScoped wl(_apiTestRWLock); |
1099 *thereIsEncoder = true; | 1100 *thereIsEncoder = true; |
1100 } | 1101 } |
1101 Wait(500); | 1102 Wait(500); |
1102 } | 1103 } |
1103 | 1104 |
1104 } // namespace webrtc | 1105 } // namespace webrtc |
OLD | NEW |