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 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 receiveACM = _acmA.get(); | 816 receiveACM = _acmA.get(); |
817 thereIsDecoder = &_thereIsDecoderA; | 817 thereIsDecoder = &_thereIsDecoderA; |
818 break; | 818 break; |
819 } | 819 } |
820 default: | 820 default: |
821 fprintf(stderr, "Invalid sender-side in TestRegistration(%c)\n", | 821 fprintf(stderr, "Invalid sender-side in TestRegistration(%c)\n", |
822 sendSide); | 822 sendSide); |
823 exit(-1); | 823 exit(-1); |
824 } | 824 } |
825 | 825 |
826 CodecInst myCodec; | 826 auto myCodec = sendACM->SendCodec(); |
827 if (sendACM->SendCodec(&myCodec) < 0) { | 827 if (!myCodec) { |
828 AudioCodingModule::Codec(_codecCntrA, &myCodec); | 828 CodecInst ci; |
| 829 AudioCodingModule::Codec(_codecCntrA, &ci); |
| 830 myCodec = rtc::Maybe<CodecInst>(ci); |
829 } | 831 } |
830 | 832 |
831 if (!_randomTest) { | 833 if (!_randomTest) { |
832 fprintf(stdout, "Unregistering reveive codec, NO AUDIO.\n"); | 834 fprintf(stdout, "Unregistering reveive codec, NO AUDIO.\n"); |
833 fflush (stdout); | 835 fflush (stdout); |
834 } | 836 } |
835 { | 837 { |
836 WriteLockScoped wl(_apiTestRWLock); | 838 WriteLockScoped wl(_apiTestRWLock); |
837 *thereIsDecoder = false; | 839 *thereIsDecoder = false; |
838 } | 840 } |
839 //myEvent->Wait(20); | 841 //myEvent->Wait(20); |
840 CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec.pltype)); | 842 CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec->pltype)); |
841 Wait(1000); | 843 Wait(1000); |
842 | 844 |
843 int currentPayload = myCodec.pltype; | 845 int currentPayload = myCodec->pltype; |
844 | 846 |
845 if (!FixedPayloadTypeCodec(myCodec.plname)) { | 847 if (!FixedPayloadTypeCodec(myCodec->plname)) { |
846 int32_t i; | 848 int32_t i; |
847 for (i = 0; i < 32; i++) { | 849 for (i = 0; i < 32; i++) { |
848 if (!_payloadUsed[i]) { | 850 if (!_payloadUsed[i]) { |
849 if (!_randomTest) { | 851 if (!_randomTest) { |
850 fprintf(stdout, | 852 fprintf(stdout, |
851 "Register receive codec with new Payload, AUDIO BACK.\n"); | 853 "Register receive codec with new Payload, AUDIO BACK.\n"); |
852 } | 854 } |
853 //myCodec.pltype = i + 96; | 855 //myCodec->pltype = i + 96; |
854 //CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(myCodec)); | 856 //CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec)); |
855 //CHECK_ERROR_MT(sendACM->RegisterSendCodec(myCodec)); | 857 //CHECK_ERROR_MT(sendACM->RegisterSendCodec(*myCodec)); |
856 //myEvent->Wait(20); | 858 //myEvent->Wait(20); |
857 //{ | 859 //{ |
858 // WriteLockScoped wl(_apiTestRWLock); | 860 // WriteLockScoped wl(_apiTestRWLock); |
859 // *thereIsDecoder = true; | 861 // *thereIsDecoder = true; |
860 //} | 862 //} |
861 Wait(1000); | 863 Wait(1000); |
862 | 864 |
863 if (!_randomTest) { | 865 if (!_randomTest) { |
864 fprintf(stdout, "Unregistering reveive codec, NO AUDIO.\n"); | 866 fprintf(stdout, "Unregistering reveive codec, NO AUDIO.\n"); |
865 } | 867 } |
866 //{ | 868 //{ |
867 // WriteLockScoped wl(_apiTestRWLock); | 869 // WriteLockScoped wl(_apiTestRWLock); |
868 // *thereIsDecoder = false; | 870 // *thereIsDecoder = false; |
869 //} | 871 //} |
870 //myEvent->Wait(20); | 872 //myEvent->Wait(20); |
871 //CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec.pltype)); | 873 //CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec->pltype)); |
872 Wait(1000); | 874 Wait(1000); |
873 | 875 |
874 myCodec.pltype = currentPayload; | 876 myCodec->pltype = currentPayload; |
875 if (!_randomTest) { | 877 if (!_randomTest) { |
876 fprintf(stdout, | 878 fprintf(stdout, |
877 "Register receive codec with default Payload, AUDIO BACK.\n"); | 879 "Register receive codec with default Payload, AUDIO BACK.\n"); |
878 fflush (stdout); | 880 fflush (stdout); |
879 } | 881 } |
880 CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(myCodec)); | 882 CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec)); |
881 //CHECK_ERROR_MT(sendACM->RegisterSendCodec(myCodec)); | 883 //CHECK_ERROR_MT(sendACM->RegisterSendCodec(*myCodec)); |
882 myEvent->Wait(20); | 884 myEvent->Wait(20); |
883 { | 885 { |
884 WriteLockScoped wl(_apiTestRWLock); | 886 WriteLockScoped wl(_apiTestRWLock); |
885 *thereIsDecoder = true; | 887 *thereIsDecoder = true; |
886 } | 888 } |
887 Wait(1000); | 889 Wait(1000); |
888 | 890 |
889 break; | 891 break; |
890 } | 892 } |
891 } | 893 } |
892 if (i == 32) { | 894 if (i == 32) { |
893 CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(myCodec)); | 895 CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec)); |
894 { | 896 { |
895 WriteLockScoped wl(_apiTestRWLock); | 897 WriteLockScoped wl(_apiTestRWLock); |
896 *thereIsDecoder = true; | 898 *thereIsDecoder = true; |
897 } | 899 } |
898 } | 900 } |
899 } else { | 901 } else { |
900 if (!_randomTest) { | 902 if (!_randomTest) { |
901 fprintf(stdout, | 903 fprintf(stdout, |
902 "Register receive codec with fixed Payload, AUDIO BACK.\n"); | 904 "Register receive codec with fixed Payload, AUDIO BACK.\n"); |
903 fflush (stdout); | 905 fflush (stdout); |
904 } | 906 } |
905 CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(myCodec)); | 907 CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec)); |
906 //CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec.pltype)); | 908 //CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec->pltype)); |
907 //CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(myCodec)); | 909 //CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec)); |
908 myEvent->Wait(20); | 910 myEvent->Wait(20); |
909 { | 911 { |
910 WriteLockScoped wl(_apiTestRWLock); | 912 WriteLockScoped wl(_apiTestRWLock); |
911 *thereIsDecoder = true; | 913 *thereIsDecoder = true; |
912 } | 914 } |
913 } | 915 } |
914 delete myEvent; | 916 delete myEvent; |
915 if (!_randomTest) { | 917 if (!_randomTest) { |
916 fprintf(stdout, | 918 fprintf(stdout, |
917 "---------------------------------------------------------\n"); | 919 "---------------------------------------------------------\n"); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 fprintf(stdout, "-----------------------------------------------\n"); | 996 fprintf(stdout, "-----------------------------------------------\n"); |
995 } | 997 } |
996 | 998 |
997 // Fault Test | 999 // Fault Test |
998 CHECK_PROTECTED_MT(myACM->SetVAD(false, true, (ACMVADMode) - 1)); | 1000 CHECK_PROTECTED_MT(myACM->SetVAD(false, true, (ACMVADMode) - 1)); |
999 CHECK_PROTECTED_MT(myACM->SetVAD(false, true, (ACMVADMode) 4)); | 1001 CHECK_PROTECTED_MT(myACM->SetVAD(false, true, (ACMVADMode) 4)); |
1000 | 1002 |
1001 } | 1003 } |
1002 | 1004 |
1003 void APITest::CurrentCodec(char side) { | 1005 void APITest::CurrentCodec(char side) { |
1004 CodecInst myCodec; | 1006 auto myCodec = (side == 'A' ? _acmA : _acmB)->SendCodec(); |
1005 if (side == 'A') { | |
1006 _acmA->SendCodec(&myCodec); | |
1007 } else { | |
1008 _acmB->SendCodec(&myCodec); | |
1009 } | |
1010 | 1007 |
1011 if (!_randomTest) { | 1008 if (!_randomTest) { |
1012 fprintf(stdout, "\n\n"); | 1009 fprintf(stdout, "\n\n"); |
1013 fprintf(stdout, "Send codec in Side A\n"); | 1010 fprintf(stdout, "Send codec in Side A\n"); |
1014 fprintf(stdout, "----------------------------\n"); | 1011 fprintf(stdout, "----------------------------\n"); |
1015 fprintf(stdout, "Name................. %s\n", myCodec.plname); | 1012 fprintf(stdout, "Name................. %s\n", myCodec->plname); |
1016 fprintf(stdout, "Sampling Frequency... %d\n", myCodec.plfreq); | 1013 fprintf(stdout, "Sampling Frequency... %d\n", myCodec->plfreq); |
1017 fprintf(stdout, "Rate................. %d\n", myCodec.rate); | 1014 fprintf(stdout, "Rate................. %d\n", myCodec->rate); |
1018 fprintf(stdout, "Payload-type......... %d\n", myCodec.pltype); | 1015 fprintf(stdout, "Payload-type......... %d\n", myCodec->pltype); |
1019 fprintf(stdout, "Packet-size.......... %d\n", myCodec.pacsize); | 1016 fprintf(stdout, "Packet-size.......... %d\n", myCodec->pacsize); |
1020 } | 1017 } |
1021 | 1018 |
1022 Wait(100); | 1019 Wait(100); |
1023 } | 1020 } |
1024 | 1021 |
1025 void APITest::ChangeCodec(char side) { | 1022 void APITest::ChangeCodec(char side) { |
1026 CodecInst myCodec; | 1023 CodecInst myCodec; |
1027 AudioCodingModule* myACM; | 1024 AudioCodingModule* myACM; |
1028 uint8_t* codecCntr; | 1025 uint8_t* codecCntr; |
1029 bool* thereIsEncoder; | 1026 bool* thereIsEncoder; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 CHECK_ERROR_MT(myACM->RegisterSendCodec(myCodec)); | 1105 CHECK_ERROR_MT(myACM->RegisterSendCodec(myCodec)); |
1109 myChannel->ResetStats(); | 1106 myChannel->ResetStats(); |
1110 { | 1107 { |
1111 WriteLockScoped wl(_apiTestRWLock); | 1108 WriteLockScoped wl(_apiTestRWLock); |
1112 *thereIsEncoder = true; | 1109 *thereIsEncoder = true; |
1113 } | 1110 } |
1114 Wait(500); | 1111 Wait(500); |
1115 } | 1112 } |
1116 | 1113 |
1117 } // namespace webrtc | 1114 } // namespace webrtc |
OLD | NEW |