OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 options.extended_filter_aec.Set(false); | 381 options.extended_filter_aec.Set(false); |
382 options.delay_agnostic_aec.Set(false); | 382 options.delay_agnostic_aec.Set(false); |
383 options.experimental_ns.Set(false); | 383 options.experimental_ns.Set(false); |
384 options.aec_dump.Set(false); | 384 options.aec_dump.Set(false); |
385 return options; | 385 return options; |
386 } | 386 } |
387 | 387 |
388 std::string GetEnableString(bool enable) { | 388 std::string GetEnableString(bool enable) { |
389 return enable ? "enable" : "disable"; | 389 return enable ? "enable" : "disable"; |
390 } | 390 } |
| 391 |
| 392 webrtc::AudioState::Config MakeAudioStateConfig(VoEWrapper* voe_wrapper) { |
| 393 webrtc::AudioState::Config config; |
| 394 config.voice_engine = voe_wrapper->engine(); |
| 395 return config; |
| 396 } |
| 397 |
391 } // namespace { | 398 } // namespace { |
392 | 399 |
393 WebRtcVoiceEngine::WebRtcVoiceEngine() | 400 WebRtcVoiceEngine::WebRtcVoiceEngine() |
394 : voe_wrapper_(new VoEWrapper()), | 401 : voe_wrapper_(new VoEWrapper()), |
395 tracing_(new VoETraceWrapper()), | 402 tracing_(new VoETraceWrapper()), |
396 adm_(NULL), | 403 audio_state_(webrtc::AudioState::Create(MakeAudioStateConfig(voe()))), |
397 log_filter_(SeverityToFilter(kDefaultLogSeverity)), | 404 log_filter_(SeverityToFilter(kDefaultLogSeverity)) { |
398 is_dumping_aec_(false) { | |
399 Construct(); | 405 Construct(); |
400 } | 406 } |
401 | 407 |
402 WebRtcVoiceEngine::WebRtcVoiceEngine(VoEWrapper* voe_wrapper, | 408 WebRtcVoiceEngine::WebRtcVoiceEngine(VoEWrapper* voe_wrapper, |
403 VoETraceWrapper* tracing) | 409 VoETraceWrapper* tracing, |
| 410 webrtc::AudioState* audio_state) |
404 : voe_wrapper_(voe_wrapper), | 411 : voe_wrapper_(voe_wrapper), |
405 tracing_(tracing), | 412 tracing_(tracing), |
406 adm_(NULL), | 413 audio_state_(audio_state), |
407 log_filter_(SeverityToFilter(kDefaultLogSeverity)), | 414 log_filter_(SeverityToFilter(kDefaultLogSeverity)) { |
408 is_dumping_aec_(false) { | |
409 Construct(); | 415 Construct(); |
410 } | 416 } |
411 | 417 |
412 void WebRtcVoiceEngine::Construct() { | 418 void WebRtcVoiceEngine::Construct() { |
| 419 std::memset(&default_agc_config_, 0, sizeof(default_agc_config_)); |
413 SetTraceFilter(log_filter_); | 420 SetTraceFilter(log_filter_); |
414 initialized_ = false; | |
415 LOG(LS_VERBOSE) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; | 421 LOG(LS_VERBOSE) << "WebRtcVoiceEngine::WebRtcVoiceEngine"; |
416 SetTraceOptions(""); | 422 SetTraceOptions(""); |
417 if (tracing_->SetTraceCallback(this) == -1) { | 423 if (tracing_->SetTraceCallback(this) == -1) { |
418 LOG_RTCERR0(SetTraceCallback); | 424 LOG_RTCERR0(SetTraceCallback); |
419 } | 425 } |
420 if (voe_wrapper_->base()->RegisterVoiceEngineObserver(*this) == -1) { | |
421 LOG_RTCERR0(RegisterVoiceEngineObserver); | |
422 } | |
423 // Clear the default agc state. | |
424 memset(&default_agc_config_, 0, sizeof(default_agc_config_)); | |
425 | 426 |
426 // Load our audio codec list. | 427 // Load our audio codec list. |
427 ConstructCodecs(); | 428 ConstructCodecs(); |
428 | 429 |
429 // Load our RTP Header extensions. | 430 // Load our RTP Header extensions. |
430 rtp_header_extensions_.push_back( | 431 rtp_header_extensions_.push_back( |
431 RtpHeaderExtension(kRtpAudioLevelHeaderExtension, | 432 RtpHeaderExtension(kRtpAudioLevelHeaderExtension, |
432 kRtpAudioLevelHeaderExtensionDefaultId)); | 433 kRtpAudioLevelHeaderExtensionDefaultId)); |
433 rtp_header_extensions_.push_back( | 434 rtp_header_extensions_.push_back( |
434 RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension, | 435 RtpHeaderExtension(kRtpAbsoluteSenderTimeHeaderExtension, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 if (voe_wrapper_->codec()->GetCodec(index, *codec) == -1) { | 503 if (voe_wrapper_->codec()->GetCodec(index, *codec) == -1) { |
503 return false; | 504 return false; |
504 } | 505 } |
505 // Change the sample rate of G722 to 8000 to match SDP. | 506 // Change the sample rate of G722 to 8000 to match SDP. |
506 MaybeFixupG722(codec, 8000); | 507 MaybeFixupG722(codec, 8000); |
507 return true; | 508 return true; |
508 } | 509 } |
509 | 510 |
510 WebRtcVoiceEngine::~WebRtcVoiceEngine() { | 511 WebRtcVoiceEngine::~WebRtcVoiceEngine() { |
511 LOG(LS_VERBOSE) << "WebRtcVoiceEngine::~WebRtcVoiceEngine"; | 512 LOG(LS_VERBOSE) << "WebRtcVoiceEngine::~WebRtcVoiceEngine"; |
512 if (voe_wrapper_->base()->DeRegisterVoiceEngineObserver() == -1) { | |
513 LOG_RTCERR0(DeRegisterVoiceEngineObserver); | |
514 } | |
515 if (adm_) { | 513 if (adm_) { |
516 voe_wrapper_.reset(); | 514 voe_wrapper_.reset(); |
517 adm_->Release(); | 515 adm_->Release(); |
518 adm_ = NULL; | 516 adm_ = NULL; |
519 } | 517 } |
520 | 518 |
521 tracing_->SetTraceCallback(NULL); | 519 tracing_->SetTraceCallback(NULL); |
522 } | 520 } |
523 | 521 |
524 bool WebRtcVoiceEngine::Init(rtc::Thread* worker_thread) { | 522 bool WebRtcVoiceEngine::Init(rtc::Thread* thread) { |
525 RTC_DCHECK(worker_thread == rtc::Thread::Current()); | 523 RTC_DCHECK(thread == rtc::Thread::Current()); |
526 LOG(LS_INFO) << "WebRtcVoiceEngine::Init"; | 524 LOG(LS_INFO) << "WebRtcVoiceEngine::Init"; |
527 bool res = InitInternal(); | 525 bool res = InitInternal(); |
528 if (res) { | 526 if (res) { |
529 LOG(LS_INFO) << "WebRtcVoiceEngine::Init Done!"; | 527 LOG(LS_INFO) << "WebRtcVoiceEngine::Init Done!"; |
530 } else { | 528 } else { |
531 LOG(LS_ERROR) << "WebRtcVoiceEngine::Init failed"; | 529 LOG(LS_ERROR) << "WebRtcVoiceEngine::Init failed"; |
532 Terminate(); | 530 Terminate(); |
533 } | 531 } |
534 return res; | 532 return res; |
535 } | 533 } |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 if (length < 72) { | 1192 if (length < 72) { |
1195 std::string msg(trace, length); | 1193 std::string msg(trace, length); |
1196 LOG(LS_ERROR) << "Malformed webrtc log message: "; | 1194 LOG(LS_ERROR) << "Malformed webrtc log message: "; |
1197 LOG_V(sev) << msg; | 1195 LOG_V(sev) << msg; |
1198 } else { | 1196 } else { |
1199 std::string msg(trace + 71, length - 72); | 1197 std::string msg(trace + 71, length - 72); |
1200 LOG_V(sev) << "webrtc: " << msg; | 1198 LOG_V(sev) << "webrtc: " << msg; |
1201 } | 1199 } |
1202 } | 1200 } |
1203 | 1201 |
1204 void WebRtcVoiceEngine::CallbackOnError(int channel_id, int err_code) { | |
1205 RTC_DCHECK(channel_id == -1); | |
1206 LOG(LS_WARNING) << "VoiceEngine error " << err_code << " reported on channel " | |
1207 << channel_id << "."; | |
1208 rtc::CritScope lock(&channels_cs_); | |
1209 for (WebRtcVoiceMediaChannel* channel : channels_) { | |
1210 channel->OnError(err_code); | |
1211 } | |
1212 } | |
1213 | |
1214 void WebRtcVoiceEngine::RegisterChannel(WebRtcVoiceMediaChannel* channel) { | 1202 void WebRtcVoiceEngine::RegisterChannel(WebRtcVoiceMediaChannel* channel) { |
1215 RTC_DCHECK(channel != NULL); | 1203 RTC_DCHECK(channel); |
1216 rtc::CritScope lock(&channels_cs_); | |
1217 channels_.push_back(channel); | 1204 channels_.push_back(channel); |
1218 } | 1205 } |
1219 | 1206 |
1220 void WebRtcVoiceEngine::UnregisterChannel(WebRtcVoiceMediaChannel* channel) { | 1207 void WebRtcVoiceEngine::UnregisterChannel(WebRtcVoiceMediaChannel* channel) { |
1221 rtc::CritScope lock(&channels_cs_); | |
1222 auto it = std::find(channels_.begin(), channels_.end(), channel); | 1208 auto it = std::find(channels_.begin(), channels_.end(), channel); |
1223 if (it != channels_.end()) { | 1209 RTC_DCHECK(it != channels_.end()); |
1224 channels_.erase(it); | 1210 channels_.erase(it); |
1225 } | |
1226 } | 1211 } |
1227 | 1212 |
1228 // Adjusts the default AGC target level by the specified delta. | 1213 // Adjusts the default AGC target level by the specified delta. |
1229 // NB: If we start messing with other config fields, we'll want | 1214 // NB: If we start messing with other config fields, we'll want |
1230 // to save the current webrtc::AgcConfig as well. | 1215 // to save the current webrtc::AgcConfig as well. |
1231 bool WebRtcVoiceEngine::AdjustAgcLevel(int delta) { | 1216 bool WebRtcVoiceEngine::AdjustAgcLevel(int delta) { |
1232 webrtc::AgcConfig config = default_agc_config_; | 1217 webrtc::AgcConfig config = default_agc_config_; |
1233 config.targetLeveldBOv -= delta; | 1218 config.targetLeveldBOv -= delta; |
1234 | 1219 |
1235 LOG(LS_INFO) << "Adjusting AGC level from default -" | 1220 LOG(LS_INFO) << "Adjusting AGC level from default -" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 // RTC_DCHECK(voe_audio_transport); | 1311 // RTC_DCHECK(voe_audio_transport); |
1327 RTC_DCHECK(call); | 1312 RTC_DCHECK(call); |
1328 audio_capture_thread_checker_.DetachFromThread(); | 1313 audio_capture_thread_checker_.DetachFromThread(); |
1329 webrtc::AudioSendStream::Config config(nullptr); | 1314 webrtc::AudioSendStream::Config config(nullptr); |
1330 config.voe_channel_id = channel_; | 1315 config.voe_channel_id = channel_; |
1331 config.rtp.ssrc = ssrc; | 1316 config.rtp.ssrc = ssrc; |
1332 stream_ = call_->CreateAudioSendStream(config); | 1317 stream_ = call_->CreateAudioSendStream(config); |
1333 RTC_DCHECK(stream_); | 1318 RTC_DCHECK(stream_); |
1334 } | 1319 } |
1335 ~WebRtcAudioSendStream() override { | 1320 ~WebRtcAudioSendStream() override { |
1336 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); | 1321 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
1337 Stop(); | 1322 Stop(); |
1338 call_->DestroyAudioSendStream(stream_); | 1323 call_->DestroyAudioSendStream(stream_); |
1339 } | 1324 } |
1340 | 1325 |
1341 // Starts the rendering by setting a sink to the renderer to get data | 1326 // Starts the rendering by setting a sink to the renderer to get data |
1342 // callback. | 1327 // callback. |
1343 // This method is called on the libjingle worker thread. | 1328 // This method is called on the libjingle worker thread. |
1344 // TODO(xians): Make sure Start() is called only once. | 1329 // TODO(xians): Make sure Start() is called only once. |
1345 void Start(AudioRenderer* renderer) { | 1330 void Start(AudioRenderer* renderer) { |
1346 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); | 1331 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
1347 RTC_DCHECK(renderer); | 1332 RTC_DCHECK(renderer); |
1348 if (renderer_) { | 1333 if (renderer_) { |
1349 RTC_DCHECK(renderer_ == renderer); | 1334 RTC_DCHECK(renderer_ == renderer); |
1350 return; | 1335 return; |
1351 } | 1336 } |
1352 renderer->SetSink(this); | 1337 renderer->SetSink(this); |
1353 renderer_ = renderer; | 1338 renderer_ = renderer; |
1354 } | 1339 } |
1355 | 1340 |
1356 webrtc::AudioSendStream::Stats GetStats() const { | 1341 webrtc::AudioSendStream::Stats GetStats() const { |
1357 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); | 1342 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
1358 return stream_->GetStats(); | 1343 return stream_->GetStats(); |
1359 } | 1344 } |
1360 | 1345 |
1361 // Stops rendering by setting the sink of the renderer to nullptr. No data | 1346 // Stops rendering by setting the sink of the renderer to nullptr. No data |
1362 // callback will be received after this method. | 1347 // callback will be received after this method. |
1363 // This method is called on the libjingle worker thread. | 1348 // This method is called on the libjingle worker thread. |
1364 void Stop() { | 1349 void Stop() { |
1365 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); | 1350 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
1366 if (renderer_) { | 1351 if (renderer_) { |
1367 renderer_->SetSink(nullptr); | 1352 renderer_->SetSink(nullptr); |
1368 renderer_ = nullptr; | 1353 renderer_ = nullptr; |
1369 } | 1354 } |
1370 } | 1355 } |
1371 | 1356 |
1372 // AudioRenderer::Sink implementation. | 1357 // AudioRenderer::Sink implementation. |
1373 // This method is called on the audio thread. | 1358 // This method is called on the audio thread. |
1374 void OnData(const void* audio_data, | 1359 void OnData(const void* audio_data, |
1375 int bits_per_sample, | 1360 int bits_per_sample, |
1376 int sample_rate, | 1361 int sample_rate, |
1377 int number_of_channels, | 1362 int number_of_channels, |
1378 size_t number_of_frames) override { | 1363 size_t number_of_frames) override { |
| 1364 RTC_DCHECK(!thread_checker_.CalledOnValidThread()); |
1379 RTC_DCHECK(audio_capture_thread_checker_.CalledOnValidThread()); | 1365 RTC_DCHECK(audio_capture_thread_checker_.CalledOnValidThread()); |
1380 RTC_DCHECK(voe_audio_transport_); | 1366 RTC_DCHECK(voe_audio_transport_); |
1381 voe_audio_transport_->OnData(channel_, | 1367 voe_audio_transport_->OnData(channel_, |
1382 audio_data, | 1368 audio_data, |
1383 bits_per_sample, | 1369 bits_per_sample, |
1384 sample_rate, | 1370 sample_rate, |
1385 number_of_channels, | 1371 number_of_channels, |
1386 number_of_frames); | 1372 number_of_frames); |
1387 } | 1373 } |
1388 | 1374 |
1389 // Callback from the |renderer_| when it is going away. In case Start() has | 1375 // Callback from the |renderer_| when it is going away. In case Start() has |
1390 // never been called, this callback won't be triggered. | 1376 // never been called, this callback won't be triggered. |
1391 void OnClose() override { | 1377 void OnClose() override { |
1392 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); | 1378 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
1393 // Set |renderer_| to nullptr to make sure no more callback will get into | 1379 // Set |renderer_| to nullptr to make sure no more callback will get into |
1394 // the renderer. | 1380 // the renderer. |
1395 renderer_ = nullptr; | 1381 renderer_ = nullptr; |
1396 } | 1382 } |
1397 | 1383 |
1398 // Accessor to the VoE channel ID. | 1384 // Accessor to the VoE channel ID. |
1399 int channel() const { | 1385 int channel() const { |
1400 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); | 1386 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
1401 return channel_; | 1387 return channel_; |
1402 } | 1388 } |
1403 | 1389 |
1404 private: | 1390 private: |
1405 rtc::ThreadChecker signal_thread_checker_; | 1391 rtc::ThreadChecker thread_checker_; |
1406 rtc::ThreadChecker audio_capture_thread_checker_; | 1392 rtc::ThreadChecker audio_capture_thread_checker_; |
1407 const int channel_ = -1; | 1393 const int channel_ = -1; |
1408 webrtc::AudioTransport* const voe_audio_transport_ = nullptr; | 1394 webrtc::AudioTransport* const voe_audio_transport_ = nullptr; |
1409 webrtc::Call* call_ = nullptr; | 1395 webrtc::Call* call_ = nullptr; |
1410 webrtc::AudioSendStream* stream_ = nullptr; | 1396 webrtc::AudioSendStream* stream_ = nullptr; |
1411 | 1397 |
1412 // Raw pointer to AudioRenderer owned by LocalAudioTrackHandler. | 1398 // Raw pointer to AudioRenderer owned by LocalAudioTrackHandler. |
1413 // PeerConnection will make sure invalidating the pointer before the object | 1399 // PeerConnection will make sure invalidating the pointer before the object |
1414 // goes away. | 1400 // goes away. |
1415 AudioRenderer* renderer_ = nullptr; | 1401 AudioRenderer* renderer_ = nullptr; |
(...skipping 11 matching lines...) Expand all Loading... |
1427 private: | 1413 private: |
1428 int channel_; | 1414 int channel_; |
1429 | 1415 |
1430 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioReceiveStream); | 1416 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioReceiveStream); |
1431 }; | 1417 }; |
1432 | 1418 |
1433 // WebRtcVoiceMediaChannel | 1419 // WebRtcVoiceMediaChannel |
1434 WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, | 1420 WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine, |
1435 const AudioOptions& options, | 1421 const AudioOptions& options, |
1436 webrtc::Call* call) | 1422 webrtc::Call* call) |
1437 : engine_(engine), | 1423 : engine_(engine), call_(call) { |
1438 send_bitrate_setting_(false), | |
1439 send_bitrate_bps_(0), | |
1440 options_(), | |
1441 dtmf_allowed_(false), | |
1442 desired_playout_(false), | |
1443 nack_enabled_(false), | |
1444 playout_(false), | |
1445 typing_noise_detected_(false), | |
1446 desired_send_(SEND_NOTHING), | |
1447 send_(SEND_NOTHING), | |
1448 call_(call) { | |
1449 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel"; | 1424 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::WebRtcVoiceMediaChannel"; |
1450 RTC_DCHECK(nullptr != call); | 1425 RTC_DCHECK(call); |
1451 engine->RegisterChannel(this); | 1426 engine->RegisterChannel(this); |
1452 SetOptions(options); | 1427 SetOptions(options); |
1453 } | 1428 } |
1454 | 1429 |
1455 WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() { | 1430 WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel() { |
1456 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1431 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
1457 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel"; | 1432 LOG(LS_VERBOSE) << "WebRtcVoiceMediaChannel::~WebRtcVoiceMediaChannel"; |
1458 | 1433 |
1459 // Remove any remaining send streams. | 1434 // Remove any remaining send streams. |
1460 while (!send_streams_.empty()) { | 1435 while (!send_streams_.empty()) { |
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2645 sinfo.codec_name = stats.codec_name; | 2620 sinfo.codec_name = stats.codec_name; |
2646 sinfo.ext_seqnum = stats.ext_seqnum; | 2621 sinfo.ext_seqnum = stats.ext_seqnum; |
2647 sinfo.jitter_ms = stats.jitter_ms; | 2622 sinfo.jitter_ms = stats.jitter_ms; |
2648 sinfo.rtt_ms = stats.rtt_ms; | 2623 sinfo.rtt_ms = stats.rtt_ms; |
2649 sinfo.audio_level = stats.audio_level; | 2624 sinfo.audio_level = stats.audio_level; |
2650 sinfo.aec_quality_min = stats.aec_quality_min; | 2625 sinfo.aec_quality_min = stats.aec_quality_min; |
2651 sinfo.echo_delay_median_ms = stats.echo_delay_median_ms; | 2626 sinfo.echo_delay_median_ms = stats.echo_delay_median_ms; |
2652 sinfo.echo_delay_std_ms = stats.echo_delay_std_ms; | 2627 sinfo.echo_delay_std_ms = stats.echo_delay_std_ms; |
2653 sinfo.echo_return_loss = stats.echo_return_loss; | 2628 sinfo.echo_return_loss = stats.echo_return_loss; |
2654 sinfo.echo_return_loss_enhancement = stats.echo_return_loss_enhancement; | 2629 sinfo.echo_return_loss_enhancement = stats.echo_return_loss_enhancement; |
2655 sinfo.typing_noise_detected = typing_noise_detected_; | 2630 sinfo.typing_noise_detected = |
2656 // TODO(solenberg): Move to AudioSendStream. | 2631 (send_ == SEND_NOTHING ? false : stats.typing_noise_detected); |
2657 // sinfo.typing_noise_detected = stats.typing_noise_detected; | |
2658 info->senders.push_back(sinfo); | 2632 info->senders.push_back(sinfo); |
2659 } | 2633 } |
2660 | 2634 |
2661 // Get SSRC and stats for each receiver. | 2635 // Get SSRC and stats for each receiver. |
2662 RTC_DCHECK(info->receivers.size() == 0); | 2636 RTC_DCHECK(info->receivers.size() == 0); |
2663 for (const auto& stream : receive_streams_) { | 2637 for (const auto& stream : receive_streams_) { |
2664 webrtc::AudioReceiveStream::Stats stats = stream.second->GetStats(); | 2638 webrtc::AudioReceiveStream::Stats stats = stream.second->GetStats(); |
2665 VoiceReceiverInfo rinfo; | 2639 VoiceReceiverInfo rinfo; |
2666 rinfo.add_ssrc(stats.remote_ssrc); | 2640 rinfo.add_ssrc(stats.remote_ssrc); |
2667 rinfo.bytes_rcvd = stats.bytes_rcvd; | 2641 rinfo.bytes_rcvd = stats.bytes_rcvd; |
(...skipping 19 matching lines...) Expand all Loading... |
2687 rinfo.decoding_plc = stats.decoding_plc; | 2661 rinfo.decoding_plc = stats.decoding_plc; |
2688 rinfo.decoding_cng = stats.decoding_cng; | 2662 rinfo.decoding_cng = stats.decoding_cng; |
2689 rinfo.decoding_plc_cng = stats.decoding_plc_cng; | 2663 rinfo.decoding_plc_cng = stats.decoding_plc_cng; |
2690 rinfo.capture_start_ntp_time_ms = stats.capture_start_ntp_time_ms; | 2664 rinfo.capture_start_ntp_time_ms = stats.capture_start_ntp_time_ms; |
2691 info->receivers.push_back(rinfo); | 2665 info->receivers.push_back(rinfo); |
2692 } | 2666 } |
2693 | 2667 |
2694 return true; | 2668 return true; |
2695 } | 2669 } |
2696 | 2670 |
2697 void WebRtcVoiceMediaChannel::OnError(int error) { | |
2698 if (send_ == SEND_NOTHING) { | |
2699 return; | |
2700 } | |
2701 if (error == VE_TYPING_NOISE_WARNING) { | |
2702 typing_noise_detected_ = true; | |
2703 } else if (error == VE_TYPING_NOISE_OFF_WARNING) { | |
2704 typing_noise_detected_ = false; | |
2705 } | |
2706 } | |
2707 | |
2708 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { | 2671 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { |
2709 unsigned int ulevel = 0; | 2672 unsigned int ulevel = 0; |
2710 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); | 2673 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel); |
2711 return (ret == 0) ? static_cast<int>(ulevel) : -1; | 2674 return (ret == 0) ? static_cast<int>(ulevel) : -1; |
2712 } | 2675 } |
2713 | 2676 |
2714 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { | 2677 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { |
2715 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 2678 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
2716 const auto it = receive_channels_.find(ssrc); | 2679 const auto it = receive_channels_.find(ssrc); |
2717 if (it != receive_channels_.end()) { | 2680 if (it != receive_channels_.end()) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2780 LOG_RTCERR1(StartPlayout, channel); | 2743 LOG_RTCERR1(StartPlayout, channel); |
2781 return false; | 2744 return false; |
2782 } | 2745 } |
2783 } else { | 2746 } else { |
2784 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2747 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
2785 engine()->voe()->base()->StopPlayout(channel); | 2748 engine()->voe()->base()->StopPlayout(channel); |
2786 } | 2749 } |
2787 return true; | 2750 return true; |
2788 } | 2751 } |
2789 | 2752 |
2790 // Convert VoiceEngine error code into VoiceMediaChannel::Error enum. | |
2791 VoiceMediaChannel::Error | |
2792 WebRtcVoiceMediaChannel::WebRtcErrorToChannelError(int err_code) { | |
2793 switch (err_code) { | |
2794 case 0: | |
2795 return ERROR_NONE; | |
2796 case VE_CANNOT_START_RECORDING: | |
2797 case VE_MIC_VOL_ERROR: | |
2798 case VE_GET_MIC_VOL_ERROR: | |
2799 case VE_CANNOT_ACCESS_MIC_VOL: | |
2800 return ERROR_REC_DEVICE_OPEN_FAILED; | |
2801 case VE_SATURATION_WARNING: | |
2802 return ERROR_REC_DEVICE_SATURATION; | |
2803 case VE_REC_DEVICE_REMOVED: | |
2804 return ERROR_REC_DEVICE_REMOVED; | |
2805 case VE_RUNTIME_REC_WARNING: | |
2806 case VE_RUNTIME_REC_ERROR: | |
2807 return ERROR_REC_RUNTIME_ERROR; | |
2808 case VE_CANNOT_START_PLAYOUT: | |
2809 case VE_SPEAKER_VOL_ERROR: | |
2810 case VE_GET_SPEAKER_VOL_ERROR: | |
2811 case VE_CANNOT_ACCESS_SPEAKER_VOL: | |
2812 return ERROR_PLAY_DEVICE_OPEN_FAILED; | |
2813 case VE_RUNTIME_PLAY_WARNING: | |
2814 case VE_RUNTIME_PLAY_ERROR: | |
2815 return ERROR_PLAY_RUNTIME_ERROR; | |
2816 case VE_TYPING_NOISE_WARNING: | |
2817 return ERROR_REC_TYPING_NOISE_DETECTED; | |
2818 default: | |
2819 return VoiceMediaChannel::ERROR_OTHER; | |
2820 } | |
2821 } | |
2822 | |
2823 bool WebRtcVoiceMediaChannel::SetHeaderExtension(ExtensionSetterFunction setter, | 2753 bool WebRtcVoiceMediaChannel::SetHeaderExtension(ExtensionSetterFunction setter, |
2824 int channel_id, const RtpHeaderExtension* extension) { | 2754 int channel_id, const RtpHeaderExtension* extension) { |
2825 bool enable = false; | 2755 bool enable = false; |
2826 int id = 0; | 2756 int id = 0; |
2827 std::string uri; | 2757 std::string uri; |
2828 if (extension) { | 2758 if (extension) { |
2829 enable = true; | 2759 enable = true; |
2830 id = extension->id; | 2760 id = extension->id; |
2831 uri = extension->uri; | 2761 uri = extension->uri; |
2832 } | 2762 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2893 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); | 2823 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); |
2894 return false; | 2824 return false; |
2895 } | 2825 } |
2896 } | 2826 } |
2897 return true; | 2827 return true; |
2898 } | 2828 } |
2899 | 2829 |
2900 } // namespace cricket | 2830 } // namespace cricket |
2901 | 2831 |
2902 #endif // HAVE_WEBRTC_VOICE | 2832 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |