m126 merge fixes

This commit is contained in:
Jim Gustafson 2024-06-21 17:30:37 -07:00
parent 49c96f3e79
commit 99c102adad
18 changed files with 89 additions and 25 deletions

View file

@ -151,6 +151,9 @@ class AudioDeviceModule : public webrtc::RefCountInterface {
virtual bool BuiltInAECIsAvailable() const = 0;
virtual bool BuiltInAGCIsAvailable() const = 0;
virtual bool BuiltInNSIsAvailable() const = 0;
// RingRTC change to allow control of AEC3 vs AECM
// When using software AEC, use AECM instead of AEC3.
virtual bool UseAecm() const { return false; }
// Enables the built-in audio effects. Only supported on Android.
virtual int32_t EnableBuiltInAEC(bool enable) = 0;

View file

@ -536,7 +536,17 @@ class RTC_EXPORT AudioProcessing : public RefCountInterface {
// but some components may change behavior based on this information.
// Default false. This method takes a lock. To achieve this in a lock-less
// manner the PostRuntimeSetting can instead be used.
virtual void set_output_will_be_muted(bool muted) = 0;
//
// RingRTC change to make it possible to share an APM (and thus, WebRtcVoiceEngine)
// between PeerConnections created from the same PeerConnectionFactory.
// Without this change, the code has a "last user wins" behavior,
// which breaks when creating multiple PeerConnections from the
// same PeerConnectionFactory. In particular, this happens when using
// ICE forking and the unused PeerConnections signal they are not using
// captured output after the used PeerConnection signals that it is using
// captured output. In that case, the call will end up
// without APM processing, which means it will have noise and echo.
virtual void set_capture_output_used(void* user, bool muted) = 0;
// Enqueues a runtime setting.
virtual void SetRuntimeSetting(RuntimeSetting setting) = 0;

View file

@ -703,7 +703,7 @@ void ChannelReceive::ReceivePacket(const uint8_t* packet,
const std::vector<uint32_t> csrcs(header.arrOfCSRCs,
header.arrOfCSRCs + header.numCSRCs);
// RingRTC change to determine if TOC is encrypted
bool has_encrypted_toc = header.extension.hasAudioLevel && ((header.extension.audioLevel & 0x1) != 0);
bool has_encrypted_toc = header.extension.audio_level() && ((header.extension.audio_level()->level() & 0x1) != 0);
const FrameDecryptorInterface::Result decrypt_result =
frame_decryptor_->Decrypt(
cricket::MEDIA_TYPE_AUDIO, csrcs,

View file

@ -373,6 +373,11 @@ int16_t WebRtcOpus_EnableDtx(OpusEncInst* inst) {
// RingRTC change to log opus setters
RTC_LOG(LS_INFO) << "WebRtcOpus_EnableDtx";
if (inst) {
// RingRTC change to force the Opus signal type to voice
int ret = ENCODER_CTL(inst, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
if (ret != OPUS_OK) {
return ret;
}
return ENCODER_CTL(inst, OPUS_SET_DTX(1));
} else {
return -1;

View file

@ -953,7 +953,7 @@ void P2PTransportChannel::StartGatheringWithSharedGatherer(
RTC_DCHECK_RUN_ON(network_thread_);
if (gathering_state_ != kIceGatheringGathering) {
gathering_state_ = kIceGatheringGathering;
SignalGatheringState(this);
SendGatheringStateEvent();
}
// Note: we must set this before calling OnPortReady below to make sure

View file

@ -6187,7 +6187,7 @@ TEST_F(P2PTransportChannelPingTest, Forking) {
kShortTimeout, clock);
transport1->SetRemoteIceParameters(kIceParams[1]);
transport1->AddRemoteCandidate(
CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1));
CreateUdpCandidate(IceCandidateType::kHost, "1.1.1.1", 1, 1));
ASSERT_EQ(1u, transport1->connections().size());
Connection* transport1_conn =
WaitForConnectionTo(transport1.get(), "1.1.1.1", 1, &clock);
@ -6208,7 +6208,7 @@ TEST_F(P2PTransportChannelPingTest, Forking) {
kShortTimeout, clock);
transport2->SetRemoteIceParameters(kIceParams[2]);
transport2->AddRemoteCandidate(
CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 2));
CreateUdpCandidate(IceCandidateType::kHost, "2.2.2.2", 2, 2));
ASSERT_EQ(1u, transport2->connections().size());
Connection* transport2_conn =
WaitForConnectionTo(transport2.get(), "2.2.2.2", 2, &clock);

View file

@ -282,7 +282,6 @@ BasicPortAllocator::CreateIceGatherer(const std::string& name) {
// 4. User setters to set flags and other settings
new_allocator->set_flags(flags());
new_allocator->set_proxy(user_agent(), proxy());
new_allocator->SetPortRange(min_port(), max_port());
new_allocator->set_max_ipv6_networks(max_ipv6_networks());
new_allocator->set_step_delay(step_delay());

View file

@ -341,6 +341,8 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> {
rtc::PacketTransportInternal* rtcp_packet_transport) {
auto rtp_transport = std::make_unique<webrtc::RtpTransport>(
rtcp_packet_transport == nullptr);
// RingRTC change to drop all incoming packets until explicitly allowed
rtp_transport->SetIncomingRtpEnabled(true);
SendTask(network_thread_,
[&rtp_transport, rtp_packet_transport, rtcp_packet_transport] {
@ -357,6 +359,8 @@ class ChannelTest : public ::testing::Test, public sigslot::has_slots<> {
cricket::DtlsTransportInternal* rtcp_dtls_transport) {
auto dtls_srtp_transport = std::make_unique<webrtc::DtlsSrtpTransport>(
rtcp_dtls_transport == nullptr, field_trials_);
// RingRTC change to drop all incoming packets until explicitly allowed
dtls_srtp_transport->SetIncomingRtpEnabled(true);
SendTask(network_thread_,
[&dtls_srtp_transport, rtp_dtls_transport, rtcp_dtls_transport] {

View file

@ -62,6 +62,9 @@ class DtlsSrtpTransportTest : public ::testing::Test,
auto dtls_srtp_transport =
std::make_unique<DtlsSrtpTransport>(rtcp_mux_enabled, field_trials_);
// RingRTC change to drop all incoming packets until explicitly allowed
dtls_srtp_transport->SetIncomingRtpEnabled(true);
dtls_srtp_transport->SetDtlsTransports(rtp_dtls, rtcp_dtls);
return dtls_srtp_transport;

View file

@ -83,6 +83,8 @@ class SignalObserver : public sigslot::has_slots<> {
TEST(RtpTransportTest, SettingRtcpAndRtpSignalsReady) {
RtpTransport transport(kMuxDisabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
SignalObserver observer(&transport);
rtc::FakePacketTransport fake_rtcp("fake_rtcp");
fake_rtcp.SetWritable(true);
@ -97,6 +99,8 @@ TEST(RtpTransportTest, SettingRtcpAndRtpSignalsReady) {
TEST(RtpTransportTest, SettingRtpAndRtcpSignalsReady) {
RtpTransport transport(kMuxDisabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
SignalObserver observer(&transport);
rtc::FakePacketTransport fake_rtcp("fake_rtcp");
fake_rtcp.SetWritable(true);
@ -111,6 +115,8 @@ TEST(RtpTransportTest, SettingRtpAndRtcpSignalsReady) {
TEST(RtpTransportTest, SettingRtpWithRtcpMuxEnabledSignalsReady) {
RtpTransport transport(kMuxEnabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
SignalObserver observer(&transport);
rtc::FakePacketTransport fake_rtp("fake_rtp");
fake_rtp.SetWritable(true);
@ -121,6 +127,8 @@ TEST(RtpTransportTest, SettingRtpWithRtcpMuxEnabledSignalsReady) {
TEST(RtpTransportTest, DisablingRtcpMuxSignalsNotReady) {
RtpTransport transport(kMuxEnabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
SignalObserver observer(&transport);
rtc::FakePacketTransport fake_rtp("fake_rtp");
fake_rtp.SetWritable(true);
@ -134,6 +142,8 @@ TEST(RtpTransportTest, DisablingRtcpMuxSignalsNotReady) {
TEST(RtpTransportTest, EnablingRtcpMuxSignalsReady) {
RtpTransport transport(kMuxDisabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
SignalObserver observer(&transport);
rtc::FakePacketTransport fake_rtp("fake_rtp");
fake_rtp.SetWritable(true);
@ -148,6 +158,8 @@ TEST(RtpTransportTest, EnablingRtcpMuxSignalsReady) {
// Tests the SignalNetworkRoute is fired when setting a packet transport.
TEST(RtpTransportTest, SetRtpTransportWithNetworkRouteChanged) {
RtpTransport transport(kMuxDisabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
SignalObserver observer(&transport);
rtc::FakePacketTransport fake_rtp("fake_rtp");
@ -177,6 +189,8 @@ TEST(RtpTransportTest, SetRtpTransportWithNetworkRouteChanged) {
TEST(RtpTransportTest, SetRtcpTransportWithNetworkRouteChanged) {
RtpTransport transport(kMuxDisabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
SignalObserver observer(&transport);
rtc::FakePacketTransport fake_rtcp("fake_rtcp");
@ -210,6 +224,8 @@ TEST(RtpTransportTest, RtcpPacketSentOverCorrectTransport) {
// If the RTCP-mux is not enabled, RTCP packets are expected to be sent over
// the RtcpPacketTransport.
RtpTransport transport(kMuxDisabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
rtc::FakePacketTransport fake_rtcp("fake_rtcp");
rtc::FakePacketTransport fake_rtp("fake_rtp");
transport.SetRtcpPacketTransport(&fake_rtcp); // rtcp ready
@ -232,6 +248,8 @@ TEST(RtpTransportTest, RtcpPacketSentOverCorrectTransport) {
TEST(RtpTransportTest, ChangingReadyToSendStateOnlySignalsWhenChanged) {
RtpTransport transport(kMuxEnabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
TransportObserver observer(&transport);
rtc::FakePacketTransport fake_rtp("fake_rtp");
fake_rtp.SetWritable(true);
@ -257,6 +275,8 @@ TEST(RtpTransportTest, ChangingReadyToSendStateOnlySignalsWhenChanged) {
// received.
TEST(RtpTransportTest, SignalDemuxedRtcp) {
RtpTransport transport(kMuxDisabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
rtc::FakePacketTransport fake_rtp("fake_rtp");
fake_rtp.SetDestination(&fake_rtp, true);
transport.SetRtpPacketTransport(&fake_rtp);
@ -280,6 +300,8 @@ static const int kRtpLen = 12;
// handled payload type is received.
TEST(RtpTransportTest, SignalHandledRtpPayloadType) {
RtpTransport transport(kMuxDisabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
rtc::FakePacketTransport fake_rtp("fake_rtp");
fake_rtp.SetDestination(&fake_rtp, true);
transport.SetRtpPacketTransport(&fake_rtp);
@ -303,6 +325,8 @@ TEST(RtpTransportTest, SignalHandledRtpPayloadType) {
TEST(RtpTransportTest, ReceivedPacketEcnMarkingPropagatedToDemuxedPacket) {
RtpTransport transport(kMuxDisabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
// Setup FakePacketTransport to send packets to itself.
rtc::FakePacketTransport fake_rtp("fake_rtp");
fake_rtp.SetDestination(&fake_rtp, true);
@ -328,6 +352,8 @@ TEST(RtpTransportTest, ReceivedPacketEcnMarkingPropagatedToDemuxedPacket) {
// unhandled payload type is received.
TEST(RtpTransportTest, DontSignalUnhandledRtpPayloadType) {
RtpTransport transport(kMuxDisabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
rtc::FakePacketTransport fake_rtp("fake_rtp");
fake_rtp.SetDestination(&fake_rtp, true);
transport.SetRtpPacketTransport(&fake_rtp);
@ -352,6 +378,8 @@ TEST(RtpTransportTest, RecursiveSetSendDoesNotCrash) {
const int kShortTimeout = 100;
test::RunLoop loop;
RtpTransport transport(kMuxEnabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
rtc::FakePacketTransport fake_rtp("fake_rtp");
transport.SetRtpPacketTransport(&fake_rtp);
TransportObserver observer(&transport);
@ -376,6 +404,8 @@ TEST(RtpTransportTest, RecursiveOnSentPacketDoesNotCrash) {
const int kShortTimeout = 100;
test::RunLoop loop;
RtpTransport transport(kMuxEnabled);
// RingRTC change to drop all incoming packets until explicitly allowed
transport.SetIncomingRtpEnabled(true);
rtc::FakePacketTransport fake_rtp("fake_rtp");
transport.SetRtpPacketTransport(&fake_rtp);
fake_rtp.SetDestination(&fake_rtp, true);

View file

@ -63,6 +63,10 @@ class SrtpTransportTest : public ::testing::Test, public sigslot::has_slots<> {
srtp_transport2_ =
std::make_unique<SrtpTransport>(rtcp_mux_enabled, field_trials_);
// RingRTC change to drop all incoming packets until explicitly allowed
srtp_transport1_->SetIncomingRtpEnabled(true);
srtp_transport2_->SetIncomingRtpEnabled(true);
srtp_transport1_->SetRtpPacketTransport(rtp_packet_transport1_.get());
srtp_transport2_->SetRtpPacketTransport(rtp_packet_transport2_.get());
@ -433,6 +437,9 @@ TEST_F(SrtpTransportTest, RemoveSrtpReceiveStream) {
auto rtp_packet_transport = std::make_unique<rtc::FakePacketTransport>(
"fake_packet_transport_loopback");
// RingRTC change to drop all incoming packets until explicitly allowed
srtp_transport->SetIncomingRtpEnabled(true);
bool asymmetric = false;
rtp_packet_transport->SetDestination(rtp_packet_transport.get(), asymmetric);
srtp_transport->SetRtpPacketTransport(rtp_packet_transport.get());

View file

@ -320,8 +320,6 @@ class InjectableNetworkImpl : public InjectableNetwork, public rtc::NetworkManag
rtc::AsyncPacketSocket* CreateClientTcpSocket(
const rtc::SocketAddress& local_address,
const rtc::SocketAddress& remote_address,
const rtc::ProxyInfo& proxy_info,
const std::string& user_agent,
const rtc::PacketSocketTcpOptions& tcp_options) override {
// TODO: Support TCP for TURN
return nullptr;

View file

@ -393,7 +393,7 @@ Rust_sessionDescriptionFromV4(bool offer,
audio->AddCodec(opus_red);
}
auto add_video_feedback_params = [] (cricket::VideoCodec* video_codec) {
auto add_video_feedback_params = [] (cricket::Codec* video_codec) {
video_codec->AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamTransportCc, cricket::kParamValueEmpty));
video_codec->AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamCcm, cricket::kRtcpFbCcmParamFir));
video_codec->AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, cricket::kParamValueEmpty));
@ -618,7 +618,7 @@ CreateSessionDescriptionForGroupCall(bool local,
remote_audio->AddCodec(opus_red);
}
auto add_video_feedback_params = [] (cricket::VideoCodec* video_codec) {
auto add_video_feedback_params = [] (cricket::Codec* video_codec) {
video_codec->AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamTransportCc, cricket::kParamValueEmpty));
video_codec->AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamCcm, cricket::kRtcpFbCcmParamFir));
video_codec->AddFeedbackParam(cricket::FeedbackParam(cricket::kRtcpFbParamNack, cricket::kParamValueEmpty));
@ -649,7 +649,7 @@ CreateSessionDescriptionForGroupCall(bool local,
remote_video->AddCodec(red_rtx);
}
auto audio_level = webrtc::RtpExtension(webrtc::AudioLevel::Uri(), AUDIO_LEVEL_EXT_ID);
auto audio_level = webrtc::RtpExtension(webrtc::AudioLevelExtension::Uri(), AUDIO_LEVEL_EXT_ID);
// Note: Do not add transport-cc for audio. Using transport-cc with audio is still experimental in WebRTC.
// And don't add abs_send_time because it's only used for video.
local_audio->AddRtpHeaderExtension(audio_level);
@ -973,7 +973,7 @@ Rust_addIceCandidateFromServer(PeerConnectionInterface* pc_borrowed_rc,
// WebRTC generally prefers IPv6 over IPv4 for local candidates (see rtc_base::IPAddressPrecedence).
// So we leave the priority unset to allow the local candidate preference to break the tie.
candidate.set_component(cricket::ICE_CANDIDATE_COMPONENT_RTP);
candidate.set_type(cricket::LOCAL_PORT_TYPE); // AKA "host"
candidate.set_type(webrtc::IceCandidateType::kHost);
candidate.set_address(rtc::SocketAddress(IpToRtcIp(ip), port));
candidate.set_protocol(tcp ? cricket::TCP_PROTOCOL_NAME : cricket::UDP_PROTOCOL_NAME);

View file

@ -5,6 +5,7 @@
#include "api/create_peerconnection_factory.h"
#include "api/enable_media.h"
#include "api/environment/environment.h"
#include "api/task_queue/default_task_queue_factory.h"
#include "api/rtc_event_log/rtc_event_log_factory.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
@ -49,7 +50,8 @@ class RingRTCVideoEncoderFactory : public VideoEncoderFactory {
return factory_.GetSupportedFormats();
}
std::unique_ptr<VideoEncoder> CreateVideoEncoder(
std::unique_ptr<VideoEncoder> Create(
const Environment& env,
const SdpVideoFormat& format) override {
if (format.IsCodecInList(
factory_.GetSupportedFormats())) {
@ -60,7 +62,7 @@ class RingRTCVideoEncoderFactory : public VideoEncoderFactory {
// The adapter has a passthrough mode for the case that simulcast is not
// used, so all responsibility can be delegated to it.
return std::make_unique<SimulcastEncoderAdapter>(
&factory_, *original_format);
env, &factory_, nullptr, *original_format);
}
}
return nullptr;

View file

@ -35,7 +35,7 @@ void PeerConnectionObserverRffi::OnIceCandidate(const IceCandidateInterface* can
candidate->ToString(&sdp);
rust_candidate.sdp_borrowed = sdp.c_str();
rust_candidate.is_relayed = (candidate->candidate().type() == cricket::RELAY_PORT_TYPE);
rust_candidate.is_relayed = (candidate->candidate().type() == IceCandidateType::kRelay);
rust_candidate.relay_protocol = TransportProtocol::kUnknown;
if (candidate->candidate().relay_protocol() == cricket::UDP_PROTOCOL_NAME) {
rust_candidate.relay_protocol = TransportProtocol::kUdp;
@ -95,7 +95,7 @@ void PeerConnectionObserverRffi::OnIceSelectedCandidatePairChanged(
auto& remote = event.selected_candidate_pair.remote_candidate();
auto local_adapter_type = local.network_type();
auto local_adapter_type_under_vpn = local.underlying_type_for_vpn();
bool local_relayed = (local.type() == cricket::RELAY_PORT_TYPE) || !local.relay_protocol().empty();
bool local_relayed = (local.type() == IceCandidateType::kRelay) || !local.relay_protocol().empty();
TransportProtocol local_relay_protocol = TransportProtocol::kUnknown;
if (local.relay_protocol() == cricket::UDP_PROTOCOL_NAME) {
local_relay_protocol = TransportProtocol::kUdp;
@ -104,7 +104,7 @@ void PeerConnectionObserverRffi::OnIceSelectedCandidatePairChanged(
} else if (local.relay_protocol() == cricket::TLS_PROTOCOL_NAME) {
local_relay_protocol = TransportProtocol::kTls;
}
bool remote_relayed = (remote.type() == cricket::RELAY_PORT_TYPE);
bool remote_relayed = (remote.type() == IceCandidateType::kRelay);
auto network_route = webrtc::rffi::NetworkRoute{ local_adapter_type, local_adapter_type_under_vpn, local_relayed, local_relay_protocol, remote_relayed};
callbacks_.onIceNetworkRouteChange(observer_, network_route, SdpSerializeCandidate(local).c_str(), SdpSerializeCandidate(remote).c_str());

View file

@ -843,11 +843,12 @@ public class PeerConnection {
return offerExtmapAllowMixed;
}
@CalledByNative("RTCConfiguration")
@PortAllocatorFlags
int getPortAllocatorFlags() {
return portAllocatorFlags;
}
// RingRTC change to use default port allocator flags
// @CalledByNative("RTCConfiguration")
// @PortAllocatorFlags
// int getPortAllocatorFlags() {
// return portAllocatorFlags;
// }
};
private final List<MediaStream> localStreams = new ArrayList<>();

View file

@ -280,8 +280,9 @@ void JavaToNativeRTCConfiguration(
rtc_config->turn_logging_id = JavaToNativeString(jni, j_turn_logging_id);
}
rtc_config->port_allocator_config.flags =
Java_RTCConfiguration_getPortAllocatorFlags(jni, j_rtc_config);
// RingRTC change to use default port allocator flags
// rtc_config->port_allocator_config.flags =
// Java_RTCConfiguration_getPortAllocatorFlags(jni, j_rtc_config);
}
rtc::KeyType GetRtcConfigKeyType(JNIEnv* env,

View file

@ -37,7 +37,8 @@ EncoderRtcpFeedback::EncoderRtcpFeedback(
per_layer_keyframes_(per_layer_keyframes),
get_packet_infos_(std::move(get_packet_infos)),
video_stream_encoder_(encoder),
time_last_packet_delivery_queue_(per_layer_keyframes ? ssrcs.size() : 1,
// RingRTC change to enable per-layer PLI for screen sharing
time_last_packet_delivery_queue_(ssrcs.size(),
Timestamp::Zero()),
min_keyframe_send_interval_(
TimeDelta::Millis(KeyframeIntervalSettings::ParseFromFieldTrials()