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 14 matching lines...) Expand all Loading... |
25 { | 25 { |
26 delete recorder; | 26 delete recorder; |
27 } | 27 } |
28 | 28 |
29 FileRecorderImpl::FileRecorderImpl(uint32_t instanceID, | 29 FileRecorderImpl::FileRecorderImpl(uint32_t instanceID, |
30 FileFormats fileFormat) | 30 FileFormats fileFormat) |
31 : _instanceID(instanceID), | 31 : _instanceID(instanceID), |
32 _fileFormat(fileFormat), | 32 _fileFormat(fileFormat), |
33 _moduleFile(MediaFile::CreateMediaFile(_instanceID)), | 33 _moduleFile(MediaFile::CreateMediaFile(_instanceID)), |
34 codec_info_(), | 34 codec_info_(), |
35 _amrFormat(AMRFileStorage), | |
36 _audioBuffer(), | 35 _audioBuffer(), |
37 _audioEncoder(instanceID), | 36 _audioEncoder(instanceID), |
38 _audioResampler() | 37 _audioResampler() |
39 { | 38 { |
40 } | 39 } |
41 | 40 |
42 FileRecorderImpl::~FileRecorderImpl() | 41 FileRecorderImpl::~FileRecorderImpl() |
43 { | 42 { |
44 MediaFile::DestroyMediaFile(_moduleFile); | 43 MediaFile::DestroyMediaFile(_moduleFile); |
45 } | 44 } |
46 | 45 |
47 FileFormats FileRecorderImpl::RecordingFileFormat() const | 46 FileFormats FileRecorderImpl::RecordingFileFormat() const |
48 { | 47 { |
49 return _fileFormat; | 48 return _fileFormat; |
50 } | 49 } |
51 | 50 |
52 int32_t FileRecorderImpl::RegisterModuleFileCallback( | 51 int32_t FileRecorderImpl::RegisterModuleFileCallback( |
53 FileCallback* callback) | 52 FileCallback* callback) |
54 { | 53 { |
55 if(_moduleFile == NULL) | 54 if(_moduleFile == NULL) |
56 { | 55 { |
57 return -1; | 56 return -1; |
58 } | 57 } |
59 return _moduleFile->SetModuleFileCallback(callback); | 58 return _moduleFile->SetModuleFileCallback(callback); |
60 } | 59 } |
61 | 60 |
62 int32_t FileRecorderImpl::StartRecordingAudioFile( | 61 int32_t FileRecorderImpl::StartRecordingAudioFile( |
63 const char* fileName, | 62 const char* fileName, |
64 const CodecInst& codecInst, | 63 const CodecInst& codecInst, |
65 uint32_t notificationTimeMs, | 64 uint32_t notificationTimeMs) |
66 ACMAMRPackingFormat amrFormat) | |
67 { | 65 { |
68 if(_moduleFile == NULL) | 66 if(_moduleFile == NULL) |
69 { | 67 { |
70 return -1; | 68 return -1; |
71 } | 69 } |
72 codec_info_ = codecInst; | 70 codec_info_ = codecInst; |
73 _amrFormat = amrFormat; | |
74 | |
75 int32_t retVal = 0; | 71 int32_t retVal = 0; |
76 retVal =_moduleFile->StartRecordingAudioFile(fileName, _fileFormat, | 72 retVal =_moduleFile->StartRecordingAudioFile(fileName, _fileFormat, |
77 codecInst, | 73 codecInst, |
78 notificationTimeMs); | 74 notificationTimeMs); |
79 | 75 |
80 if( retVal == 0) | 76 if( retVal == 0) |
81 { | 77 { |
82 retVal = SetUpAudioEncoder(); | 78 retVal = SetUpAudioEncoder(); |
83 } | 79 } |
84 if( retVal != 0) | 80 if( retVal != 0) |
85 { | 81 { |
86 LOG(LS_WARNING) << "Failed to initialize file " << fileName | 82 LOG(LS_WARNING) << "Failed to initialize file " << fileName |
87 << " for recording."; | 83 << " for recording."; |
88 | 84 |
89 if(IsRecording()) | 85 if(IsRecording()) |
90 { | 86 { |
91 StopRecording(); | 87 StopRecording(); |
92 } | 88 } |
93 } | 89 } |
94 return retVal; | 90 return retVal; |
95 } | 91 } |
96 | 92 |
97 int32_t FileRecorderImpl::StartRecordingAudioFile( | 93 int32_t FileRecorderImpl::StartRecordingAudioFile( |
98 OutStream& destStream, | 94 OutStream& destStream, |
99 const CodecInst& codecInst, | 95 const CodecInst& codecInst, |
100 uint32_t notificationTimeMs, | 96 uint32_t notificationTimeMs) |
101 ACMAMRPackingFormat amrFormat) | |
102 { | 97 { |
103 codec_info_ = codecInst; | 98 codec_info_ = codecInst; |
104 _amrFormat = amrFormat; | |
105 | |
106 int32_t retVal = _moduleFile->StartRecordingAudioStream( | 99 int32_t retVal = _moduleFile->StartRecordingAudioStream( |
107 destStream, | 100 destStream, |
108 _fileFormat, | 101 _fileFormat, |
109 codecInst, | 102 codecInst, |
110 notificationTimeMs); | 103 notificationTimeMs); |
111 | 104 |
112 if( retVal == 0) | 105 if( retVal == 0) |
113 { | 106 { |
114 retVal = SetUpAudioEncoder(); | 107 retVal = SetUpAudioEncoder(); |
115 } | 108 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 codecInst = codec_info_; | 252 codecInst = codec_info_; |
260 return 0; | 253 return 0; |
261 } | 254 } |
262 | 255 |
263 int32_t FileRecorderImpl::WriteEncodedAudioData(const int8_t* audioBuffer, | 256 int32_t FileRecorderImpl::WriteEncodedAudioData(const int8_t* audioBuffer, |
264 size_t bufferLength) | 257 size_t bufferLength) |
265 { | 258 { |
266 return _moduleFile->IncomingAudioData(audioBuffer, bufferLength); | 259 return _moduleFile->IncomingAudioData(audioBuffer, bufferLength); |
267 } | 260 } |
268 } // namespace webrtc | 261 } // namespace webrtc |
OLD | NEW |