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 // TODO(hlundin): Reformat file to meet style guide. | 11 // TODO(henrik.lundin): Refactor or replace all of this application. |
12 | 12 |
13 /* header includes */ | 13 /* header includes */ |
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 #ifdef WIN32 | 17 #ifdef WIN32 |
18 #include <winsock2.h> | 18 #include <winsock2.h> |
19 #endif | 19 #endif |
20 #ifdef WEBRTC_LINUX | 20 #ifdef WEBRTC_LINUX |
21 #include <netinet/in.h> | 21 #include <netinet/in.h> |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 #include "G726Interface.h" | 189 #include "G726Interface.h" |
190 #endif | 190 #endif |
191 #ifdef CODEC_GSMFR | 191 #ifdef CODEC_GSMFR |
192 #include "GSMFRInterface.h" | 192 #include "GSMFRInterface.h" |
193 #include "GSMFRCreation.h" | 193 #include "GSMFRCreation.h" |
194 #endif | 194 #endif |
195 #if (defined(CODEC_CNGCODEC8) || defined(CODEC_CNGCODEC16) || \ | 195 #if (defined(CODEC_CNGCODEC8) || defined(CODEC_CNGCODEC16) || \ |
196 defined(CODEC_CNGCODEC32) || defined(CODEC_CNGCODEC48)) | 196 defined(CODEC_CNGCODEC32) || defined(CODEC_CNGCODEC48)) |
197 #include "webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h" | 197 #include "webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h" |
198 #endif | 198 #endif |
199 #if ((defined CODEC_SPEEX_8) || (defined CODEC_SPEEX_16)) | |
200 #include "SpeexInterface.h" | |
201 #endif | |
202 #ifdef CODEC_OPUS | 199 #ifdef CODEC_OPUS |
203 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" | 200 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" |
204 #endif | 201 #endif |
205 | 202 |
206 /***********************************/ | 203 /***********************************/ |
207 /* Global codec instance variables */ | 204 /* Global codec instance variables */ |
208 /***********************************/ | 205 /***********************************/ |
209 | 206 |
210 WebRtcVadInst* VAD_inst[2]; | 207 WebRtcVadInst* VAD_inst[2]; |
211 | 208 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 #ifdef CODEC_ISAC_SWB | 257 #ifdef CODEC_ISAC_SWB |
261 ISACStruct* ISACSWB_inst[2]; | 258 ISACStruct* ISACSWB_inst[2]; |
262 #endif | 259 #endif |
263 #ifdef CODEC_GSMFR | 260 #ifdef CODEC_GSMFR |
264 GSMFR_encinst_t* GSMFRenc_inst[2]; | 261 GSMFR_encinst_t* GSMFRenc_inst[2]; |
265 #endif | 262 #endif |
266 #if (defined(CODEC_CNGCODEC8) || defined(CODEC_CNGCODEC16) || \ | 263 #if (defined(CODEC_CNGCODEC8) || defined(CODEC_CNGCODEC16) || \ |
267 defined(CODEC_CNGCODEC32) || defined(CODEC_CNGCODEC48)) | 264 defined(CODEC_CNGCODEC32) || defined(CODEC_CNGCODEC48)) |
268 webrtc::ComfortNoiseEncoder *CNG_encoder[2]; | 265 webrtc::ComfortNoiseEncoder *CNG_encoder[2]; |
269 #endif | 266 #endif |
270 #ifdef CODEC_SPEEX_8 | |
271 SPEEX_encinst_t* SPEEX8enc_inst[2]; | |
272 #endif | |
273 #ifdef CODEC_SPEEX_16 | |
274 SPEEX_encinst_t* SPEEX16enc_inst[2]; | |
275 #endif | |
276 #ifdef CODEC_OPUS | 267 #ifdef CODEC_OPUS |
277 OpusEncInst* opus_inst[2]; | 268 OpusEncInst* opus_inst[2]; |
278 #endif | 269 #endif |
279 | 270 |
280 int main(int argc, char* argv[]) { | 271 int main(int argc, char* argv[]) { |
281 size_t packet_size; | 272 size_t packet_size; |
282 int fs; | 273 int fs; |
283 webrtc::NetEqDecoder usedCodec; | 274 webrtc::NetEqDecoder usedCodec; |
284 int payloadType; | 275 int payloadType; |
285 int bitrate = 0; | 276 int bitrate = 0; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 printf(" : isacswb iSAC SWB (32kHz and 32.0-52.0 kbps). " | 411 printf(" : isacswb iSAC SWB (32kHz and 32.0-52.0 kbps). " |
421 "To set rate specify a rate parameter as last parameter\n"); | 412 "To set rate specify a rate parameter as last parameter\n"); |
422 #endif | 413 #endif |
423 #ifdef CODEC_GSMFR | 414 #ifdef CODEC_GSMFR |
424 printf(" : gsmfr GSM FR codec (8kHz and 13kbps)\n"); | 415 printf(" : gsmfr GSM FR codec (8kHz and 13kbps)\n"); |
425 #endif | 416 #endif |
426 #ifdef CODEC_G722 | 417 #ifdef CODEC_G722 |
427 printf(" : g722 g722 coder (16kHz) (the 64kbps " | 418 printf(" : g722 g722 coder (16kHz) (the 64kbps " |
428 "version)\n"); | 419 "version)\n"); |
429 #endif | 420 #endif |
430 #ifdef CODEC_SPEEX_8 | |
431 printf(" : speex8 speex coder (8 kHz)\n"); | |
432 #endif | |
433 #ifdef CODEC_SPEEX_16 | |
434 printf(" : speex16 speex coder (16 kHz)\n"); | |
435 #endif | |
436 #ifdef CODEC_RED | 421 #ifdef CODEC_RED |
437 #ifdef CODEC_G711 | 422 #ifdef CODEC_G711 |
438 printf(" : red_pcm Redundancy RTP packet with 2*G711A " | 423 printf(" : red_pcm Redundancy RTP packet with 2*G711A " |
439 "frames\n"); | 424 "frames\n"); |
440 #endif | 425 #endif |
441 #ifdef CODEC_ISAC | 426 #ifdef CODEC_ISAC |
442 printf(" : red_isac Redundancy RTP packet with 2*iSAC " | 427 printf(" : red_isac Redundancy RTP packet with 2*iSAC " |
443 "frames\n"); | 428 "frames\n"); |
444 #endif | 429 #endif |
445 #endif // CODEC_RED | 430 #endif // CODEC_RED |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 exit(0); | 990 exit(0); |
1006 } | 991 } |
1007 WebRtcG7291_EncoderInit(G729_1_inst[k], bitrate, 0 /* flag8kHz*/, | 992 WebRtcG7291_EncoderInit(G729_1_inst[k], bitrate, 0 /* flag8kHz*/, |
1008 0 /*flagG729mode*/); | 993 0 /*flagG729mode*/); |
1009 } else { | 994 } else { |
1010 printf("\nError - G.729.1 input is always 16 kHz \n"); | 995 printf("\nError - G.729.1 input is always 16 kHz \n"); |
1011 exit(0); | 996 exit(0); |
1012 } | 997 } |
1013 break; | 998 break; |
1014 #endif | 999 #endif |
1015 #ifdef CODEC_SPEEX_8 | |
1016 case webrtc::kDecoderSPEEX_8: | |
1017 if (sampfreq == 8000) { | |
1018 if ((enc_frameSize == 160) || (enc_frameSize == 320) || | |
1019 (enc_frameSize == 480)) { | |
1020 ok = WebRtcSpeex_CreateEnc(&SPEEX8enc_inst[k], sampfreq); | |
1021 if (ok != 0) { | |
1022 printf("Error: Couldn't allocate memory for Speex encoding " | |
1023 "instance\n"); | |
1024 exit(0); | |
1025 } | |
1026 } else { | |
1027 printf("\nError: Speex only supports 20, 40, and 60 ms!!\n\n"); | |
1028 exit(0); | |
1029 } | |
1030 if ((vad == 1) && (enc_frameSize != 160)) { | |
1031 printf("\nError - This simulation only supports VAD for Speex at " | |
1032 "20ms packets (not %" PRIuS "ms)\n", | |
1033 (enc_frameSize >> 3)); | |
1034 vad = 0; | |
1035 } | |
1036 ok = WebRtcSpeex_EncoderInit(SPEEX8enc_inst[k], 0 /*vbr*/, | |
1037 3 /*complexity*/, vad); | |
1038 if (ok != 0) | |
1039 exit(0); | |
1040 } else { | |
1041 printf("\nError - Speex8 called with sample frequency other than 8 " | |
1042 "kHz.\n\n"); | |
1043 } | |
1044 break; | |
1045 #endif | |
1046 #ifdef CODEC_SPEEX_16 | |
1047 case webrtc::kDecoderSPEEX_16: | |
1048 if (sampfreq == 16000) { | |
1049 if ((enc_frameSize == 320) || (enc_frameSize == 640) || | |
1050 (enc_frameSize == 960)) { | |
1051 ok = WebRtcSpeex_CreateEnc(&SPEEX16enc_inst[k], sampfreq); | |
1052 if (ok != 0) { | |
1053 printf("Error: Couldn't allocate memory for Speex encoding " | |
1054 "instance\n"); | |
1055 exit(0); | |
1056 } | |
1057 } else { | |
1058 printf("\nError: Speex only supports 20, 40, and 60 ms!!\n\n"); | |
1059 exit(0); | |
1060 } | |
1061 if ((vad == 1) && (enc_frameSize != 320)) { | |
1062 printf("\nError - This simulation only supports VAD for Speex at " | |
1063 "20ms packets (not %" PRIuS "ms)\n", | |
1064 (enc_frameSize >> 4)); | |
1065 vad = 0; | |
1066 } | |
1067 ok = WebRtcSpeex_EncoderInit(SPEEX16enc_inst[k], 0 /*vbr*/, | |
1068 3 /*complexity*/, vad); | |
1069 if (ok != 0) | |
1070 exit(0); | |
1071 } else { | |
1072 printf("\nError - Speex16 called with sample frequency other than 16 " | |
1073 "kHz.\n\n"); | |
1074 } | |
1075 break; | |
1076 #endif | |
1077 | 1000 |
1078 #ifdef CODEC_G722_1_16 | 1001 #ifdef CODEC_G722_1_16 |
1079 case webrtc::kDecoderG722_1_16: | 1002 case webrtc::kDecoderG722_1_16: |
1080 if (sampfreq == 16000) { | 1003 if (sampfreq == 16000) { |
1081 ok = WebRtcG7221_CreateEnc16(&G722_1_16enc_inst[k]); | 1004 ok = WebRtcG7221_CreateEnc16(&G722_1_16enc_inst[k]); |
1082 if (ok != 0) { | 1005 if (ok != 0) { |
1083 printf("Error: Couldn't allocate memory for G.722.1 instance\n"); | 1006 printf("Error: Couldn't allocate memory for G.722.1 instance\n"); |
1084 exit(0); | 1007 exit(0); |
1085 } | 1008 } |
1086 if (enc_frameSize == 320) { | 1009 if (enc_frameSize == 320) { |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 #ifdef CODEC_G729 | 1401 #ifdef CODEC_G729 |
1479 case webrtc::NetEqDecoder::kDecoderG729: | 1402 case webrtc::NetEqDecoder::kDecoderG729: |
1480 WebRtcG729_FreeEnc(G729enc_inst[k]); | 1403 WebRtcG729_FreeEnc(G729enc_inst[k]); |
1481 break; | 1404 break; |
1482 #endif | 1405 #endif |
1483 #ifdef CODEC_G729_1 | 1406 #ifdef CODEC_G729_1 |
1484 case webrtc::NetEqDecoder::kDecoderG729_1: | 1407 case webrtc::NetEqDecoder::kDecoderG729_1: |
1485 WebRtcG7291_Free(G729_1_inst[k]); | 1408 WebRtcG7291_Free(G729_1_inst[k]); |
1486 break; | 1409 break; |
1487 #endif | 1410 #endif |
1488 #ifdef CODEC_SPEEX_8 | |
1489 case webrtc::NetEqDecoder::kDecoderSPEEX_8: | |
1490 WebRtcSpeex_FreeEnc(SPEEX8enc_inst[k]); | |
1491 break; | |
1492 #endif | |
1493 #ifdef CODEC_SPEEX_16 | |
1494 case webrtc::NetEqDecoder::kDecoderSPEEX_16: | |
1495 WebRtcSpeex_FreeEnc(SPEEX16enc_inst[k]); | |
1496 break; | |
1497 #endif | |
1498 | 1411 |
1499 #ifdef CODEC_G722_1_16 | 1412 #ifdef CODEC_G722_1_16 |
1500 case webrtc::NetEqDecoder::kDecoderG722_1_16: | 1413 case webrtc::NetEqDecoder::kDecoderG722_1_16: |
1501 WebRtcG7221_FreeEnc16(G722_1_16enc_inst[k]); | 1414 WebRtcG7221_FreeEnc16(G722_1_16enc_inst[k]); |
1502 break; | 1415 break; |
1503 #endif | 1416 #endif |
1504 #ifdef CODEC_G722_1_24 | 1417 #ifdef CODEC_G722_1_24 |
1505 case webrtc::NetEqDecoder::kDecoderG722_1_24: | 1418 case webrtc::NetEqDecoder::kDecoderG722_1_24: |
1506 WebRtcG7221_FreeEnc24(G722_1_24enc_inst[k]); | 1419 WebRtcG7221_FreeEnc24(G722_1_24enc_inst[k]); |
1507 break; | 1420 break; |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 memmove(ptrL + stride, ptrL, ptrR - ptrL); | 1789 memmove(ptrL + stride, ptrL, ptrR - ptrL); |
1877 | 1790 |
1878 // copy from temp to left pointer | 1791 // copy from temp to left pointer |
1879 memcpy(ptrL, temp, stride); | 1792 memcpy(ptrL, temp, stride); |
1880 | 1793 |
1881 // advance pointers | 1794 // advance pointers |
1882 ptrL += stride * 2; | 1795 ptrL += stride * 2; |
1883 ptrR += stride; | 1796 ptrR += stride; |
1884 } | 1797 } |
1885 } | 1798 } |
OLD | NEW |