mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-14 06:10:40 +01:00

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}
68 lines
1.9 KiB
C++
68 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2018 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 "modules/rtp_rtcp/source/mid_oracle.h"
|
|
|
|
#include "rtc_base/logging.h"
|
|
#include "test/gtest.h"
|
|
|
|
namespace {
|
|
|
|
using ::webrtc::RTCPReportBlock;
|
|
using ::webrtc::MidOracle;
|
|
|
|
RTCPReportBlock ReportBlockWithSourceSsrc(uint32_t ssrc) {
|
|
RTCPReportBlock report_block;
|
|
report_block.source_ssrc = ssrc;
|
|
return report_block;
|
|
}
|
|
|
|
TEST(MidOracleTest, DoNotSendMidInitially) {
|
|
MidOracle mid_oracle("mid");
|
|
EXPECT_FALSE(mid_oracle.send_mid());
|
|
}
|
|
|
|
TEST(MidOracleTest, SendMidOnceSsrcSet) {
|
|
MidOracle mid_oracle("mid");
|
|
mid_oracle.SetSsrc(52);
|
|
EXPECT_TRUE(mid_oracle.send_mid());
|
|
}
|
|
|
|
TEST(MidOracleTest, IgnoreReportBlockWithUnknownSourceSsrc) {
|
|
MidOracle mid_oracle("mid");
|
|
mid_oracle.SetSsrc(52);
|
|
mid_oracle.OnReceivedRtcpReportBlocks({ReportBlockWithSourceSsrc(63)});
|
|
EXPECT_TRUE(mid_oracle.send_mid());
|
|
}
|
|
|
|
TEST(MidOracleTest, StopSendingMidAfterReceivingRtcpReportWithKnownSourceSsrc) {
|
|
constexpr uint32_t kSsrc = 52;
|
|
|
|
MidOracle mid_oracle("mid");
|
|
mid_oracle.SetSsrc(kSsrc);
|
|
mid_oracle.OnReceivedRtcpReportBlocks({ReportBlockWithSourceSsrc(kSsrc)});
|
|
|
|
EXPECT_FALSE(mid_oracle.send_mid());
|
|
}
|
|
|
|
TEST(MidOracleTest, RestartSendingMidWhenSsrcChanges) {
|
|
constexpr uint32_t kInitialSsrc = 52;
|
|
constexpr uint32_t kChangedSsrc = 63;
|
|
|
|
MidOracle mid_oracle("mid");
|
|
mid_oracle.SetSsrc(kInitialSsrc);
|
|
mid_oracle.OnReceivedRtcpReportBlocks(
|
|
{ReportBlockWithSourceSsrc(kInitialSsrc)});
|
|
mid_oracle.SetSsrc(kChangedSsrc);
|
|
|
|
EXPECT_TRUE(mid_oracle.send_mid());
|
|
}
|
|
|
|
} // namespace
|