| 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 22 matching lines...) Expand all Loading... |
| 33 #include "rtc_base/format_macros.h" | 33 #include "rtc_base/format_macros.h" |
| 34 #include "rtc_base/location.h" | 34 #include "rtc_base/location.h" |
| 35 #include "rtc_base/logging.h" | 35 #include "rtc_base/logging.h" |
| 36 #include "rtc_base/rate_limiter.h" | 36 #include "rtc_base/rate_limiter.h" |
| 37 #include "rtc_base/task_queue.h" | 37 #include "rtc_base/task_queue.h" |
| 38 #include "rtc_base/thread_checker.h" | 38 #include "rtc_base/thread_checker.h" |
| 39 #include "rtc_base/timeutils.h" | 39 #include "rtc_base/timeutils.h" |
| 40 #include "system_wrappers/include/field_trial.h" | 40 #include "system_wrappers/include/field_trial.h" |
| 41 #include "system_wrappers/include/metrics.h" | 41 #include "system_wrappers/include/metrics.h" |
| 42 #include "system_wrappers/include/trace.h" | 42 #include "system_wrappers/include/trace.h" |
| 43 #include "voice_engine/statistics.h" | |
| 44 #include "voice_engine/utility.h" | 43 #include "voice_engine/utility.h" |
| 45 | 44 |
| 46 namespace webrtc { | 45 namespace webrtc { |
| 47 namespace voe { | 46 namespace voe { |
| 48 | 47 |
| 49 namespace { | 48 namespace { |
| 50 | 49 |
| 51 constexpr double kAudioSampleDurationSeconds = 0.01; | 50 constexpr double kAudioSampleDurationSeconds = 0.01; |
| 52 constexpr int64_t kMaxRetransmissionWindowMs = 1000; | 51 constexpr int64_t kMaxRetransmissionWindowMs = 1000; |
| 53 constexpr int64_t kMinRetransmissionWindowMs = 30; | 52 constexpr int64_t kMinRetransmissionWindowMs = 30; |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 | 439 |
| 441 // Push data from ACM to RTP/RTCP-module to deliver audio frame for | 440 // Push data from ACM to RTP/RTCP-module to deliver audio frame for |
| 442 // packetization. | 441 // packetization. |
| 443 // This call will trigger Transport::SendPacket() from the RTP/RTCP module. | 442 // This call will trigger Transport::SendPacket() from the RTP/RTCP module. |
| 444 if (!_rtpRtcpModule->SendOutgoingData( | 443 if (!_rtpRtcpModule->SendOutgoingData( |
| 445 (FrameType&)frameType, payloadType, timeStamp, | 444 (FrameType&)frameType, payloadType, timeStamp, |
| 446 // Leaving the time when this frame was | 445 // Leaving the time when this frame was |
| 447 // received from the capture device as | 446 // received from the capture device as |
| 448 // undefined for voice for now. | 447 // undefined for voice for now. |
| 449 -1, payloadData, payloadSize, fragmentation, nullptr, nullptr)) { | 448 -1, payloadData, payloadSize, fragmentation, nullptr, nullptr)) { |
| 450 _engineStatisticsPtr->SetLastError( | 449 LOG(LS_ERROR) << |
| 451 VE_RTP_RTCP_MODULE_ERROR, kTraceWarning, | 450 "Channel::SendData() failed to send data to RTP/RTCP module"; |
| 452 "Channel::SendData() failed to send data to RTP/RTCP module"); | |
| 453 return -1; | 451 return -1; |
| 454 } | 452 } |
| 455 | 453 |
| 456 return 0; | 454 return 0; |
| 457 } | 455 } |
| 458 | 456 |
| 459 bool Channel::SendRtp(const uint8_t* data, | 457 bool Channel::SendRtp(const uint8_t* data, |
| 460 size_t len, | 458 size_t len, |
| 461 const PacketOptions& options) { | 459 const PacketOptions& options) { |
| 462 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 460 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
| 463 "Channel::SendPacket(channel=%d, len=%" PRIuS ")", len); | 461 "Channel::SendPacket(channel=%d, len=%" PRIuS ")", len); |
| 464 | 462 |
| 465 rtc::CritScope cs(&_callbackCritSect); | 463 rtc::CritScope cs(&_callbackCritSect); |
| 466 | 464 |
| 467 if (_transportPtr == NULL) { | 465 if (_transportPtr == NULL) { |
| 468 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), | 466 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), |
| 469 "Channel::SendPacket() failed to send RTP packet due to" | 467 "Channel::SendPacket() failed to send RTP packet due to" |
| 470 " invalid transport object"); | 468 " invalid transport object"); |
| 471 return false; | 469 return false; |
| 472 } | 470 } |
| 473 | 471 |
| 474 uint8_t* bufferToSendPtr = (uint8_t*)data; | 472 uint8_t* bufferToSendPtr = (uint8_t*)data; |
| 475 size_t bufferLength = len; | 473 size_t bufferLength = len; |
| 476 | 474 |
| 477 if (!_transportPtr->SendRtp(bufferToSendPtr, bufferLength, options)) { | 475 if (!_transportPtr->SendRtp(bufferToSendPtr, bufferLength, options)) { |
| 478 std::string transport_name = | 476 LOG(LS_ERROR) << "Channel::SendPacket() RTP transmission failed"; |
| 479 _externalTransport ? "external transport" : "WebRtc sockets"; | |
| 480 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 481 "Channel::SendPacket() RTP transmission using %s failed", | |
| 482 transport_name.c_str()); | |
| 483 return false; | 477 return false; |
| 484 } | 478 } |
| 485 return true; | 479 return true; |
| 486 } | 480 } |
| 487 | 481 |
| 488 bool Channel::SendRtcp(const uint8_t* data, size_t len) { | 482 bool Channel::SendRtcp(const uint8_t* data, size_t len) { |
| 489 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 483 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
| 490 "Channel::SendRtcp(len=%" PRIuS ")", len); | 484 "Channel::SendRtcp(len=%" PRIuS ")", len); |
| 491 | 485 |
| 492 rtc::CritScope cs(&_callbackCritSect); | 486 rtc::CritScope cs(&_callbackCritSect); |
| 493 if (_transportPtr == NULL) { | 487 if (_transportPtr == NULL) { |
| 494 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), | 488 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), |
| 495 "Channel::SendRtcp() failed to send RTCP packet" | 489 "Channel::SendRtcp() failed to send RTCP packet" |
| 496 " due to invalid transport object"); | 490 " due to invalid transport object"); |
| 497 return false; | 491 return false; |
| 498 } | 492 } |
| 499 | 493 |
| 500 uint8_t* bufferToSendPtr = (uint8_t*)data; | 494 uint8_t* bufferToSendPtr = (uint8_t*)data; |
| 501 size_t bufferLength = len; | 495 size_t bufferLength = len; |
| 502 | 496 |
| 503 int n = _transportPtr->SendRtcp(bufferToSendPtr, bufferLength); | 497 int n = _transportPtr->SendRtcp(bufferToSendPtr, bufferLength); |
| 504 if (n < 0) { | 498 if (n < 0) { |
| 505 std::string transport_name = | 499 LOG(LS_ERROR) << "Channel::SendRtcp() transmission failed"; |
| 506 _externalTransport ? "external transport" : "WebRtc sockets"; | |
| 507 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 508 "Channel::SendRtcp() transmission using %s failed", | |
| 509 transport_name.c_str()); | |
| 510 return false; | 500 return false; |
| 511 } | 501 } |
| 512 return true; | 502 return true; |
| 513 } | 503 } |
| 514 | 504 |
| 515 void Channel::OnIncomingSSRCChanged(uint32_t ssrc) { | 505 void Channel::OnIncomingSSRCChanged(uint32_t ssrc) { |
| 516 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 506 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 517 "Channel::OnIncomingSSRCChanged(SSRC=%d)", ssrc); | 507 "Channel::OnIncomingSSRCChanged(SSRC=%d)", ssrc); |
| 518 | 508 |
| 519 // Update ssrc so that NTP for AV sync can be updated. | 509 // Update ssrc so that NTP for AV sync can be updated. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 549 audio_coding_->Codec(payloadName, &dummyCodec, frequency, channels); | 539 audio_coding_->Codec(payloadName, &dummyCodec, frequency, channels); |
| 550 receiveCodec.pacsize = dummyCodec.pacsize; | 540 receiveCodec.pacsize = dummyCodec.pacsize; |
| 551 | 541 |
| 552 // Register the new codec to the ACM | 542 // Register the new codec to the ACM |
| 553 if (!audio_coding_->RegisterReceiveCodec(receiveCodec.pltype, | 543 if (!audio_coding_->RegisterReceiveCodec(receiveCodec.pltype, |
| 554 CodecInstToSdp(receiveCodec))) { | 544 CodecInstToSdp(receiveCodec))) { |
| 555 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | 545 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
| 556 "Channel::OnInitializeDecoder() invalid codec (" | 546 "Channel::OnInitializeDecoder() invalid codec (" |
| 557 "pt=%d, name=%s) received - 1", | 547 "pt=%d, name=%s) received - 1", |
| 558 payloadType, payloadName); | 548 payloadType, payloadName); |
| 559 _engineStatisticsPtr->SetLastError(VE_AUDIO_CODING_MODULE_ERROR); | |
| 560 return -1; | 549 return -1; |
| 561 } | 550 } |
| 562 | 551 |
| 563 return 0; | 552 return 0; |
| 564 } | 553 } |
| 565 | 554 |
| 566 int32_t Channel::OnReceivedPayloadData(const uint8_t* payloadData, | 555 int32_t Channel::OnReceivedPayloadData(const uint8_t* payloadData, |
| 567 size_t payloadSize, | 556 size_t payloadSize, |
| 568 const WebRtcRTPHeader* rtpHeader) { | 557 const WebRtcRTPHeader* rtpHeader) { |
| 569 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 558 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
| 570 "Channel::OnReceivedPayloadData(payloadSize=%" PRIuS | 559 "Channel::OnReceivedPayloadData(payloadSize=%" PRIuS |
| 571 "," | 560 "," |
| 572 " payloadType=%u, audioChannel=%" PRIuS ")", | 561 " payloadType=%u, audioChannel=%" PRIuS ")", |
| 573 payloadSize, rtpHeader->header.payloadType, | 562 payloadSize, rtpHeader->header.payloadType, |
| 574 rtpHeader->type.Audio.channel); | 563 rtpHeader->type.Audio.channel); |
| 575 | 564 |
| 576 if (!channel_state_.Get().playing) { | 565 if (!channel_state_.Get().playing) { |
| 577 // Avoid inserting into NetEQ when we are not playing. Count the | 566 // Avoid inserting into NetEQ when we are not playing. Count the |
| 578 // packet as discarded. | 567 // packet as discarded. |
| 579 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 568 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
| 580 "received packet is discarded since playing is not" | 569 "received packet is discarded since playing is not" |
| 581 " activated"); | 570 " activated"); |
| 582 return 0; | 571 return 0; |
| 583 } | 572 } |
| 584 | 573 |
| 585 // Push the incoming payload (parsed and ready for decoding) into the ACM | 574 // Push the incoming payload (parsed and ready for decoding) into the ACM |
| 586 if (audio_coding_->IncomingPacket(payloadData, payloadSize, *rtpHeader) != | 575 if (audio_coding_->IncomingPacket(payloadData, payloadSize, *rtpHeader) != |
| 587 0) { | 576 0) { |
| 588 _engineStatisticsPtr->SetLastError( | 577 LOG(LS_ERROR) << |
| 589 VE_AUDIO_CODING_MODULE_ERROR, kTraceWarning, | 578 "Channel::OnReceivedPayloadData() unable to push data to the ACM"; |
| 590 "Channel::OnReceivedPayloadData() unable to push data to the ACM"); | |
| 591 return -1; | 579 return -1; |
| 592 } | 580 } |
| 593 | 581 |
| 594 int64_t round_trip_time = 0; | 582 int64_t round_trip_time = 0; |
| 595 _rtpRtcpModule->RTT(rtp_receiver_->SSRC(), &round_trip_time, NULL, NULL, | 583 _rtpRtcpModule->RTT(rtp_receiver_->SSRC(), &round_trip_time, NULL, NULL, |
| 596 NULL); | 584 NULL); |
| 597 | 585 |
| 598 std::vector<uint16_t> nack_list = audio_coding_->GetNackList(round_trip_time); | 586 std::vector<uint16_t> nack_list = audio_coding_->GetNackList(round_trip_time); |
| 599 if (!nack_list.empty()) { | 587 if (!nack_list.empty()) { |
| 600 // Can't use nack_list.data() since it's not supported by all | 588 // Can't use nack_list.data() since it's not supported by all |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 rtp_payload_registry_(new RTPPayloadRegistry()), | 740 rtp_payload_registry_(new RTPPayloadRegistry()), |
| 753 rtp_receive_statistics_( | 741 rtp_receive_statistics_( |
| 754 ReceiveStatistics::Create(Clock::GetRealTimeClock())), | 742 ReceiveStatistics::Create(Clock::GetRealTimeClock())), |
| 755 rtp_receiver_( | 743 rtp_receiver_( |
| 756 RtpReceiver::CreateAudioReceiver(Clock::GetRealTimeClock(), | 744 RtpReceiver::CreateAudioReceiver(Clock::GetRealTimeClock(), |
| 757 this, | 745 this, |
| 758 this, | 746 this, |
| 759 rtp_payload_registry_.get())), | 747 rtp_payload_registry_.get())), |
| 760 telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()), | 748 telephone_event_handler_(rtp_receiver_->GetTelephoneEventHandler()), |
| 761 _outputAudioLevel(), | 749 _outputAudioLevel(), |
| 762 _externalTransport(false), | |
| 763 _timeStamp(0), // This is just an offset, RTP module will add it's own | 750 _timeStamp(0), // This is just an offset, RTP module will add it's own |
| 764 // random offset | 751 // random offset |
| 765 ntp_estimator_(Clock::GetRealTimeClock()), | 752 ntp_estimator_(Clock::GetRealTimeClock()), |
| 766 playout_timestamp_rtp_(0), | 753 playout_timestamp_rtp_(0), |
| 767 playout_delay_ms_(0), | 754 playout_delay_ms_(0), |
| 768 send_sequence_number_(0), | 755 send_sequence_number_(0), |
| 769 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), | 756 rtp_ts_wraparound_handler_(new rtc::TimestampWrapAroundHandler()), |
| 770 capture_start_rtp_time_stamp_(-1), | 757 capture_start_rtp_time_stamp_(-1), |
| 771 capture_start_ntp_time_ms_(-1), | 758 capture_start_ntp_time_ms_(-1), |
| 772 _engineStatisticsPtr(NULL), | |
| 773 _moduleProcessThreadPtr(NULL), | 759 _moduleProcessThreadPtr(NULL), |
| 774 _audioDeviceModulePtr(NULL), | 760 _audioDeviceModulePtr(NULL), |
| 775 _callbackCritSectPtr(NULL), | |
| 776 _transportPtr(NULL), | 761 _transportPtr(NULL), |
| 777 input_mute_(false), | 762 input_mute_(false), |
| 778 previous_frame_muted_(false), | 763 previous_frame_muted_(false), |
| 779 _outputGain(1.0f), | 764 _outputGain(1.0f), |
| 780 _includeAudioLevelIndication(false), | 765 _includeAudioLevelIndication(false), |
| 781 transport_overhead_per_packet_(0), | 766 transport_overhead_per_packet_(0), |
| 782 rtp_overhead_per_packet_(0), | 767 rtp_overhead_per_packet_(0), |
| 783 _outputSpeechType(AudioFrame::kNormalSpeech), | 768 _outputSpeechType(AudioFrame::kNormalSpeech), |
| 784 rtcp_observer_(new VoERtcpObserver(this)), | 769 rtcp_observer_(new VoERtcpObserver(this)), |
| 785 associate_send_channel_(ChannelOwner(nullptr)), | 770 associate_send_channel_(ChannelOwner(nullptr)), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 | 813 |
| 829 int32_t Channel::Init() { | 814 int32_t Channel::Init() { |
| 830 RTC_DCHECK(construction_thread_.CalledOnValidThread()); | 815 RTC_DCHECK(construction_thread_.CalledOnValidThread()); |
| 831 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 816 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 832 "Channel::Init()"); | 817 "Channel::Init()"); |
| 833 | 818 |
| 834 channel_state_.Reset(); | 819 channel_state_.Reset(); |
| 835 | 820 |
| 836 // --- Initial sanity | 821 // --- Initial sanity |
| 837 | 822 |
| 838 if ((_engineStatisticsPtr == NULL) || (_moduleProcessThreadPtr == NULL)) { | 823 if (_moduleProcessThreadPtr == NULL) { |
| 839 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), | 824 WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId), |
| 840 "Channel::Init() must call SetEngineInformation() first"); | 825 "Channel::Init() must call SetEngineInformation() first"); |
| 841 return -1; | 826 return -1; |
| 842 } | 827 } |
| 843 | 828 |
| 844 // --- Add modules to process thread (for periodic schedulation) | 829 // --- Add modules to process thread (for periodic schedulation) |
| 845 | 830 |
| 846 _moduleProcessThreadPtr->RegisterModule(_rtpRtcpModule.get(), RTC_FROM_HERE); | 831 _moduleProcessThreadPtr->RegisterModule(_rtpRtcpModule.get(), RTC_FROM_HERE); |
| 847 | 832 |
| 848 // --- ACM initialization | 833 // --- ACM initialization |
| 849 | 834 |
| 850 if (audio_coding_->InitializeReceiver() == -1) { | 835 if (audio_coding_->InitializeReceiver() == -1) { |
| 851 _engineStatisticsPtr->SetLastError( | 836 LOG(LS_ERROR) << "Channel::Init() unable to initialize the ACM - 1"; |
| 852 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, | |
| 853 "Channel::Init() unable to initialize the ACM - 1"); | |
| 854 return -1; | 837 return -1; |
| 855 } | 838 } |
| 856 | 839 |
| 857 // --- RTP/RTCP module initialization | 840 // --- RTP/RTCP module initialization |
| 858 | 841 |
| 859 // Ensure that RTCP is enabled by default for the created channel. | 842 // Ensure that RTCP is enabled by default for the created channel. |
| 860 // Note that, the module will keep generating RTCP until it is explicitly | 843 // Note that, the module will keep generating RTCP until it is explicitly |
| 861 // disabled by the user. | 844 // disabled by the user. |
| 862 // After StopListen (when no sockets exists), RTCP packets will no longer | 845 // After StopListen (when no sockets exists), RTCP packets will no longer |
| 863 // be transmitted since the Transport object will then be invalid. | 846 // be transmitted since the Transport object will then be invalid. |
| 864 telephone_event_handler_->SetTelephoneEventForwardToDecoder(true); | 847 telephone_event_handler_->SetTelephoneEventForwardToDecoder(true); |
| 865 // RTCP is enabled by default. | 848 // RTCP is enabled by default. |
| 866 _rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound); | 849 _rtpRtcpModule->SetRTCPStatus(RtcpMode::kCompound); |
| 867 // --- Register all permanent callbacks | 850 // --- Register all permanent callbacks |
| 868 if (audio_coding_->RegisterTransportCallback(this) == -1) { | 851 if (audio_coding_->RegisterTransportCallback(this) == -1) { |
| 869 _engineStatisticsPtr->SetLastError( | 852 LOG(LS_ERROR) << "Channel::Init() callbacks not registered"; |
| 870 VE_CANNOT_INIT_CHANNEL, kTraceError, | |
| 871 "Channel::Init() callbacks not registered"); | |
| 872 return -1; | 853 return -1; |
| 873 } | 854 } |
| 874 | 855 |
| 875 return 0; | 856 return 0; |
| 876 } | 857 } |
| 877 | 858 |
| 878 void Channel::Terminate() { | 859 void Channel::Terminate() { |
| 879 RTC_DCHECK(construction_thread_.CalledOnValidThread()); | 860 RTC_DCHECK(construction_thread_.CalledOnValidThread()); |
| 880 // Must be called on the same thread as Init(). | 861 // Must be called on the same thread as Init(). |
| 881 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), | 862 WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 896 " (Audio coding module)"); | 877 " (Audio coding module)"); |
| 897 } | 878 } |
| 898 | 879 |
| 899 // De-register modules in process thread | 880 // De-register modules in process thread |
| 900 if (_moduleProcessThreadPtr) | 881 if (_moduleProcessThreadPtr) |
| 901 _moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get()); | 882 _moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get()); |
| 902 | 883 |
| 903 // End of modules shutdown | 884 // End of modules shutdown |
| 904 } | 885 } |
| 905 | 886 |
| 906 int32_t Channel::SetEngineInformation(Statistics& engineStatistics, | 887 int32_t Channel::SetEngineInformation(ProcessThread& moduleProcessThread, |
| 907 ProcessThread& moduleProcessThread, | |
| 908 AudioDeviceModule& audioDeviceModule, | 888 AudioDeviceModule& audioDeviceModule, |
| 909 rtc::CriticalSection* callbackCritSect, | |
| 910 rtc::TaskQueue* encoder_queue) { | 889 rtc::TaskQueue* encoder_queue) { |
| 911 RTC_DCHECK(encoder_queue); | 890 RTC_DCHECK(encoder_queue); |
| 912 RTC_DCHECK(!encoder_queue_); | 891 RTC_DCHECK(!encoder_queue_); |
| 913 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 892 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 914 "Channel::SetEngineInformation()"); | 893 "Channel::SetEngineInformation()"); |
| 915 _engineStatisticsPtr = &engineStatistics; | |
| 916 _moduleProcessThreadPtr = &moduleProcessThread; | 894 _moduleProcessThreadPtr = &moduleProcessThread; |
| 917 _audioDeviceModulePtr = &audioDeviceModule; | 895 _audioDeviceModulePtr = &audioDeviceModule; |
| 918 _callbackCritSectPtr = callbackCritSect; | |
| 919 encoder_queue_ = encoder_queue; | 896 encoder_queue_ = encoder_queue; |
| 920 return 0; | 897 return 0; |
| 921 } | 898 } |
| 922 | 899 |
| 923 void Channel::SetSink(std::unique_ptr<AudioSinkInterface> sink) { | 900 void Channel::SetSink(std::unique_ptr<AudioSinkInterface> sink) { |
| 924 rtc::CritScope cs(&_callbackCritSect); | 901 rtc::CritScope cs(&_callbackCritSect); |
| 925 audio_sink_ = std::move(sink); | 902 audio_sink_ = std::move(sink); |
| 926 } | 903 } |
| 927 | 904 |
| 928 const rtc::scoped_refptr<AudioDecoderFactory>& | 905 const rtc::scoped_refptr<AudioDecoderFactory>& |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 rtc::CritScope cs(&encoder_queue_lock_); | 944 rtc::CritScope cs(&encoder_queue_lock_); |
| 968 encoder_queue_is_active_ = true; | 945 encoder_queue_is_active_ = true; |
| 969 } | 946 } |
| 970 // Resume the previous sequence number which was reset by StopSend(). This | 947 // Resume the previous sequence number which was reset by StopSend(). This |
| 971 // needs to be done before |sending| is set to true on the RTP/RTCP module. | 948 // needs to be done before |sending| is set to true on the RTP/RTCP module. |
| 972 if (send_sequence_number_) { | 949 if (send_sequence_number_) { |
| 973 _rtpRtcpModule->SetSequenceNumber(send_sequence_number_); | 950 _rtpRtcpModule->SetSequenceNumber(send_sequence_number_); |
| 974 } | 951 } |
| 975 _rtpRtcpModule->SetSendingMediaStatus(true); | 952 _rtpRtcpModule->SetSendingMediaStatus(true); |
| 976 if (_rtpRtcpModule->SetSendingStatus(true) != 0) { | 953 if (_rtpRtcpModule->SetSendingStatus(true) != 0) { |
| 977 _engineStatisticsPtr->SetLastError( | 954 LOG(LS_ERROR) << "StartSend() RTP/RTCP failed to start sending"; |
| 978 VE_RTP_RTCP_MODULE_ERROR, kTraceError, | |
| 979 "StartSend() RTP/RTCP failed to start sending"); | |
| 980 _rtpRtcpModule->SetSendingMediaStatus(false); | 955 _rtpRtcpModule->SetSendingMediaStatus(false); |
| 981 rtc::CritScope cs(&_callbackCritSect); | 956 rtc::CritScope cs(&_callbackCritSect); |
| 982 channel_state_.SetSending(false); | 957 channel_state_.SetSending(false); |
| 983 return -1; | 958 return -1; |
| 984 } | 959 } |
| 985 | 960 |
| 986 return 0; | 961 return 0; |
| 987 } | 962 } |
| 988 | 963 |
| 989 void Channel::StopSend() { | 964 void Channel::StopSend() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1016 // the next StartSend(). This is needed for restarting device, otherwise | 991 // the next StartSend(). This is needed for restarting device, otherwise |
| 1017 // it might cause libSRTP to complain about packets being replayed. | 992 // it might cause libSRTP to complain about packets being replayed. |
| 1018 // TODO(xians): Remove this workaround after RtpRtcpModule's refactoring | 993 // TODO(xians): Remove this workaround after RtpRtcpModule's refactoring |
| 1019 // CL is landed. See issue | 994 // CL is landed. See issue |
| 1020 // https://code.google.com/p/webrtc/issues/detail?id=2111 . | 995 // https://code.google.com/p/webrtc/issues/detail?id=2111 . |
| 1021 send_sequence_number_ = _rtpRtcpModule->SequenceNumber(); | 996 send_sequence_number_ = _rtpRtcpModule->SequenceNumber(); |
| 1022 | 997 |
| 1023 // Reset sending SSRC and sequence number and triggers direct transmission | 998 // Reset sending SSRC and sequence number and triggers direct transmission |
| 1024 // of RTCP BYE | 999 // of RTCP BYE |
| 1025 if (_rtpRtcpModule->SetSendingStatus(false) == -1) { | 1000 if (_rtpRtcpModule->SetSendingStatus(false) == -1) { |
| 1026 _engineStatisticsPtr->SetLastError( | 1001 LOG(LS_ERROR) << "StartSend() RTP/RTCP failed to stop sending"; |
| 1027 VE_RTP_RTCP_MODULE_ERROR, kTraceWarning, | |
| 1028 "StartSend() RTP/RTCP failed to stop sending"); | |
| 1029 } | 1002 } |
| 1030 _rtpRtcpModule->SetSendingMediaStatus(false); | 1003 _rtpRtcpModule->SetSendingMediaStatus(false); |
| 1031 } | 1004 } |
| 1032 | 1005 |
| 1033 bool Channel::SetEncoder(int payload_type, | 1006 bool Channel::SetEncoder(int payload_type, |
| 1034 std::unique_ptr<AudioEncoder> encoder) { | 1007 std::unique_ptr<AudioEncoder> encoder) { |
| 1035 RTC_DCHECK_GE(payload_type, 0); | 1008 RTC_DCHECK_GE(payload_type, 0); |
| 1036 RTC_DCHECK_LE(payload_type, 127); | 1009 RTC_DCHECK_LE(payload_type, 127); |
| 1037 // TODO(ossu): Make CodecInsts up, for now: one for the RTP/RTCP module and | 1010 // TODO(ossu): Make CodecInsts up, for now: one for the RTP/RTCP module and |
| 1038 // one for for us to keep track of sample rate and number of channels, etc. | 1011 // one for for us to keep track of sample rate and number of channels, etc. |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 void Channel::SetReceiverFrameLengthRange(int min_frame_length_ms, | 1164 void Channel::SetReceiverFrameLengthRange(int min_frame_length_ms, |
| 1192 int max_frame_length_ms) { | 1165 int max_frame_length_ms) { |
| 1193 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { | 1166 audio_coding_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* encoder) { |
| 1194 if (*encoder) { | 1167 if (*encoder) { |
| 1195 (*encoder)->SetReceiverFrameLengthRange(min_frame_length_ms, | 1168 (*encoder)->SetReceiverFrameLengthRange(min_frame_length_ms, |
| 1196 max_frame_length_ms); | 1169 max_frame_length_ms); |
| 1197 } | 1170 } |
| 1198 }); | 1171 }); |
| 1199 } | 1172 } |
| 1200 | 1173 |
| 1201 int32_t Channel::RegisterExternalTransport(Transport* transport) { | 1174 void Channel::RegisterTransport(Transport* transport) { |
| 1202 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 1203 "Channel::RegisterExternalTransport()"); | |
| 1204 | |
| 1205 rtc::CritScope cs(&_callbackCritSect); | 1175 rtc::CritScope cs(&_callbackCritSect); |
| 1206 if (_externalTransport) { | |
| 1207 _engineStatisticsPtr->SetLastError( | |
| 1208 VE_INVALID_OPERATION, kTraceError, | |
| 1209 "RegisterExternalTransport() external transport already enabled"); | |
| 1210 return -1; | |
| 1211 } | |
| 1212 _externalTransport = true; | |
| 1213 _transportPtr = transport; | 1176 _transportPtr = transport; |
| 1214 return 0; | |
| 1215 } | |
| 1216 | |
| 1217 int32_t Channel::DeRegisterExternalTransport() { | |
| 1218 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 1219 "Channel::DeRegisterExternalTransport()"); | |
| 1220 | |
| 1221 rtc::CritScope cs(&_callbackCritSect); | |
| 1222 if (_transportPtr) { | |
| 1223 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | |
| 1224 "DeRegisterExternalTransport() all transport is disabled"); | |
| 1225 } else { | |
| 1226 _engineStatisticsPtr->SetLastError( | |
| 1227 VE_INVALID_OPERATION, kTraceWarning, | |
| 1228 "DeRegisterExternalTransport() external transport already " | |
| 1229 "disabled"); | |
| 1230 } | |
| 1231 _externalTransport = false; | |
| 1232 _transportPtr = NULL; | |
| 1233 return 0; | |
| 1234 } | 1177 } |
| 1235 | 1178 |
| 1236 void Channel::OnRtpPacket(const RtpPacketReceived& packet) { | 1179 void Channel::OnRtpPacket(const RtpPacketReceived& packet) { |
| 1237 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 1180 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1238 "Channel::OnRtpPacket()"); | 1181 "Channel::OnRtpPacket()"); |
| 1239 | 1182 |
| 1240 RTPHeader header; | 1183 RTPHeader header; |
| 1241 packet.GetHeader(&header); | 1184 packet.GetHeader(&header); |
| 1242 | 1185 |
| 1243 // Store playout timestamp for the received RTP packet | 1186 // Store playout timestamp for the received RTP packet |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 "Channel::SendTelephoneEventOutband(...)"); | 1316 "Channel::SendTelephoneEventOutband(...)"); |
| 1374 RTC_DCHECK_LE(0, event); | 1317 RTC_DCHECK_LE(0, event); |
| 1375 RTC_DCHECK_GE(255, event); | 1318 RTC_DCHECK_GE(255, event); |
| 1376 RTC_DCHECK_LE(0, duration_ms); | 1319 RTC_DCHECK_LE(0, duration_ms); |
| 1377 RTC_DCHECK_GE(65535, duration_ms); | 1320 RTC_DCHECK_GE(65535, duration_ms); |
| 1378 if (!Sending()) { | 1321 if (!Sending()) { |
| 1379 return -1; | 1322 return -1; |
| 1380 } | 1323 } |
| 1381 if (_rtpRtcpModule->SendTelephoneEventOutband( | 1324 if (_rtpRtcpModule->SendTelephoneEventOutband( |
| 1382 event, duration_ms, kTelephoneEventAttenuationdB) != 0) { | 1325 event, duration_ms, kTelephoneEventAttenuationdB) != 0) { |
| 1383 _engineStatisticsPtr->SetLastError( | 1326 LOG(LS_ERROR) << "SendTelephoneEventOutband() failed to send event"; |
| 1384 VE_SEND_DTMF_FAILED, kTraceWarning, | |
| 1385 "SendTelephoneEventOutband() failed to send event"); | |
| 1386 return -1; | 1327 return -1; |
| 1387 } | 1328 } |
| 1388 return 0; | 1329 return 0; |
| 1389 } | 1330 } |
| 1390 | 1331 |
| 1391 int Channel::SetSendTelephoneEventPayloadType(int payload_type, | 1332 int Channel::SetSendTelephoneEventPayloadType(int payload_type, |
| 1392 int payload_frequency) { | 1333 int payload_frequency) { |
| 1393 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1334 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1394 "Channel::SetSendTelephoneEventPayloadType()"); | 1335 "Channel::SetSendTelephoneEventPayloadType()"); |
| 1395 RTC_DCHECK_LE(0, payload_type); | 1336 RTC_DCHECK_LE(0, payload_type); |
| 1396 RTC_DCHECK_GE(127, payload_type); | 1337 RTC_DCHECK_GE(127, payload_type); |
| 1397 CodecInst codec = {0}; | 1338 CodecInst codec = {0}; |
| 1398 codec.pltype = payload_type; | 1339 codec.pltype = payload_type; |
| 1399 codec.plfreq = payload_frequency; | 1340 codec.plfreq = payload_frequency; |
| 1400 memcpy(codec.plname, "telephone-event", 16); | 1341 memcpy(codec.plname, "telephone-event", 16); |
| 1401 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { | 1342 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { |
| 1402 _rtpRtcpModule->DeRegisterSendPayload(codec.pltype); | 1343 _rtpRtcpModule->DeRegisterSendPayload(codec.pltype); |
| 1403 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { | 1344 if (_rtpRtcpModule->RegisterSendPayload(codec) != 0) { |
| 1404 _engineStatisticsPtr->SetLastError( | 1345 LOG(LS_ERROR) << "SetSendTelephoneEventPayloadType() failed to register " |
| 1405 VE_RTP_RTCP_MODULE_ERROR, kTraceError, | 1346 "send payload type"; |
| 1406 "SetSendTelephoneEventPayloadType() failed to register send" | |
| 1407 "payload type"); | |
| 1408 return -1; | 1347 return -1; |
| 1409 } | 1348 } |
| 1410 } | 1349 } |
| 1411 return 0; | 1350 return 0; |
| 1412 } | 1351 } |
| 1413 | 1352 |
| 1414 int Channel::SetLocalSSRC(unsigned int ssrc) { | 1353 int Channel::SetLocalSSRC(unsigned int ssrc) { |
| 1415 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1354 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1416 "Channel::SetLocalSSRC()"); | 1355 "Channel::SetLocalSSRC()"); |
| 1417 if (channel_state_.Get().sending) { | 1356 if (channel_state_.Get().sending) { |
| 1418 _engineStatisticsPtr->SetLastError(VE_ALREADY_SENDING, kTraceError, | 1357 LOG(LS_ERROR) << "SetLocalSSRC() already sending"; |
| 1419 "SetLocalSSRC() already sending"); | |
| 1420 return -1; | 1358 return -1; |
| 1421 } | 1359 } |
| 1422 _rtpRtcpModule->SetSSRC(ssrc); | 1360 _rtpRtcpModule->SetSSRC(ssrc); |
| 1423 return 0; | 1361 return 0; |
| 1424 } | 1362 } |
| 1425 | 1363 |
| 1426 int Channel::GetRemoteSSRC(unsigned int& ssrc) { | 1364 int Channel::GetRemoteSSRC(unsigned int& ssrc) { |
| 1427 ssrc = rtp_receiver_->SSRC(); | 1365 ssrc = rtp_receiver_->SSRC(); |
| 1428 return 0; | 1366 return 0; |
| 1429 } | 1367 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 void Channel::SetRTCPStatus(bool enable) { | 1448 void Channel::SetRTCPStatus(bool enable) { |
| 1511 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1449 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1512 "Channel::SetRTCPStatus()"); | 1450 "Channel::SetRTCPStatus()"); |
| 1513 _rtpRtcpModule->SetRTCPStatus(enable ? RtcpMode::kCompound : RtcpMode::kOff); | 1451 _rtpRtcpModule->SetRTCPStatus(enable ? RtcpMode::kCompound : RtcpMode::kOff); |
| 1514 } | 1452 } |
| 1515 | 1453 |
| 1516 int Channel::SetRTCP_CNAME(const char cName[256]) { | 1454 int Channel::SetRTCP_CNAME(const char cName[256]) { |
| 1517 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1455 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1518 "Channel::SetRTCP_CNAME()"); | 1456 "Channel::SetRTCP_CNAME()"); |
| 1519 if (_rtpRtcpModule->SetCNAME(cName) != 0) { | 1457 if (_rtpRtcpModule->SetCNAME(cName) != 0) { |
| 1520 _engineStatisticsPtr->SetLastError( | 1458 LOG(LS_ERROR) << "SetRTCP_CNAME() failed to set RTCP CNAME"; |
| 1521 VE_RTP_RTCP_MODULE_ERROR, kTraceError, | |
| 1522 "SetRTCP_CNAME() failed to set RTCP CNAME"); | |
| 1523 return -1; | 1459 return -1; |
| 1524 } | 1460 } |
| 1525 return 0; | 1461 return 0; |
| 1526 } | 1462 } |
| 1527 | 1463 |
| 1528 int Channel::GetRemoteRTCPReportBlocks( | 1464 int Channel::GetRemoteRTCPReportBlocks( |
| 1529 std::vector<ReportBlock>* report_blocks) { | 1465 std::vector<ReportBlock>* report_blocks) { |
| 1530 if (report_blocks == NULL) { | 1466 if (report_blocks == NULL) { |
| 1531 _engineStatisticsPtr->SetLastError( | 1467 LOG(LS_ERROR) << "GetRemoteRTCPReportBlock()s invalid report_blocks."; |
| 1532 VE_INVALID_ARGUMENT, kTraceError, | |
| 1533 "GetRemoteRTCPReportBlock()s invalid report_blocks."); | |
| 1534 return -1; | 1468 return -1; |
| 1535 } | 1469 } |
| 1536 | 1470 |
| 1537 // Get the report blocks from the latest received RTCP Sender or Receiver | 1471 // Get the report blocks from the latest received RTCP Sender or Receiver |
| 1538 // Report. Each element in the vector contains the sender's SSRC and a | 1472 // Report. Each element in the vector contains the sender's SSRC and a |
| 1539 // report block according to RFC 3550. | 1473 // report block according to RFC 3550. |
| 1540 std::vector<RTCPReportBlock> rtcp_report_blocks; | 1474 std::vector<RTCPReportBlock> rtcp_report_blocks; |
| 1541 if (_rtpRtcpModule->RemoteRTCPStat(&rtcp_report_blocks) != 0) { | 1475 if (_rtpRtcpModule->RemoteRTCPStat(&rtcp_report_blocks) != 0) { |
| 1542 return -1; | 1476 return -1; |
| 1543 } | 1477 } |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1781 uint32_t Channel::GetDelayEstimate() const { | 1715 uint32_t Channel::GetDelayEstimate() const { |
| 1782 rtc::CritScope lock(&video_sync_lock_); | 1716 rtc::CritScope lock(&video_sync_lock_); |
| 1783 return audio_coding_->FilteredCurrentDelayMs() + playout_delay_ms_; | 1717 return audio_coding_->FilteredCurrentDelayMs() + playout_delay_ms_; |
| 1784 } | 1718 } |
| 1785 | 1719 |
| 1786 int Channel::SetMinimumPlayoutDelay(int delayMs) { | 1720 int Channel::SetMinimumPlayoutDelay(int delayMs) { |
| 1787 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), | 1721 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1788 "Channel::SetMinimumPlayoutDelay()"); | 1722 "Channel::SetMinimumPlayoutDelay()"); |
| 1789 if ((delayMs < kVoiceEngineMinMinPlayoutDelayMs) || | 1723 if ((delayMs < kVoiceEngineMinMinPlayoutDelayMs) || |
| 1790 (delayMs > kVoiceEngineMaxMinPlayoutDelayMs)) { | 1724 (delayMs > kVoiceEngineMaxMinPlayoutDelayMs)) { |
| 1791 _engineStatisticsPtr->SetLastError( | 1725 LOG(LS_ERROR) << "SetMinimumPlayoutDelay() invalid min delay"; |
| 1792 VE_INVALID_ARGUMENT, kTraceError, | |
| 1793 "SetMinimumPlayoutDelay() invalid min delay"); | |
| 1794 return -1; | 1726 return -1; |
| 1795 } | 1727 } |
| 1796 if (audio_coding_->SetMinimumPlayoutDelay(delayMs) != 0) { | 1728 if (audio_coding_->SetMinimumPlayoutDelay(delayMs) != 0) { |
| 1797 _engineStatisticsPtr->SetLastError( | 1729 LOG(LS_ERROR) << "SetMinimumPlayoutDelay() failed to set min playout delay"; |
| 1798 VE_AUDIO_CODING_MODULE_ERROR, kTraceError, | |
| 1799 "SetMinimumPlayoutDelay() failed to set min playout delay"); | |
| 1800 return -1; | 1730 return -1; |
| 1801 } | 1731 } |
| 1802 return 0; | 1732 return 0; |
| 1803 } | 1733 } |
| 1804 | 1734 |
| 1805 int Channel::GetPlayoutTimestamp(unsigned int& timestamp) { | 1735 int Channel::GetPlayoutTimestamp(unsigned int& timestamp) { |
| 1806 uint32_t playout_timestamp_rtp = 0; | 1736 uint32_t playout_timestamp_rtp = 0; |
| 1807 { | 1737 { |
| 1808 rtc::CritScope lock(&video_sync_lock_); | 1738 rtc::CritScope lock(&video_sync_lock_); |
| 1809 playout_timestamp_rtp = playout_timestamp_rtp_; | 1739 playout_timestamp_rtp = playout_timestamp_rtp_; |
| 1810 } | 1740 } |
| 1811 if (playout_timestamp_rtp == 0) { | 1741 if (playout_timestamp_rtp == 0) { |
| 1812 _engineStatisticsPtr->SetLastError( | 1742 LOG(LS_ERROR) << "GetPlayoutTimestamp() failed to retrieve timestamp"; |
| 1813 VE_CANNOT_RETRIEVE_VALUE, kTraceStateInfo, | |
| 1814 "GetPlayoutTimestamp() failed to retrieve timestamp"); | |
| 1815 return -1; | 1743 return -1; |
| 1816 } | 1744 } |
| 1817 timestamp = playout_timestamp_rtp; | 1745 timestamp = playout_timestamp_rtp; |
| 1818 return 0; | 1746 return 0; |
| 1819 } | 1747 } |
| 1820 | 1748 |
| 1821 int Channel::GetRtpRtcp(RtpRtcp** rtpRtcpModule, | 1749 int Channel::GetRtpRtcp(RtpRtcp** rtpRtcpModule, |
| 1822 RtpReceiver** rtp_receiver) const { | 1750 RtpReceiver** rtp_receiver) const { |
| 1823 *rtpRtcpModule = _rtpRtcpModule.get(); | 1751 *rtpRtcpModule = _rtpRtcpModule.get(); |
| 1824 *rtp_receiver = rtp_receiver_.get(); | 1752 *rtp_receiver = rtp_receiver_.get(); |
| 1825 return 0; | 1753 return 0; |
| 1826 } | 1754 } |
| 1827 | 1755 |
| 1828 void Channel::UpdatePlayoutTimestamp(bool rtcp) { | 1756 void Channel::UpdatePlayoutTimestamp(bool rtcp) { |
| 1829 jitter_buffer_playout_timestamp_ = audio_coding_->PlayoutTimestamp(); | 1757 jitter_buffer_playout_timestamp_ = audio_coding_->PlayoutTimestamp(); |
| 1830 | 1758 |
| 1831 if (!jitter_buffer_playout_timestamp_) { | 1759 if (!jitter_buffer_playout_timestamp_) { |
| 1832 // This can happen if this channel has not received any RTP packets. In | 1760 // This can happen if this channel has not received any RTP packets. In |
| 1833 // this case, NetEq is not capable of computing a playout timestamp. | 1761 // this case, NetEq is not capable of computing a playout timestamp. |
| 1834 return; | 1762 return; |
| 1835 } | 1763 } |
| 1836 | 1764 |
| 1837 uint16_t delay_ms = 0; | 1765 uint16_t delay_ms = 0; |
| 1838 if (_audioDeviceModulePtr->PlayoutDelay(&delay_ms) == -1) { | 1766 if (_audioDeviceModulePtr->PlayoutDelay(&delay_ms) == -1) { |
| 1839 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), | 1767 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, _channelId), |
| 1840 "Channel::UpdatePlayoutTimestamp() failed to read playout" | 1768 "Channel::UpdatePlayoutTimestamp() failed to read playout" |
| 1841 " delay from the ADM"); | 1769 " delay from the ADM"); |
| 1842 _engineStatisticsPtr->SetLastError( | |
| 1843 VE_CANNOT_RETRIEVE_VALUE, kTraceError, | |
| 1844 "UpdatePlayoutTimestamp() failed to retrieve playout delay"); | |
| 1845 return; | 1770 return; |
| 1846 } | 1771 } |
| 1847 | 1772 |
| 1848 RTC_DCHECK(jitter_buffer_playout_timestamp_); | 1773 RTC_DCHECK(jitter_buffer_playout_timestamp_); |
| 1849 uint32_t playout_timestamp = *jitter_buffer_playout_timestamp_; | 1774 uint32_t playout_timestamp = *jitter_buffer_playout_timestamp_; |
| 1850 | 1775 |
| 1851 // Remove the playout delay. | 1776 // Remove the playout delay. |
| 1852 playout_timestamp -= (delay_ms * (GetRtpTimestampRateHz() / 1000)); | 1777 playout_timestamp -= (delay_ms * (GetRtpTimestampRateHz() / 1000)); |
| 1853 | 1778 |
| 1854 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), | 1779 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId, _channelId), |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 int64_t min_rtt = 0; | 1885 int64_t min_rtt = 0; |
| 1961 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != | 1886 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) != |
| 1962 0) { | 1887 0) { |
| 1963 return 0; | 1888 return 0; |
| 1964 } | 1889 } |
| 1965 return rtt; | 1890 return rtt; |
| 1966 } | 1891 } |
| 1967 | 1892 |
| 1968 } // namespace voe | 1893 } // namespace voe |
| 1969 } // namespace webrtc | 1894 } // namespace webrtc |
| OLD | NEW |