Add MID sending to RTPSender
This CL adds the ability to configure RTPSender to include the
MID header extension when sending packets. The MID will be
included on every packet at the start of the stream until an RTCP
acknoledgment is received for that SSRC at which point it will
stop being included. The MID will be included on regular RTP
streams as well as RTX streams.
Bug: webrtc:4050
Change-Id: Ie27ebee1cd00a67f2b931f5363788f523e3e684f
Reviewed-on: https://webrtc-review.googlesource.com/60582
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22574}
diff --git a/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_unittest.cc
index 6d8de07..d769ec3 100644
--- a/modules/rtp_rtcp/source/rtp_sender_unittest.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_unittest.cc
@@ -43,6 +43,7 @@
const int kAbsoluteSendTimeExtensionId = 14;
const int kTransportSequenceNumberExtensionId = 13;
const int kVideoTimingExtensionId = 12;
+const int kMidExtensionId = 11;
const int kPayload = 100;
const int kRtxPayload = 98;
const uint32_t kTimestamp = 10;
@@ -83,6 +84,7 @@
kAudioLevelExtensionId);
receivers_extensions_.Register(kRtpExtensionVideoTiming,
kVideoTimingExtensionId);
+ receivers_extensions_.Register(kRtpExtensionMid, kMidExtensionId);
}
bool SendRtp(const uint8_t* data,
@@ -1171,6 +1173,30 @@
EXPECT_EQ(kFlexfecSsrc, flexfec_packet.Ssrc());
}
+// Test that the MID header extension is included on sent packets when
+// configured.
+TEST_P(RtpSenderTestWithoutPacer, MidIncludedOnSentPackets) {
+ const char kMid[] = "mid";
+
+ // Register MID header extension and set the MID for the RTPSender.
+ rtp_sender_->SetSendingMediaStatus(false);
+ rtp_sender_->RegisterRtpHeaderExtension(kRtpExtensionMid, kMidExtensionId);
+ rtp_sender_->SetMid(kMid);
+ rtp_sender_->SetSendingMediaStatus(true);
+
+ // Send a couple packets.
+ SendGenericPayload();
+ SendGenericPayload();
+
+ // Expect both packets to have the MID set.
+ ASSERT_EQ(2u, transport_.sent_packets_.size());
+ for (const RtpPacketReceived& packet : transport_.sent_packets_) {
+ std::string mid;
+ ASSERT_TRUE(packet.GetExtension<RtpMid>(&mid));
+ EXPECT_EQ(kMid, mid);
+ }
+}
+
TEST_P(RtpSenderTest, FecOverheadRate) {
constexpr int kFlexfecPayloadType = 118;
constexpr uint32_t kMediaSsrc = 1234;