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 | ||||
|  *  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); | ||||
|     } | ||||
|  | ||||
|      | ||||
|     static bool firstSilent=true; | ||||
|  | ||||
|     int numSamp=0; | ||||
| @@ -155,7 +154,6 @@ int main(int argc, char* argv[]) | ||||
|                     exit(EXIT_FAILURE); | ||||
|                 } | ||||
|  | ||||
|                  | ||||
|                 firstSilent=false; | ||||
|  | ||||
|                 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); | ||||
|  | ||||
|         } | ||||
|         fwrite(genSpeech,2,frameLen,outfile); | ||||
|         fwrite(state,2,frameLen,statefile); | ||||
|          | ||||
|         if (fwrite(genSpeech, 2, frameLen, | ||||
|                    outfile) != static_cast<size_t>(frameLen)) { | ||||
|           return -1; | ||||
|         } | ||||
|         if (fwrite(state, 2, frameLen, | ||||
|                    statefile) != static_cast<size_t>(frameLen)) { | ||||
|           return -1; | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     fclose(infile); | ||||
|     fclose(outfile); | ||||
|     fclose(statefile); | ||||
|     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 | ||||
|  *  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 */ | ||||
|             stream_len = WebRtcG711_EncodeA(NULL, shortdata, framelength, streamdata); | ||||
|             if (argc==6){ | ||||
|                 /* Write bits to file */ | ||||
|                 fwrite(streamdata,sizeof(unsigned char),stream_len,bitp); | ||||
|               /* Write bits to file */ | ||||
|               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); | ||||
|         } else if (!strcmp(law,"u")){ | ||||
|             /* u-law encoding */ | ||||
|             stream_len = WebRtcG711_EncodeU(NULL, shortdata, framelength, streamdata); | ||||
|             if (argc==6){ | ||||
|                 /* Write bits to file */ | ||||
|                 fwrite(streamdata,sizeof(unsigned char),stream_len,bitp); | ||||
|               /* Write bits to file */ | ||||
|               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); | ||||
|         } else { | ||||
| @@ -149,8 +155,11 @@ int main(int argc, char* argv[]) | ||||
|             /* exit if returned with error */ | ||||
|             printf("Error in encoder/decoder\n"); | ||||
|         } else { | ||||
|             /* Write coded speech to file */ | ||||
|             fwrite(decoded,sizeof(short),framelength,outp); | ||||
|           /* Write coded speech to file */ | ||||
|           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 | ||||
|  *  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 */ | ||||
|             printf("Error in encoder/decoder\n"); | ||||
|         } else { | ||||
|             /* Write coded bits to file */ | ||||
|             fwrite(streamdata,sizeof(short),stream_len/2,outbitp); | ||||
|             /* Write coded speech to file */ | ||||
|             fwrite(decoded,sizeof(short),framelength,outp); | ||||
|           /* Write coded bits to file */ | ||||
|           if (fwrite(streamdata, sizeof(short), stream_len/2, | ||||
|                      outbitp) != static_cast<size_t>(stream_len/2)) { | ||||
|             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; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
|  *  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); | ||||
|         printf("\nError in encoder: %d.\n", errtype); | ||||
|       } 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; | ||||
| @@ -777,7 +780,10 @@ int main(int argc, char* argv[]) | ||||
|       } | ||||
|  | ||||
|       /* 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)/ | ||||
|       // ((double)FS) ) * 8 ); | ||||
|     } 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 | ||||
|  *  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); | ||||
|                         } | ||||
|                         auxUW8 = (WebRtc_UWord8)(((streamLenTransCoding & 0xFF00) >> 8) &  0x00FF); | ||||
|                         fwrite(&auxUW8, sizeof(WebRtc_UWord8), | ||||
|                             1, transcodingBitstream); | ||||
|                         if (fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, | ||||
|                                    transcodingBitstream) != 1) { | ||||
|                           return -1; | ||||
|                         } | ||||
|  | ||||
|                         auxUW8 = (WebRtc_UWord8)(streamLenTransCoding & 0x00FF); | ||||
|                         fwrite(&auxUW8, sizeof(WebRtc_UWord8), | ||||
|                             1, transcodingBitstream); | ||||
|                         if (fwrite(&auxUW8, sizeof(WebRtc_UWord8), | ||||
|                                    1, transcodingBitstream) != 1) { | ||||
|                           return -1; | ||||
|                         } | ||||
|  | ||||
|                         fwrite((WebRtc_UWord8*)streamDataTransCoding, sizeof(WebRtc_UWord8), | ||||
|                             streamLenTransCoding, transcodingBitstream); | ||||
|                         if (fwrite((WebRtc_UWord8*)streamDataTransCoding, | ||||
|                                    sizeof(WebRtc_UWord8), | ||||
|                                    streamLenTransCoding, | ||||
|                                    transcodingBitstream) != | ||||
|                             static_cast<size_t>(streamLenTransCoding)) { | ||||
|                           return -1; | ||||
|                         } | ||||
|  | ||||
|                         WebRtcIsac_ReadBwIndex((WebRtc_Word16*)streamDataTransCoding, &indexStream); | ||||
|                         if(indexStream != bnIdxTC) | ||||
| @@ -939,12 +948,18 @@ int main(int argc, char* argv[]) | ||||
|         /* Write decoded speech frame to file */ | ||||
|         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)) | ||||
|         { | ||||
|             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 | ||||
|  *  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. | ||||
|         if(senderIdx == 0) | ||||
|         { | ||||
|           fwrite(&(packetData[senderIdx]->arrival_time), sizeof(unsigned int), 1, | ||||
|                  arrivalTimeFile1); | ||||
|           if (fwrite(&(packetData[senderIdx]->arrival_time), | ||||
|                      sizeof(unsigned int), | ||||
|                      1, arrivalTimeFile1) != 1) { | ||||
|             return -1; | ||||
|           } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|           fwrite(&(packetData[senderIdx]->arrival_time), sizeof(unsigned int), 1, | ||||
|                  arrivalTimeFile2); | ||||
|           if (fwrite(&(packetData[senderIdx]->arrival_time), | ||||
|                      sizeof(unsigned int), | ||||
|                      1, arrivalTimeFile2) != 1) { | ||||
|             return -1; | ||||
|           } | ||||
|         } | ||||
|  | ||||
|         // BWE | ||||
| @@ -426,13 +432,19 @@ int main(int argc, char* argv[]) | ||||
|         { | ||||
|           WebRtcSpl_UpsampleBy2(audioBuff60ms, lenDecodedAudio, resampledAudio60ms, | ||||
|                                 resamplerState[receiverIdx]); | ||||
|           fwrite(resampledAudio60ms, sizeof(short), lenDecodedAudio << 1, | ||||
|                  outFile[receiverIdx]); | ||||
|           if (fwrite(resampledAudio60ms, sizeof(short), lenDecodedAudio << 1, | ||||
|                      outFile[receiverIdx]) != | ||||
|               static_cast<size_t>(lenDecodedAudio << 1)) { | ||||
|             return -1; | ||||
|           } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|           fwrite(audioBuff60ms, sizeof(short), lenDecodedAudio, | ||||
|                  outFile[receiverIdx]); | ||||
|           if (fwrite(audioBuff60ms, sizeof(short), lenDecodedAudio, | ||||
|                      outFile[receiverIdx]) != | ||||
|               static_cast<size_t>(lenDecodedAudio)) { | ||||
|             return -1; | ||||
|           } | ||||
|         } | ||||
|         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 | ||||
|  *  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) | ||||
| 		{ | ||||
| 			WebRtc_UWord8 auxUW8; | ||||
| 			auxUW8 = (WebRtc_UWord8)(((stream_len & 0x7F00) >> 8) & 0xFF); | ||||
| 			fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, outp); | ||||
|                   WebRtc_UWord8 auxUW8; | ||||
|                   auxUW8 = (WebRtc_UWord8)(((stream_len & 0x7F00) >> 8) & 0xFF); | ||||
|                   if (fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, outp) != 1) { | ||||
|                     return -1; | ||||
|                   } | ||||
|  | ||||
| 			auxUW8 = (WebRtc_UWord8)(stream_len & 0xFF); | ||||
| 			fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, outp); | ||||
| 			fwrite(payload, 1, stream_len, outp); | ||||
|                   auxUW8 = (WebRtc_UWord8)(stream_len & 0xFF); | ||||
|                   if (fwrite(&auxUW8, sizeof(WebRtc_UWord8), 1, outp) != 1) { | ||||
|                     return -1; | ||||
|                   } | ||||
|                   if (fwrite(payload, 1, stream_len, | ||||
|                              outp) != (size_t)stream_len) { | ||||
|                     return -1; | ||||
|                   } | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| @@ -462,7 +469,10 @@ valid values are 8 and 16.\n", sampFreqKHz); | ||||
| 			} | ||||
|  | ||||
| 			// 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; | ||||
| 		} | ||||
|         // 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 | ||||
|  *  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 */ | ||||
|  | ||||
|     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 */ | ||||
|     if (argc==6) { | ||||
| @@ -204,7 +208,10 @@ int main(int argc, char* argv[]) | ||||
|  | ||||
|     /* 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 */ | ||||
|   | ||||
| @@ -431,9 +431,16 @@ WebRtc_Word32 AudioCodingModuleImpl::Process() { | ||||
|     CriticalSectionScoped lock(*_callbackCritSect); | ||||
| #ifdef ACM_QA_TEST | ||||
|     if(_outgoingPL != NULL) { | ||||
|       fwrite(&rtp_timestamp, sizeof(WebRtc_UWord32), 1, _outgoingPL); | ||||
|       fwrite(¤t_payload_type, sizeof(WebRtc_UWord8), 1, _outgoingPL); | ||||
|       fwrite(&length_bytes, sizeof(WebRtc_Word16), 1, _outgoingPL); | ||||
|       if (fwrite(&rtp_timestamp, sizeof(WebRtc_UWord32), 1, _outgoingPL) != 1) { | ||||
|         return -1; | ||||
|       } | ||||
|       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 | ||||
|  | ||||
| @@ -1489,11 +1496,18 @@ WebRtc_Word32 AudioCodingModuleImpl::IncomingPacket( | ||||
|     CriticalSectionScoped lock(*_acmCritSect); | ||||
| #ifdef ACM_QA_TEST | ||||
|     if(_incomingPL != NULL) { | ||||
|       fwrite(&rtp_info.header.timestamp, sizeof(WebRtc_UWord32), 1, | ||||
|              _incomingPL); | ||||
|       fwrite(&rtp_info.header.payloadType, sizeof(WebRtc_UWord8), 1, | ||||
|              _incomingPL); | ||||
|       fwrite(&payload_length, sizeof(WebRtc_Word16), 1, _incomingPL); | ||||
|       if (fwrite(&rtp_info.header.timestamp, sizeof(WebRtc_UWord32), | ||||
|                  1, _incomingPL) != 1) { | ||||
|         return -1; | ||||
|       } | ||||
|       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 | ||||
|  | ||||
|   | ||||
| @@ -181,8 +181,11 @@ WebRtc_Word32 PCMFile::Read10MsData(AudioFrame& audio_frame) { | ||||
| void PCMFile::Write10MsData(AudioFrame& audio_frame) { | ||||
|   if (audio_frame.num_channels_ == 1) { | ||||
|     if (!save_stereo_) { | ||||
|       fwrite(audio_frame.data_, sizeof(WebRtc_UWord16), | ||||
|              audio_frame.samples_per_channel_, pcm_file_); | ||||
|       if (fwrite(audio_frame.data_, sizeof(WebRtc_UWord16), | ||||
|                  audio_frame.samples_per_channel_, pcm_file_) != | ||||
|           static_cast<size_t>(audio_frame.samples_per_channel_)) { | ||||
|         return; | ||||
|       } | ||||
|     } else { | ||||
|       WebRtc_Word16* stereo_audio = | ||||
|           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) + 1] = audio_frame.data_[k]; | ||||
|       } | ||||
|       fwrite(stereo_audio, sizeof(WebRtc_Word16), | ||||
|              2 * audio_frame.samples_per_channel_, pcm_file_); | ||||
|       if (fwrite(stereo_audio, sizeof(WebRtc_Word16), | ||||
|                  2 * audio_frame.samples_per_channel_, pcm_file_) != | ||||
|           static_cast<size_t>(2 * audio_frame.samples_per_channel_)) { | ||||
|         return; | ||||
|       } | ||||
|       delete[] stereo_audio; | ||||
|     } | ||||
|   } else { | ||||
|     fwrite(audio_frame.data_, sizeof(WebRtc_Word16), | ||||
|            audio_frame.num_channels_ * audio_frame.samples_per_channel_, | ||||
|            pcm_file_); | ||||
|     if (fwrite(audio_frame.data_, sizeof(WebRtc_Word16), | ||||
|                audio_frame.num_channels_ * audio_frame.samples_per_channel_, | ||||
|                pcm_file_) != static_cast<size_t>( | ||||
|             audio_frame.num_channels_ * audio_frame.samples_per_channel_)) { | ||||
|       return; | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| void PCMFile::Write10MsData(WebRtc_Word16* playout_buffer, | ||||
|                             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() { | ||||
|   | ||||
| @@ -165,12 +165,23 @@ void RTPFile::WriteHeader() | ||||
| { | ||||
|     // Write data in a format that NetEQ and RTP Play can parse | ||||
|     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 | ||||
|     fwrite(&dummy_variable, 4, 1, _rtpFile); | ||||
|     fwrite(&dummy_variable, 4, 1, _rtpFile); | ||||
|     fwrite(&dummy_variable, 4, 1, _rtpFile); | ||||
|     fwrite(&dummy_variable, 2, 1, _rtpFile); | ||||
|     fwrite(&dummy_variable, 2, 1, _rtpFile); | ||||
|     WebRtc_UWord32 dummy_variable = 0; | ||||
|     // should be converted to network endian format, but does not matter when 0 | ||||
|     if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) { | ||||
|       return; | ||||
|     } | ||||
|     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); | ||||
| } | ||||
|  | ||||
| @@ -205,11 +216,21 @@ void RTPFile::Write(const WebRtc_UWord8 payloadType, const WebRtc_UWord32 timeSt | ||||
|  | ||||
|     offsetMs = (timeStamp/(frequency/1000)); | ||||
|     offsetMs = htonl(offsetMs); | ||||
|     fwrite(&lengthBytes, 2, 1, _rtpFile); | ||||
|     fwrite(&plen, 2, 1, _rtpFile); | ||||
|     fwrite(&offsetMs, 4, 1, _rtpFile); | ||||
|     fwrite(rtpHeader, 12, 1, _rtpFile); | ||||
|     fwrite(payloadData, 1, payloadSize, _rtpFile); | ||||
|     if (fwrite(&lengthBytes, 2, 1, _rtpFile) != 1) { | ||||
|       return; | ||||
|     } | ||||
|     if (fwrite(&plen, 2, 1, _rtpFile) != 1) { | ||||
|       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, | ||||
|   | ||||
| @@ -378,7 +378,9 @@ WebRtc_Word16 WebRtcNetEQ_CalcOptimalBufLvl(AutomodeInst_t *inst, WebRtc_Word32 | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|     /* special code for offline delay logging */ | ||||
|     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); | ||||
| #endif | ||||
|  | ||||
| @@ -518,7 +520,9 @@ WebRtc_Word16 WebRtcNetEQ_CalcOptimalBufLvl(AutomodeInst_t *inst, WebRtc_Word32 | ||||
|  | ||||
| #ifdef NETEQ_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 | ||||
|  | ||||
|     /* Sanity check: Bopt must be strictly positive */ | ||||
|   | ||||
| @@ -317,14 +317,23 @@ int WebRtcNetEQ_PacketBufferInsert(PacketBuf_t *bufferInst, const RTPPacket_t *R | ||||
|     if (*flushed) | ||||
|     { | ||||
|         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; | ||||
|     fwrite( &temp_var, sizeof(int), 1, delay_fid2 ); | ||||
|     fwrite( &RTPpacket->timeStamp, sizeof(WebRtc_UWord32), 1, delay_fid2 ); | ||||
|     fwrite( &RTPpacket->seqNumber, sizeof(WebRtc_UWord16), 1, delay_fid2 ); | ||||
|     fwrite( &RTPpacket->payloadType, sizeof(int), 1, delay_fid2 ); | ||||
|     fwrite( &RTPpacket->payloadLen, sizeof(WebRtc_Word16), 1, delay_fid2 ); | ||||
|     if ((fwrite(&temp_var, sizeof(int), | ||||
|                 1, delay_fid2) != 1) || | ||||
|         (fwrite(&RTPpacket->timeStamp, sizeof(WebRtc_UWord32), | ||||
|                 1, delay_fid2) != 1) || | ||||
|         (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++; | ||||
| #endif /* NETEQ_DELAY_LOGGING */ | ||||
|  | ||||
|   | ||||
| @@ -318,8 +318,12 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | ||||
|             } | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_CHANGE_FS; | ||||
|             fwrite(&temp_var, sizeof(int), 1, delay_fid2); | ||||
|             fwrite(&inst->fs, sizeof(WebRtc_UWord16), 1, delay_fid2); | ||||
|             if ((fwrite(&temp_var, sizeof(int), | ||||
|                         1, delay_fid2) != 1) || | ||||
|                 (fwrite(&inst->fs, sizeof(WebRtc_UWord16), | ||||
|                         1, delay_fid2) != 1)) { | ||||
|               return -1; | ||||
|             } | ||||
| #endif | ||||
|         } | ||||
|  | ||||
| @@ -508,9 +512,17 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | ||||
|                 pw16_decoded_buffer, &speechType); | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_DECODE_ONE_DESC; | ||||
|             fwrite(&temp_var, sizeof(int), 1, delay_fid2); | ||||
|             fwrite(&inst->endTimestamp, sizeof(WebRtc_UWord32), 1, delay_fid2); | ||||
|             fwrite(&dspInfo->samplesLeft, sizeof(WebRtc_UWord16), 1, delay_fid2); | ||||
|             if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||
|               return -1; | ||||
|             } | ||||
|             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++; | ||||
| #endif | ||||
|         } | ||||
| @@ -692,7 +704,9 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | ||||
|         case DSP_INSTR_MERGE: | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|             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; | ||||
| #endif | ||||
|             /* Call Merge with history*/ | ||||
| @@ -710,7 +724,9 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | ||||
|  | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|             temp_var += len; | ||||
|             fwrite(&temp_var, sizeof(int), 1, delay_fid2); | ||||
|             if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||
|               return -1; | ||||
|             } | ||||
| #endif | ||||
|             /* 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; | ||||
| @@ -756,9 +772,13 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | ||||
|                 inst->w16_concealedTS += len; | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|                 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; | ||||
|                 fwrite(&temp_var, sizeof(int), 1, delay_fid2); | ||||
|                 if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||
|                   return -1; | ||||
|                 } | ||||
| #endif | ||||
|                 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); | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|                     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; | ||||
|                     fwrite(&temp_var, sizeof(int), 1, delay_fid2); | ||||
|                     if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||
|                       return -1; | ||||
|                     } | ||||
| #endif | ||||
|                     len = 0; | ||||
|                 } | ||||
| @@ -827,9 +851,13 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | ||||
|                                            (len-borrowedSamples)); | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|                     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; | ||||
|                     fwrite(&temp_var, sizeof(int), 1, delay_fid2); | ||||
|                     if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||
|                       return -1; | ||||
|                     } | ||||
| #endif | ||||
|                     len = len - borrowedSamples; | ||||
|                 } | ||||
| @@ -839,7 +867,9 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | ||||
|             { | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|                 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; | ||||
| #endif | ||||
|                 return_value = WebRtcNetEQ_Accelerate(inst, | ||||
| @@ -856,7 +886,9 @@ int WebRtcNetEQ_RecOutInternal(DSPInst_t *inst, WebRtc_Word16 *pw16_outData, | ||||
|  | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|                 temp_var -= len; | ||||
|                 fwrite(&temp_var, sizeof(int), 1, delay_fid2); | ||||
|                 if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||
|                   return -1; | ||||
|                 } | ||||
| #endif | ||||
|             } | ||||
|             /* 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 | ||||
|             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 */ | ||||
|             fwrite(&temp_var, sizeof(int), 1, delay_fid2); | ||||
|             if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||
|               return -1; | ||||
|             } | ||||
| #endif | ||||
|             /* If last packet was decoded as inband CNG, set mode to CNG instead */ | ||||
|             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; | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|             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; | ||||
|             fwrite(&temp_var, sizeof(int), 1, delay_fid2); | ||||
|             if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||
|               return -1; | ||||
|             } | ||||
| #endif | ||||
|  | ||||
|             break; | ||||
|   | ||||
| @@ -646,9 +646,14 @@ int WebRtcNetEQ_SignalMcu(MCUInst_t *inst) | ||||
|  | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|             temp_var = NETEQ_DELAY_LOGGING_SIGNAL_DECODE; | ||||
|             fwrite(&temp_var,sizeof(int),1,delay_fid2); | ||||
|             fwrite(&temp_pkt.timeStamp,sizeof(WebRtc_UWord32),1,delay_fid2); | ||||
|             fwrite(&dspInfo.samplesLeft, sizeof(WebRtc_UWord16), 1, delay_fid2); | ||||
|             if ((fwrite(&temp_var, sizeof(int), | ||||
|                         1, delay_fid2) != 1) || | ||||
|                 (fwrite(&temp_pkt.timeStamp, sizeof(WebRtc_UWord32), | ||||
|                         1, delay_fid2) != 1) || | ||||
|                 (fwrite(&dspInfo.samplesLeft, sizeof(WebRtc_UWord16), | ||||
|                         1, delay_fid2) != 1)) { | ||||
|               return -1; | ||||
|             } | ||||
| #endif | ||||
|  | ||||
|             *blockPtr = temp_pkt.payloadLen; | ||||
| @@ -762,4 +767,3 @@ int WebRtcNetEQ_SignalMcu(MCUInst_t *inst) | ||||
|     return 0; | ||||
|  | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -561,8 +561,12 @@ int main(int argc, char* argv[]) | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|         temp_var = NETEQ_DELAY_LOGGING_SIGNAL_CLOCK; | ||||
|         clock_float = (float) simClock; | ||||
|         fwrite(&temp_var,sizeof(int),1,delay_fid2); | ||||
|         fwrite(&clock_float, sizeof(float),1,delay_fid2); | ||||
|         if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||
|           return -1; | ||||
|         } | ||||
|         if (fwrite(&clock_float, sizeof(float), 1, delay_fid2) != 1) { | ||||
|           return -1; | ||||
|         } | ||||
| #endif | ||||
|         /* time to set extra delay */ | ||||
|         if (extraDelay > -1 && simClock >= nextExtraDelayTime) { | ||||
| @@ -657,7 +661,9 @@ int main(int argc, char* argv[]) | ||||
|             } | ||||
|  | ||||
|             // write to file | ||||
|             fwrite(out_data,writeLen,2,out_file); | ||||
|             if (fwrite(out_data, writeLen, 2, out_file) != 2) { | ||||
|               return -1; | ||||
|             } | ||||
|             writtenSamples += writeLen; | ||||
|  | ||||
|  | ||||
| @@ -678,8 +684,13 @@ int main(int argc, char* argv[]) | ||||
|  | ||||
| #ifdef NETEQ_DELAY_LOGGING | ||||
|     temp_var = NETEQ_DELAY_LOGGING_SIGNAL_EOF; | ||||
|     fwrite(&temp_var,sizeof(int),1,delay_fid2); | ||||
|     fwrite(&tot_received_packets,sizeof(WebRtc_UWord32),1,delay_fid2); | ||||
|     if (fwrite(&temp_var, sizeof(int), 1, delay_fid2) != 1) { | ||||
|       return -1; | ||||
|     } | ||||
|     if (fwrite(&tot_received_packets, sizeof(WebRtc_UWord32), | ||||
|                1, delay_fid2) != 1) { | ||||
|       return -1; | ||||
|     } | ||||
|     fprintf(delay_fid2,"End of file\n"); | ||||
|     fclose(delay_fid2); | ||||
| #endif | ||||
|   | ||||
| @@ -252,7 +252,7 @@ int main(int argc, char* argv[]) | ||||
| 	WebRtc_Word16 seqNo=0xFFF; | ||||
| 	WebRtc_UWord32 ssrc=1235412312; | ||||
| 	WebRtc_UWord32 timestamp=0xAC1245; | ||||
| 	WebRtc_UWord16 length, plen; | ||||
|         WebRtc_UWord16 length, plen; | ||||
| 	WebRtc_UWord32 offset; | ||||
| 	double sendtime = 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, "#!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 | ||||
| 	fwrite(&dummy_variable, 4, 1, out_file); | ||||
| 	fwrite(&dummy_variable, 4, 1, out_file); | ||||
| 	fwrite(&dummy_variable, 4, 1, out_file); | ||||
| 	fwrite(&dummy_variable, 2, 1, out_file); | ||||
| 	fwrite(&dummy_variable, 2, 1, out_file); | ||||
|         if (fwrite(&dummy_variable, 4, 1, out_file) != 1) { | ||||
|           return -1; | ||||
|         } | ||||
|         if (fwrite(&dummy_variable, 4, 1, out_file) != 1) { | ||||
|           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 | ||||
| 	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); | ||||
|             offset = (WebRtc_UWord32) sendtime; //(timestamp/(fs/1000)); | ||||
|             offset = htonl(offset); | ||||
|             fwrite(&length, 2, 1, out_file); | ||||
|             fwrite(&plen, 2, 1, out_file); | ||||
|             fwrite(&offset, 4, 1, out_file); | ||||
|             fwrite(rtp_data, 12 + enc_len, 1, out_file); | ||||
|             if (fwrite(&length, 2, 1, out_file) != 1) { | ||||
|               return -1; | ||||
|             } | ||||
|             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; | ||||
|         } | ||||
| @@ -683,13 +701,20 @@ int main(int argc, char* argv[]) | ||||
| 			do { | ||||
| #endif //MULTIPLE_SAME_TIMESTAMP | ||||
| 			/* write RTP packet to file */ | ||||
| 			length = htons(12 + enc_len + 8); | ||||
| 			plen = htons(12 + enc_len); | ||||
| 			offset = (WebRtc_UWord32) sendtime; //(timestamp/(fs/1000)); | ||||
| 			offset = htonl(offset); | ||||
| 			fwrite(&length, 2, 1, out_file); | ||||
| 			fwrite(&plen, 2, 1, out_file); | ||||
| 			fwrite(&offset, 4, 1, out_file); | ||||
|                           length = htons(12 + enc_len + 8); | ||||
|                           plen = htons(12 + enc_len); | ||||
|                           offset = (WebRtc_UWord32) sendtime; | ||||
|                           //(timestamp/(fs/1000)); | ||||
|                           offset = htonl(offset); | ||||
|                           if (fwrite(&length, 2, 1, out_file) != 1) { | ||||
|                             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 | ||||
| 			for (int k=0; k<12+enc_len; k++) { | ||||
| 				rtp_data[k] = rand() + rand(); | ||||
| @@ -700,7 +725,9 @@ int main(int argc, char* argv[]) | ||||
| 				rtp_data[k] = rand() + rand(); | ||||
| 			} | ||||
| #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 | ||||
| 			} while ( (seqNo%REPEAT_PACKET_DISTANCE == 0) && (mult_pack++ < REPEAT_PACKET_COUNT) ); | ||||
| #endif //MULTIPLE_SAME_TIMESTAMP | ||||
| @@ -708,11 +735,23 @@ int main(int argc, char* argv[]) | ||||
| #ifdef INSERT_OLD_PACKETS | ||||
| 			if (packet_age >= OLD_PACKET*fs) { | ||||
| 				if (!first_old_packet) { | ||||
| 					// send the old packet | ||||
| 					fwrite(&old_length, 2, 1, out_file); | ||||
| 					fwrite(&old_plen, 2, 1, out_file); | ||||
| 					fwrite(&offset, 4, 1, out_file); | ||||
| 					fwrite(old_rtp_data, 12 + old_enc_len, 1, out_file); | ||||
|                                   // send the old packet | ||||
|                                   if (fwrite(&old_length, 2, 1, | ||||
|                                              out_file) != 1) { | ||||
|                                     return -1; | ||||
|                                   } | ||||
|                                   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 | ||||
| 				old_length=length; | ||||
|   | ||||
| @@ -167,7 +167,12 @@ int main(int argc, char* argv[]) | ||||
| 			} | ||||
|  | ||||
| 			// 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