| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 if(!_ptrFileUtilityObj) | 125 if(!_ptrFileUtilityObj) |
| 126 { | 126 { |
| 127 WEBRTC_TRACE(kTraceError, kTraceFile, _id, | 127 WEBRTC_TRACE(kTraceError, kTraceFile, _id, |
| 128 "Playing, but no FileUtility object!"); | 128 "Playing, but no FileUtility object!"); |
| 129 StopPlaying(); | 129 StopPlaying(); |
| 130 return -1; | 130 return -1; |
| 131 } | 131 } |
| 132 | 132 |
| 133 switch(_fileFormat) | 133 switch(_fileFormat) |
| 134 { | 134 { |
| 135 case kFileFormatPcm48kHzFile: | |
| 136 case kFileFormatPcm32kHzFile: | 135 case kFileFormatPcm32kHzFile: |
| 137 case kFileFormatPcm16kHzFile: | 136 case kFileFormatPcm16kHzFile: |
| 138 case kFileFormatPcm8kHzFile: | 137 case kFileFormatPcm8kHzFile: |
| 139 bytesRead = _ptrFileUtilityObj->ReadPCMData( | 138 bytesRead = _ptrFileUtilityObj->ReadPCMData( |
| 140 *_ptrInStream, | 139 *_ptrInStream, |
| 141 buffer, | 140 buffer, |
| 142 bufferLengthInBytes); | 141 bufferLengthInBytes); |
| 143 break; | 142 break; |
| 144 case kFileFormatCompressedFile: | 143 case kFileFormatCompressedFile: |
| 145 bytesRead = _ptrFileUtilityObj->ReadCompressedData( | 144 bytesRead = _ptrFileUtilityObj->ReadCompressedData( |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 "Not a valid Compressed file!"); | 472 "Not a valid Compressed file!"); |
| 474 StopPlaying(); | 473 StopPlaying(); |
| 475 return -1; | 474 return -1; |
| 476 } | 475 } |
| 477 _fileFormat = kFileFormatCompressedFile; | 476 _fileFormat = kFileFormatCompressedFile; |
| 478 break; | 477 break; |
| 479 } | 478 } |
| 480 case kFileFormatPcm8kHzFile: | 479 case kFileFormatPcm8kHzFile: |
| 481 case kFileFormatPcm16kHzFile: | 480 case kFileFormatPcm16kHzFile: |
| 482 case kFileFormatPcm32kHzFile: | 481 case kFileFormatPcm32kHzFile: |
| 483 case kFileFormatPcm48kHzFile: | |
| 484 { | 482 { |
| 485 // ValidFileFormat() called in the beginneing of this function | 483 // ValidFileFormat() called in the beginneing of this function |
| 486 // prevents codecInst from being NULL here. | 484 // prevents codecInst from being NULL here. |
| 487 assert(codecInst != NULL); | 485 assert(codecInst != NULL); |
| 488 if(!ValidFrequency(codecInst->plfreq) || | 486 if(!ValidFrequency(codecInst->plfreq) || |
| 489 _ptrFileUtilityObj->InitPCMReading(stream, startPointMs, | 487 _ptrFileUtilityObj->InitPCMReading(stream, startPointMs, |
| 490 stopPointMs, | 488 stopPointMs, |
| 491 codecInst->plfreq) == -1) | 489 codecInst->plfreq) == -1) |
| 492 { | 490 { |
| 493 WEBRTC_TRACE(kTraceError, kTraceFile, _id, | 491 WEBRTC_TRACE(kTraceError, kTraceFile, _id, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 | 624 |
| 627 int32_t bytesWritten = 0; | 625 int32_t bytesWritten = 0; |
| 628 uint32_t samplesWritten = codec_info_.pacsize; | 626 uint32_t samplesWritten = codec_info_.pacsize; |
| 629 if(_ptrFileUtilityObj) | 627 if(_ptrFileUtilityObj) |
| 630 { | 628 { |
| 631 switch(_fileFormat) | 629 switch(_fileFormat) |
| 632 { | 630 { |
| 633 case kFileFormatPcm8kHzFile: | 631 case kFileFormatPcm8kHzFile: |
| 634 case kFileFormatPcm16kHzFile: | 632 case kFileFormatPcm16kHzFile: |
| 635 case kFileFormatPcm32kHzFile: | 633 case kFileFormatPcm32kHzFile: |
| 636 case kFileFormatPcm48kHzFile: | |
| 637 bytesWritten = _ptrFileUtilityObj->WritePCMData( | 634 bytesWritten = _ptrFileUtilityObj->WritePCMData( |
| 638 *_ptrOutStream, | 635 *_ptrOutStream, |
| 639 buffer, | 636 buffer, |
| 640 bufferLengthInBytes); | 637 bufferLengthInBytes); |
| 641 | 638 |
| 642 // Sample size is 2 bytes. | 639 // Sample size is 2 bytes. |
| 643 if(bytesWritten > 0) | 640 if(bytesWritten > 0) |
| 644 { | 641 { |
| 645 samplesWritten = bytesWritten/sizeof(int16_t); | 642 samplesWritten = bytesWritten/sizeof(int16_t); |
| 646 } | 643 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 "Failed to initialize Compressed file!"); | 838 "Failed to initialize Compressed file!"); |
| 842 delete _ptrFileUtilityObj; | 839 delete _ptrFileUtilityObj; |
| 843 _ptrFileUtilityObj = NULL; | 840 _ptrFileUtilityObj = NULL; |
| 844 return -1; | 841 return -1; |
| 845 } | 842 } |
| 846 _fileFormat = kFileFormatCompressedFile; | 843 _fileFormat = kFileFormatCompressedFile; |
| 847 break; | 844 break; |
| 848 } | 845 } |
| 849 case kFileFormatPcm8kHzFile: | 846 case kFileFormatPcm8kHzFile: |
| 850 case kFileFormatPcm16kHzFile: | 847 case kFileFormatPcm16kHzFile: |
| 851 case kFileFormatPcm32kHzFile: | |
| 852 case kFileFormatPcm48kHzFile: | |
| 853 { | 848 { |
| 854 if(!ValidFrequency(codecInst.plfreq) || | 849 if(!ValidFrequency(codecInst.plfreq) || |
| 855 _ptrFileUtilityObj->InitPCMWriting(stream, codecInst.plfreq) == | 850 _ptrFileUtilityObj->InitPCMWriting(stream, codecInst.plfreq) == |
| 856 -1) | 851 -1) |
| 857 { | 852 { |
| 858 WEBRTC_TRACE(kTraceError, kTraceFile, _id, | 853 WEBRTC_TRACE(kTraceError, kTraceFile, _id, |
| 859 "Failed to initialize PCM file!"); | 854 "Failed to initialize 8 or 16KHz PCM file!"); |
| 860 delete _ptrFileUtilityObj; | 855 delete _ptrFileUtilityObj; |
| 861 _ptrFileUtilityObj = NULL; | 856 _ptrFileUtilityObj = NULL; |
| 862 return -1; | 857 return -1; |
| 863 } | 858 } |
| 864 _fileFormat = format; | 859 _fileFormat = format; |
| 865 break; | 860 break; |
| 866 } | 861 } |
| 867 case kFileFormatPreencodedFile: | 862 case kFileFormatPreencodedFile: |
| 868 { | 863 { |
| 869 if(_ptrFileUtilityObj->InitPreEncodedWriting(stream, codecInst) == | 864 if(_ptrFileUtilityObj->InitPreEncodedWriting(stream, codecInst) == |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 } | 1063 } |
| 1069 | 1064 |
| 1070 bool MediaFileImpl::ValidFileFormat(const FileFormats format, | 1065 bool MediaFileImpl::ValidFileFormat(const FileFormats format, |
| 1071 const CodecInst* codecInst) | 1066 const CodecInst* codecInst) |
| 1072 { | 1067 { |
| 1073 if(codecInst == NULL) | 1068 if(codecInst == NULL) |
| 1074 { | 1069 { |
| 1075 if(format == kFileFormatPreencodedFile || | 1070 if(format == kFileFormatPreencodedFile || |
| 1076 format == kFileFormatPcm8kHzFile || | 1071 format == kFileFormatPcm8kHzFile || |
| 1077 format == kFileFormatPcm16kHzFile || | 1072 format == kFileFormatPcm16kHzFile || |
| 1078 format == kFileFormatPcm32kHzFile || | 1073 format == kFileFormatPcm32kHzFile) |
| 1079 format == kFileFormatPcm48kHzFile) | |
| 1080 { | 1074 { |
| 1081 WEBRTC_TRACE(kTraceError, kTraceFile, -1, | 1075 WEBRTC_TRACE(kTraceError, kTraceFile, -1, |
| 1082 "Codec info required for file format specified!"); | 1076 "Codec info required for file format specified!"); |
| 1083 return false; | 1077 return false; |
| 1084 } | 1078 } |
| 1085 } | 1079 } |
| 1086 return true; | 1080 return true; |
| 1087 } | 1081 } |
| 1088 | 1082 |
| 1089 bool MediaFileImpl::ValidFileName(const char* fileName) | 1083 bool MediaFileImpl::ValidFileName(const char* fileName) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1114 { | 1108 { |
| 1115 WEBRTC_TRACE(kTraceError, kTraceFile, -1, | 1109 WEBRTC_TRACE(kTraceError, kTraceFile, -1, |
| 1116 "minimum play duration for files is 20 ms!"); | 1110 "minimum play duration for files is 20 ms!"); |
| 1117 return false; | 1111 return false; |
| 1118 } | 1112 } |
| 1119 return true; | 1113 return true; |
| 1120 } | 1114 } |
| 1121 | 1115 |
| 1122 bool MediaFileImpl::ValidFrequency(const uint32_t frequency) | 1116 bool MediaFileImpl::ValidFrequency(const uint32_t frequency) |
| 1123 { | 1117 { |
| 1124 if((frequency == 8000) || (frequency == 16000)|| (frequency == 32000) || (fr
equency == 48000)) | 1118 if((frequency == 8000) || (frequency == 16000)|| (frequency == 32000)) |
| 1125 { | 1119 { |
| 1126 return true; | 1120 return true; |
| 1127 } | 1121 } |
| 1128 WEBRTC_TRACE(kTraceError, kTraceFile, -1, | 1122 WEBRTC_TRACE(kTraceError, kTraceFile, -1, |
| 1129 "Frequency should be 8000, 16000, 32000, or 48000 (Hz)"); | 1123 "Frequency should be 8000, 16000 or 32000 (Hz)"); |
| 1130 return false; | 1124 return false; |
| 1131 } | 1125 } |
| 1132 } // namespace webrtc | 1126 } // namespace webrtc |
| OLD | NEW |