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