| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 OutputMixer::OutputMixer(uint32_t instanceId) : | 93 OutputMixer::OutputMixer(uint32_t instanceId) : |
| 94 _mixerModule(*AudioConferenceMixer::Create(instanceId)), | 94 _mixerModule(*AudioConferenceMixer::Create(instanceId)), |
| 95 _audioLevel(), | 95 _audioLevel(), |
| 96 _instanceId(instanceId), | 96 _instanceId(instanceId), |
| 97 _externalMediaCallbackPtr(NULL), | 97 _externalMediaCallbackPtr(NULL), |
| 98 _externalMedia(false), | 98 _externalMedia(false), |
| 99 _panLeft(1.0f), | 99 _panLeft(1.0f), |
| 100 _panRight(1.0f), | 100 _panRight(1.0f), |
| 101 _mixingFrequencyHz(8000), | 101 _mixingFrequencyHz(8000), |
| 102 _outputFileRecorderPtr(NULL), | |
| 103 _outputFileRecording(false) | 102 _outputFileRecording(false) |
| 104 { | 103 { |
| 105 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), | 104 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), |
| 106 "OutputMixer::OutputMixer() - ctor"); | 105 "OutputMixer::OutputMixer() - ctor"); |
| 107 | 106 |
| 108 if (_mixerModule.RegisterMixedStreamCallback(this) == -1) | 107 if (_mixerModule.RegisterMixedStreamCallback(this) == -1) |
| 109 { | 108 { |
| 110 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), | 109 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), |
| 111 "OutputMixer::OutputMixer() failed to register mixer" | 110 "OutputMixer::OutputMixer() failed to register mixer" |
| 112 "callbacks"); | 111 "callbacks"); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 126 OutputMixer::~OutputMixer() | 125 OutputMixer::~OutputMixer() |
| 127 { | 126 { |
| 128 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), | 127 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId,-1), |
| 129 "OutputMixer::~OutputMixer() - dtor"); | 128 "OutputMixer::~OutputMixer() - dtor"); |
| 130 if (_externalMedia) | 129 if (_externalMedia) |
| 131 { | 130 { |
| 132 DeRegisterExternalMediaProcessing(); | 131 DeRegisterExternalMediaProcessing(); |
| 133 } | 132 } |
| 134 { | 133 { |
| 135 rtc::CritScope cs(&_fileCritSect); | 134 rtc::CritScope cs(&_fileCritSect); |
| 136 if (_outputFileRecorderPtr) | 135 if (output_file_recorder_) { |
| 137 { | 136 output_file_recorder_->RegisterModuleFileCallback(NULL); |
| 138 _outputFileRecorderPtr->RegisterModuleFileCallback(NULL); | 137 output_file_recorder_->StopRecording(); |
| 139 _outputFileRecorderPtr->StopRecording(); | |
| 140 FileRecorder::DestroyFileRecorder(_outputFileRecorderPtr); | |
| 141 _outputFileRecorderPtr = NULL; | |
| 142 } | 138 } |
| 143 } | 139 } |
| 144 _mixerModule.UnRegisterMixedStreamCallback(); | 140 _mixerModule.UnRegisterMixedStreamCallback(); |
| 145 delete &_mixerModule; | 141 delete &_mixerModule; |
| 146 } | 142 } |
| 147 | 143 |
| 148 int32_t | 144 int32_t |
| 149 OutputMixer::SetEngineInformation(voe::Statistics& engineStatistics) | 145 OutputMixer::SetEngineInformation(voe::Statistics& engineStatistics) |
| 150 { | 146 { |
| 151 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), | 147 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 format = kFileFormatWavFile; | 284 format = kFileFormatWavFile; |
| 289 } | 285 } |
| 290 else | 286 else |
| 291 { | 287 { |
| 292 format = kFileFormatCompressedFile; | 288 format = kFileFormatCompressedFile; |
| 293 } | 289 } |
| 294 | 290 |
| 295 rtc::CritScope cs(&_fileCritSect); | 291 rtc::CritScope cs(&_fileCritSect); |
| 296 | 292 |
| 297 // Destroy the old instance | 293 // Destroy the old instance |
| 298 if (_outputFileRecorderPtr) | 294 if (output_file_recorder_) { |
| 299 { | 295 output_file_recorder_->RegisterModuleFileCallback(NULL); |
| 300 _outputFileRecorderPtr->RegisterModuleFileCallback(NULL); | 296 output_file_recorder_.reset(); |
| 301 FileRecorder::DestroyFileRecorder(_outputFileRecorderPtr); | |
| 302 _outputFileRecorderPtr = NULL; | |
| 303 } | 297 } |
| 304 | 298 |
| 305 _outputFileRecorderPtr = FileRecorder::CreateFileRecorder( | 299 output_file_recorder_ = FileRecorder::CreateFileRecorder( |
| 306 _instanceId, | 300 _instanceId, (const FileFormats)format); |
| 307 (const FileFormats)format); | 301 if (!output_file_recorder_) { |
| 308 if (_outputFileRecorderPtr == NULL) | 302 _engineStatisticsPtr->SetLastError( |
| 309 { | 303 VE_INVALID_ARGUMENT, kTraceError, |
| 310 _engineStatisticsPtr->SetLastError( | 304 "StartRecordingPlayout() fileRecorder format isnot correct"); |
| 311 VE_INVALID_ARGUMENT, kTraceError, | 305 return -1; |
| 312 "StartRecordingPlayout() fileRecorder format isnot correct"); | |
| 313 return -1; | |
| 314 } | 306 } |
| 315 | 307 |
| 316 if (_outputFileRecorderPtr->StartRecordingAudioFile( | 308 if (output_file_recorder_->StartRecordingAudioFile( |
| 317 fileName, | 309 fileName, (const CodecInst&)*codecInst, notificationTime) != 0) { |
| 318 (const CodecInst&)*codecInst, | 310 _engineStatisticsPtr->SetLastError( |
| 319 notificationTime) != 0) | 311 VE_BAD_FILE, kTraceError, |
| 320 { | 312 "StartRecordingAudioFile() failed to start file recording"); |
| 321 _engineStatisticsPtr->SetLastError( | 313 output_file_recorder_->StopRecording(); |
| 322 VE_BAD_FILE, kTraceError, | 314 output_file_recorder_.reset(); |
| 323 "StartRecordingAudioFile() failed to start file recording"); | 315 return -1; |
| 324 _outputFileRecorderPtr->StopRecording(); | |
| 325 FileRecorder::DestroyFileRecorder(_outputFileRecorderPtr); | |
| 326 _outputFileRecorderPtr = NULL; | |
| 327 return -1; | |
| 328 } | 316 } |
| 329 _outputFileRecorderPtr->RegisterModuleFileCallback(this); | 317 output_file_recorder_->RegisterModuleFileCallback(this); |
| 330 _outputFileRecording = true; | 318 _outputFileRecording = true; |
| 331 | 319 |
| 332 return 0; | 320 return 0; |
| 333 } | 321 } |
| 334 | 322 |
| 335 int OutputMixer::StartRecordingPlayout(OutStream* stream, | 323 int OutputMixer::StartRecordingPlayout(OutStream* stream, |
| 336 const CodecInst* codecInst) | 324 const CodecInst* codecInst) |
| 337 { | 325 { |
| 338 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), | 326 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), |
| 339 "OutputMixer::StartRecordingPlayout()"); | 327 "OutputMixer::StartRecordingPlayout()"); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 368 format = kFileFormatWavFile; | 356 format = kFileFormatWavFile; |
| 369 } | 357 } |
| 370 else | 358 else |
| 371 { | 359 { |
| 372 format = kFileFormatCompressedFile; | 360 format = kFileFormatCompressedFile; |
| 373 } | 361 } |
| 374 | 362 |
| 375 rtc::CritScope cs(&_fileCritSect); | 363 rtc::CritScope cs(&_fileCritSect); |
| 376 | 364 |
| 377 // Destroy the old instance | 365 // Destroy the old instance |
| 378 if (_outputFileRecorderPtr) | 366 if (output_file_recorder_) { |
| 379 { | 367 output_file_recorder_->RegisterModuleFileCallback(NULL); |
| 380 _outputFileRecorderPtr->RegisterModuleFileCallback(NULL); | 368 output_file_recorder_.reset(); |
| 381 FileRecorder::DestroyFileRecorder(_outputFileRecorderPtr); | |
| 382 _outputFileRecorderPtr = NULL; | |
| 383 } | 369 } |
| 384 | 370 |
| 385 _outputFileRecorderPtr = FileRecorder::CreateFileRecorder( | 371 output_file_recorder_ = FileRecorder::CreateFileRecorder( |
| 386 _instanceId, | 372 _instanceId, (const FileFormats)format); |
| 387 (const FileFormats)format); | 373 if (!output_file_recorder_) { |
| 388 if (_outputFileRecorderPtr == NULL) | 374 _engineStatisticsPtr->SetLastError( |
| 389 { | 375 VE_INVALID_ARGUMENT, kTraceError, |
| 390 _engineStatisticsPtr->SetLastError( | 376 "StartRecordingPlayout() fileRecorder format isnot correct"); |
| 391 VE_INVALID_ARGUMENT, kTraceError, | 377 return -1; |
| 392 "StartRecordingPlayout() fileRecorder format isnot correct"); | |
| 393 return -1; | |
| 394 } | 378 } |
| 395 | 379 |
| 396 if (_outputFileRecorderPtr->StartRecordingAudioFile(*stream, | 380 if (output_file_recorder_->StartRecordingAudioFile(*stream, *codecInst, |
| 397 *codecInst, | 381 notificationTime) != 0) { |
| 398 notificationTime) != 0) | 382 _engineStatisticsPtr->SetLastError( |
| 399 { | 383 VE_BAD_FILE, kTraceError, |
| 400 _engineStatisticsPtr->SetLastError(VE_BAD_FILE, kTraceError, | 384 "StartRecordingAudioFile() failed to start file recording"); |
| 401 "StartRecordingAudioFile() failed to start file recording"); | 385 output_file_recorder_->StopRecording(); |
| 402 _outputFileRecorderPtr->StopRecording(); | 386 output_file_recorder_.reset(); |
| 403 FileRecorder::DestroyFileRecorder(_outputFileRecorderPtr); | 387 return -1; |
| 404 _outputFileRecorderPtr = NULL; | |
| 405 return -1; | |
| 406 } | 388 } |
| 407 | 389 |
| 408 _outputFileRecorderPtr->RegisterModuleFileCallback(this); | 390 output_file_recorder_->RegisterModuleFileCallback(this); |
| 409 _outputFileRecording = true; | 391 _outputFileRecording = true; |
| 410 | 392 |
| 411 return 0; | 393 return 0; |
| 412 } | 394 } |
| 413 | 395 |
| 414 int OutputMixer::StopRecordingPlayout() | 396 int OutputMixer::StopRecordingPlayout() |
| 415 { | 397 { |
| 416 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), | 398 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,-1), |
| 417 "OutputMixer::StopRecordingPlayout()"); | 399 "OutputMixer::StopRecordingPlayout()"); |
| 418 | 400 |
| 419 if (!_outputFileRecording) | 401 if (!_outputFileRecording) |
| 420 { | 402 { |
| 421 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), | 403 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,-1), |
| 422 "StopRecordingPlayout() file isnot recording"); | 404 "StopRecordingPlayout() file isnot recording"); |
| 423 return -1; | 405 return -1; |
| 424 } | 406 } |
| 425 | 407 |
| 426 rtc::CritScope cs(&_fileCritSect); | 408 rtc::CritScope cs(&_fileCritSect); |
| 427 | 409 |
| 428 if (_outputFileRecorderPtr->StopRecording() != 0) | 410 if (output_file_recorder_->StopRecording() != 0) { |
| 429 { | 411 _engineStatisticsPtr->SetLastError( |
| 430 _engineStatisticsPtr->SetLastError( | 412 VE_STOP_RECORDING_FAILED, kTraceError, |
| 431 VE_STOP_RECORDING_FAILED, kTraceError, | 413 "StopRecording(), could not stop recording"); |
| 432 "StopRecording(), could not stop recording"); | 414 return -1; |
| 433 return -1; | |
| 434 } | 415 } |
| 435 _outputFileRecorderPtr->RegisterModuleFileCallback(NULL); | 416 output_file_recorder_->RegisterModuleFileCallback(NULL); |
| 436 FileRecorder::DestroyFileRecorder(_outputFileRecorderPtr); | 417 output_file_recorder_.reset(); |
| 437 _outputFileRecorderPtr = NULL; | |
| 438 _outputFileRecording = false; | 418 _outputFileRecording = false; |
| 439 | 419 |
| 440 return 0; | 420 return 0; |
| 441 } | 421 } |
| 442 | 422 |
| 443 int OutputMixer::GetMixedAudio(int sample_rate_hz, | 423 int OutputMixer::GetMixedAudio(int sample_rate_hz, |
| 444 size_t num_channels, | 424 size_t num_channels, |
| 445 AudioFrame* frame) { | 425 AudioFrame* frame) { |
| 446 WEBRTC_TRACE( | 426 WEBRTC_TRACE( |
| 447 kTraceStream, kTraceVoice, VoEId(_instanceId,-1), | 427 kTraceStream, kTraceVoice, VoEId(_instanceId,-1), |
| 448 "OutputMixer::GetMixedAudio(sample_rate_hz=%d, num_channels=%" PRIuS ")", | 428 "OutputMixer::GetMixedAudio(sample_rate_hz=%d, num_channels=%" PRIuS ")", |
| 449 sample_rate_hz, num_channels); | 429 sample_rate_hz, num_channels); |
| 450 | 430 |
| 451 // --- Record playout if enabled | 431 // --- Record playout if enabled |
| 452 { | 432 { |
| 453 rtc::CritScope cs(&_fileCritSect); | 433 rtc::CritScope cs(&_fileCritSect); |
| 454 if (_outputFileRecording && _outputFileRecorderPtr) | 434 if (_outputFileRecording && output_file_recorder_) |
| 455 _outputFileRecorderPtr->RecordAudioToFile(_audioFrame); | 435 output_file_recorder_->RecordAudioToFile(_audioFrame); |
| 456 } | 436 } |
| 457 | 437 |
| 458 frame->num_channels_ = num_channels; | 438 frame->num_channels_ = num_channels; |
| 459 frame->sample_rate_hz_ = sample_rate_hz; | 439 frame->sample_rate_hz_ = sample_rate_hz; |
| 460 // TODO(andrew): Ideally the downmixing would occur much earlier, in | 440 // TODO(andrew): Ideally the downmixing would occur much earlier, in |
| 461 // AudioCodingModule. | 441 // AudioCodingModule. |
| 462 RemixAndResample(_audioFrame, &resampler_, frame); | 442 RemixAndResample(_audioFrame, &resampler_, frame); |
| 463 return 0; | 443 return 0; |
| 464 } | 444 } |
| 465 | 445 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 } | 498 } |
| 519 } | 499 } |
| 520 | 500 |
| 521 // --- Measure audio level (0-9) for the combined signal | 501 // --- Measure audio level (0-9) for the combined signal |
| 522 _audioLevel.ComputeLevel(_audioFrame); | 502 _audioLevel.ComputeLevel(_audioFrame); |
| 523 | 503 |
| 524 return 0; | 504 return 0; |
| 525 } | 505 } |
| 526 } // namespace voe | 506 } // namespace voe |
| 527 } // namespace webrtc | 507 } // namespace webrtc |
| OLD | NEW |