Check return result of fwrite [Audio Module]
Description: On ChromeOS/ARM, compiler enforces to check return result of a function. Currently, we don't check return result of fwrite, it causes building errors. The following files need to patch. The patch should be similar, before I patch all of them, I will start with 2 files, please take a quick look, if the patch is OK, I will continue and upload a new patch that covers all of them. it to all of them. Review URL: https://webrtc-codereview.appspot.com/566016 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2345 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
		| @@ -1,5 +1,5 @@ | |||||||
| /* | /* | ||||||
|  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | ||||||
|  * |  * | ||||||
|  *  Use of this source code is governed by a BSD-style license |  *  Use of this source code is governed by a BSD-style license | ||||||
|  *  that can be found in the LICENSE file in the root of the source |  *  that can be found in the LICENSE file in the root of the source | ||||||
| @@ -120,7 +120,6 @@ int main(int argc, char* argv[]) | |||||||
|         exit(EXIT_FAILURE); |         exit(EXIT_FAILURE); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|      |  | ||||||
|     static bool firstSilent=true; |     static bool firstSilent=true; | ||||||
|  |  | ||||||
|     int numSamp=0; |     int numSamp=0; | ||||||
| @@ -155,7 +154,6 @@ int main(int argc, char* argv[]) | |||||||
|                     exit(EXIT_FAILURE); |                     exit(EXIT_FAILURE); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                  |  | ||||||
|                 firstSilent=false; |                 firstSilent=false; | ||||||
|  |  | ||||||
|                 res=WebRtcCng_Encode(e_inst, &anaSpeech[frameLen/2], frameLen/2, SIDpkt,&size,1); |                 res=WebRtcCng_Encode(e_inst, &anaSpeech[frameLen/2], frameLen/2, SIDpkt,&size,1); | ||||||
| @@ -210,16 +208,17 @@ int main(int argc, char* argv[]) | |||||||
|             memset(state,0,frameLen*2); |             memset(state,0,frameLen*2); | ||||||
|  |  | ||||||
|         } |         } | ||||||
|         fwrite(genSpeech,2,frameLen,outfile); |         if (fwrite(genSpeech, 2, frameLen, | ||||||
|         fwrite(state,2,frameLen,statefile); |                    outfile) != static_cast<size_t>(frameLen)) { | ||||||
|          |           return -1; | ||||||
|  |         } | ||||||
|  |         if (fwrite(state, 2, frameLen, | ||||||
|  |                    statefile) != static_cast<size_t>(frameLen)) { | ||||||
|  |           return -1; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|      |  | ||||||
|     fclose(infile); |     fclose(infile); | ||||||
|     fclose(outfile); |     fclose(outfile); | ||||||
|     fclose(statefile); |     fclose(statefile); | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /* | /* | ||||||
|  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | ||||||
|  * |  * | ||||||
|  *  Use of this source code is governed by a BSD-style license |  *  Use of this source code is governed by a BSD-style license | ||||||
|  *  that can be found in the LICENSE file in the root of the source |  *  that can be found in the LICENSE file in the root of the source | ||||||
| @@ -129,16 +129,22 @@ int main(int argc, char* argv[]) | |||||||
|             /* A-law encoding */ |             /* A-law encoding */ | ||||||
|             stream_len = WebRtcG711_EncodeA(NULL, shortdata, framelength, streamdata); |             stream_len = WebRtcG711_EncodeA(NULL, shortdata, framelength, streamdata); | ||||||
|             if (argc==6){ |             if (argc==6){ | ||||||
|                 /* Write bits to file */ |               /* Write bits to file */ | ||||||
|                 fwrite(streamdata,sizeof(unsigned char),stream_len,bitp); |               if (fwrite(streamdata, sizeof(unsigned char), stream_len, | ||||||
|  |                          bitp) != static_cast<size_t>(stream_len)) { | ||||||
|  |                 return -1; | ||||||
|  |               } | ||||||
|             } |             } | ||||||
|             err = WebRtcG711_DecodeA(NULL, streamdata, stream_len, decoded, speechType); |             err = WebRtcG711_DecodeA(NULL, streamdata, stream_len, decoded, speechType); | ||||||
|         } else if (!strcmp(law,"u")){ |         } else if (!strcmp(law,"u")){ | ||||||
|             /* u-law encoding */ |             /* u-law encoding */ | ||||||
|             stream_len = WebRtcG711_EncodeU(NULL, shortdata, framelength, streamdata); |             stream_len = WebRtcG711_EncodeU(NULL, shortdata, framelength, streamdata); | ||||||
|             if (argc==6){ |             if (argc==6){ | ||||||
|                 /* Write bits to file */ |               /* Write bits to file */ | ||||||
|                 fwrite(streamdata,sizeof(unsigned char),stream_len,bitp); |               if (fwrite(streamdata, sizeof(unsigned char), stream_len, | ||||||
|  |                          bitp) != static_cast<size_t>(stream_len)) { | ||||||
|  |                 return -1; | ||||||
|  |               } | ||||||
|             } |             } | ||||||
|             err = WebRtcG711_DecodeU(NULL, streamdata, stream_len, decoded, speechType); |             err = WebRtcG711_DecodeU(NULL, streamdata, stream_len, decoded, speechType); | ||||||
|         } else { |         } else { | ||||||
| @@ -149,8 +155,11 @@ int main(int argc, char* argv[]) | |||||||
|             /* exit if returned with error */ |             /* exit if returned with error */ | ||||||
|             printf("Error in encoder/decoder\n"); |             printf("Error in encoder/decoder\n"); | ||||||
|         } else { |         } else { | ||||||
|             /* Write coded speech to file */ |           /* Write coded speech to file */ | ||||||
|             fwrite(decoded,sizeof(short),framelength,outp); |           if (fwrite(decoded, sizeof(short), framelength, | ||||||
|  |                      outp) != static_cast<size_t>(framelength)) { | ||||||
|  |             return -1; | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /* | /* | ||||||
|  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | ||||||
|  * |  * | ||||||
|  *  Use of this source code is governed by a BSD-style license |  *  Use of this source code is governed by a BSD-style license | ||||||
|  *  that can be found in the LICENSE file in the root of the source |  *  that can be found in the LICENSE file in the root of the source | ||||||
| @@ -133,10 +133,16 @@ int main(int argc, char* argv[]) | |||||||
|             /* exit if returned with error */ |             /* exit if returned with error */ | ||||||
|             printf("Error in encoder/decoder\n"); |             printf("Error in encoder/decoder\n"); | ||||||
|         } else { |         } else { | ||||||
|             /* Write coded bits to file */ |           /* Write coded bits to file */ | ||||||
|             fwrite(streamdata,sizeof(short),stream_len/2,outbitp); |           if (fwrite(streamdata, sizeof(short), stream_len/2, | ||||||
|             /* Write coded speech to file */ |                      outbitp) != static_cast<size_t>(stream_len/2)) { | ||||||
|             fwrite(decoded,sizeof(short),framelength,outp); |             return -1; | ||||||
|  |           } | ||||||
|  |           /* Write coded speech to file */ | ||||||
|  |           if (fwrite(decoded, sizeof(short), framelength, | ||||||
|  |                      outp) != static_cast<size_t>(framelength)) { | ||||||
|  |             return -1; | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -154,4 +160,3 @@ int main(int argc, char* argv[]) | |||||||
|  |  | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /* | /* | ||||||
|  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | ||||||
|  * |  * | ||||||
|  *  Use of this source code is governed by a BSD-style license |  *  Use of this source code is governed by a BSD-style license | ||||||
|  *  that can be found in the LICENSE file in the root of the source |  *  that can be found in the LICENSE file in the root of the source | ||||||
| @@ -628,7 +628,10 @@ int main(int argc, char* argv[]) | |||||||
|         errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); |         errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst); | ||||||
|         printf("\nError in encoder: %d.\n", errtype); |         printf("\nError in encoder: %d.\n", errtype); | ||||||
|       } else { |       } else { | ||||||
|         fwrite(streamdata, sizeof(char), stream_len, outbits); |         if (fwrite(streamdata, sizeof(char), | ||||||
|  |                    stream_len, outbits) != (size_t)stream_len) { | ||||||
|  |           return -1; | ||||||
|  |         } | ||||||
|       } |       } | ||||||
|  |  | ||||||
|       cur_framesmpls += FRAMESAMPLES_10ms; |       cur_framesmpls += FRAMESAMPLES_10ms; | ||||||
| @@ -777,7 +780,10 @@ int main(int argc, char* argv[]) | |||||||
|       } |       } | ||||||
|  |  | ||||||
|       /* Write decoded speech frame to file */ |       /* Write decoded speech frame to file */ | ||||||
|       fwrite(decoded, sizeof(WebRtc_Word16), declen, outp); |       if (fwrite(decoded, sizeof(WebRtc_Word16), | ||||||
|  |                  declen, outp) != (size_t)declen) { | ||||||
|  |         return -1; | ||||||
|  |       } | ||||||
|       //   fprintf( ratefile, "%f \n", stream_len / ( ((double)declen)/ |       //   fprintf( ratefile, "%f \n", stream_len / ( ((double)declen)/ | ||||||
|       // ((double)FS) ) * 8 ); |       // ((double)FS) ) * 8 ); | ||||||
|     } else { |     } else { | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /* | /* | ||||||
|  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | ||||||
|  * |  * | ||||||
|  *  Use of this source code is governed by a BSD-style license |  *  Use of this source code is governed by a BSD-style license | ||||||
|  *  that can be found in the LICENSE file in the root of the source |  *  that can be found in the LICENSE file in the root of the source | ||||||
| @@ -692,15 +692,24 @@ int main(int argc, char* argv[]) | |||||||
|                             exit(0); |                             exit(0); | ||||||
|                         } |                         } | ||||||
|                         auxUW8 = (WebRtc_UWord8)(((streamLenTransCoding & 0xFF00) >> 8) &  0x00FF); |                         auxUW8 = (WebRtc_UWord8)(((streamLenTransCoding & 0xFF00) >> 8) &  0x00FF); | ||||||
|                         fwrite(&auxUW8, sizeof(WebRtc_UWord8), |                         if (fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, | ||||||
|                             1, transcodingBitstream); |                                    transcodingBitstream) != 1) { | ||||||
|  |                           return -1; | ||||||
|  |                         } | ||||||
|  |  | ||||||
|                         auxUW8 = (WebRtc_UWord8)(streamLenTransCoding & 0x00FF); |                         auxUW8 = (WebRtc_UWord8)(streamLenTransCoding & 0x00FF); | ||||||
|                         fwrite(&auxUW8, sizeof(WebRtc_UWord8), |                         if (fwrite(&auxUW8, sizeof(WebRtc_UWord8), | ||||||
|                             1, transcodingBitstream); |                                    1, transcodingBitstream) != 1) { | ||||||
|  |                           return -1; | ||||||
|  |                         } | ||||||
|  |  | ||||||
|                         fwrite((WebRtc_UWord8*)streamDataTransCoding, sizeof(WebRtc_UWord8), |                         if (fwrite((WebRtc_UWord8*)streamDataTransCoding, | ||||||
|                             streamLenTransCoding, transcodingBitstream); |                                    sizeof(WebRtc_UWord8), | ||||||
|  |                                    streamLenTransCoding, | ||||||
|  |                                    transcodingBitstream) != | ||||||
|  |                             static_cast<size_t>(streamLenTransCoding)) { | ||||||
|  |                           return -1; | ||||||
|  |                         } | ||||||
|  |  | ||||||
|                         WebRtcIsac_ReadBwIndex((WebRtc_Word16*)streamDataTransCoding, &indexStream); |                         WebRtcIsac_ReadBwIndex((WebRtc_Word16*)streamDataTransCoding, &indexStream); | ||||||
|                         if(indexStream != bnIdxTC) |                         if(indexStream != bnIdxTC) | ||||||
| @@ -939,12 +948,18 @@ int main(int argc, char* argv[]) | |||||||
|         /* Write decoded speech frame to file */ |         /* Write decoded speech frame to file */ | ||||||
|         if((declen > 0) && (numFileLoop == 0)) |         if((declen > 0) && (numFileLoop == 0)) | ||||||
|         { |         { | ||||||
|             fwrite(decoded, sizeof(WebRtc_Word16), declen, outp); |           if (fwrite(decoded, sizeof(WebRtc_Word16), declen, | ||||||
|  |                      outp) != static_cast<size_t>(declen)) { | ||||||
|  |             return -1; | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if((declenTC > 0) && (numFileLoop == 0)) |         if((declenTC > 0) && (numFileLoop == 0)) | ||||||
|         { |         { | ||||||
|             fwrite(decodedTC, sizeof(WebRtc_Word16), declen, transCodingFile); |           if (fwrite(decodedTC, sizeof(WebRtc_Word16), declen, | ||||||
|  |                      transCodingFile) != static_cast<size_t>(declen)) { | ||||||
|  |             return -1; | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /* | /* | ||||||
|  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | ||||||
|  * |  * | ||||||
|  *  Use of this source code is governed by a BSD-style license |  *  Use of this source code is governed by a BSD-style license | ||||||
|  *  that can be found in the LICENSE file in the root of the source |  *  that can be found in the LICENSE file in the root of the source | ||||||
| @@ -392,13 +392,19 @@ int main(int argc, char* argv[]) | |||||||
|         // Write the arrival time. |         // Write the arrival time. | ||||||
|         if(senderIdx == 0) |         if(senderIdx == 0) | ||||||
|         { |         { | ||||||
|           fwrite(&(packetData[senderIdx]->arrival_time), sizeof(unsigned int), 1, |           if (fwrite(&(packetData[senderIdx]->arrival_time), | ||||||
|                  arrivalTimeFile1); |                      sizeof(unsigned int), | ||||||
|  |                      1, arrivalTimeFile1) != 1) { | ||||||
|  |             return -1; | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|           fwrite(&(packetData[senderIdx]->arrival_time), sizeof(unsigned int), 1, |           if (fwrite(&(packetData[senderIdx]->arrival_time), | ||||||
|                  arrivalTimeFile2); |                      sizeof(unsigned int), | ||||||
|  |                      1, arrivalTimeFile2) != 1) { | ||||||
|  |             return -1; | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // BWE |         // BWE | ||||||
| @@ -426,13 +432,19 @@ int main(int argc, char* argv[]) | |||||||
|         { |         { | ||||||
|           WebRtcSpl_UpsampleBy2(audioBuff60ms, lenDecodedAudio, resampledAudio60ms, |           WebRtcSpl_UpsampleBy2(audioBuff60ms, lenDecodedAudio, resampledAudio60ms, | ||||||
|                                 resamplerState[receiverIdx]); |                                 resamplerState[receiverIdx]); | ||||||
|           fwrite(resampledAudio60ms, sizeof(short), lenDecodedAudio << 1, |           if (fwrite(resampledAudio60ms, sizeof(short), lenDecodedAudio << 1, | ||||||
|                  outFile[receiverIdx]); |                      outFile[receiverIdx]) != | ||||||
|  |               static_cast<size_t>(lenDecodedAudio << 1)) { | ||||||
|  |             return -1; | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|           fwrite(audioBuff60ms, sizeof(short), lenDecodedAudio, |           if (fwrite(audioBuff60ms, sizeof(short), lenDecodedAudio, | ||||||
|                  outFile[receiverIdx]); |                      outFile[receiverIdx]) != | ||||||
|  |               static_cast<size_t>(lenDecodedAudio)) { | ||||||
|  |             return -1; | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|         num10ms[senderIdx] = 0; |         num10ms[senderIdx] = 0; | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /* | /* | ||||||
|  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | ||||||
|  * |  * | ||||||
|  *  Use of this source code is governed by a BSD-style license |  *  Use of this source code is governed by a BSD-style license | ||||||
|  *  that can be found in the LICENSE file in the root of the source |  *  that can be found in the LICENSE file in the root of the source | ||||||
| @@ -429,13 +429,20 @@ valid values are 8 and 16.\n", sampFreqKHz); | |||||||
|  |  | ||||||
| 		if(onlyEncode) | 		if(onlyEncode) | ||||||
| 		{ | 		{ | ||||||
| 			WebRtc_UWord8 auxUW8; |                   WebRtc_UWord8 auxUW8; | ||||||
| 			auxUW8 = (WebRtc_UWord8)(((stream_len & 0x7F00) >> 8) & 0xFF); |                   auxUW8 = (WebRtc_UWord8)(((stream_len & 0x7F00) >> 8) & 0xFF); | ||||||
| 			fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, outp); |                   if (fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, outp) != 1) { | ||||||
|  |                     return -1; | ||||||
|  |                   } | ||||||
|  |  | ||||||
| 			auxUW8 = (WebRtc_UWord8)(stream_len & 0xFF); |                   auxUW8 = (WebRtc_UWord8)(stream_len & 0xFF); | ||||||
| 			fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, outp); |                   if (fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, outp) != 1) { | ||||||
| 			fwrite(payload, 1, stream_len, outp); |                     return -1; | ||||||
|  |                   } | ||||||
|  |                   if (fwrite(payload, 1, stream_len, | ||||||
|  |                              outp) != (size_t)stream_len) { | ||||||
|  |                     return -1; | ||||||
|  |                   } | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| 		{ | 		{ | ||||||
| @@ -462,7 +469,10 @@ valid values are 8 and 16.\n", sampFreqKHz); | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			// Write decoded speech frame to file | 			// Write decoded speech frame to file | ||||||
| 			fwrite(decoded, sizeof(WebRtc_Word16), declen, outp); |                         if (fwrite(decoded, sizeof(WebRtc_Word16), | ||||||
|  |                                    declen, outp) != (size_t)declen) { | ||||||
|  |                           return -1; | ||||||
|  |                         } | ||||||
| 			cur_framesmpls = declen; | 			cur_framesmpls = declen; | ||||||
| 		} | 		} | ||||||
|         // Update Statistics |         // Update Statistics | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /* | /* | ||||||
|  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | ||||||
|  * |  * | ||||||
|  *  Use of this source code is governed by a BSD-style license |  *  Use of this source code is governed by a BSD-style license | ||||||
|  *  that can be found in the LICENSE file in the root of the source |  *  that can be found in the LICENSE file in the root of the source | ||||||
| @@ -168,7 +168,11 @@ int main(int argc, char* argv[]) | |||||||
|  |  | ||||||
|     /* write byte file */ |     /* write byte file */ | ||||||
|  |  | ||||||
|     fwrite(encoded_data, sizeof(WebRtc_Word16), ((len+1)/sizeof(WebRtc_Word16)), efileid); |     if (fwrite(encoded_data, sizeof(WebRtc_Word16), | ||||||
|  |                ((len+1)/sizeof(WebRtc_Word16)), efileid) != | ||||||
|  |         (size_t)(((len+1)/sizeof(WebRtc_Word16)))) { | ||||||
|  |       return -1; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /* get channel data if provided */ |     /* get channel data if provided */ | ||||||
|     if (argc==6) { |     if (argc==6) { | ||||||
| @@ -204,7 +208,10 @@ int main(int argc, char* argv[]) | |||||||
|  |  | ||||||
|     /* write output file */ |     /* write output file */ | ||||||
|  |  | ||||||
|     fwrite(decoded_data,sizeof(WebRtc_Word16),len,ofileid); |     if (fwrite(decoded_data, sizeof(WebRtc_Word16), len, | ||||||
|  |                ofileid) != (size_t)len) { | ||||||
|  |       return -1; | ||||||
|  |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /* close files */ |   /* close files */ | ||||||
|   | |||||||
| @@ -431,9 +431,16 @@ WebRtc_Word32 AudioCodingModuleImpl::Process() { | |||||||
|     CriticalSectionScoped lock(*_callbackCritSect); |     CriticalSectionScoped lock(*_callbackCritSect); | ||||||
| #ifdef ACM_QA_TEST | #ifdef ACM_QA_TEST | ||||||
|     if(_outgoingPL != NULL) { |     if(_outgoingPL != NULL) { | ||||||
|       fwrite(&rtp_timestamp, sizeof(WebRtc_UWord32), 1, _outgoingPL); |       if (fwrite(&rtp_timestamp, sizeof(WebRtc_UWord32), 1, _outgoingPL) != 1) { | ||||||
|       fwrite(¤t_payload_type, sizeof(WebRtc_UWord8), 1, _outgoingPL); |         return -1; | ||||||
|       fwrite(&length_bytes, sizeof(WebRtc_Word16), 1, _outgoingPL); |       } | ||||||
|  |       if (fwrite(¤t_payload_type, sizeof(WebRtc_UWord8), | ||||||
|  |                  1, _outgoingPL) != 1) { | ||||||
|  |         return -1; | ||||||
|  |       } | ||||||
|  |       if (fwrite(&length_bytes, sizeof(WebRtc_Word16), 1, _outgoingPL) != 1) { | ||||||
|  |         return -1; | ||||||
|  |       } | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -1489,11 +1496,18 @@ WebRtc_Word32 AudioCodingModuleImpl::IncomingPacket( | |||||||
|     CriticalSectionScoped lock(*_acmCritSect); |     CriticalSectionScoped lock(*_acmCritSect); | ||||||
| #ifdef ACM_QA_TEST | #ifdef ACM_QA_TEST | ||||||
|     if(_incomingPL != NULL) { |     if(_incomingPL != NULL) { | ||||||
|       fwrite(&rtp_info.header.timestamp, sizeof(WebRtc_UWord32), 1, |       if (fwrite(&rtp_info.header.timestamp, sizeof(WebRtc_UWord32), | ||||||
|              _incomingPL); |                  1, _incomingPL) != 1) { | ||||||
|       fwrite(&rtp_info.header.payloadType, sizeof(WebRtc_UWord8), 1, |         return -1; | ||||||
|              _incomingPL); |       } | ||||||
|       fwrite(&payload_length, sizeof(WebRtc_Word16), 1, _incomingPL); |       if (fwrite(&rtp_info.header.payloadType, sizeof(WebRtc_UWord8), | ||||||
|  |                  1, _incomingPL) != 1) { | ||||||
|  |         return -1; | ||||||
|  |       } | ||||||
|  |       if (fwrite(&payload_length, sizeof(WebRtc_Word16), | ||||||
|  |                  1, _incomingPL) != 1) { | ||||||
|  |         return -1; | ||||||
|  |       } | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   | |||||||
| @@ -181,8 +181,11 @@ WebRtc_Word32 PCMFile::Read10MsData(AudioFrame& audio_frame) { | |||||||
| void PCMFile::Write10MsData(AudioFrame& audio_frame) { | void PCMFile::Write10MsData(AudioFrame& audio_frame) { | ||||||
|   if (audio_frame.num_channels_ == 1) { |   if (audio_frame.num_channels_ == 1) { | ||||||
|     if (!save_stereo_) { |     if (!save_stereo_) { | ||||||
|       fwrite(audio_frame.data_, sizeof(WebRtc_UWord16), |       if (fwrite(audio_frame.data_, sizeof(WebRtc_UWord16), | ||||||
|              audio_frame.samples_per_channel_, pcm_file_); |                  audio_frame.samples_per_channel_, pcm_file_) != | ||||||
|  |           static_cast<size_t>(audio_frame.samples_per_channel_)) { | ||||||
|  |         return; | ||||||
|  |       } | ||||||
|     } else { |     } else { | ||||||
|       WebRtc_Word16* stereo_audio = |       WebRtc_Word16* stereo_audio = | ||||||
|           new WebRtc_Word16[2 * audio_frame.samples_per_channel_]; |           new WebRtc_Word16[2 * audio_frame.samples_per_channel_]; | ||||||
| @@ -191,20 +194,29 @@ void PCMFile::Write10MsData(AudioFrame& audio_frame) { | |||||||
|         stereo_audio[k << 1] = audio_frame.data_[k]; |         stereo_audio[k << 1] = audio_frame.data_[k]; | ||||||
|         stereo_audio[(k << 1) + 1] = audio_frame.data_[k]; |         stereo_audio[(k << 1) + 1] = audio_frame.data_[k]; | ||||||
|       } |       } | ||||||
|       fwrite(stereo_audio, sizeof(WebRtc_Word16), |       if (fwrite(stereo_audio, sizeof(WebRtc_Word16), | ||||||
|              2 * audio_frame.samples_per_channel_, pcm_file_); |                  2 * audio_frame.samples_per_channel_, pcm_file_) != | ||||||
|  |           static_cast<size_t>(2 * audio_frame.samples_per_channel_)) { | ||||||
|  |         return; | ||||||
|  |       } | ||||||
|       delete[] stereo_audio; |       delete[] stereo_audio; | ||||||
|     } |     } | ||||||
|   } else { |   } else { | ||||||
|     fwrite(audio_frame.data_, sizeof(WebRtc_Word16), |     if (fwrite(audio_frame.data_, sizeof(WebRtc_Word16), | ||||||
|            audio_frame.num_channels_ * audio_frame.samples_per_channel_, |                audio_frame.num_channels_ * audio_frame.samples_per_channel_, | ||||||
|            pcm_file_); |                pcm_file_) != static_cast<size_t>( | ||||||
|  |             audio_frame.num_channels_ * audio_frame.samples_per_channel_)) { | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| void PCMFile::Write10MsData(WebRtc_Word16* playout_buffer, | void PCMFile::Write10MsData(WebRtc_Word16* playout_buffer, | ||||||
|                             WebRtc_UWord16 length_smpls) { |                             WebRtc_UWord16 length_smpls) { | ||||||
|   fwrite(playout_buffer, sizeof(WebRtc_UWord16), length_smpls, pcm_file_); |   if (fwrite(playout_buffer, sizeof(WebRtc_UWord16), | ||||||
|  |              length_smpls, pcm_file_) != length_smpls) { | ||||||
|  |     return; | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| void PCMFile::Close() { | void PCMFile::Close() { | ||||||
|   | |||||||
| @@ -165,12 +165,23 @@ void RTPFile::WriteHeader() | |||||||
| { | { | ||||||
|     // Write data in a format that NetEQ and RTP Play can parse |     // Write data in a format that NetEQ and RTP Play can parse | ||||||
|     fprintf(_rtpFile, "#!RTPencode%s\n", "1.0"); |     fprintf(_rtpFile, "#!RTPencode%s\n", "1.0"); | ||||||
|     WebRtc_UWord32 dummy_variable = 0; // should be converted to network endian format, but does not matter when 0 |     WebRtc_UWord32 dummy_variable = 0; | ||||||
|     fwrite(&dummy_variable, 4, 1, _rtpFile); |     // should be converted to network endian format, but does not matter when 0 | ||||||
|     fwrite(&dummy_variable, 4, 1, _rtpFile); |     if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) { | ||||||
|     fwrite(&dummy_variable, 4, 1, _rtpFile); |       return; | ||||||
|     fwrite(&dummy_variable, 2, 1, _rtpFile); |     } | ||||||
|     fwrite(&dummy_variable, 2, 1, _rtpFile); |     if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) { | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|  |     if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) { | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|  |     if (fwrite(&dummy_variable, 2, 1, _rtpFile) != 1) { | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|  |     if (fwrite(&dummy_variable, 2, 1, _rtpFile) != 1) { | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|     fflush(_rtpFile); |     fflush(_rtpFile); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -205,11 +216,21 @@ void RTPFile::Write(const WebRtc_UWord8 payloadType, const WebRtc_UWord32 timeSt | |||||||
|  |  | ||||||
|     offsetMs = (timeStamp/(frequency/1000)); |     offsetMs = (timeStamp/(frequency/1000)); | ||||||
|     offsetMs = htonl(offsetMs); |     offsetMs = htonl(offsetMs); | ||||||
|     fwrite(&lengthBytes, 2, 1, _rtpFile); |     if (fwrite(&lengthBytes, 2, 1, _rtpFile) != 1) { | ||||||
|     fwrite(&plen, 2, 1, _rtpFile); |       return; | ||||||
|     fwrite(&offsetMs, 4, 1, _rtpFile); |     } | ||||||
|     fwrite(rtpHeader, 12, 1, _rtpFile); |     if (fwrite(&plen, 2, 1, _rtpFile) != 1) { | ||||||
|     fwrite(payloadData, 1, payloadSize, _rtpFile); |       return; | ||||||
|  |     } | ||||||
|  |     if (fwrite(&offsetMs, 4, 1, _rtpFile) != 1) { | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|  |     if (fwrite(rtpHeader, 12, 1, _rtpFile) != 1) { | ||||||
|  |       return; | ||||||
|  |     } | ||||||
|  |     if (fwrite(payloadData, 1, payloadSize, _rtpFile) != payloadSize) { | ||||||
|  |       return; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| WebRtc_UWord16 RTPFile::Read(WebRtcRTPHeader* rtpInfo, | WebRtc_UWord16 RTPFile::Read(WebRtcRTPHeader* rtpInfo, | ||||||
|   | |||||||
| @@ -378,7 +378,9 @@ WebRtc_Word16 WebRtcNetEQ_CalcOptimalBufLvl(AutomodeInst_t *inst, WebRtc_Word32 | |||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|     /* special code for offline delay logging */ |     /* special code for offline delay logging */ | ||||||
|     temp_var = NETEQ_DELAY_LOGGING_SIGNAL_OPTBUF; |     temp_var = NETEQ_DELAY_LOGGING_SIGNAL_OPTBUF; | ||||||
|     fwrite( &temp_var, sizeof(int), 1, delay_fid2 ); |     if (fwrite( &temp_var, sizeof(int), 1, delay_fid2 ) != 1) { | ||||||
|  |       return -1; | ||||||
|  |     } | ||||||
|     temp_var = (int) (Bopt * inst->packetSpeechLenSamp); |     temp_var = (int) (Bopt * inst->packetSpeechLenSamp); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -518,7 +520,9 @@ WebRtc_Word16 WebRtcNetEQ_CalcOptimalBufLvl(AutomodeInst_t *inst, WebRtc_Word32 | |||||||
|  |  | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|     /* special code for offline delay logging */ |     /* special code for offline delay logging */ | ||||||
|     fwrite( &temp_var, sizeof(int), 1, delay_fid2 ); |     if (fwrite( &temp_var, sizeof(int), 1, delay_fid2 ) != 1) { | ||||||
|  |       return -1; | ||||||
|  |     } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     /* Sanity check: Bopt must be strictly positive */ |     /* Sanity check: Bopt must be strictly positive */ | ||||||
|   | |||||||
| @@ -317,14 +317,23 @@ int WebRtcNetEQ_PacketBufferInsert(PacketBuf_t *bufferInst, const RTPPacket_t *R | |||||||
|     if (*flushed) |     if (*flushed) | ||||||
|     { |     { | ||||||
|         temp_var = NETEQ_DELAY_LOGGING_SIGNAL_FLUSH; |         temp_var = NETEQ_DELAY_LOGGING_SIGNAL_FLUSH; | ||||||
|         fwrite( &temp_var, sizeof(int), 1, delay_fid2 ); |         if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |           return -1; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|     temp_var = NETEQ_DELAY_LOGGING_SIGNAL_RECIN; |     temp_var = NETEQ_DELAY_LOGGING_SIGNAL_RECIN; | ||||||
|     fwrite( &temp_var, sizeof(int), 1, delay_fid2 ); |     if ((fwrite(&temp_var, sizeof(int), | ||||||
|     fwrite( &RTPpacket->timeStamp, sizeof(WebRtc_UWord32), 1, delay_fid2 ); |                 1, delay_fid2) != 1) || | ||||||
|     fwrite( &RTPpacket->seqNumber, sizeof(WebRtc_UWord16), 1, delay_fid2 ); |         (fwrite(&RTPpacket->timeStamp, sizeof(WebRtc_UWord32), | ||||||
|     fwrite( &RTPpacket->payloadType, sizeof(int), 1, delay_fid2 ); |                 1, delay_fid2) != 1) || | ||||||
|     fwrite( &RTPpacket->payloadLen, sizeof(WebRtc_Word16), 1, delay_fid2 ); |         (fwrite(&RTPpacket->seqNumber, sizeof(WebRtc_UWord16), | ||||||
|  |                 1, delay_fid2) != 1) || | ||||||
|  |         (fwrite(&RTPpacket->payloadType, sizeof(int), | ||||||
|  |                 1, delay_fid2) != 1) || | ||||||
|  |         (fwrite(&RTPpacket->payloadLen, sizeof(WebRtc_Word16), | ||||||
|  |                 1, delay_fid2) != 1)) { | ||||||
|  |       return -1; | ||||||
|  |     } | ||||||
|     tot_received_packets++; |     tot_received_packets++; | ||||||
| #endif /* NETEQ_DELAY_LOGGING */ | #endif /* NETEQ_DELAY_LOGGING */ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -318,8 +318,12 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | |||||||
|             } |             } | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_CHANGE_FS; |             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_CHANGE_FS; | ||||||
|             fwrite(&temp_var, sizeof(int), 1, delay_fid2); |             if ((fwrite(&temp_var, sizeof(int), | ||||||
|             fwrite(&inst->fs, sizeof(WebRtc_UWord16), 1, delay_fid2); |                         1, delay_fid2) != 1) || | ||||||
|  |                 (fwrite(&inst->fs, sizeof(WebRtc_UWord16), | ||||||
|  |                         1, delay_fid2) != 1)) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
| #endif | #endif | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -508,9 +512,17 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | |||||||
|                 pw16_decoded_buffer, &speechType); |                 pw16_decoded_buffer, &speechType); | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_DECODE_ONE_DESC; |             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_DECODE_ONE_DESC; | ||||||
|             fwrite(&temp_var, sizeof(int), 1, delay_fid2); |             if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|             fwrite(&inst->endTimestamp, sizeof(WebRtc_UWord32), 1, delay_fid2); |               return -1; | ||||||
|             fwrite(&dspInfo->samplesLeft, sizeof(WebRtc_UWord16), 1, delay_fid2); |             } | ||||||
|  |             if (fwrite(&inst->endTimestamp, sizeof(WebRtc_UWord32), | ||||||
|  |                        1, delay_fid2) != 1) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
|  |             if (fwrite(&dspInfo->samplesLeft, sizeof(WebRtc_UWord16), | ||||||
|  |                        1, delay_fid2) != 1) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
|             tot_received_packets++; |             tot_received_packets++; | ||||||
| #endif | #endif | ||||||
|         } |         } | ||||||
| @@ -692,7 +704,9 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | |||||||
|         case DSP_INSTR_MERGE: |         case DSP_INSTR_MERGE: | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_MERGE_INFO; |             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_MERGE_INFO; | ||||||
|             fwrite(&temp_var, sizeof(int), 1, delay_fid2); |             if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
|             temp_var = -len; |             temp_var = -len; | ||||||
| #endif | #endif | ||||||
|             /* Call Merge with history*/ |             /* Call Merge with history*/ | ||||||
| @@ -710,7 +724,9 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | |||||||
|  |  | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|             temp_var += len; |             temp_var += len; | ||||||
|             fwrite(&temp_var, sizeof(int), 1, delay_fid2); |             if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
| #endif | #endif | ||||||
|             /* If last packet was decoded as a inband CNG set mode to CNG instead */ |             /* If last packet was decoded as a inband CNG set mode to CNG instead */ | ||||||
|             if (speechType == TYPE_CNG) inst->w16_mode = MODE_CODEC_INTERNAL_CNG; |             if (speechType == TYPE_CNG) inst->w16_mode = MODE_CODEC_INTERNAL_CNG; | ||||||
| @@ -756,9 +772,13 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | |||||||
|                 inst->w16_concealedTS += len; |                 inst->w16_concealedTS += len; | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|                 temp_var = NETEQ_DELAY_LOGGING_SIGNAL_EXPAND_INFO; |                 temp_var = NETEQ_DELAY_LOGGING_SIGNAL_EXPAND_INFO; | ||||||
|                 fwrite(&temp_var, sizeof(int), 1, delay_fid2); |                 if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |                   return -1; | ||||||
|  |                 } | ||||||
|                 temp_var = len; |                 temp_var = len; | ||||||
|                 fwrite(&temp_var, sizeof(int), 1, delay_fid2); |                 if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |                   return -1; | ||||||
|  |                 } | ||||||
| #endif | #endif | ||||||
|                 len = 0; /* already written the data, so do not write it again further down. */ |                 len = 0; /* already written the data, so do not write it again further down. */ | ||||||
|             } |             } | ||||||
| @@ -812,9 +832,13 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | |||||||
|                     inst->curPosition += (borrowedSamples - len); |                     inst->curPosition += (borrowedSamples - len); | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|                     temp_var = NETEQ_DELAY_LOGGING_SIGNAL_ACCELERATE_INFO; |                     temp_var = NETEQ_DELAY_LOGGING_SIGNAL_ACCELERATE_INFO; | ||||||
|                     fwrite(&temp_var, sizeof(int), 1, delay_fid2); |                     if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |                       return -1; | ||||||
|  |                     } | ||||||
|                     temp_var = 3 * inst->timestampsPerCall - len; |                     temp_var = 3 * inst->timestampsPerCall - len; | ||||||
|                     fwrite(&temp_var, sizeof(int), 1, delay_fid2); |                     if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |                       return -1; | ||||||
|  |                     } | ||||||
| #endif | #endif | ||||||
|                     len = 0; |                     len = 0; | ||||||
|                 } |                 } | ||||||
| @@ -827,9 +851,13 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | |||||||
|                                            (len-borrowedSamples)); |                                            (len-borrowedSamples)); | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|                     temp_var = NETEQ_DELAY_LOGGING_SIGNAL_ACCELERATE_INFO; |                     temp_var = NETEQ_DELAY_LOGGING_SIGNAL_ACCELERATE_INFO; | ||||||
|                     fwrite(&temp_var, sizeof(int), 1, delay_fid2); |                     if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |                       return -1; | ||||||
|  |                     } | ||||||
|                     temp_var = 3 * inst->timestampsPerCall - len; |                     temp_var = 3 * inst->timestampsPerCall - len; | ||||||
|                     fwrite(&temp_var, sizeof(int), 1, delay_fid2); |                     if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |                       return -1; | ||||||
|  |                     } | ||||||
| #endif | #endif | ||||||
|                     len = len - borrowedSamples; |                     len = len - borrowedSamples; | ||||||
|                 } |                 } | ||||||
| @@ -839,7 +867,9 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | |||||||
|             { |             { | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|                 temp_var = NETEQ_DELAY_LOGGING_SIGNAL_ACCELERATE_INFO; |                 temp_var = NETEQ_DELAY_LOGGING_SIGNAL_ACCELERATE_INFO; | ||||||
|                 fwrite(&temp_var, sizeof(int), 1, delay_fid2); |                 if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |                   return -1; | ||||||
|  |                 } | ||||||
|                 temp_var = len; |                 temp_var = len; | ||||||
| #endif | #endif | ||||||
|                 return_value = WebRtcNetEQ_Accelerate(inst, |                 return_value = WebRtcNetEQ_Accelerate(inst, | ||||||
| @@ -856,7 +886,9 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | |||||||
|  |  | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|                 temp_var -= len; |                 temp_var -= len; | ||||||
|                 fwrite(&temp_var, sizeof(int), 1, delay_fid2); |                 if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |                   return -1; | ||||||
|  |                 } | ||||||
| #endif | #endif | ||||||
|             } |             } | ||||||
|             /* If last packet was decoded as a inband CNG set mode to CNG instead */ |             /* If last packet was decoded as a inband CNG set mode to CNG instead */ | ||||||
| @@ -1147,9 +1179,13 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | |||||||
|  |  | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_PREEMPTIVE_INFO; |             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_PREEMPTIVE_INFO; | ||||||
|             fwrite(&temp_var, sizeof(int), 1, delay_fid2); |             if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
|             temp_var = len - w16_tmp1; /* number of samples added */ |             temp_var = len - w16_tmp1; /* number of samples added */ | ||||||
|             fwrite(&temp_var, sizeof(int), 1, delay_fid2); |             if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
| #endif | #endif | ||||||
|             /* If last packet was decoded as inband CNG, set mode to CNG instead */ |             /* If last packet was decoded as inband CNG, set mode to CNG instead */ | ||||||
|             if (speechType == TYPE_CNG) inst->w16_mode = MODE_CODEC_INTERNAL_CNG; |             if (speechType == TYPE_CNG) inst->w16_mode = MODE_CODEC_INTERNAL_CNG; | ||||||
| @@ -1256,9 +1292,13 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | |||||||
|             inst->w16_mode = MODE_FADE_TO_BGN; |             inst->w16_mode = MODE_FADE_TO_BGN; | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_EXPAND_INFO; |             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_EXPAND_INFO; | ||||||
|             fwrite(&temp_var, sizeof(int), 1, delay_fid2); |             if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
|             temp_var = len; |             temp_var = len; | ||||||
|             fwrite(&temp_var, sizeof(int), 1, delay_fid2); |             if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|             break; |             break; | ||||||
|   | |||||||
| @@ -646,9 +646,14 @@ int WebRtcNetEQ_SignalMcu(MCUInst_t *inst) | |||||||
|  |  | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_DECODE; |             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_DECODE; | ||||||
|             fwrite(&temp_var,sizeof(int),1,delay_fid2); |             if ((fwrite(&temp_var, sizeof(int), | ||||||
|             fwrite(&temp_pkt.timeStamp,sizeof(WebRtc_UWord32),1,delay_fid2); |                         1, delay_fid2) != 1) || | ||||||
|             fwrite(&dspInfo.samplesLeft, sizeof(WebRtc_UWord16), 1, delay_fid2); |                 (fwrite(&temp_pkt.timeStamp, sizeof(WebRtc_UWord32), | ||||||
|  |                         1, delay_fid2) != 1) || | ||||||
|  |                 (fwrite(&dspInfo.samplesLeft, sizeof(WebRtc_UWord16), | ||||||
|  |                         1, delay_fid2) != 1)) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|             *blockPtr = temp_pkt.payloadLen; |             *blockPtr = temp_pkt.payloadLen; | ||||||
| @@ -762,4 +767,3 @@ int WebRtcNetEQ_SignalMcu(MCUInst_t *inst) | |||||||
|     return 0; |     return 0; | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -561,8 +561,12 @@ int main(int argc, char* argv[]) | |||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|         temp_var = NETEQ_DELAY_LOGGING_SIGNAL_CLOCK; |         temp_var = NETEQ_DELAY_LOGGING_SIGNAL_CLOCK; | ||||||
|         clock_float = (float) simClock; |         clock_float = (float) simClock; | ||||||
|         fwrite(&temp_var,sizeof(int),1,delay_fid2); |         if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|         fwrite(&clock_float, sizeof(float),1,delay_fid2); |           return -1; | ||||||
|  |         } | ||||||
|  |         if (fwrite(&clock_float, sizeof(float), 1, delay_fid2) != 1) { | ||||||
|  |           return -1; | ||||||
|  |         } | ||||||
| #endif | #endif | ||||||
|         /* time to set extra delay */ |         /* time to set extra delay */ | ||||||
|         if (extraDelay > -1 && simClock >= nextExtraDelayTime) { |         if (extraDelay > -1 && simClock >= nextExtraDelayTime) { | ||||||
| @@ -657,7 +661,9 @@ int main(int argc, char* argv[]) | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             // write to file |             // write to file | ||||||
|             fwrite(out_data,writeLen,2,out_file); |             if (fwrite(out_data, writeLen, 2, out_file) != 2) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
|             writtenSamples += writeLen; |             writtenSamples += writeLen; | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -678,8 +684,13 @@ int main(int argc, char* argv[]) | |||||||
|  |  | ||||||
| #ifdef NETEQ_DELAY_LOGGING | #ifdef NETEQ_DELAY_LOGGING | ||||||
|     temp_var = NETEQ_DELAY_LOGGING_SIGNAL_EOF; |     temp_var = NETEQ_DELAY_LOGGING_SIGNAL_EOF; | ||||||
|     fwrite(&temp_var,sizeof(int),1,delay_fid2); |     if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||||
|     fwrite(&tot_received_packets,sizeof(WebRtc_UWord32),1,delay_fid2); |       return -1; | ||||||
|  |     } | ||||||
|  |     if (fwrite(&tot_received_packets, sizeof(WebRtc_UWord32), | ||||||
|  |                1, delay_fid2) != 1) { | ||||||
|  |       return -1; | ||||||
|  |     } | ||||||
|     fprintf(delay_fid2,"End of file\n"); |     fprintf(delay_fid2,"End of file\n"); | ||||||
|     fclose(delay_fid2); |     fclose(delay_fid2); | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -252,7 +252,7 @@ int main(int argc, char* argv[]) | |||||||
| 	WebRtc_Word16 seqNo=0xFFF; | 	WebRtc_Word16 seqNo=0xFFF; | ||||||
| 	WebRtc_UWord32 ssrc=1235412312; | 	WebRtc_UWord32 ssrc=1235412312; | ||||||
| 	WebRtc_UWord32 timestamp=0xAC1245; | 	WebRtc_UWord32 timestamp=0xAC1245; | ||||||
| 	WebRtc_UWord16 length, plen; |         WebRtc_UWord16 length, plen; | ||||||
| 	WebRtc_UWord32 offset; | 	WebRtc_UWord32 offset; | ||||||
| 	double sendtime = 0; | 	double sendtime = 0; | ||||||
|     int red_PT[2] = {0}; |     int red_PT[2] = {0}; | ||||||
| @@ -547,11 +547,21 @@ int main(int argc, char* argv[]) | |||||||
| 	//fprintf(out_file, "#!RTPencode%s\n", "1.0"); | 	//fprintf(out_file, "#!RTPencode%s\n", "1.0"); | ||||||
| 	fprintf(out_file, "#!rtpplay%s \n", "1.0"); // this is the string that rtpplay needs | 	fprintf(out_file, "#!rtpplay%s \n", "1.0"); // this is the string that rtpplay needs | ||||||
| 	WebRtc_UWord32 dummy_variable = 0; // should be converted to network endian format, but does not matter when 0 | 	WebRtc_UWord32 dummy_variable = 0; // should be converted to network endian format, but does not matter when 0 | ||||||
| 	fwrite(&dummy_variable, 4, 1, out_file); |         if (fwrite(&dummy_variable, 4, 1, out_file) != 1) { | ||||||
| 	fwrite(&dummy_variable, 4, 1, out_file); |           return -1; | ||||||
| 	fwrite(&dummy_variable, 4, 1, out_file); |         } | ||||||
| 	fwrite(&dummy_variable, 2, 1, out_file); |         if (fwrite(&dummy_variable, 4, 1, out_file) != 1) { | ||||||
| 	fwrite(&dummy_variable, 2, 1, out_file); |           return -1; | ||||||
|  |         } | ||||||
|  |         if (fwrite(&dummy_variable, 4, 1, out_file) != 1) { | ||||||
|  |           return -1; | ||||||
|  |         } | ||||||
|  |         if (fwrite(&dummy_variable, 2, 1, out_file) != 1) { | ||||||
|  |           return -1; | ||||||
|  |         } | ||||||
|  |         if (fwrite(&dummy_variable, 2, 1, out_file) != 1) { | ||||||
|  |           return -1; | ||||||
|  |         } | ||||||
|  |  | ||||||
| #ifdef TIMESTAMP_WRAPAROUND | #ifdef TIMESTAMP_WRAPAROUND | ||||||
| 	timestamp = 0xFFFFFFFF - fs*10; /* should give wrap-around in 10 seconds */ | 	timestamp = 0xFFFFFFFF - fs*10; /* should give wrap-around in 10 seconds */ | ||||||
| @@ -600,10 +610,18 @@ int main(int argc, char* argv[]) | |||||||
|             plen = htons(12 + enc_len); |             plen = htons(12 + enc_len); | ||||||
|             offset = (WebRtc_UWord32) sendtime; //(timestamp/(fs/1000)); |             offset = (WebRtc_UWord32) sendtime; //(timestamp/(fs/1000)); | ||||||
|             offset = htonl(offset); |             offset = htonl(offset); | ||||||
|             fwrite(&length, 2, 1, out_file); |             if (fwrite(&length, 2, 1, out_file) != 1) { | ||||||
|             fwrite(&plen, 2, 1, out_file); |               return -1; | ||||||
|             fwrite(&offset, 4, 1, out_file); |             } | ||||||
|             fwrite(rtp_data, 12 + enc_len, 1, out_file); |             if (fwrite(&plen, 2, 1, out_file) != 1) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
|  |             if (fwrite(&offset, 4, 1, out_file) != 1) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
|  |             if (fwrite(rtp_data, 12 + enc_len, 1, out_file) != 1) { | ||||||
|  |               return -1; | ||||||
|  |             } | ||||||
|  |  | ||||||
|             dtmfSent = true; |             dtmfSent = true; | ||||||
|         } |         } | ||||||
| @@ -683,13 +701,20 @@ int main(int argc, char* argv[]) | |||||||
| 			do { | 			do { | ||||||
| #endif //MULTIPLE_SAME_TIMESTAMP | #endif //MULTIPLE_SAME_TIMESTAMP | ||||||
| 			/* write RTP packet to file */ | 			/* write RTP packet to file */ | ||||||
| 			length = htons(12 + enc_len + 8); |                           length = htons(12 + enc_len + 8); | ||||||
| 			plen = htons(12 + enc_len); |                           plen = htons(12 + enc_len); | ||||||
| 			offset = (WebRtc_UWord32) sendtime; //(timestamp/(fs/1000)); |                           offset = (WebRtc_UWord32) sendtime; | ||||||
| 			offset = htonl(offset); |                           //(timestamp/(fs/1000)); | ||||||
| 			fwrite(&length, 2, 1, out_file); |                           offset = htonl(offset); | ||||||
| 			fwrite(&plen, 2, 1, out_file); |                           if (fwrite(&length, 2, 1, out_file) != 1) { | ||||||
| 			fwrite(&offset, 4, 1, out_file); |                             return -1; | ||||||
|  |                           } | ||||||
|  |                           if (fwrite(&plen, 2, 1, out_file) != 1) { | ||||||
|  |                             return -1; | ||||||
|  |                           } | ||||||
|  |                           if (fwrite(&offset, 4, 1, out_file) != 1) { | ||||||
|  |                             return -1; | ||||||
|  |                           } | ||||||
| #ifdef RANDOM_DATA | #ifdef RANDOM_DATA | ||||||
| 			for (int k=0; k<12+enc_len; k++) { | 			for (int k=0; k<12+enc_len; k++) { | ||||||
| 				rtp_data[k] = rand() + rand(); | 				rtp_data[k] = rand() + rand(); | ||||||
| @@ -700,7 +725,9 @@ int main(int argc, char* argv[]) | |||||||
| 				rtp_data[k] = rand() + rand(); | 				rtp_data[k] = rand() + rand(); | ||||||
| 			} | 			} | ||||||
| #endif | #endif | ||||||
| 			fwrite(rtp_data, 12 + enc_len, 1, out_file); |                         if (fwrite(rtp_data, 12 + enc_len, 1, out_file) != 1) { | ||||||
|  |                           return -1; | ||||||
|  |                         } | ||||||
| #ifdef MULTIPLE_SAME_TIMESTAMP | #ifdef MULTIPLE_SAME_TIMESTAMP | ||||||
| 			} while ( (seqNo%REPEAT_PACKET_DISTANCE == 0) && (mult_pack++ < REPEAT_PACKET_COUNT) ); | 			} while ( (seqNo%REPEAT_PACKET_DISTANCE == 0) && (mult_pack++ < REPEAT_PACKET_COUNT) ); | ||||||
| #endif //MULTIPLE_SAME_TIMESTAMP | #endif //MULTIPLE_SAME_TIMESTAMP | ||||||
| @@ -708,11 +735,23 @@ int main(int argc, char* argv[]) | |||||||
| #ifdef INSERT_OLD_PACKETS | #ifdef INSERT_OLD_PACKETS | ||||||
| 			if (packet_age >= OLD_PACKET*fs) { | 			if (packet_age >= OLD_PACKET*fs) { | ||||||
| 				if (!first_old_packet) { | 				if (!first_old_packet) { | ||||||
| 					// send the old packet |                                   // send the old packet | ||||||
| 					fwrite(&old_length, 2, 1, out_file); |                                   if (fwrite(&old_length, 2, 1, | ||||||
| 					fwrite(&old_plen, 2, 1, out_file); |                                              out_file) != 1) { | ||||||
| 					fwrite(&offset, 4, 1, out_file); |                                     return -1; | ||||||
| 					fwrite(old_rtp_data, 12 + old_enc_len, 1, out_file); |                                   } | ||||||
|  |                                   if (fwrite(&old_plen, 2, 1, | ||||||
|  |                                              out_file) != 1) { | ||||||
|  |                                     return -1; | ||||||
|  |                                   } | ||||||
|  |                                   if (fwrite(&offset, 4, 1, | ||||||
|  |                                              out_file) != 1) { | ||||||
|  |                                     return -1; | ||||||
|  |                                   } | ||||||
|  |                                   if (fwrite(old_rtp_data, 12 + old_enc_len, | ||||||
|  |                                              1, out_file) != 1) { | ||||||
|  |                                     return -1; | ||||||
|  |                                   } | ||||||
| 				} | 				} | ||||||
| 				// store current packet as old | 				// store current packet as old | ||||||
| 				old_length=length; | 				old_length=length; | ||||||
|   | |||||||
| @@ -167,7 +167,12 @@ int main(int argc, char* argv[]) | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			// write packet to file | 			// write packet to file | ||||||
| 			fwrite(temp_packet, sizeof(unsigned char), ntohs(*((WebRtc_UWord16*) temp_packet)), out_file); |                         if (fwrite(temp_packet, sizeof(unsigned char), | ||||||
|  |                                    ntohs(*((WebRtc_UWord16*) temp_packet)), | ||||||
|  |                                    out_file) != | ||||||
|  |                             ntohs(*((WebRtc_UWord16*) temp_packet))) { | ||||||
|  |                           return -1; | ||||||
|  |                         } | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 leozwang@webrtc.org
					leozwang@webrtc.org