| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 "OutputMixer::RecordFileEnded() =>" | 73 "OutputMixer::RecordFileEnded() =>" |
| 74 "output file recorder module is shutdown"); | 74 "output file recorder module is shutdown"); |
| 75 } | 75 } |
| 76 | 76 |
| 77 int32_t | 77 int32_t |
| 78 OutputMixer::Create(OutputMixer*& mixer, uint32_t instanceId) | 78 OutputMixer::Create(OutputMixer*& mixer, uint32_t instanceId) |
| 79 { | 79 { |
| 80 WEBRTC_TRACE(kTraceMemory, kTraceVoice, instanceId, | 80 WEBRTC_TRACE(kTraceMemory, kTraceVoice, instanceId, |
| 81 "OutputMixer::Create(instanceId=%d)", instanceId); | 81 "OutputMixer::Create(instanceId=%d)", instanceId); |
| 82 mixer = new OutputMixer(instanceId); | 82 mixer = new OutputMixer(instanceId); |
| 83 if (mixer == NULL) | 83 if (mixer == nullptr) { |
| 84 { | 84 WEBRTC_TRACE(kTraceMemory, kTraceVoice, instanceId, |
| 85 WEBRTC_TRACE(kTraceMemory, kTraceVoice, instanceId, | 85 "OutputMixer::Create() unable to allocate memory for" |
| 86 "OutputMixer::Create() unable to allocate memory for" | 86 "mixer"); |
| 87 "mixer"); | 87 return -1; |
| 88 return -1; | |
| 89 } | 88 } |
| 90 return 0; | 89 return 0; |
| 91 } | 90 } |
| 92 | 91 |
| 93 OutputMixer::OutputMixer(uint32_t instanceId) : | 92 OutputMixer::OutputMixer(uint32_t instanceId) |
| 94 _mixerModule(*AudioConferenceMixer::Create(instanceId)), | 93 : _mixerModule(*AudioConferenceMixer::Create(instanceId)), |
| 95 _audioLevel(), | 94 _audioLevel(), |
| 96 _instanceId(instanceId), | 95 _instanceId(instanceId), |
| 97 _externalMediaCallbackPtr(NULL), | 96 _externalMediaCallbackPtr(nullptr), |
| 98 _externalMedia(false), | 97 _externalMedia(false), |
| 99 _panLeft(1.0f), | 98 _panLeft(1.0f), |
| 100 _panRight(1.0f), | 99 _panRight(1.0f), |
| 101 _mixingFrequencyHz(8000), | 100 _mixingFrequencyHz(8000), |
| 102 _outputFileRecording(false) | 101 _outputFileRecording(false) { |
| 103 { | 102 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, -1), |
| 104 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), | 103 "OutputMixer::OutputMixer() - ctor"); |
| 105 "OutputMixer::OutputMixer() - ctor"); | |
| 106 | 104 |
| 107 if (_mixerModule.RegisterMixedStreamCallback(this) == -1) | 105 if (_mixerModule.RegisterMixedStreamCallback(this) == -1) { |
| 108 { | 106 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, -1), |
| 109 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), | 107 "OutputMixer::OutputMixer() failed to register mixer" |
| 110 "OutputMixer::OutputMixer() failed to register mixer" | 108 "callbacks"); |
| 111 "callbacks"); | 109 } |
| 112 } | |
| 113 } | 110 } |
| 114 | 111 |
| 115 void | 112 void |
| 116 OutputMixer::Destroy(OutputMixer*& mixer) | 113 OutputMixer::Destroy(OutputMixer*& mixer) |
| 117 { | 114 { |
| 118 if (mixer) | 115 if (mixer) |
| 119 { | 116 { |
| 120 delete mixer; | 117 delete mixer; |
| 121 mixer = NULL; | 118 mixer = nullptr; |
| 122 } | 119 } |
| 123 } | 120 } |
| 124 | 121 |
| 125 OutputMixer::~OutputMixer() | 122 OutputMixer::~OutputMixer() |
| 126 { | 123 { |
| 127 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), | 124 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), |
| 128 "OutputMixer::~OutputMixer() - dtor"); | 125 "OutputMixer::~OutputMixer() - dtor"); |
| 129 if (_externalMedia) | 126 if (_externalMedia) |
| 130 { | 127 { |
| 131 DeRegisterExternalMediaProcessing(); | 128 DeRegisterExternalMediaProcessing(); |
| 132 } | 129 } |
| 133 { | 130 { |
| 134 rtc::CritScope cs(&_fileCritSect); | 131 rtc::CritScope cs(&_fileCritSect); |
| 135 if (output_file_recorder_) { | 132 if (output_file_recorder_) { |
| 136 output_file_recorder_->RegisterModuleFileCallback(NULL); | 133 output_file_recorder_->RegisterModuleFileCallback(nullptr); |
| 137 output_file_recorder_->StopRecording(); | 134 output_file_recorder_->StopRecording(); |
| 138 } | 135 } |
| 139 } | 136 } |
| 140 _mixerModule.UnRegisterMixedStreamCallback(); | 137 _mixerModule.UnRegisterMixedStreamCallback(); |
| 141 delete &_mixerModule; | 138 delete &_mixerModule; |
| 142 } | 139 } |
| 143 | 140 |
| 144 int32_t | 141 int32_t |
| 145 OutputMixer::SetEngineInformation(voe::Statistics& engineStatistics) | 142 OutputMixer::SetEngineInformation(voe::Statistics& engineStatistics) |
| 146 { | 143 { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 173 return 0; | 170 return 0; |
| 174 } | 171 } |
| 175 | 172 |
| 176 int OutputMixer::DeRegisterExternalMediaProcessing() | 173 int OutputMixer::DeRegisterExternalMediaProcessing() |
| 177 { | 174 { |
| 178 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), | 175 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), |
| 179 "OutputMixer::DeRegisterExternalMediaProcessing()"); | 176 "OutputMixer::DeRegisterExternalMediaProcessing()"); |
| 180 | 177 |
| 181 rtc::CritScope cs(&_callbackCritSect); | 178 rtc::CritScope cs(&_callbackCritSect); |
| 182 _externalMedia = false; | 179 _externalMedia = false; |
| 183 _externalMediaCallbackPtr = NULL; | 180 _externalMediaCallbackPtr = nullptr; |
| 184 | 181 |
| 185 return 0; | 182 return 0; |
| 186 } | 183 } |
| 187 | 184 |
| 188 int32_t | 185 int32_t |
| 189 OutputMixer::SetMixabilityStatus(MixerParticipant& participant, | 186 OutputMixer::SetMixabilityStatus(MixerParticipant& participant, |
| 190 bool mixable) | 187 bool mixable) |
| 191 { | 188 { |
| 192 return _mixerModule.SetMixabilityStatus(&participant, mixable); | 189 return _mixerModule.SetMixabilityStatus(&participant, mixable); |
| 193 } | 190 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 { | 254 { |
| 258 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,-1), | 255 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,-1), |
| 259 "StartRecordingPlayout() is already recording"); | 256 "StartRecordingPlayout() is already recording"); |
| 260 return 0; | 257 return 0; |
| 261 } | 258 } |
| 262 | 259 |
| 263 FileFormats format; | 260 FileFormats format; |
| 264 const uint32_t notificationTime(0); | 261 const uint32_t notificationTime(0); |
| 265 CodecInst dummyCodec={100,"L16",16000,320,1,320000}; | 262 CodecInst dummyCodec={100,"L16",16000,320,1,320000}; |
| 266 | 263 |
| 267 if ((codecInst != NULL) && | 264 if ((codecInst != nullptr) && |
| 268 ((codecInst->channels < 1) || (codecInst->channels > 2))) | 265 ((codecInst->channels < 1) || (codecInst->channels > 2))) { |
| 269 { | 266 _engineStatisticsPtr->SetLastError( |
| 270 _engineStatisticsPtr->SetLastError( | 267 VE_BAD_ARGUMENT, kTraceError, |
| 271 VE_BAD_ARGUMENT, kTraceError, | 268 "StartRecordingPlayout() invalid compression"); |
| 272 "StartRecordingPlayout() invalid compression"); | 269 return (-1); |
| 273 return(-1); | |
| 274 } | 270 } |
| 275 if(codecInst == NULL) | 271 if (codecInst == nullptr) { |
| 276 { | 272 format = kFileFormatPcm16kHzFile; |
| 277 format = kFileFormatPcm16kHzFile; | 273 codecInst = &dummyCodec; |
| 278 codecInst=&dummyCodec; | |
| 279 } | 274 } |
| 280 else if((STR_CASE_CMP(codecInst->plname,"L16") == 0) || | 275 else if((STR_CASE_CMP(codecInst->plname,"L16") == 0) || |
| 281 (STR_CASE_CMP(codecInst->plname,"PCMU") == 0) || | 276 (STR_CASE_CMP(codecInst->plname,"PCMU") == 0) || |
| 282 (STR_CASE_CMP(codecInst->plname,"PCMA") == 0)) | 277 (STR_CASE_CMP(codecInst->plname,"PCMA") == 0)) |
| 283 { | 278 { |
| 284 format = kFileFormatWavFile; | 279 format = kFileFormatWavFile; |
| 285 } | 280 } |
| 286 else | 281 else |
| 287 { | 282 { |
| 288 format = kFileFormatCompressedFile; | 283 format = kFileFormatCompressedFile; |
| 289 } | 284 } |
| 290 | 285 |
| 291 rtc::CritScope cs(&_fileCritSect); | 286 rtc::CritScope cs(&_fileCritSect); |
| 292 | 287 |
| 293 // Destroy the old instance | 288 // Destroy the old instance |
| 294 if (output_file_recorder_) { | 289 if (output_file_recorder_) { |
| 295 output_file_recorder_->RegisterModuleFileCallback(NULL); | 290 output_file_recorder_->RegisterModuleFileCallback(nullptr); |
| 296 output_file_recorder_.reset(); | 291 output_file_recorder_.reset(); |
| 297 } | 292 } |
| 298 | 293 |
| 299 output_file_recorder_ = FileRecorder::CreateFileRecorder( | 294 output_file_recorder_ = FileRecorder::CreateFileRecorder( |
| 300 _instanceId, (const FileFormats)format); | 295 _instanceId, (const FileFormats)format); |
| 301 if (!output_file_recorder_) { | 296 if (!output_file_recorder_) { |
| 302 _engineStatisticsPtr->SetLastError( | 297 _engineStatisticsPtr->SetLastError( |
| 303 VE_INVALID_ARGUMENT, kTraceError, | 298 VE_INVALID_ARGUMENT, kTraceError, |
| 304 "StartRecordingPlayout() fileRecorder format isnot correct"); | 299 "StartRecordingPlayout() fileRecorder format isnot correct"); |
| 305 return -1; | 300 return -1; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 330 { | 325 { |
| 331 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,-1), | 326 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,-1), |
| 332 "StartRecordingPlayout() is already recording"); | 327 "StartRecordingPlayout() is already recording"); |
| 333 return 0; | 328 return 0; |
| 334 } | 329 } |
| 335 | 330 |
| 336 FileFormats format; | 331 FileFormats format; |
| 337 const uint32_t notificationTime(0); | 332 const uint32_t notificationTime(0); |
| 338 CodecInst dummyCodec={100,"L16",16000,320,1,320000}; | 333 CodecInst dummyCodec={100,"L16",16000,320,1,320000}; |
| 339 | 334 |
| 340 if (codecInst != NULL && codecInst->channels != 1) | 335 if (codecInst != nullptr && codecInst->channels != 1) { |
| 341 { | 336 _engineStatisticsPtr->SetLastError( |
| 342 _engineStatisticsPtr->SetLastError( | 337 VE_BAD_ARGUMENT, kTraceError, |
| 343 VE_BAD_ARGUMENT, kTraceError, | 338 "StartRecordingPlayout() invalid compression"); |
| 344 "StartRecordingPlayout() invalid compression"); | 339 return (-1); |
| 345 return(-1); | |
| 346 } | 340 } |
| 347 if(codecInst == NULL) | 341 if (codecInst == nullptr) { |
| 348 { | 342 format = kFileFormatPcm16kHzFile; |
| 349 format = kFileFormatPcm16kHzFile; | 343 codecInst = &dummyCodec; |
| 350 codecInst=&dummyCodec; | |
| 351 } | 344 } |
| 352 else if((STR_CASE_CMP(codecInst->plname,"L16") == 0) || | 345 else if((STR_CASE_CMP(codecInst->plname,"L16") == 0) || |
| 353 (STR_CASE_CMP(codecInst->plname,"PCMU") == 0) || | 346 (STR_CASE_CMP(codecInst->plname,"PCMU") == 0) || |
| 354 (STR_CASE_CMP(codecInst->plname,"PCMA") == 0)) | 347 (STR_CASE_CMP(codecInst->plname,"PCMA") == 0)) |
| 355 { | 348 { |
| 356 format = kFileFormatWavFile; | 349 format = kFileFormatWavFile; |
| 357 } | 350 } |
| 358 else | 351 else |
| 359 { | 352 { |
| 360 format = kFileFormatCompressedFile; | 353 format = kFileFormatCompressedFile; |
| 361 } | 354 } |
| 362 | 355 |
| 363 rtc::CritScope cs(&_fileCritSect); | 356 rtc::CritScope cs(&_fileCritSect); |
| 364 | 357 |
| 365 // Destroy the old instance | 358 // Destroy the old instance |
| 366 if (output_file_recorder_) { | 359 if (output_file_recorder_) { |
| 367 output_file_recorder_->RegisterModuleFileCallback(NULL); | 360 output_file_recorder_->RegisterModuleFileCallback(nullptr); |
| 368 output_file_recorder_.reset(); | 361 output_file_recorder_.reset(); |
| 369 } | 362 } |
| 370 | 363 |
| 371 output_file_recorder_ = FileRecorder::CreateFileRecorder( | 364 output_file_recorder_ = FileRecorder::CreateFileRecorder( |
| 372 _instanceId, (const FileFormats)format); | 365 _instanceId, (const FileFormats)format); |
| 373 if (!output_file_recorder_) { | 366 if (!output_file_recorder_) { |
| 374 _engineStatisticsPtr->SetLastError( | 367 _engineStatisticsPtr->SetLastError( |
| 375 VE_INVALID_ARGUMENT, kTraceError, | 368 VE_INVALID_ARGUMENT, kTraceError, |
| 376 "StartRecordingPlayout() fileRecorder format isnot correct"); | 369 "StartRecordingPlayout() fileRecorder format isnot correct"); |
| 377 return -1; | 370 return -1; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 406 } | 399 } |
| 407 | 400 |
| 408 rtc::CritScope cs(&_fileCritSect); | 401 rtc::CritScope cs(&_fileCritSect); |
| 409 | 402 |
| 410 if (output_file_recorder_->StopRecording() != 0) { | 403 if (output_file_recorder_->StopRecording() != 0) { |
| 411 _engineStatisticsPtr->SetLastError( | 404 _engineStatisticsPtr->SetLastError( |
| 412 VE_STOP_RECORDING_FAILED, kTraceError, | 405 VE_STOP_RECORDING_FAILED, kTraceError, |
| 413 "StopRecording(), could not stop recording"); | 406 "StopRecording(), could not stop recording"); |
| 414 return -1; | 407 return -1; |
| 415 } | 408 } |
| 416 output_file_recorder_->RegisterModuleFileCallback(NULL); | 409 output_file_recorder_->RegisterModuleFileCallback(nullptr); |
| 417 output_file_recorder_.reset(); | 410 output_file_recorder_.reset(); |
| 418 _outputFileRecording = false; | 411 _outputFileRecording = false; |
| 419 | 412 |
| 420 return 0; | 413 return 0; |
| 421 } | 414 } |
| 422 | 415 |
| 423 int OutputMixer::GetMixedAudio(int sample_rate_hz, | 416 int OutputMixer::GetMixedAudio(int sample_rate_hz, |
| 424 size_t num_channels, | 417 size_t num_channels, |
| 425 AudioFrame* frame) { | 418 AudioFrame* frame) { |
| 426 WEBRTC_TRACE( | 419 WEBRTC_TRACE( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 } | 491 } |
| 499 } | 492 } |
| 500 | 493 |
| 501 // --- Measure audio level (0-9) for the combined signal | 494 // --- Measure audio level (0-9) for the combined signal |
| 502 _audioLevel.ComputeLevel(_audioFrame); | 495 _audioLevel.ComputeLevel(_audioFrame); |
| 503 | 496 |
| 504 return 0; | 497 return 0; |
| 505 } | 498 } |
| 506 } // namespace voe | 499 } // namespace voe |
| 507 } // namespace webrtc | 500 } // namespace webrtc |
| OLD | NEW |