webrtc_m130/pc/rtp_transceiver_unittest.cc
Markus Handell 6f727da62b Revert "RtpTransceiverInterface: introduce SetOfferedRtpHeaderExtensions."
This reverts commit 71db9acc4019b8c9c13b14e6a022cbb3b4255b09.

Reason for revert: breaks downstream project.
Reason for force push: win bot broken.

Original change's description:
> RtpTransceiverInterface: introduce SetOfferedRtpHeaderExtensions.
>
> This change adds exposure of a new transceiver method for
> modifying the extensions offered in the next SDP negotiation,
> following spec details in https://w3c.github.io/webrtc-extensions/#rtcrtptransceiver-interface.
>
> Features:
> - The interface allows to control the negotiated direction as
>   per https://tools.ietf.org/html/rfc5285#page-7.
> - The interface allows to remove an extension from SDP
>   negotiation by modifying the direction to
>   RtpTransceiverDirection::kStopped.
>
> Note: support for signalling directionality of header extensions
> in the SDP isn't implemented yet.
>
> https://chromestatus.com/feature/5680189201711104.
> Intent to prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/65YdUi02yZk
>
> Bug: chromium:1051821
> Change-Id: Iaabc34446f038c46d93c442e90c2a77f77d542d4
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176408
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Markus Handell <handellm@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31487}

TBR=hta@webrtc.org,handellm@webrtc.org

# Not skipping CQ checks because original CL landed > 1 day ago.

No-Try: true
Bug: chromium:1051821
Change-Id: I70e1a07225d7eeec7480fa5577d8ff647eba6902
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177103
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31516}
2020-06-12 16:26:49 +00:00

105 lines
3.7 KiB
C++

/*
* Copyright 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.
*/
// This file contains tests for |RtpTransceiver|.
#include "pc/rtp_transceiver.h"
#include <memory>
#include "media/base/fake_media_engine.h"
#include "pc/test/mock_channel_interface.h"
#include "pc/test/mock_rtp_receiver_internal.h"
#include "pc/test/mock_rtp_sender_internal.h"
#include "test/gmock.h"
#include "test/gtest.h"
using ::testing::ElementsAre;
using ::testing::Eq;
using ::testing::Field;
using ::testing::Not;
using ::testing::Return;
using ::testing::ReturnRef;
namespace webrtc {
// Checks that a channel cannot be set on a stopped |RtpTransceiver|.
TEST(RtpTransceiverTest, CannotSetChannelOnStoppedTransceiver) {
RtpTransceiver transceiver(cricket::MediaType::MEDIA_TYPE_AUDIO);
cricket::MockChannelInterface channel1;
sigslot::signal1<cricket::ChannelInterface*> signal;
EXPECT_CALL(channel1, media_type())
.WillRepeatedly(Return(cricket::MediaType::MEDIA_TYPE_AUDIO));
EXPECT_CALL(channel1, SignalFirstPacketReceived())
.WillRepeatedly(ReturnRef(signal));
transceiver.SetChannel(&channel1);
EXPECT_EQ(&channel1, transceiver.channel());
// Stop the transceiver.
transceiver.Stop();
EXPECT_EQ(&channel1, transceiver.channel());
cricket::MockChannelInterface channel2;
EXPECT_CALL(channel2, media_type())
.WillRepeatedly(Return(cricket::MediaType::MEDIA_TYPE_AUDIO));
// Channel can no longer be set, so this call should be a no-op.
transceiver.SetChannel(&channel2);
EXPECT_EQ(&channel1, transceiver.channel());
}
// Checks that a channel can be unset on a stopped |RtpTransceiver|
TEST(RtpTransceiverTest, CanUnsetChannelOnStoppedTransceiver) {
RtpTransceiver transceiver(cricket::MediaType::MEDIA_TYPE_VIDEO);
cricket::MockChannelInterface channel;
sigslot::signal1<cricket::ChannelInterface*> signal;
EXPECT_CALL(channel, media_type())
.WillRepeatedly(Return(cricket::MediaType::MEDIA_TYPE_VIDEO));
EXPECT_CALL(channel, SignalFirstPacketReceived())
.WillRepeatedly(ReturnRef(signal));
transceiver.SetChannel(&channel);
EXPECT_EQ(&channel, transceiver.channel());
// Stop the transceiver.
transceiver.Stop();
EXPECT_EQ(&channel, transceiver.channel());
// Set the channel to |nullptr|.
transceiver.SetChannel(nullptr);
EXPECT_EQ(nullptr, transceiver.channel());
}
TEST(RtpTransceiverTest,
InitsWithChannelManagerRtpHeaderExtensionCapabilities) {
cricket::ChannelManager channel_manager(
std::make_unique<cricket::FakeMediaEngine>(),
std::make_unique<cricket::FakeDataEngine>(), rtc::Thread::Current(),
rtc::Thread::Current());
std::vector<RtpHeaderExtensionCapability> extensions({
RtpHeaderExtensionCapability("uri1", 1,
RtpTransceiverDirection::kSendRecv),
RtpHeaderExtensionCapability("uri2", 2,
RtpTransceiverDirection::kRecvOnly),
});
RtpTransceiver transceiver(
RtpSenderProxyWithInternal<RtpSenderInternal>::Create(
rtc::Thread::Current(),
new rtc::RefCountedObject<MockRtpSenderInternal>()),
RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create(
rtc::Thread::Current(),
new rtc::RefCountedObject<MockRtpReceiverInternal>()),
&channel_manager, extensions);
EXPECT_EQ(transceiver.HeaderExtensionsToOffer(), extensions);
}
} // namespace webrtc