| 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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 "Channel::RecordFileEnded() => output file recorder module is" | 710 "Channel::RecordFileEnded() => output file recorder module is" |
| 711 " shutdown"); | 711 " shutdown"); |
| 712 } | 712 } |
| 713 | 713 |
| 714 Channel::Channel(int32_t channelId, | 714 Channel::Channel(int32_t channelId, |
| 715 uint32_t instanceId, | 715 uint32_t instanceId, |
| 716 const Config& config) : | 716 const Config& config) : |
| 717 _fileCritSect(*CriticalSectionWrapper::CreateCriticalSection()), | 717 _fileCritSect(*CriticalSectionWrapper::CreateCriticalSection()), |
| 718 _callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()), | 718 _callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()), |
| 719 volume_settings_critsect_(*CriticalSectionWrapper::CreateCriticalSection()), | 719 volume_settings_critsect_(*CriticalSectionWrapper::CreateCriticalSection()), |
| 720 video_sync_critsect_(*CriticalSectionWrapper::CreateCriticalSection()), |
| 720 _instanceId(instanceId), | 721 _instanceId(instanceId), |
| 721 _channelId(channelId), | 722 _channelId(channelId), |
| 722 rtp_header_parser_(RtpHeaderParser::Create()), | 723 rtp_header_parser_(RtpHeaderParser::Create()), |
| 723 rtp_payload_registry_( | 724 rtp_payload_registry_( |
| 724 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), | 725 new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(true))), |
| 725 rtp_receive_statistics_(ReceiveStatistics::Create( | 726 rtp_receive_statistics_(ReceiveStatistics::Create( |
| 726 Clock::GetRealTimeClock())), | 727 Clock::GetRealTimeClock())), |
| 727 rtp_receiver_(RtpReceiver::CreateAudioReceiver( | 728 rtp_receiver_(RtpReceiver::CreateAudioReceiver( |
| 728 VoEModuleId(instanceId, channelId), Clock::GetRealTimeClock(), this, | 729 VoEModuleId(instanceId, channelId), Clock::GetRealTimeClock(), this, |
| 729 this, this, rtp_payload_registry_.get())), | 730 this, this, rtp_payload_registry_.get())), |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 } | 893 } |
| 893 // De-register modules in process thread | 894 // De-register modules in process thread |
| 894 _moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get()); | 895 _moduleProcessThreadPtr->DeRegisterModule(_rtpRtcpModule.get()); |
| 895 | 896 |
| 896 // End of modules shutdown | 897 // End of modules shutdown |
| 897 | 898 |
| 898 // Delete other objects | 899 // Delete other objects |
| 899 delete &_callbackCritSect; | 900 delete &_callbackCritSect; |
| 900 delete &_fileCritSect; | 901 delete &_fileCritSect; |
| 901 delete &volume_settings_critsect_; | 902 delete &volume_settings_critsect_; |
| 903 delete &video_sync_critsect_; |
| 902 } | 904 } |
| 903 | 905 |
| 904 int32_t | 906 int32_t |
| 905 Channel::Init() | 907 Channel::Init() |
| 906 { | 908 { |
| 907 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), | 909 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), |
| 908 "Channel::Init()"); | 910 "Channel::Init()"); |
| 909 | 911 |
| 910 channel_state_.Reset(); | 912 channel_state_.Reset(); |
| 911 | 913 |
| (...skipping 2642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3554 "Channel::GetNetworkStatistics()"); | 3556 "Channel::GetNetworkStatistics()"); |
| 3555 return audio_coding_->GetNetworkStatistics(&stats); | 3557 return audio_coding_->GetNetworkStatistics(&stats); |
| 3556 } | 3558 } |
| 3557 | 3559 |
| 3558 void Channel::GetDecodingCallStatistics(AudioDecodingCallStats* stats) const { | 3560 void Channel::GetDecodingCallStatistics(AudioDecodingCallStats* stats) const { |
| 3559 audio_coding_->GetDecodingCallStatistics(stats); | 3561 audio_coding_->GetDecodingCallStatistics(stats); |
| 3560 } | 3562 } |
| 3561 | 3563 |
| 3562 bool Channel::GetDelayEstimate(int* jitter_buffer_delay_ms, | 3564 bool Channel::GetDelayEstimate(int* jitter_buffer_delay_ms, |
| 3563 int* playout_buffer_delay_ms) const { | 3565 int* playout_buffer_delay_ms) const { |
| 3566 CriticalSectionScoped cs(&video_sync_critsect_); |
| 3564 if (_average_jitter_buffer_delay_us == 0) { | 3567 if (_average_jitter_buffer_delay_us == 0) { |
| 3565 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), | 3568 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), |
| 3566 "Channel::GetDelayEstimate() no valid estimate."); | 3569 "Channel::GetDelayEstimate() no valid estimate."); |
| 3567 return false; | 3570 return false; |
| 3568 } | 3571 } |
| 3569 *jitter_buffer_delay_ms = (_average_jitter_buffer_delay_us + 500) / 1000 + | 3572 *jitter_buffer_delay_ms = (_average_jitter_buffer_delay_us + 500) / 1000 + |
| 3570 _recPacketDelayMs; | 3573 _recPacketDelayMs; |
| 3571 *playout_buffer_delay_ms = playout_delay_ms_; | 3574 *playout_buffer_delay_ms = playout_delay_ms_; |
| 3572 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), | 3575 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), |
| 3573 "Channel::GetDelayEstimate()"); | 3576 "Channel::GetDelayEstimate()"); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3633 if (_audioDeviceModulePtr->PlayoutDelay(&delay_ms) == -1) { | 3636 if (_audioDeviceModulePtr->PlayoutDelay(&delay_ms) == -1) { |
| 3634 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), | 3637 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId,_channelId), |
| 3635 "Channel::UpdatePlayoutTimestamp() failed to read playout" | 3638 "Channel::UpdatePlayoutTimestamp() failed to read playout" |
| 3636 " delay from the ADM"); | 3639 " delay from the ADM"); |
| 3637 _engineStatisticsPtr->SetLastError( | 3640 _engineStatisticsPtr->SetLastError( |
| 3638 VE_CANNOT_RETRIEVE_VALUE, kTraceError, | 3641 VE_CANNOT_RETRIEVE_VALUE, kTraceError, |
| 3639 "UpdatePlayoutTimestamp() failed to retrieve playout delay"); | 3642 "UpdatePlayoutTimestamp() failed to retrieve playout delay"); |
| 3640 return; | 3643 return; |
| 3641 } | 3644 } |
| 3642 | 3645 |
| 3643 jitter_buffer_playout_timestamp_ = playout_timestamp; | 3646 { |
| 3647 CriticalSectionScoped cs(&video_sync_critsect_); |
| 3648 jitter_buffer_playout_timestamp_ = playout_timestamp; |
| 3644 | 3649 |
| 3645 // Remove the playout delay. | 3650 // Remove the playout delay. |
| 3646 playout_timestamp -= (delay_ms * (GetPlayoutFrequency() / 1000)); | 3651 playout_timestamp -= (delay_ms * (GetPlayoutFrequency() / 1000)); |
| 3647 | 3652 |
| 3648 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), | 3653 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), |
| 3649 "Channel::UpdatePlayoutTimestamp() => playoutTimestamp = %lu", | 3654 "Channel::UpdatePlayoutTimestamp() => playoutTimestamp = %lu", |
| 3650 playout_timestamp); | 3655 playout_timestamp); |
| 3651 | 3656 |
| 3652 if (rtcp) { | 3657 if (rtcp) { |
| 3653 playout_timestamp_rtcp_ = playout_timestamp; | 3658 playout_timestamp_rtcp_ = playout_timestamp; |
| 3654 } else { | 3659 } else { |
| 3655 playout_timestamp_rtp_ = playout_timestamp; | 3660 playout_timestamp_rtp_ = playout_timestamp; |
| 3661 } |
| 3662 playout_delay_ms_ = delay_ms; |
| 3656 } | 3663 } |
| 3657 playout_delay_ms_ = delay_ms; | |
| 3658 } | 3664 } |
| 3659 | 3665 |
| 3660 int Channel::GetPlayoutTimestamp(unsigned int& timestamp) { | 3666 int Channel::GetPlayoutTimestamp(unsigned int& timestamp) { |
| 3661 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), | 3667 WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId), |
| 3662 "Channel::GetPlayoutTimestamp()"); | 3668 "Channel::GetPlayoutTimestamp()"); |
| 3669 CriticalSectionScoped cs(&video_sync_critsect_); |
| 3663 if (playout_timestamp_rtp_ == 0) { | 3670 if (playout_timestamp_rtp_ == 0) { |
| 3664 _engineStatisticsPtr->SetLastError( | 3671 _engineStatisticsPtr->SetLastError( |
| 3665 VE_CANNOT_RETRIEVE_VALUE, kTraceError, | 3672 VE_CANNOT_RETRIEVE_VALUE, kTraceError, |
| 3666 "GetPlayoutTimestamp() failed to retrieve timestamp"); | 3673 "GetPlayoutTimestamp() failed to retrieve timestamp"); |
| 3667 return -1; | 3674 return -1; |
| 3668 } | 3675 } |
| 3669 timestamp = playout_timestamp_rtp_; | 3676 timestamp = playout_timestamp_rtp_; |
| 3670 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, | 3677 WEBRTC_TRACE(kTraceStateInfo, kTraceVoice, |
| 3671 VoEId(_instanceId,_channelId), | 3678 VoEId(_instanceId,_channelId), |
| 3672 "GetPlayoutTimestamp() => timestamp=%u", timestamp); | 3679 "GetPlayoutTimestamp() => timestamp=%u", timestamp); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3922 } | 3929 } |
| 3923 } | 3930 } |
| 3924 | 3931 |
| 3925 // Called for incoming RTP packets after successful RTP header parsing. | 3932 // Called for incoming RTP packets after successful RTP header parsing. |
| 3926 void Channel::UpdatePacketDelay(uint32_t rtp_timestamp, | 3933 void Channel::UpdatePacketDelay(uint32_t rtp_timestamp, |
| 3927 uint16_t sequence_number) { | 3934 uint16_t sequence_number) { |
| 3928 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), | 3935 WEBRTC_TRACE(kTraceStream, kTraceVoice, VoEId(_instanceId,_channelId), |
| 3929 "Channel::UpdatePacketDelay(timestamp=%lu, sequenceNumber=%u)", | 3936 "Channel::UpdatePacketDelay(timestamp=%lu, sequenceNumber=%u)", |
| 3930 rtp_timestamp, sequence_number); | 3937 rtp_timestamp, sequence_number); |
| 3931 | 3938 |
| 3939 CriticalSectionScoped cs(&video_sync_critsect_); |
| 3940 |
| 3932 // Get frequency of last received payload | 3941 // Get frequency of last received payload |
| 3933 int rtp_receive_frequency = GetPlayoutFrequency(); | 3942 int rtp_receive_frequency = GetPlayoutFrequency(); |
| 3934 | 3943 |
| 3935 // Update the least required delay. | 3944 // Update the least required delay. |
| 3936 least_required_delay_ms_ = audio_coding_->LeastRequiredDelayMs(); | 3945 least_required_delay_ms_ = audio_coding_->LeastRequiredDelayMs(); |
| 3937 | 3946 |
| 3938 // |jitter_buffer_playout_timestamp_| updated in UpdatePlayoutTimestamp for | 3947 // |jitter_buffer_playout_timestamp_| updated in UpdatePlayoutTimestamp for |
| 3939 // every incoming packet. | 3948 // every incoming packet. |
| 3940 uint32_t timestamp_diff_ms = (rtp_timestamp - | 3949 uint32_t timestamp_diff_ms = (rtp_timestamp - |
| 3941 jitter_buffer_playout_timestamp_) / (rtp_receive_frequency / 1000); | 3950 jitter_buffer_playout_timestamp_) / (rtp_receive_frequency / 1000); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4131 int64_t min_rtt = 0; | 4140 int64_t min_rtt = 0; |
| 4132 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) | 4141 if (_rtpRtcpModule->RTT(remoteSSRC, &rtt, &avg_rtt, &min_rtt, &max_rtt) |
| 4133 != 0) { | 4142 != 0) { |
| 4134 return 0; | 4143 return 0; |
| 4135 } | 4144 } |
| 4136 return rtt; | 4145 return rtt; |
| 4137 } | 4146 } |
| 4138 | 4147 |
| 4139 } // namespace voe | 4148 } // namespace voe |
| 4140 } // namespace webrtc | 4149 } // namespace webrtc |
| OLD | NEW |