diff --git a/webrtc/audio/audio_receive_stream.cc b/webrtc/audio/audio_receive_stream.cc index 05d6edfa4c..2fe199f698 100644 --- a/webrtc/audio/audio_receive_stream.cc +++ b/webrtc/audio/audio_receive_stream.cc @@ -260,11 +260,7 @@ rtc::Optional AudioReceiveStream::GetInfo() const { return rtc::Optional(); } - int jitter_buffer_delay_ms = 0; - int playout_buffer_delay_ms = 0; - channel_proxy_->GetDelayEstimate(&jitter_buffer_delay_ms, - &playout_buffer_delay_ms); - info.current_delay_ms = jitter_buffer_delay_ms + playout_buffer_delay_ms; + info.current_delay_ms = channel_proxy_->GetDelayEstimate(); return rtc::Optional(info); } diff --git a/webrtc/modules/audio_coding/include/audio_coding_module.h b/webrtc/modules/audio_coding/include/audio_coding_module.h index cd99579e1d..7843fb876d 100644 --- a/webrtc/modules/audio_coding/include/audio_coding_module.h +++ b/webrtc/modules/audio_coding/include/audio_coding_module.h @@ -637,7 +637,8 @@ class AudioCodingModule { // virtual int SetMaximumPlayoutDelay(int time_ms) = 0; - // + // TODO(kwiberg): Consider if this is needed anymore, now that voe::Channel + // doesn't use it. // The shortest latency, in milliseconds, required by jitter buffer. This // is computed based on inter-arrival times and playout mode of NetEq. The // actual delay is the maximum of least-required-delay and the minimum-delay diff --git a/webrtc/test/mock_voe_channel_proxy.h b/webrtc/test/mock_voe_channel_proxy.h index ea51154f54..7932473dd3 100644 --- a/webrtc/test/mock_voe_channel_proxy.h +++ b/webrtc/test/mock_voe_channel_proxy.h @@ -76,8 +76,6 @@ class MockVoEChannelProxy : public voe::ChannelProxy { MOCK_METHOD0(DisassociateSendChannel, void()); MOCK_CONST_METHOD2(GetRtpRtcp, void(RtpRtcp** rtp_rtcp, RtpReceiver** rtp_receiver)); - MOCK_CONST_METHOD2(GetDelayEstimate, void(int* jitter_buffer_delay_ms, - int* playout_buffer_delay_ms)); MOCK_CONST_METHOD0(GetPlayoutTimestamp, uint32_t()); MOCK_METHOD1(SetMinimumPlayoutDelay, void(int delay_ms)); MOCK_CONST_METHOD1(GetRecCodec, bool(CodecInst* codec_inst)); diff --git a/webrtc/test/mock_voice_engine.h b/webrtc/test/mock_voice_engine.h index cd0b7d26a1..6177304372 100644 --- a/webrtc/test/mock_voice_engine.h +++ b/webrtc/test/mock_voice_engine.h @@ -289,22 +289,6 @@ class MockVoiceEngine : public VoiceEngineImpl { int(int channel, bool& enable, int& redPayloadtype)); MOCK_METHOD3(SetNACKStatus, int(int channel, bool enable, int maxNoPackets)); - // VoEVideoSync - MOCK_METHOD1(GetPlayoutBufferSize, int(int& buffer_ms)); - MOCK_METHOD2(SetMinimumPlayoutDelay, int(int channel, int delay_ms)); - MOCK_METHOD3(GetDelayEstimate, - int(int channel, - int* jitter_buffer_delay_ms, - int* playout_buffer_delay_ms)); - MOCK_CONST_METHOD1(GetLeastRequiredDelayMs, int(int channel)); - MOCK_METHOD2(SetInitTimestamp, int(int channel, unsigned int timestamp)); - MOCK_METHOD2(SetInitSequenceNumber, int(int channel, short sequenceNumber)); - MOCK_METHOD2(GetPlayoutTimestamp, int(int channel, unsigned int& timestamp)); - MOCK_METHOD3(GetRtpRtcp, - int(int channel, - RtpRtcp** rtpRtcpModule, - RtpReceiver** rtp_receiver)); - // VoEVolumeControl MOCK_METHOD1(SetSpeakerVolume, int(unsigned int volume)); MOCK_METHOD1(GetSpeakerVolume, int(unsigned int& volume)); diff --git a/webrtc/voice_engine/BUILD.gn b/webrtc/voice_engine/BUILD.gn index 028e4d1985..e2755f3004 100644 --- a/webrtc/voice_engine/BUILD.gn +++ b/webrtc/voice_engine/BUILD.gn @@ -83,7 +83,6 @@ rtc_static_library("voice_engine") { "include/voe_neteq_stats.h", "include/voe_network.h", "include/voe_rtp_rtcp.h", - "include/voe_video_sync.h", "include/voe_volume_control.h", "monitor_module.cc", "monitor_module.h", @@ -115,8 +114,6 @@ rtc_static_library("voice_engine") { "voe_network_impl.h", "voe_rtp_rtcp_impl.cc", "voe_rtp_rtcp_impl.h", - "voe_video_sync_impl.cc", - "voe_video_sync_impl.h", "voe_volume_control_impl.cc", "voe_volume_control_impl.h", "voice_engine_defines.h", @@ -376,7 +373,6 @@ if (rtc_include_tests) { "test/auto_test/standard/rtp_rtcp_before_streaming_test.cc", "test/auto_test/standard/rtp_rtcp_extensions.cc", "test/auto_test/standard/rtp_rtcp_test.cc", - "test/auto_test/standard/video_sync_test.cc", "test/auto_test/standard/voe_base_misc_test.cc", "test/auto_test/standard/volume_test.cc", "test/auto_test/voe_conference_test.cc", diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc index d69654fb0f..006e3db69b 100644 --- a/webrtc/voice_engine/channel.cc +++ b/webrtc/voice_engine/channel.cc @@ -1150,16 +1150,16 @@ int32_t Channel::StopPlayout() { int32_t Channel::StartSend() { WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), "Channel::StartSend()"); - // Resume the previous sequence number which was reset by StopSend(). - // This needs to be done before |sending| is set to true. - if (send_sequence_number_) - SetInitSequenceNumber(send_sequence_number_); - if (channel_state_.Get().sending) { return 0; } channel_state_.SetSending(true); + // Resume the previous sequence number which was reset by StopSend(). This + // needs to be done before |sending| is set to true on the RTP/RTCP module. + if (send_sequence_number_) { + _rtpRtcpModule->SetSequenceNumber(send_sequence_number_); + } _rtpRtcpModule->SetSendingMediaStatus(true); if (_rtpRtcpModule->SetSendingStatus(true) != 0) { _engineStatisticsPtr->SetLastError( @@ -2740,23 +2740,9 @@ void Channel::GetDecodingCallStatistics(AudioDecodingCallStats* stats) const { audio_coding_->GetDecodingCallStatistics(stats); } -bool Channel::GetDelayEstimate(int* jitter_buffer_delay_ms, - int* playout_buffer_delay_ms) const { - rtc::CritScope lock(&video_sync_lock_); - *jitter_buffer_delay_ms = audio_coding_->FilteredCurrentDelayMs(); - *playout_buffer_delay_ms = playout_delay_ms_; - return true; -} - uint32_t Channel::GetDelayEstimate() const { - int jitter_buffer_delay_ms = 0; - int playout_buffer_delay_ms = 0; - GetDelayEstimate(&jitter_buffer_delay_ms, &playout_buffer_delay_ms); - return jitter_buffer_delay_ms + playout_buffer_delay_ms; -} - -int Channel::LeastRequiredDelayMs() const { - return audio_coding_->LeastRequiredDelayMs(); + rtc::CritScope lock(&video_sync_lock_); + return audio_coding_->FilteredCurrentDelayMs() + playout_delay_ms_; } int Channel::SetMinimumPlayoutDelay(int delayMs) { @@ -2794,30 +2780,6 @@ int Channel::GetPlayoutTimestamp(unsigned int& timestamp) { return 0; } -int Channel::SetInitTimestamp(unsigned int timestamp) { - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), - "Channel::SetInitTimestamp()"); - if (channel_state_.Get().sending) { - _engineStatisticsPtr->SetLastError(VE_SENDING, kTraceError, - "SetInitTimestamp() already sending"); - return -1; - } - _rtpRtcpModule->SetStartTimestamp(timestamp); - return 0; -} - -int Channel::SetInitSequenceNumber(short sequenceNumber) { - WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId, _channelId), - "Channel::SetInitSequenceNumber()"); - if (channel_state_.Get().sending) { - _engineStatisticsPtr->SetLastError( - VE_SENDING, kTraceError, "SetInitSequenceNumber() already sending"); - return -1; - } - _rtpRtcpModule->SetSequenceNumber(sequenceNumber); - return 0; -} - int Channel::GetRtpRtcp(RtpRtcp** rtpRtcpModule, RtpReceiver** rtp_receiver) const { *rtpRtcpModule = _rtpRtcpModule.get(); diff --git a/webrtc/voice_engine/channel.h b/webrtc/voice_engine/channel.h index d53cc06d40..03b19cc3a2 100644 --- a/webrtc/voice_engine/channel.h +++ b/webrtc/voice_engine/channel.h @@ -258,17 +258,10 @@ class Channel int GetNetworkStatistics(NetworkStatistics& stats); void GetDecodingCallStatistics(AudioDecodingCallStats* stats) const; - // VoEVideoSync - bool GetDelayEstimate(int* jitter_buffer_delay_ms, - int* playout_buffer_delay_ms) const; + // Audio+Video Sync uint32_t GetDelayEstimate() const; - int LeastRequiredDelayMs() const; int SetMinimumPlayoutDelay(int delayMs); int GetPlayoutTimestamp(unsigned int& timestamp); - int SetInitTimestamp(unsigned int timestamp); - int SetInitSequenceNumber(short sequenceNumber); - - // VoEVideoSyncExtended int GetRtpRtcp(RtpRtcp** rtpRtcpModule, RtpReceiver** rtp_receiver) const; // DTMF diff --git a/webrtc/voice_engine/channel_proxy.cc b/webrtc/voice_engine/channel_proxy.cc index a58b2e1955..4e690fb62f 100644 --- a/webrtc/voice_engine/channel_proxy.cc +++ b/webrtc/voice_engine/channel_proxy.cc @@ -23,22 +23,24 @@ ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {} ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) : channel_owner_(channel_owner) { RTC_CHECK(channel_owner_.channel()); + module_process_thread_checker_.DetachFromThread(); } ChannelProxy::~ChannelProxy() {} void ChannelProxy::SetRTCPStatus(bool enable) { + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->SetRTCPStatus(enable); } void ChannelProxy::SetLocalSSRC(uint32_t ssrc) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); int error = channel()->SetLocalSSRC(ssrc); RTC_DCHECK_EQ(0, error); } void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); // Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array. std::string c_name_limited = c_name.substr(0, 255); int error = channel()->SetRTCP_CNAME(c_name_limited.c_str()); @@ -46,29 +48,29 @@ void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) { } void ChannelProxy::SetNACKStatus(bool enable, int max_packets) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->SetNACKStatus(enable, max_packets); } void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); int error = channel()->SetSendAudioLevelIndicationStatus(enable, id); RTC_DCHECK_EQ(0, error); } void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id); RTC_DCHECK_EQ(0, error); } void ChannelProxy::EnableSendTransportSequenceNumber(int id) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->EnableSendTransportSequenceNumber(id); } void ChannelProxy::EnableReceiveTransportSequenceNumber(int id) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->EnableReceiveTransportSequenceNumber(id); } @@ -77,7 +79,7 @@ void ChannelProxy::RegisterSenderCongestionControlObjects( TransportFeedbackObserver* transport_feedback_observer, PacketRouter* packet_router, RtcpBandwidthObserver* bandwidth_observer) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->RegisterSenderCongestionControlObjects( rtp_packet_sender, transport_feedback_observer, packet_router, bandwidth_observer); @@ -85,17 +87,17 @@ void ChannelProxy::RegisterSenderCongestionControlObjects( void ChannelProxy::RegisterReceiverCongestionControlObjects( PacketRouter* packet_router) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->RegisterReceiverCongestionControlObjects(packet_router); } void ChannelProxy::ResetCongestionControlObjects() { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->ResetCongestionControlObjects(); } CallStatistics ChannelProxy::GetRTCPStatistics() const { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); CallStatistics stats = {0}; int error = channel()->GetRTPStatistics(stats); RTC_DCHECK_EQ(0, error); @@ -103,7 +105,7 @@ CallStatistics ChannelProxy::GetRTCPStatistics() const { } std::vector ChannelProxy::GetRemoteRTCPReportBlocks() const { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); std::vector blocks; int error = channel()->GetRemoteRTCPReportBlocks(&blocks); RTC_DCHECK_EQ(0, error); @@ -111,7 +113,7 @@ std::vector ChannelProxy::GetRemoteRTCPReportBlocks() const { } NetworkStatistics ChannelProxy::GetNetworkStatistics() const { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); NetworkStatistics stats = {0}; int error = channel()->GetNetworkStatistics(stats); RTC_DCHECK_EQ(0, error); @@ -119,14 +121,14 @@ NetworkStatistics ChannelProxy::GetNetworkStatistics() const { } AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); AudioDecodingCallStats stats; channel()->GetDecodingCallStatistics(&stats); return stats; } int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); uint32_t level = 0; int error = channel()->GetSpeechOutputLevelFullRange(level); RTC_DCHECK_EQ(0, error); @@ -134,53 +136,55 @@ int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const { } uint32_t ChannelProxy::GetDelayEstimate() const { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() || + module_process_thread_checker_.CalledOnValidThread()); return channel()->GetDelayEstimate(); } bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type, int payload_frequency) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); return channel()->SetSendTelephoneEventPayloadType(payload_type, payload_frequency) == 0; } bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); return channel()->SendTelephoneEventOutband(event, duration_ms) == 0; } void ChannelProxy::SetBitrate(int bitrate_bps, int64_t probing_interval_ms) { - // May be called on different threads and needs to be handled by the channel. + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() || + module_process_thread_checker_.CalledOnValidThread()); channel()->SetBitRate(bitrate_bps, probing_interval_ms); } void ChannelProxy::SetRecPayloadType(int payload_type, const SdpAudioFormat& format) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); const int result = channel()->SetRecPayloadType(payload_type, format); RTC_DCHECK_EQ(0, result); } void ChannelProxy::SetSink(std::unique_ptr sink) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->SetSink(std::move(sink)); } void ChannelProxy::SetInputMute(bool muted) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); int error = channel()->SetInputMute(muted); RTC_DCHECK_EQ(0, error); } void ChannelProxy::RegisterExternalTransport(Transport* transport) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); int error = channel()->RegisterExternalTransport(transport); RTC_DCHECK_EQ(0, error); } void ChannelProxy::DeRegisterExternalTransport() { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->DeRegisterExternalTransport(); } @@ -198,35 +202,35 @@ bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) { const rtc::scoped_refptr& ChannelProxy::GetAudioDecoderFactory() const { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); return channel()->GetAudioDecoderFactory(); } void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); int error = channel()->SetChannelOutputVolumeScaling(scaling); RTC_DCHECK_EQ(0, error); } void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->SetRtcEventLog(event_log); } void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); bool ret = channel()->EnableAudioNetworkAdaptor(config_string); RTC_DCHECK(ret); ;} void ChannelProxy::DisableAudioNetworkAdaptor() { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->DisableAudioNetworkAdaptor(); } void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms, int max_frame_length_ms) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->SetReceiverFrameLengthRange(min_frame_length_ms, max_frame_length_ms); } @@ -234,51 +238,42 @@ void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms, AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo( int sample_rate_hz, AudioFrame* audio_frame) { - RTC_DCHECK_RUNS_SERIALIZED(&race_checker_); + RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame); } int ChannelProxy::NeededFrequency() const { + RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); return static_cast(channel()->NeededFrequency(-1)); } void ChannelProxy::SetTransportOverhead(int transport_overhead_per_packet) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->SetTransportOverhead(transport_overhead_per_packet); } void ChannelProxy::AssociateSendChannel( const ChannelProxy& send_channel_proxy) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->set_associate_send_channel(send_channel_proxy.channel_owner_); } void ChannelProxy::DisassociateSendChannel() { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->set_associate_send_channel(ChannelOwner(nullptr)); } void ChannelProxy::GetRtpRtcp(RtpRtcp** rtp_rtcp, RtpReceiver** rtp_receiver) const { - // Called on Call's module_process_thread_. + RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); RTC_DCHECK(rtp_rtcp); RTC_DCHECK(rtp_receiver); int error = channel()->GetRtpRtcp(rtp_rtcp, rtp_receiver); RTC_DCHECK_EQ(0, error); } -void ChannelProxy::GetDelayEstimate(int* jitter_buffer_delay_ms, - int* playout_buffer_delay_ms) const { - // Called on Call's module_process_thread_. - RTC_DCHECK(jitter_buffer_delay_ms); - RTC_DCHECK(playout_buffer_delay_ms); - bool error = channel()->GetDelayEstimate(jitter_buffer_delay_ms, - playout_buffer_delay_ms); - RTC_DCHECK(error); -} - uint32_t ChannelProxy::GetPlayoutTimestamp() const { - // Called on video capture thread. + RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_); unsigned int timestamp = 0; int error = channel()->GetPlayoutTimestamp(timestamp); RTC_DCHECK(!error || timestamp == 0); @@ -286,7 +281,7 @@ uint32_t ChannelProxy::GetPlayoutTimestamp() const { } void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) { - // Called on Call's module_process_thread_. + RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); // Limit to range accepted by both VoE and ACM, so we're at least getting as // close as possible, instead of failing. delay_ms = std::max(0, std::min(delay_ms, 10000)); @@ -295,42 +290,42 @@ void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) { } void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); channel()->SetRtcpRttStats(rtcp_rtt_stats); } bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); return channel()->GetRecCodec(*codec_inst) == 0; } bool ChannelProxy::GetSendCodec(CodecInst* codec_inst) const { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); return channel()->GetSendCodec(*codec_inst) == 0; } bool ChannelProxy::SetVADStatus(bool enable) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); return channel()->SetVADStatus(enable, VADNormal, false) == 0; } bool ChannelProxy::SetCodecFECStatus(bool enable) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); return channel()->SetCodecFECStatus(enable) == 0; } bool ChannelProxy::SetOpusDtx(bool enable) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); return channel()->SetOpusDtx(enable) == 0; } bool ChannelProxy::SetOpusMaxPlaybackRate(int frequency_hz) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); return channel()->SetOpusMaxPlaybackRate(frequency_hz) == 0; } bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); // Validation code copied from VoECodecImpl::SetSendCodec(). if ((STR_CASE_CMP(codec_inst.plname, "L16") == 0) && (codec_inst.pacsize >= 960)) { @@ -352,7 +347,7 @@ bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) { bool ChannelProxy::SetSendCNPayloadType(int type, PayloadFrequencies frequency) { - RTC_DCHECK(thread_checker_.CalledOnValidThread()); + RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); // Validation code copied from VoECodecImpl::SetSendCNPayloadType(). if (type < 96 || type > 127) { // Only allow dynamic range: 96 to 127 diff --git a/webrtc/voice_engine/channel_proxy.h b/webrtc/voice_engine/channel_proxy.h index 966abc4868..b70dcc454d 100644 --- a/webrtc/voice_engine/channel_proxy.h +++ b/webrtc/voice_engine/channel_proxy.h @@ -105,8 +105,6 @@ class ChannelProxy { virtual void DisassociateSendChannel(); virtual void GetRtpRtcp(RtpRtcp** rtp_rtcp, RtpReceiver** rtp_receiver) const; - virtual void GetDelayEstimate(int* jitter_buffer_delay_ms, - int* playout_buffer_delay_ms) const; virtual uint32_t GetPlayoutTimestamp() const; virtual void SetMinimumPlayoutDelay(int delay_ms); virtual void SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats); @@ -122,8 +120,18 @@ class ChannelProxy { private: Channel* channel() const; - rtc::ThreadChecker thread_checker_; - rtc::RaceChecker race_checker_; + // Thread checkers document and lock usage of some methods on voe::Channel to + // specific threads we know about. The goal is to eventually split up + // voe::Channel into parts with single-threaded semantics, and thereby reduce + // the need for locks. + rtc::ThreadChecker worker_thread_checker_; + rtc::ThreadChecker module_process_thread_checker_; + // Methods accessed from audio and video threads are checked for sequential- + // only access. We don't necessarily own and control these threads, so thread + // checkers cannot be used. E.g. Chromium may transfer "ownership" from one + // audio thread to another, but access is still sequential. + rtc::RaceChecker audio_thread_race_checker_; + rtc::RaceChecker video_capture_thread_race_checker_; ChannelOwner channel_owner_; RTC_DISALLOW_COPY_AND_ASSIGN(ChannelProxy); diff --git a/webrtc/voice_engine/include/voe_video_sync.h b/webrtc/voice_engine/include/voe_video_sync.h deleted file mode 100644 index 655ba63543..0000000000 --- a/webrtc/voice_engine/include/voe_video_sync.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// This sub-API supports the following functionalities: -// -// - RTP header modification (time stamp and sequence number fields). -// - Playout delay tuning to synchronize the voice with video. -// - Playout delay monitoring. -// -// Usage example, omitting error checking: -// -// using namespace webrtc; -// VoiceEngine* voe = VoiceEngine::Create(); -// VoEBase* base = VoEBase::GetInterface(voe); -// VoEVideoSync* vsync = VoEVideoSync::GetInterface(voe); -// base->Init(); -// ... -// int buffer_ms(0); -// vsync->GetPlayoutBufferSize(buffer_ms); -// ... -// base->Terminate(); -// base->Release(); -// vsync->Release(); -// VoiceEngine::Delete(voe); -// -#ifndef WEBRTC_VOICE_ENGINE_VOE_VIDEO_SYNC_H -#define WEBRTC_VOICE_ENGINE_VOE_VIDEO_SYNC_H - -#include "webrtc/common_types.h" - -namespace webrtc { - -class RtpReceiver; -class RtpRtcp; -class VoiceEngine; - -class WEBRTC_DLLEXPORT VoEVideoSync { - public: - // Factory for the VoEVideoSync sub-API. Increases an internal - // reference counter if successful. Returns NULL if the API is not - // supported or if construction fails. - static VoEVideoSync* GetInterface(VoiceEngine* voiceEngine); - - // Releases the VoEVideoSync sub-API and decreases an internal - // reference counter. Returns the new reference count. This value should - // be zero for all sub-API:s before the VoiceEngine object can be safely - // deleted. - virtual int Release() = 0; - - // Gets the current sound card buffer size (playout delay). - virtual int GetPlayoutBufferSize(int& buffer_ms) = 0; - - // Sets a minimum target delay for the jitter buffer. This delay is - // maintained by the jitter buffer, unless channel condition (jitter in - // inter-arrival times) dictates a higher required delay. The overall - // jitter buffer delay is max of |delay_ms| and the latency that NetEq - // computes based on inter-arrival times and its playout mode. - virtual int SetMinimumPlayoutDelay(int channel, int delay_ms) = 0; - - // Gets the |jitter_buffer_delay_ms| (including the algorithmic delay), and - // the |playout_buffer_delay_ms| for a specified |channel|. - virtual int GetDelayEstimate(int channel, - int* jitter_buffer_delay_ms, - int* playout_buffer_delay_ms) = 0; - - // Returns the least required jitter buffer delay. This is computed by the - // the jitter buffer based on the inter-arrival time of RTP packets and - // playout mode. NetEq maintains this latency unless a higher value is - // requested by calling SetMinimumPlayoutDelay(). - virtual int GetLeastRequiredDelayMs(int channel) const = 0; - - // Manual initialization of the RTP timestamp. - virtual int SetInitTimestamp(int channel, unsigned int timestamp) = 0; - - // Manual initialization of the RTP sequence number. - virtual int SetInitSequenceNumber(int channel, short sequenceNumber) = 0; - - // Get the received RTP timestamp - virtual int GetPlayoutTimestamp(int channel, unsigned int& timestamp) = 0; - - virtual int GetRtpRtcp(int channel, - RtpRtcp** rtpRtcpModule, - RtpReceiver** rtp_receiver) = 0; - - protected: - VoEVideoSync() {} - virtual ~VoEVideoSync() {} -}; - -} // namespace webrtc - -#endif // #ifndef WEBRTC_VOICE_ENGINE_VOE_VIDEO_SYNC_H diff --git a/webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.cc b/webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.cc index 3c558305e3..79474d7ce9 100644 --- a/webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.cc +++ b/webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.cc @@ -23,7 +23,6 @@ BeforeInitializationFixture::BeforeInitializationFixture() voe_apm_ = webrtc::VoEAudioProcessing::GetInterface(voice_engine_); voe_network_ = webrtc::VoENetwork::GetInterface(voice_engine_); voe_file_ = webrtc::VoEFile::GetInterface(voice_engine_); - voe_vsync_ = webrtc::VoEVideoSync::GetInterface(voice_engine_); voe_hardware_ = webrtc::VoEHardware::GetInterface(voice_engine_); voe_neteq_stats_ = webrtc::VoENetEqStats::GetInterface(voice_engine_); } @@ -36,7 +35,6 @@ BeforeInitializationFixture::~BeforeInitializationFixture() { voe_apm_->Release(); voe_network_->Release(); voe_file_->Release(); - voe_vsync_->Release(); voe_hardware_->Release(); voe_neteq_stats_->Release(); diff --git a/webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.h b/webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.h index 63bb6c0864..e9f5a507e4 100644 --- a/webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.h +++ b/webrtc/voice_engine/test/auto_test/fixtures/before_initialization_fixture.h @@ -24,7 +24,6 @@ #include "webrtc/voice_engine/include/voe_neteq_stats.h" #include "webrtc/voice_engine/include/voe_network.h" #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" -#include "webrtc/voice_engine/include/voe_video_sync.h" #include "webrtc/voice_engine/include/voe_volume_control.h" #include "webrtc/voice_engine/test/auto_test/voe_test_common.h" @@ -56,7 +55,6 @@ class BeforeInitializationFixture : public testing::Test { webrtc::VoEAudioProcessing* voe_apm_; webrtc::VoENetwork* voe_network_; webrtc::VoEFile* voe_file_; - webrtc::VoEVideoSync* voe_vsync_; webrtc::VoEHardware* voe_hardware_; webrtc::VoENetEqStats* voe_neteq_stats_; }; diff --git a/webrtc/voice_engine/test/auto_test/standard/video_sync_test.cc b/webrtc/voice_engine/test/auto_test/standard/video_sync_test.cc deleted file mode 100644 index 0aacd53bb2..0000000000 --- a/webrtc/voice_engine/test/auto_test/standard/video_sync_test.cc +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include - -#include -#include - -#include "webrtc/voice_engine/test/auto_test/fixtures/after_streaming_fixture.h" - -#ifdef WEBRTC_IOS - const int kMinimumReasonableDelayEstimateMs = 30; -#else - const int kMinimumReasonableDelayEstimateMs = 45; -#endif // !WEBRTC_IOS - -class VideoSyncTest : public AfterStreamingFixture { - protected: - // This test will verify that delay estimates converge (e.g. the standard - // deviation for the last five seconds' estimates is less than 20) without - // manual observation. The test runs for 15 seconds, sampling once per second. - // All samples are checked so they are greater than |min_estimate|. - int CollectEstimatesDuring15Seconds(int min_estimate) { - Sleep(1000); - - std::vector all_delay_estimates; - for (int second = 0; second < 15; second++) { - int jitter_buffer_delay_ms = 0; - int playout_buffer_delay_ms = 0; - EXPECT_EQ(0, voe_vsync_->GetDelayEstimate(channel_, - &jitter_buffer_delay_ms, - &playout_buffer_delay_ms)); - - EXPECT_GT(jitter_buffer_delay_ms, min_estimate) << - "The delay estimate can not conceivably get lower than " << - min_estimate << " ms, it's unrealistic."; - - all_delay_estimates.push_back(jitter_buffer_delay_ms); - Sleep(1000); - } - - return ComputeStandardDeviation( - all_delay_estimates.begin() + 10, all_delay_estimates.end()); - } - - void CheckEstimatesConvergeReasonablyWell(int min_estimate) { - float standard_deviation = CollectEstimatesDuring15Seconds(min_estimate); - EXPECT_LT(standard_deviation, 30.0f); - } - - // Computes the standard deviation by first estimating the sample variance - // with an unbiased estimator. - float ComputeStandardDeviation(std::vector::const_iterator start, - std::vector::const_iterator end) const { - int num_elements = end - start; - int mean = std::accumulate(start, end, 0) / num_elements; - assert(num_elements > 1); - - float variance = 0; - for (; start != end; ++start) { - variance += (*start - mean) * (*start - mean) / (num_elements - 1); - } - return sqrt(variance); - } -}; - -TEST_F(VideoSyncTest, - CanNotGetPlayoutTimestampWhilePlayingWithoutSettingItFirst) { - unsigned int ignored; - EXPECT_EQ(-1, voe_vsync_->GetPlayoutTimestamp(channel_, ignored)); -} - -TEST_F(VideoSyncTest, CannotSetInitTimestampWhilePlaying) { - EXPECT_EQ(-1, voe_vsync_->SetInitTimestamp(channel_, 12345)); -} - -TEST_F(VideoSyncTest, CannotSetInitSequenceNumberWhilePlaying) { - EXPECT_EQ(-1, voe_vsync_->SetInitSequenceNumber(channel_, 123)); -} - -TEST_F(VideoSyncTest, CanSetInitTimestampWhileStopped) { - EXPECT_EQ(0, voe_base_->StopSend(channel_)); - EXPECT_EQ(0, voe_vsync_->SetInitTimestamp(channel_, 12345)); -} - -TEST_F(VideoSyncTest, CanSetInitSequenceNumberWhileStopped) { - EXPECT_EQ(0, voe_base_->StopSend(channel_)); - EXPECT_EQ(0, voe_vsync_->SetInitSequenceNumber(channel_, 123)); -} - -// TODO(phoglund): pending investigation in -// http://code.google.com/p/webrtc/issues/detail?id=438 -TEST_F(VideoSyncTest, - DISABLED_DelayEstimatesStabilizeDuring15sAndAreNotTooLow) { - EXPECT_EQ(0, voe_base_->StopSend(channel_)); - EXPECT_EQ(0, voe_vsync_->SetInitTimestamp(channel_, 12345)); - EXPECT_EQ(0, voe_vsync_->SetInitSequenceNumber(channel_, 123)); - EXPECT_EQ(0, voe_base_->StartSend(channel_)); - - CheckEstimatesConvergeReasonablyWell(kMinimumReasonableDelayEstimateMs); -} - -// TODO(phoglund): pending investigation in -// http://code.google.com/p/webrtc/issues/detail?id=438 -TEST_F(VideoSyncTest, - DISABLED_DelayEstimatesStabilizeAfterNetEqMinDelayChanges45s) { - EXPECT_EQ(0, voe_base_->StopSend(channel_)); - EXPECT_EQ(0, voe_vsync_->SetInitTimestamp(channel_, 12345)); - EXPECT_EQ(0, voe_vsync_->SetInitSequenceNumber(channel_, 123)); - EXPECT_EQ(0, voe_base_->StartSend(channel_)); - - CheckEstimatesConvergeReasonablyWell(kMinimumReasonableDelayEstimateMs); - EXPECT_EQ(0, voe_vsync_->SetMinimumPlayoutDelay(channel_, 200)); - CheckEstimatesConvergeReasonablyWell(kMinimumReasonableDelayEstimateMs); - EXPECT_EQ(0, voe_vsync_->SetMinimumPlayoutDelay(channel_, 0)); - CheckEstimatesConvergeReasonablyWell(kMinimumReasonableDelayEstimateMs); -} - -TEST_F(VideoSyncTest, CanGetPlayoutBufferSize) { - int ignored; - EXPECT_EQ(0, voe_vsync_->GetPlayoutBufferSize(ignored)); -} diff --git a/webrtc/voice_engine/test/auto_test/voe_standard_test.cc b/webrtc/voice_engine/test/auto_test/voe_standard_test.cc index 451082c652..1c3a492f58 100644 --- a/webrtc/voice_engine/test/auto_test/voe_standard_test.cc +++ b/webrtc/voice_engine/test/auto_test/voe_standard_test.cc @@ -50,8 +50,6 @@ void SubAPIManager::DisplayStatus() const { TEST_LOG(" Network\n"); if (_rtp_rtcp) TEST_LOG(" RTP_RTCP\n"); - if (_videoSync) - TEST_LOG(" VideoSync\n"); if (_volumeControl) TEST_LOG(" VolumeControl\n"); if (_apm) @@ -72,8 +70,6 @@ void SubAPIManager::DisplayStatus() const { TEST_LOG(" Network\n"); if (!_rtp_rtcp) TEST_LOG(" RTP_RTCP\n"); - if (!_videoSync) - TEST_LOG(" VideoSync\n"); if (!_volumeControl) TEST_LOG(" VolumeControl\n"); if (!_apm) diff --git a/webrtc/voice_engine/test/auto_test/voe_standard_test.h b/webrtc/voice_engine/test/auto_test/voe_standard_test.h index 6109603b28..5370ba469f 100644 --- a/webrtc/voice_engine/test/auto_test/voe_standard_test.h +++ b/webrtc/voice_engine/test/auto_test/voe_standard_test.h @@ -36,7 +36,6 @@ class SubAPIManager { _netEqStats(false), _network(false), _rtp_rtcp(false), - _videoSync(false), _volumeControl(false), _apm(false) { _codec = true; @@ -45,7 +44,6 @@ class SubAPIManager { _netEqStats = true; _network = true; _rtp_rtcp = true; - _videoSync = true; _volumeControl = true; _apm = true; } @@ -55,7 +53,7 @@ class SubAPIManager { private: bool _base, _codec; bool _file, _hardware; - bool _netEqStats, _network, _rtp_rtcp, _videoSync, _volumeControl, _apm; + bool _netEqStats, _network, _rtp_rtcp, _volumeControl, _apm; }; } // namespace voetest diff --git a/webrtc/voice_engine/test/auto_test/voe_test_defines.h b/webrtc/voice_engine/test/auto_test/voe_test_defines.h index 5d433d66db..1db5ee1764 100644 --- a/webrtc/voice_engine/test/auto_test/voe_test_defines.h +++ b/webrtc/voice_engine/test/auto_test/voe_test_defines.h @@ -24,7 +24,6 @@ #define _TEST_AUDIO_PROCESSING_ #define _TEST_FILE_ #define _TEST_NETWORK_ -#define _TEST_VIDEO_SYNC_ #define _TEST_NETEQ_STATS_ #define TESTED_AUDIO_LAYER kAudioPlatformDefault diff --git a/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc b/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc index 72d53b9eff..8f933f4aaa 100644 --- a/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc +++ b/webrtc/voice_engine/test/cmd_test/voe_cmd_test.cc @@ -34,7 +34,6 @@ #include "webrtc/voice_engine/include/voe_neteq_stats.h" #include "webrtc/voice_engine/include/voe_network.h" #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" -#include "webrtc/voice_engine/include/voe_video_sync.h" #include "webrtc/voice_engine/include/voe_volume_control.h" #include "webrtc/voice_engine/test/channel_transport/channel_transport.h" @@ -58,7 +57,6 @@ VoERTP_RTCP* rtp_rtcp = NULL; VoEAudioProcessing* apm = NULL; VoENetwork* netw = NULL; VoEFile* file = NULL; -VoEVideoSync* vsync = NULL; VoEHardware* hardware = NULL; VoENetEqStats* neteqst = NULL; @@ -129,7 +127,6 @@ int main(int argc, char** argv) { rtp_rtcp = VoERTP_RTCP::GetInterface(m_voe); netw = VoENetwork::GetInterface(m_voe); file = VoEFile::GetInterface(m_voe); - vsync = VoEVideoSync::GetInterface(m_voe); hardware = VoEHardware::GetInterface(m_voe); neteqst = VoENetEqStats::GetInterface(m_voe); @@ -195,9 +192,6 @@ int main(int argc, char** argv) { if (file) file->Release(); - if (vsync) - vsync->Release(); - if (hardware) hardware->Release(); diff --git a/webrtc/voice_engine/voe_video_sync_impl.cc b/webrtc/voice_engine/voe_video_sync_impl.cc deleted file mode 100644 index e82cbb3b5e..0000000000 --- a/webrtc/voice_engine/voe_video_sync_impl.cc +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/voice_engine/voe_video_sync_impl.h" - -#include "webrtc/system_wrappers/include/trace.h" -#include "webrtc/voice_engine/channel.h" -#include "webrtc/voice_engine/include/voe_errors.h" -#include "webrtc/voice_engine/voice_engine_impl.h" - -namespace webrtc { - -VoEVideoSync* VoEVideoSync::GetInterface(VoiceEngine* voiceEngine) { - if (NULL == voiceEngine) { - return NULL; - } - VoiceEngineImpl* s = static_cast(voiceEngine); - s->AddRef(); - return s; -} - -VoEVideoSyncImpl::VoEVideoSyncImpl(voe::SharedData* shared) : _shared(shared) { - WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), - "VoEVideoSyncImpl::VoEVideoSyncImpl() - ctor"); -} - -VoEVideoSyncImpl::~VoEVideoSyncImpl() { - WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_shared->instance_id(), -1), - "VoEVideoSyncImpl::~VoEVideoSyncImpl() - dtor"); -} - -int VoEVideoSyncImpl::GetPlayoutTimestamp(int channel, - unsigned int& timestamp) { - if (!_shared->statistics().Initialized()) { - _shared->SetLastError(VE_NOT_INITED, kTraceError); - return -1; - } - voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); - voe::Channel* channel_ptr = ch.channel(); - if (channel_ptr == NULL) { - _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, - "GetPlayoutTimestamp() failed to locate channel"); - return -1; - } - return channel_ptr->GetPlayoutTimestamp(timestamp); -} - -int VoEVideoSyncImpl::SetInitTimestamp(int channel, unsigned int timestamp) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), - "SetInitTimestamp(channel=%d, timestamp=%lu)", channel, - timestamp); - - if (!_shared->statistics().Initialized()) { - _shared->SetLastError(VE_NOT_INITED, kTraceError); - return -1; - } - voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); - voe::Channel* channelPtr = ch.channel(); - if (channelPtr == NULL) { - _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, - "SetInitTimestamp() failed to locate channel"); - return -1; - } - return channelPtr->SetInitTimestamp(timestamp); -} - -int VoEVideoSyncImpl::SetInitSequenceNumber(int channel, short sequenceNumber) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), - "SetInitSequenceNumber(channel=%d, sequenceNumber=%hd)", channel, - sequenceNumber); - - if (!_shared->statistics().Initialized()) { - _shared->SetLastError(VE_NOT_INITED, kTraceError); - return -1; - } - voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); - voe::Channel* channelPtr = ch.channel(); - if (channelPtr == NULL) { - _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, - "SetInitSequenceNumber() failed to locate channel"); - return -1; - } - return channelPtr->SetInitSequenceNumber(sequenceNumber); -} - -int VoEVideoSyncImpl::SetMinimumPlayoutDelay(int channel, int delayMs) { - WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), - "SetMinimumPlayoutDelay(channel=%d, delayMs=%d)", channel, - delayMs); - - if (!_shared->statistics().Initialized()) { - _shared->SetLastError(VE_NOT_INITED, kTraceError); - return -1; - } - voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); - voe::Channel* channelPtr = ch.channel(); - if (channelPtr == NULL) { - _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, - "SetMinimumPlayoutDelay() failed to locate channel"); - return -1; - } - return channelPtr->SetMinimumPlayoutDelay(delayMs); -} - -int VoEVideoSyncImpl::GetDelayEstimate(int channel, - int* jitter_buffer_delay_ms, - int* playout_buffer_delay_ms) { - if (!_shared->statistics().Initialized()) { - _shared->SetLastError(VE_NOT_INITED, kTraceError); - return -1; - } - voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); - voe::Channel* channelPtr = ch.channel(); - if (channelPtr == NULL) { - _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, - "GetDelayEstimate() failed to locate channel"); - return -1; - } - if (!channelPtr->GetDelayEstimate(jitter_buffer_delay_ms, - playout_buffer_delay_ms)) { - return -1; - } - return 0; -} - -int VoEVideoSyncImpl::GetPlayoutBufferSize(int& bufferMs) { - if (!_shared->statistics().Initialized()) { - _shared->SetLastError(VE_NOT_INITED, kTraceError); - return -1; - } - AudioDeviceModule::BufferType type(AudioDeviceModule::kFixedBufferSize); - uint16_t sizeMS(0); - if (_shared->audio_device()->PlayoutBuffer(&type, &sizeMS) != 0) { - _shared->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, - "GetPlayoutBufferSize() failed to read buffer size"); - return -1; - } - bufferMs = sizeMS; - return 0; -} - -int VoEVideoSyncImpl::GetRtpRtcp(int channel, - RtpRtcp** rtpRtcpModule, - RtpReceiver** rtp_receiver) { - if (!_shared->statistics().Initialized()) { - _shared->SetLastError(VE_NOT_INITED, kTraceError); - return -1; - } - voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); - voe::Channel* channelPtr = ch.channel(); - if (channelPtr == NULL) { - _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, - "GetPlayoutTimestamp() failed to locate channel"); - return -1; - } - return channelPtr->GetRtpRtcp(rtpRtcpModule, rtp_receiver); -} - -int VoEVideoSyncImpl::GetLeastRequiredDelayMs(int channel) const { - if (!_shared->statistics().Initialized()) { - _shared->SetLastError(VE_NOT_INITED, kTraceError); - return -1; - } - voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); - voe::Channel* channel_ptr = ch.channel(); - if (channel_ptr == NULL) { - _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, - "GetLeastRequiredDelayMs() failed to locate channel"); - return -1; - } - return channel_ptr->LeastRequiredDelayMs(); -} - -} // namespace webrtc diff --git a/webrtc/voice_engine/voe_video_sync_impl.h b/webrtc/voice_engine/voe_video_sync_impl.h deleted file mode 100644 index 8b367eeae1..0000000000 --- a/webrtc/voice_engine/voe_video_sync_impl.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VOICE_ENGINE_VOE_VIDEO_SYNC_IMPL_H -#define WEBRTC_VOICE_ENGINE_VOE_VIDEO_SYNC_IMPL_H - -#include "webrtc/voice_engine/include/voe_video_sync.h" - -#include "webrtc/voice_engine/shared_data.h" - -namespace webrtc { - -class VoEVideoSyncImpl : public VoEVideoSync { - public: - int GetPlayoutBufferSize(int& bufferMs) override; - - int SetMinimumPlayoutDelay(int channel, int delayMs) override; - - int GetDelayEstimate(int channel, - int* jitter_buffer_delay_ms, - int* playout_buffer_delay_ms) override; - - int GetLeastRequiredDelayMs(int channel) const override; - - int SetInitTimestamp(int channel, unsigned int timestamp) override; - - int SetInitSequenceNumber(int channel, short sequenceNumber) override; - - int GetPlayoutTimestamp(int channel, unsigned int& timestamp) override; - - int GetRtpRtcp(int channel, - RtpRtcp** rtpRtcpModule, - RtpReceiver** rtp_receiver) override; - - protected: - VoEVideoSyncImpl(voe::SharedData* shared); - ~VoEVideoSyncImpl() override; - - private: - voe::SharedData* _shared; -}; - -} // namespace webrtc - -#endif // WEBRTC_VOICE_ENGINE_VOE_VIDEO_SYNC_IMPL_H diff --git a/webrtc/voice_engine/voice_engine_impl.h b/webrtc/voice_engine/voice_engine_impl.h index ae1edcbdc5..36ea43957e 100644 --- a/webrtc/voice_engine/voice_engine_impl.h +++ b/webrtc/voice_engine/voice_engine_impl.h @@ -23,7 +23,6 @@ #include "webrtc/voice_engine/voe_neteq_stats_impl.h" #include "webrtc/voice_engine/voe_network_impl.h" #include "webrtc/voice_engine/voe_rtp_rtcp_impl.h" -#include "webrtc/voice_engine/voe_video_sync_impl.h" #include "webrtc/voice_engine/voe_volume_control_impl.h" namespace webrtc { @@ -40,7 +39,6 @@ class VoiceEngineImpl : public voe::SharedData, // Must be the first base class public VoENetEqStatsImpl, public VoENetworkImpl, public VoERTP_RTCPImpl, - public VoEVideoSyncImpl, public VoEVolumeControlImpl, public VoEBaseImpl { public: @@ -53,7 +51,6 @@ class VoiceEngineImpl : public voe::SharedData, // Must be the first base class VoENetEqStatsImpl(this), VoENetworkImpl(this), VoERTP_RTCPImpl(this), - VoEVideoSyncImpl(this), VoEVolumeControlImpl(this), VoEBaseImpl(this), _ref_count(0) {}