RtpSenderInterface::SetEncoderSelector

This cl/ adds a way of setting an EncoderSelector on a specific
RtpSenderInterface. This makes it possible to easily use different
EncoderSelector on different streams within the same or different PeerConnections.

The cl/ is almost identical to the impl. of RtpSenderInterface::SetFrameEncryptor.

Iff a EncoderSelector is set on the RtpSender, it will take precedence
over the VideoEncoderFactory::GetEncoderSelector.

Bug: webrtc:14122
Change-Id: Ief4f7c06df7f1ef4ce3245de304a48e9de0ad587
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/264542
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37150}
This commit is contained in:
Jonas Oreland
2022-06-08 11:25:46 +02:00
committed by WebRTC LUCI CQ
parent 86c452ac5a
commit 6545516a14
18 changed files with 247 additions and 8 deletions

View File

@ -49,6 +49,7 @@
#include "api/stats/rtc_stats.h"
#include "api/stats/rtc_stats_report.h"
#include "api/stats/rtcstats_objects.h"
#include "api/test/mock_encoder_selector.h"
#include "api/transport/rtp/rtp_source.h"
#include "api/uma_metrics.h"
#include "api/units/time_delta.h"
@ -3593,6 +3594,35 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
callee_track->state());
}
TEST_P(PeerConnectionIntegrationTest, EndToEndRtpSenderVideoEncoderSelector) {
ASSERT_TRUE(
CreateOneDirectionalPeerConnectionWrappers(/*caller_to_callee=*/true));
ConnectFakeSignaling();
// Add one-directional video, from caller to callee.
rtc::scoped_refptr<webrtc::VideoTrackInterface> caller_track =
caller()->CreateLocalVideoTrack();
auto sender = caller()->AddTrack(caller_track);
PeerConnectionInterface::RTCOfferAnswerOptions options;
options.offer_to_receive_video = 0;
caller()->SetOfferAnswerOptions(options);
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
ASSERT_EQ(callee()->pc()->GetReceivers().size(), 1u);
std::unique_ptr<MockEncoderSelector> encoder_selector =
std::make_unique<MockEncoderSelector>();
EXPECT_CALL(*encoder_selector, OnCurrentEncoder);
sender->SetEncoderSelector(std::move(encoder_selector));
// Expect video to be received in one direction.
MediaExpectations media_expectations;
media_expectations.CallerExpectsNoVideo();
media_expectations.CalleeExpectsSomeVideo();
EXPECT_TRUE(ExpectNewFrames(media_expectations));
}
} // namespace
} // namespace webrtc