| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 int maxBn = 56000; | 44 int maxBn = 56000; |
| 45 | 45 |
| 46 int bnWB = 32000; | 46 int bnWB = 32000; |
| 47 int bnSWB = 56000; | 47 int bnSWB = 56000; |
| 48 | 48 |
| 49 strcpy(outFileName[0], "switchSampRate_out1.pcm"); | 49 strcpy(outFileName[0], "switchSampRate_out1.pcm"); |
| 50 strcpy(outFileName[1], "switchSampRate_out2.pcm"); | 50 strcpy(outFileName[1], "switchSampRate_out2.pcm"); |
| 51 | 51 |
| 52 short clientCntr; | 52 short clientCntr; |
| 53 | 53 |
| 54 unsigned int lenEncodedInBytes[MAX_NUM_CLIENTS]; | 54 size_t lenEncodedInBytes[MAX_NUM_CLIENTS]; |
| 55 unsigned int lenAudioIn10ms[MAX_NUM_CLIENTS]; | 55 unsigned int lenAudioIn10ms[MAX_NUM_CLIENTS]; |
| 56 unsigned int lenEncodedInBytesTmp[MAX_NUM_CLIENTS]; | 56 size_t lenEncodedInBytesTmp[MAX_NUM_CLIENTS]; |
| 57 unsigned int lenAudioIn10msTmp[MAX_NUM_CLIENTS]; | 57 unsigned int lenAudioIn10msTmp[MAX_NUM_CLIENTS]; |
| 58 BottleNeckModel* packetData[MAX_NUM_CLIENTS]; | 58 BottleNeckModel* packetData[MAX_NUM_CLIENTS]; |
| 59 | 59 |
| 60 char versionNumber[100]; | 60 char versionNumber[100]; |
| 61 short samplesIn10ms[MAX_NUM_CLIENTS]; | 61 short samplesIn10ms[MAX_NUM_CLIENTS]; |
| 62 int bottleneck[MAX_NUM_CLIENTS]; | 62 int bottleneck[MAX_NUM_CLIENTS]; |
| 63 | 63 |
| 64 printf("\n\n"); | 64 printf("\n\n"); |
| 65 printf("____________________________________________\n\n"); | 65 printf("____________________________________________\n\n"); |
| 66 WebRtcIsac_version(versionNumber); | 66 WebRtcIsac_version(versionNumber); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 bottleneck[clientCntr], 30) < 0) | 182 bottleneck[clientCntr], 30) < 0) |
| 183 { | 183 { |
| 184 printf("Could not setup bottleneck and frame-size for client %d\n", | 184 printf("Could not setup bottleneck and frame-size for client %d\n", |
| 185 clientCntr + 1); | 185 clientCntr + 1); |
| 186 return -1; | 186 return -1; |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 | 190 |
| 191 | 191 |
| 192 short streamLen; | 192 size_t streamLen; |
| 193 short numSamplesRead; | 193 short numSamplesRead; |
| 194 int lenDecodedAudio; | 194 size_t lenDecodedAudio; |
| 195 short senderIdx; | 195 short senderIdx; |
| 196 short receiverIdx; | 196 short receiverIdx; |
| 197 | 197 |
| 198 printf("\n"); | 198 printf("\n"); |
| 199 short num10ms[MAX_NUM_CLIENTS]; | 199 short num10ms[MAX_NUM_CLIENTS]; |
| 200 memset(num10ms, 0, sizeof(short)*MAX_NUM_CLIENTS); | 200 memset(num10ms, 0, sizeof(short)*MAX_NUM_CLIENTS); |
| 201 FILE* arrivalTimeFile1 = fopen("arrivalTime1.dat", "wb"); | 201 FILE* arrivalTimeFile1 = fopen("arrivalTime1.dat", "wb"); |
| 202 FILE* arrivalTimeFile2 = fopen("arrivalTime2.dat", "wb"); | 202 FILE* arrivalTimeFile2 = fopen("arrivalTime2.dat", "wb"); |
| 203 short numPrint[MAX_NUM_CLIENTS]; | 203 short numPrint[MAX_NUM_CLIENTS]; |
| 204 memset(numPrint, 0, sizeof(short) * MAX_NUM_CLIENTS); | 204 memset(numPrint, 0, sizeof(short) * MAX_NUM_CLIENTS); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 //if(num10ms[senderIdx] > 6) | 275 //if(num10ms[senderIdx] > 6) |
| 276 //{ | 276 //{ |
| 277 // printf("Client %d has got more than 60 ms audio and encoded no packe
t.\n", | 277 // printf("Client %d has got more than 60 ms audio and encoded no packe
t.\n", |
| 278 // senderIdx); | 278 // senderIdx); |
| 279 // return -1; | 279 // return -1; |
| 280 //} | 280 //} |
| 281 | 281 |
| 282 // Encode | 282 // Encode |
| 283 | 283 |
| 284 | 284 |
| 285 streamLen = WebRtcIsac_Encode(codecInstance[senderIdx], | 285 int streamLen_int = WebRtcIsac_Encode(codecInstance[senderIdx], |
| 286 audioBuff10ms, | 286 audioBuff10ms, |
| 287 (uint8_t*)bitStream); | 287 (uint8_t*)bitStream); |
| 288 int16_t ggg; | 288 int16_t ggg; |
| 289 if (streamLen > 0) { | 289 if (streamLen_int > 0) { |
| 290 if ((WebRtcIsac_ReadFrameLen( | 290 if ((WebRtcIsac_ReadFrameLen( |
| 291 codecInstance[receiverIdx], | 291 codecInstance[receiverIdx], |
| 292 reinterpret_cast<const uint8_t*>(bitStream), | 292 reinterpret_cast<const uint8_t*>(bitStream), |
| 293 &ggg)) < 0) | 293 &ggg)) < 0) |
| 294 printf("ERROR\n"); | 294 printf("ERROR\n"); |
| 295 } | 295 } |
| 296 | 296 |
| 297 // Sanity check | 297 // Sanity check |
| 298 if(streamLen < 0) | 298 if(streamLen_int < 0) |
| 299 { | 299 { |
| 300 printf(" Encoder error in client %d \n", senderIdx + 1); | 300 printf(" Encoder error in client %d \n", senderIdx + 1); |
| 301 return -1; | 301 return -1; |
| 302 } | 302 } |
| 303 streamLen = static_cast<size_t>(streamLen_int); |
| 303 | 304 |
| 304 | 305 |
| 305 if(streamLen > 0) | 306 if(streamLen > 0) |
| 306 { | 307 { |
| 307 // Packet generated; model sending through a channel, do bandwidth | 308 // Packet generated; model sending through a channel, do bandwidth |
| 308 // estimation at the receiver and decode. | 309 // estimation at the receiver and decode. |
| 309 lenEncodedInBytes[senderIdx] += streamLen; | 310 lenEncodedInBytes[senderIdx] += streamLen; |
| 310 lenAudioIn10ms[senderIdx] += (unsigned int)num10ms[senderIdx]; | 311 lenAudioIn10ms[senderIdx] += (unsigned int)num10ms[senderIdx]; |
| 311 lenEncodedInBytesTmp[senderIdx] += streamLen; | 312 lenEncodedInBytesTmp[senderIdx] += streamLen; |
| 312 lenAudioIn10msTmp[senderIdx] += (unsigned int)num10ms[senderIdx]; | 313 lenAudioIn10msTmp[senderIdx] += (unsigned int)num10ms[senderIdx]; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 reinterpret_cast<const uint8_t*>(bitStream), | 417 reinterpret_cast<const uint8_t*>(bitStream), |
| 417 streamLen, | 418 streamLen, |
| 418 packetData[senderIdx]->rtp_number, | 419 packetData[senderIdx]->rtp_number, |
| 419 packetData[senderIdx]->sample_count, | 420 packetData[senderIdx]->sample_count, |
| 420 packetData[senderIdx]->arrival_time) < 0) { | 421 packetData[senderIdx]->arrival_time) < 0) { |
| 421 printf(" BWE Error at client %d \n", receiverIdx + 1); | 422 printf(" BWE Error at client %d \n", receiverIdx + 1); |
| 422 return -1; | 423 return -1; |
| 423 } | 424 } |
| 424 /**/ | 425 /**/ |
| 425 // Decode | 426 // Decode |
| 426 lenDecodedAudio = WebRtcIsac_Decode( | 427 int lenDecodedAudio_int = WebRtcIsac_Decode( |
| 427 codecInstance[receiverIdx], | 428 codecInstance[receiverIdx], |
| 428 reinterpret_cast<const uint8_t*>(bitStream), | 429 reinterpret_cast<const uint8_t*>(bitStream), |
| 429 streamLen, | 430 streamLen, |
| 430 audioBuff60ms, | 431 audioBuff60ms, |
| 431 speechType); | 432 speechType); |
| 432 if(lenDecodedAudio < 0) | 433 if(lenDecodedAudio_int < 0) |
| 433 { | 434 { |
| 434 printf(" Decoder error in client %d \n", receiverIdx + 1); | 435 printf(" Decoder error in client %d \n", receiverIdx + 1); |
| 435 return -1; | 436 return -1; |
| 436 } | 437 } |
| 437 | 438 lenDecodedAudio = static_cast<size_t>(lenDecodedAudio_int); |
| 438 | 439 |
| 439 if(encoderSampRate[senderIdx] == 16000) | 440 if(encoderSampRate[senderIdx] == 16000) |
| 440 { | 441 { |
| 441 WebRtcSpl_UpsampleBy2(audioBuff60ms, lenDecodedAudio, resampledAudio60
ms, | 442 WebRtcSpl_UpsampleBy2(audioBuff60ms, lenDecodedAudio, resampledAudio60
ms, |
| 442 resamplerState[receiverIdx]); | 443 resamplerState[receiverIdx]); |
| 443 if (fwrite(resampledAudio60ms, sizeof(short), lenDecodedAudio << 1, | 444 if (fwrite(resampledAudio60ms, sizeof(short), lenDecodedAudio << 1, |
| 444 outFile[receiverIdx]) != | 445 outFile[receiverIdx]) != |
| 445 static_cast<size_t>(lenDecodedAudio << 1)) { | 446 lenDecodedAudio << 1) { |
| 446 return -1; | 447 return -1; |
| 447 } | 448 } |
| 448 } | 449 } |
| 449 else | 450 else |
| 450 { | 451 { |
| 451 if (fwrite(audioBuff60ms, sizeof(short), lenDecodedAudio, | 452 if (fwrite(audioBuff60ms, sizeof(short), lenDecodedAudio, |
| 452 outFile[receiverIdx]) != | 453 outFile[receiverIdx]) != |
| 453 static_cast<size_t>(lenDecodedAudio)) { | 454 lenDecodedAudio) { |
| 454 return -1; | 455 return -1; |
| 455 } | 456 } |
| 456 } | 457 } |
| 457 num10ms[senderIdx] = 0; | 458 num10ms[senderIdx] = 0; |
| 458 } | 459 } |
| 459 //} | 460 //} |
| 460 //} | 461 //} |
| 461 } | 462 } |
| 462 } | 463 } |
| 463 } | 464 } |
| OLD | NEW |