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 |
11 #include "webrtc/modules/audio_coding/test/APITest.h" | 11 #include "webrtc/modules/audio_coding/test/APITest.h" |
12 | 12 |
13 #include <ctype.h> | 13 #include <ctype.h> |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 #include <stdlib.h> | 15 #include <stdlib.h> |
16 #include <string.h> | 16 #include <string.h> |
17 | 17 |
18 #include <iostream> | 18 #include <iostream> |
19 #include <ostream> | 19 #include <ostream> |
20 #include <string> | 20 #include <string> |
21 | 21 |
22 #include "webrtc/base/platform_thread.h" | 22 #include "webrtc/base/platform_thread.h" |
23 #include "webrtc/base/timeutils.h" | 23 #include "webrtc/base/timeutils.h" |
24 #include "webrtc/common_types.h" | 24 #include "webrtc/common_types.h" |
25 #include "webrtc/modules/audio_coding/acm2/acm_common_defs.h" | 25 #include "webrtc/modules/audio_coding/acm2/acm_common_defs.h" |
| 26 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" |
26 #include "webrtc/modules/audio_coding/test/utility.h" | 27 #include "webrtc/modules/audio_coding/test/utility.h" |
27 #include "webrtc/system_wrappers/include/event_wrapper.h" | 28 #include "webrtc/system_wrappers/include/event_wrapper.h" |
28 #include "webrtc/system_wrappers/include/trace.h" | 29 #include "webrtc/system_wrappers/include/trace.h" |
29 #include "webrtc/test/gtest.h" | 30 #include "webrtc/test/gtest.h" |
30 #include "webrtc/test/testsupport/fileutils.h" | 31 #include "webrtc/test/testsupport/fileutils.h" |
31 #include "webrtc/voice_engine_configurations.h" | 32 #include "webrtc/voice_engine_configurations.h" |
32 | 33 |
33 namespace webrtc { | 34 namespace webrtc { |
34 | 35 |
35 #define TEST_DURATION_SEC 600 | 36 #define TEST_DURATION_SEC 600 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 && (dummyCodec.plfreq == 32000)) { | 135 && (dummyCodec.plfreq == 32000)) { |
135 continue; | 136 continue; |
136 } | 137 } |
137 | 138 |
138 printf("Register Receive Codec %s ", dummyCodec.plname); | 139 printf("Register Receive Codec %s ", dummyCodec.plname); |
139 | 140 |
140 if ((n != 0) && !FixedPayloadTypeCodec(dummyCodec.plname)) { | 141 if ((n != 0) && !FixedPayloadTypeCodec(dummyCodec.plname)) { |
141 // Check registration with an already occupied payload type | 142 // Check registration with an already occupied payload type |
142 int currentPayloadType = dummyCodec.pltype; | 143 int currentPayloadType = dummyCodec.pltype; |
143 dummyCodec.pltype = 97; //lastPayloadType; | 144 dummyCodec.pltype = 97; //lastPayloadType; |
144 CHECK_ERROR(_acmB->RegisterReceiveCodec(dummyCodec)); | 145 EXPECT_EQ(true, _acmB->RegisterReceiveCodec(dummyCodec.pltype, |
| 146 CodecInstToSdp(dummyCodec))); |
145 dummyCodec.pltype = currentPayloadType; | 147 dummyCodec.pltype = currentPayloadType; |
146 } | 148 } |
147 | 149 |
148 if ((n < numCodecs - 1) && !FixedPayloadTypeCodec(dummyCodec.plname)) { | 150 if ((n < numCodecs - 1) && !FixedPayloadTypeCodec(dummyCodec.plname)) { |
149 // test if re-registration works; | 151 // test if re-registration works; |
150 CodecInst nextCodec; | 152 CodecInst nextCodec; |
151 int currentPayloadType = dummyCodec.pltype; | 153 int currentPayloadType = dummyCodec.pltype; |
152 AudioCodingModule::Codec(n + 1, &nextCodec); | 154 AudioCodingModule::Codec(n + 1, &nextCodec); |
153 dummyCodec.pltype = nextCodec.pltype; | 155 dummyCodec.pltype = nextCodec.pltype; |
154 if (!FixedPayloadTypeCodec(nextCodec.plname)) { | 156 if (!FixedPayloadTypeCodec(nextCodec.plname)) { |
155 _acmB->RegisterReceiveCodec(dummyCodec); | 157 _acmB->RegisterReceiveCodec(dummyCodec.pltype, |
| 158 CodecInstToSdp(dummyCodec)); |
156 } | 159 } |
157 dummyCodec.pltype = currentPayloadType; | 160 dummyCodec.pltype = currentPayloadType; |
158 } | 161 } |
159 | 162 |
160 if ((n < numCodecs - 1) && !FixedPayloadTypeCodec(dummyCodec.plname)) { | 163 if ((n < numCodecs - 1) && !FixedPayloadTypeCodec(dummyCodec.plname)) { |
161 // test if un-registration works; | 164 // test if un-registration works; |
162 CodecInst nextCodec; | 165 CodecInst nextCodec; |
163 AudioCodingModule::Codec(n + 1, &nextCodec); | 166 AudioCodingModule::Codec(n + 1, &nextCodec); |
164 nextCodec.pltype = dummyCodec.pltype; | 167 nextCodec.pltype = dummyCodec.pltype; |
165 if (!FixedPayloadTypeCodec(nextCodec.plname)) { | 168 if (!FixedPayloadTypeCodec(nextCodec.plname)) { |
166 CHECK_ERROR_MT(_acmA->RegisterReceiveCodec(nextCodec)); | 169 EXPECT_EQ(true, _acmA->RegisterReceiveCodec(nextCodec.pltype, |
| 170 CodecInstToSdp(nextCodec))); |
167 CHECK_ERROR_MT(_acmA->UnregisterReceiveCodec(nextCodec.pltype)); | 171 CHECK_ERROR_MT(_acmA->UnregisterReceiveCodec(nextCodec.pltype)); |
168 } | 172 } |
169 } | 173 } |
170 | 174 |
171 CHECK_ERROR_MT(_acmA->RegisterReceiveCodec(dummyCodec)); | 175 EXPECT_EQ(true, _acmA->RegisterReceiveCodec(dummyCodec.pltype, |
| 176 CodecInstToSdp(dummyCodec))); |
172 printf(" side A done!"); | 177 printf(" side A done!"); |
173 CHECK_ERROR_MT(_acmB->RegisterReceiveCodec(dummyCodec)); | 178 EXPECT_EQ(true, _acmB->RegisterReceiveCodec(dummyCodec.pltype, |
| 179 CodecInstToSdp(dummyCodec))); |
174 printf(" side B done!\n"); | 180 printf(" side B done!\n"); |
175 | 181 |
176 if (!strcmp(dummyCodec.plname, "CN")) { | 182 if (!strcmp(dummyCodec.plname, "CN")) { |
177 CHECK_ERROR_MT(_acmA->RegisterSendCodec(dummyCodec)); | 183 CHECK_ERROR_MT(_acmA->RegisterSendCodec(dummyCodec)); |
178 CHECK_ERROR_MT(_acmB->RegisterSendCodec(dummyCodec)); | 184 CHECK_ERROR_MT(_acmB->RegisterSendCodec(dummyCodec)); |
179 } | 185 } |
180 lastPayloadType = dummyCodec.pltype; | 186 lastPayloadType = dummyCodec.pltype; |
181 if ((lastPayloadType >= 96) && (lastPayloadType <= 127)) { | 187 if ((lastPayloadType >= 96) && (lastPayloadType <= 127)) { |
182 _payloadUsed[lastPayloadType - 96] = true; | 188 _payloadUsed[lastPayloadType - 96] = true; |
183 } | 189 } |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 //myEvent->Wait(20); | 870 //myEvent->Wait(20); |
865 //CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec->pltype)); | 871 //CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec->pltype)); |
866 Wait(1000); | 872 Wait(1000); |
867 | 873 |
868 myCodec->pltype = currentPayload; | 874 myCodec->pltype = currentPayload; |
869 if (!_randomTest) { | 875 if (!_randomTest) { |
870 fprintf(stdout, | 876 fprintf(stdout, |
871 "Register receive codec with default Payload, AUDIO BACK.\n"); | 877 "Register receive codec with default Payload, AUDIO BACK.\n"); |
872 fflush (stdout); | 878 fflush (stdout); |
873 } | 879 } |
874 CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec)); | 880 EXPECT_EQ(true, receiveACM->RegisterReceiveCodec( |
| 881 myCodec->pltype, CodecInstToSdp(*myCodec))); |
875 //CHECK_ERROR_MT(sendACM->RegisterSendCodec(*myCodec)); | 882 //CHECK_ERROR_MT(sendACM->RegisterSendCodec(*myCodec)); |
876 myEvent->Wait(20); | 883 myEvent->Wait(20); |
877 { | 884 { |
878 WriteLockScoped wl(_apiTestRWLock); | 885 WriteLockScoped wl(_apiTestRWLock); |
879 *thereIsDecoder = true; | 886 *thereIsDecoder = true; |
880 } | 887 } |
881 Wait(1000); | 888 Wait(1000); |
882 | 889 |
883 break; | 890 break; |
884 } | 891 } |
885 } | 892 } |
886 if (i == 32) { | 893 if (i == 32) { |
887 CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec)); | 894 EXPECT_EQ(true, receiveACM->RegisterReceiveCodec( |
| 895 myCodec->pltype, CodecInstToSdp(*myCodec))); |
888 { | 896 { |
889 WriteLockScoped wl(_apiTestRWLock); | 897 WriteLockScoped wl(_apiTestRWLock); |
890 *thereIsDecoder = true; | 898 *thereIsDecoder = true; |
891 } | 899 } |
892 } | 900 } |
893 } else { | 901 } else { |
894 if (!_randomTest) { | 902 if (!_randomTest) { |
895 fprintf(stdout, | 903 fprintf(stdout, |
896 "Register receive codec with fixed Payload, AUDIO BACK.\n"); | 904 "Register receive codec with fixed Payload, AUDIO BACK.\n"); |
897 fflush (stdout); | 905 fflush (stdout); |
898 } | 906 } |
899 CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec)); | 907 EXPECT_EQ(true, receiveACM->RegisterReceiveCodec(myCodec->pltype, |
| 908 CodecInstToSdp(*myCodec))); |
900 //CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec->pltype)); | 909 //CHECK_ERROR_MT(receiveACM->UnregisterReceiveCodec(myCodec->pltype)); |
901 //CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec)); | 910 //CHECK_ERROR_MT(receiveACM->RegisterReceiveCodec(*myCodec)); |
902 myEvent->Wait(20); | 911 myEvent->Wait(20); |
903 { | 912 { |
904 WriteLockScoped wl(_apiTestRWLock); | 913 WriteLockScoped wl(_apiTestRWLock); |
905 *thereIsDecoder = true; | 914 *thereIsDecoder = true; |
906 } | 915 } |
907 } | 916 } |
908 delete myEvent; | 917 delete myEvent; |
909 if (!_randomTest) { | 918 if (!_randomTest) { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 CHECK_ERROR_MT(myACM->RegisterSendCodec(myCodec)); | 1106 CHECK_ERROR_MT(myACM->RegisterSendCodec(myCodec)); |
1098 myChannel->ResetStats(); | 1107 myChannel->ResetStats(); |
1099 { | 1108 { |
1100 WriteLockScoped wl(_apiTestRWLock); | 1109 WriteLockScoped wl(_apiTestRWLock); |
1101 *thereIsEncoder = true; | 1110 *thereIsEncoder = true; |
1102 } | 1111 } |
1103 Wait(500); | 1112 Wait(500); |
1104 } | 1113 } |
1105 | 1114 |
1106 } // namespace webrtc | 1115 } // namespace webrtc |
OLD | NEW |