Replace MediaContentDirection with RtpTransceiverDirection
Bug: webrtc:8558 Change-Id: I410d17cce235e0b42038cf0b125fd916010f50ae Reviewed-on: https://webrtc-review.googlesource.com/24745 Commit-Queue: Steve Anton <steveanton@webrtc.org> Reviewed-by: Peter Thatcher <pthatcher@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20922}
This commit is contained in:
parent
36207d600a
commit
4e70a72571
@ -315,21 +315,18 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyAudioSenderParameters(
|
||||
}
|
||||
}
|
||||
|
||||
auto local_direction =
|
||||
cricket::RtpTransceiverDirectionFromMediaContentDirection(
|
||||
local_audio_description_.direction());
|
||||
bool local_send = RtpTransceiverDirectionHasSend(local_direction);
|
||||
bool local_recv = RtpTransceiverDirectionHasRecv(local_direction);
|
||||
bool local_send = false;
|
||||
int bandwidth = cricket::kAutoBandwidth;
|
||||
if (parameters.encodings.size() == 1u) {
|
||||
if (parameters.encodings[0].max_bitrate_bps) {
|
||||
bandwidth = *parameters.encodings[0].max_bitrate_bps;
|
||||
}
|
||||
local_send = parameters.encodings[0].active;
|
||||
} else {
|
||||
local_send = false;
|
||||
}
|
||||
local_direction = RtpTransceiverDirectionFromSendRecv(local_send, local_recv);
|
||||
const bool local_recv =
|
||||
RtpTransceiverDirectionHasRecv(local_audio_description_.direction());
|
||||
const auto local_direction =
|
||||
RtpTransceiverDirectionFromSendRecv(local_send, local_recv);
|
||||
if (primary_ssrc && !stream_params_result.value().empty()) {
|
||||
*primary_ssrc = stream_params_result.value()[0].first_ssrc();
|
||||
}
|
||||
@ -350,12 +347,9 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyAudioSenderParameters(
|
||||
remote_audio_description_.set_bandwidth(bandwidth);
|
||||
local_audio_description_.mutable_streams() = stream_params_result.MoveValue();
|
||||
// Direction set based on encoding "active" flag.
|
||||
local_audio_description_.set_direction(
|
||||
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||
local_direction));
|
||||
local_audio_description_.set_direction(local_direction);
|
||||
remote_audio_description_.set_direction(
|
||||
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||
RtpTransceiverDirectionReversed(local_direction)));
|
||||
RtpTransceiverDirectionReversed(local_direction));
|
||||
|
||||
// Set remote content first, to ensure the stream is created with the correct
|
||||
// codec.
|
||||
@ -409,21 +403,18 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyVideoSenderParameters(
|
||||
}
|
||||
}
|
||||
|
||||
auto local_direction =
|
||||
cricket::RtpTransceiverDirectionFromMediaContentDirection(
|
||||
local_audio_description_.direction());
|
||||
bool local_send = RtpTransceiverDirectionHasSend(local_direction);
|
||||
bool local_recv = RtpTransceiverDirectionHasRecv(local_direction);
|
||||
bool local_send = false;
|
||||
int bandwidth = cricket::kAutoBandwidth;
|
||||
if (parameters.encodings.size() == 1u) {
|
||||
if (parameters.encodings[0].max_bitrate_bps) {
|
||||
bandwidth = *parameters.encodings[0].max_bitrate_bps;
|
||||
}
|
||||
local_send = parameters.encodings[0].active;
|
||||
} else {
|
||||
local_send = false;
|
||||
}
|
||||
local_direction = RtpTransceiverDirectionFromSendRecv(local_send, local_recv);
|
||||
const bool local_recv =
|
||||
RtpTransceiverDirectionHasRecv(local_audio_description_.direction());
|
||||
const auto local_direction =
|
||||
RtpTransceiverDirectionFromSendRecv(local_send, local_recv);
|
||||
if (primary_ssrc && !stream_params_result.value().empty()) {
|
||||
*primary_ssrc = stream_params_result.value()[0].first_ssrc();
|
||||
}
|
||||
@ -444,12 +435,9 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyVideoSenderParameters(
|
||||
remote_video_description_.set_bandwidth(bandwidth);
|
||||
local_video_description_.mutable_streams() = stream_params_result.MoveValue();
|
||||
// Direction set based on encoding "active" flag.
|
||||
local_video_description_.set_direction(
|
||||
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||
local_direction));
|
||||
local_video_description_.set_direction(local_direction);
|
||||
remote_video_description_.set_direction(
|
||||
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||
RtpTransceiverDirectionReversed(local_direction)));
|
||||
RtpTransceiverDirectionReversed(local_direction));
|
||||
|
||||
// Set remote content first, to ensure the stream is created with the correct
|
||||
// codec.
|
||||
@ -500,12 +488,11 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyAudioReceiverParameters(
|
||||
}
|
||||
}
|
||||
|
||||
bool local_send = RtpTransceiverDirectionHasSend(
|
||||
cricket::RtpTransceiverDirectionFromMediaContentDirection(
|
||||
local_audio_description_.direction()));
|
||||
bool local_recv =
|
||||
const bool local_send =
|
||||
RtpTransceiverDirectionHasSend(local_audio_description_.direction());
|
||||
const bool local_recv =
|
||||
!parameters.encodings.empty() && parameters.encodings[0].active;
|
||||
auto local_direction =
|
||||
const auto local_direction =
|
||||
RtpTransceiverDirectionFromSendRecv(local_send, local_recv);
|
||||
|
||||
// Validation is done, so we can attempt applying the descriptions. Received
|
||||
@ -524,12 +511,9 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyAudioReceiverParameters(
|
||||
remote_audio_description_.mutable_streams() =
|
||||
stream_params_result.MoveValue();
|
||||
// Direction set based on encoding "active" flag.
|
||||
local_audio_description_.set_direction(
|
||||
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||
local_direction));
|
||||
local_audio_description_.set_direction(local_direction);
|
||||
remote_audio_description_.set_direction(
|
||||
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||
RtpTransceiverDirectionReversed(local_direction)));
|
||||
RtpTransceiverDirectionReversed(local_direction));
|
||||
|
||||
if (!voice_channel_->SetLocalContent(&local_audio_description_,
|
||||
cricket::CA_OFFER, nullptr)) {
|
||||
@ -579,12 +563,11 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyVideoReceiverParameters(
|
||||
}
|
||||
}
|
||||
|
||||
bool local_send = RtpTransceiverDirectionHasSend(
|
||||
cricket::RtpTransceiverDirectionFromMediaContentDirection(
|
||||
local_video_description_.direction()));
|
||||
bool local_recv =
|
||||
const bool local_send =
|
||||
RtpTransceiverDirectionHasSend(local_video_description_.direction());
|
||||
const bool local_recv =
|
||||
!parameters.encodings.empty() && parameters.encodings[0].active;
|
||||
auto local_direction =
|
||||
const auto local_direction =
|
||||
RtpTransceiverDirectionFromSendRecv(local_send, local_recv);
|
||||
|
||||
// Validation is done, so we can attempt applying the descriptions. Received
|
||||
@ -604,12 +587,9 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyVideoReceiverParameters(
|
||||
remote_video_description_.mutable_streams() =
|
||||
stream_params_result.MoveValue();
|
||||
// Direction set based on encoding "active" flag.
|
||||
local_video_description_.set_direction(
|
||||
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||
local_direction));
|
||||
local_video_description_.set_direction(local_direction);
|
||||
remote_video_description_.set_direction(
|
||||
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||
RtpTransceiverDirectionReversed(local_direction)));
|
||||
RtpTransceiverDirectionReversed(local_direction));
|
||||
|
||||
if (!video_channel_->SetLocalContent(&local_video_description_,
|
||||
cricket::CA_OFFER, nullptr)) {
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#include "media/engine/webrtcvoiceengine.h" // nogncheck
|
||||
#include "p2p/base/packettransportinternal.h"
|
||||
#include "pc/channelmanager.h"
|
||||
#include "pc/rtpmediautils.h"
|
||||
#include "pc/rtptransport.h"
|
||||
#include "pc/srtptransport.h"
|
||||
|
||||
@ -103,14 +104,6 @@ static bool ValidPacket(bool rtcp, const rtc::CopyOnWriteBuffer* packet) {
|
||||
return packet && IsValidRtpRtcpPacketSize(rtcp, packet->size());
|
||||
}
|
||||
|
||||
static bool IsReceiveContentDirection(MediaContentDirection direction) {
|
||||
return direction == MD_SENDRECV || direction == MD_RECVONLY;
|
||||
}
|
||||
|
||||
static bool IsSendContentDirection(MediaContentDirection direction) {
|
||||
return direction == MD_SENDRECV || direction == MD_SENDONLY;
|
||||
}
|
||||
|
||||
template <class Codec>
|
||||
void RtpParametersFromMediaDescription(
|
||||
const MediaContentDescriptionImpl<Codec>* desc,
|
||||
@ -510,7 +503,8 @@ bool BaseChannel::NeedsRtcpTransport() {
|
||||
|
||||
bool BaseChannel::IsReadyToReceiveMedia_w() const {
|
||||
// Receive data if we are enabled and have local content,
|
||||
return enabled() && IsReceiveContentDirection(local_content_direction_);
|
||||
return enabled() &&
|
||||
webrtc::RtpTransceiverDirectionHasRecv(local_content_direction_);
|
||||
}
|
||||
|
||||
bool BaseChannel::IsReadyToSendMedia_w() const {
|
||||
@ -522,8 +516,9 @@ bool BaseChannel::IsReadyToSendMedia_w() const {
|
||||
bool BaseChannel::IsReadyToSendMedia_n() const {
|
||||
// Send outgoing data if we are enabled, have local and remote content,
|
||||
// and we have had some form of connectivity.
|
||||
return enabled() && IsReceiveContentDirection(remote_content_direction_) &&
|
||||
IsSendContentDirection(local_content_direction_) &&
|
||||
return enabled() &&
|
||||
webrtc::RtpTransceiverDirectionHasRecv(remote_content_direction_) &&
|
||||
webrtc::RtpTransceiverDirectionHasSend(local_content_direction_) &&
|
||||
was_ever_writable() && (srtp_active() || !ShouldSetupDtlsSrtp_n());
|
||||
}
|
||||
|
||||
|
||||
10
pc/channel.h
10
pc/channel.h
@ -205,10 +205,10 @@ class BaseChannel
|
||||
rtc::PacketTransportInternal* new_packet_transport);
|
||||
|
||||
bool was_ever_writable() const { return was_ever_writable_; }
|
||||
void set_local_content_direction(MediaContentDirection direction) {
|
||||
void set_local_content_direction(webrtc::RtpTransceiverDirection direction) {
|
||||
local_content_direction_ = direction;
|
||||
}
|
||||
void set_remote_content_direction(MediaContentDirection direction) {
|
||||
void set_remote_content_direction(webrtc::RtpTransceiverDirection direction) {
|
||||
remote_content_direction_ = direction;
|
||||
}
|
||||
// These methods verify that:
|
||||
@ -413,8 +413,10 @@ class BaseChannel
|
||||
bool enabled_ = false;
|
||||
std::vector<StreamParams> local_streams_;
|
||||
std::vector<StreamParams> remote_streams_;
|
||||
MediaContentDirection local_content_direction_ = MD_INACTIVE;
|
||||
MediaContentDirection remote_content_direction_ = MD_INACTIVE;
|
||||
webrtc::RtpTransceiverDirection local_content_direction_ =
|
||||
webrtc::RtpTransceiverDirection::kInactive;
|
||||
webrtc::RtpTransceiverDirection remote_content_direction_ =
|
||||
webrtc::RtpTransceiverDirection::kInactive;
|
||||
|
||||
// The cached encrypted header extension IDs.
|
||||
rtc::Optional<std::vector<int>> catched_send_extension_ids_;
|
||||
|
||||
@ -33,6 +33,7 @@ using cricket::CA_ANSWER;
|
||||
using cricket::DtlsTransportInternal;
|
||||
using cricket::FakeVoiceMediaChannel;
|
||||
using cricket::StreamParams;
|
||||
using webrtc::RtpTransceiverDirection;
|
||||
|
||||
namespace {
|
||||
const cricket::AudioCodec kPcmuCodec(0, "PCMU", 64000, 8000, 1);
|
||||
@ -974,7 +975,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
|
||||
typename T::Content content2;
|
||||
CreateContent(0, kPcmuCodec, kH264Codec, &content2);
|
||||
// Set |content2| to be InActive.
|
||||
content2.set_direction(cricket::MD_INACTIVE);
|
||||
content2.set_direction(RtpTransceiverDirection::kInactive);
|
||||
|
||||
EXPECT_TRUE(channel1_->Enable(true));
|
||||
EXPECT_TRUE(channel2_->Enable(true));
|
||||
@ -1003,7 +1004,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
|
||||
EXPECT_FALSE(media_channel2_->sending()); // local InActive
|
||||
|
||||
// Update |content2| to be RecvOnly.
|
||||
content2.set_direction(cricket::MD_RECVONLY);
|
||||
content2.set_direction(RtpTransceiverDirection::kRecvOnly);
|
||||
EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_PRANSWER, NULL));
|
||||
EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_PRANSWER, NULL));
|
||||
|
||||
@ -1017,7 +1018,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
|
||||
EXPECT_FALSE(media_channel2_->sending()); // local RecvOnly
|
||||
|
||||
// Update |content2| to be SendRecv.
|
||||
content2.set_direction(cricket::MD_SENDRECV);
|
||||
content2.set_direction(RtpTransceiverDirection::kSendRecv);
|
||||
EXPECT_TRUE(channel2_->SetLocalContent(&content2, CA_ANSWER, NULL));
|
||||
EXPECT_TRUE(channel1_->SetRemoteContent(&content2, CA_ANSWER, NULL));
|
||||
|
||||
|
||||
@ -101,38 +101,6 @@ static bool IsSctp(const std::string& protocol) {
|
||||
return IsPlainSctp(protocol) || IsDtlsSctp(protocol);
|
||||
}
|
||||
|
||||
RtpTransceiverDirection RtpTransceiverDirectionFromMediaContentDirection(
|
||||
MediaContentDirection direction) {
|
||||
switch (direction) {
|
||||
case MD_SENDRECV:
|
||||
return RtpTransceiverDirection::kSendRecv;
|
||||
case MD_SENDONLY:
|
||||
return RtpTransceiverDirection::kSendOnly;
|
||||
case MD_RECVONLY:
|
||||
return RtpTransceiverDirection::kRecvOnly;
|
||||
case MD_INACTIVE:
|
||||
return RtpTransceiverDirection::kInactive;
|
||||
}
|
||||
RTC_NOTREACHED();
|
||||
return RtpTransceiverDirection::kInactive;
|
||||
}
|
||||
|
||||
MediaContentDirection MediaContentDirectionFromRtpTransceiverDirection(
|
||||
RtpTransceiverDirection direction) {
|
||||
switch (direction) {
|
||||
case RtpTransceiverDirection::kSendRecv:
|
||||
return MD_SENDRECV;
|
||||
case RtpTransceiverDirection::kSendOnly:
|
||||
return MD_SENDONLY;
|
||||
case RtpTransceiverDirection::kRecvOnly:
|
||||
return MD_RECVONLY;
|
||||
case RtpTransceiverDirection::kInactive:
|
||||
return MD_INACTIVE;
|
||||
}
|
||||
RTC_NOTREACHED();
|
||||
return MD_INACTIVE;
|
||||
}
|
||||
|
||||
static RtpTransceiverDirection NegotiateRtpTransceiverDirection(
|
||||
RtpTransceiverDirection offer,
|
||||
RtpTransceiverDirection wants) {
|
||||
@ -1176,13 +1144,8 @@ static bool CreateMediaContentAnswer(
|
||||
return false; // Something went seriously wrong.
|
||||
}
|
||||
|
||||
auto offer_rtd =
|
||||
RtpTransceiverDirectionFromMediaContentDirection(offer->direction());
|
||||
|
||||
answer->set_direction(
|
||||
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||
NegotiateRtpTransceiverDirection(
|
||||
offer_rtd, media_description_options.direction)));
|
||||
answer->set_direction(NegotiateRtpTransceiverDirection(
|
||||
offer->direction(), media_description_options.direction));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1260,29 +1223,6 @@ static bool IsDtlsActive(const ContentInfo* content,
|
||||
.description.secure();
|
||||
}
|
||||
|
||||
std::string MediaContentDirectionToString(MediaContentDirection direction) {
|
||||
std::string dir_str;
|
||||
switch (direction) {
|
||||
case MD_INACTIVE:
|
||||
dir_str = "inactive";
|
||||
break;
|
||||
case MD_SENDONLY:
|
||||
dir_str = "sendonly";
|
||||
break;
|
||||
case MD_RECVONLY:
|
||||
dir_str = "recvonly";
|
||||
break;
|
||||
case MD_SENDRECV:
|
||||
dir_str = "sendrecv";
|
||||
break;
|
||||
default:
|
||||
RTC_NOTREACHED();
|
||||
break;
|
||||
}
|
||||
|
||||
return dir_str;
|
||||
}
|
||||
|
||||
void MediaDescriptionOptions::AddAudioSender(
|
||||
const std::string& track_id,
|
||||
const std::vector<std::string>& stream_ids) {
|
||||
@ -1932,9 +1872,7 @@ bool MediaSessionDescriptionFactory::AddAudioContentForOffer(
|
||||
bool secure_transport = (transport_desc_factory_->secure() != SEC_DISABLED);
|
||||
SetMediaProtocol(secure_transport, audio.get());
|
||||
|
||||
audio->set_direction(
|
||||
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||
media_description_options.direction));
|
||||
audio->set_direction(media_description_options.direction);
|
||||
|
||||
desc->AddContent(media_description_options.mid, NS_JINGLE_RTP,
|
||||
media_description_options.stopped, audio.release());
|
||||
@ -2004,9 +1942,7 @@ bool MediaSessionDescriptionFactory::AddVideoContentForOffer(
|
||||
bool secure_transport = (transport_desc_factory_->secure() != SEC_DISABLED);
|
||||
SetMediaProtocol(secure_transport, video.get());
|
||||
|
||||
video->set_direction(
|
||||
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||
media_description_options.direction));
|
||||
video->set_direction(media_description_options.direction);
|
||||
|
||||
desc->AddContent(media_description_options.mid, NS_JINGLE_RTP,
|
||||
media_description_options.stopped, video.release());
|
||||
@ -2125,8 +2061,7 @@ bool MediaSessionDescriptionFactory::AddAudioContentForAnswer(
|
||||
// and the selected direction in the answer.
|
||||
// Note these will be filtered one final time in CreateMediaContentAnswer.
|
||||
auto wants_rtd = media_description_options.direction;
|
||||
auto offer_rtd = RtpTransceiverDirectionFromMediaContentDirection(
|
||||
offer_audio_description->direction());
|
||||
auto offer_rtd = offer_audio_description->direction();
|
||||
auto answer_rtd = NegotiateRtpTransceiverDirection(offer_rtd, wants_rtd);
|
||||
AudioCodecs supported_audio_codecs =
|
||||
GetAudioCodecsForAnswer(offer_rtd, answer_rtd);
|
||||
|
||||
@ -39,15 +39,6 @@ typedef std::vector<DataCodec> DataCodecs;
|
||||
typedef std::vector<CryptoParams> CryptoParamsVec;
|
||||
typedef std::vector<webrtc::RtpExtension> RtpHeaderExtensions;
|
||||
|
||||
enum MediaContentDirection {
|
||||
MD_INACTIVE,
|
||||
MD_SENDONLY,
|
||||
MD_RECVONLY,
|
||||
MD_SENDRECV
|
||||
};
|
||||
|
||||
std::string MediaContentDirectionToString(MediaContentDirection direction);
|
||||
|
||||
enum CryptoType {
|
||||
CT_NONE,
|
||||
CT_SDES,
|
||||
@ -74,12 +65,6 @@ const int kAutoBandwidth = -1;
|
||||
// Default RTCP CNAME for unit tests.
|
||||
const char kDefaultRtcpCname[] = "DefaultRtcpCname";
|
||||
|
||||
webrtc::RtpTransceiverDirection
|
||||
RtpTransceiverDirectionFromMediaContentDirection(
|
||||
MediaContentDirection direction);
|
||||
MediaContentDirection MediaContentDirectionFromRtpTransceiverDirection(
|
||||
webrtc::RtpTransceiverDirection direction);
|
||||
|
||||
// Options for an RtpSender contained with an media description/"m=" section.
|
||||
struct SenderOptions {
|
||||
std::string track_id;
|
||||
@ -171,14 +156,9 @@ class MediaContentDescription : public ContentDescription {
|
||||
direction_ = direction;
|
||||
}
|
||||
|
||||
// MediaContentDirection is deprecated; use RtpTransceiverDirection instead.
|
||||
// TODO(steveanton): Change this method to return RtpTransceiverDirection once
|
||||
// external users have switched to |transceiver_direction()|.
|
||||
MediaContentDirection direction() const {
|
||||
return MediaContentDirectionFromRtpTransceiverDirection(direction_);
|
||||
}
|
||||
void set_direction(MediaContentDirection direction) {
|
||||
direction_ = RtpTransceiverDirectionFromMediaContentDirection(direction);
|
||||
webrtc::RtpTransceiverDirection direction() const { return direction_; }
|
||||
void set_direction(webrtc::RtpTransceiverDirection direction) {
|
||||
direction_ = direction;
|
||||
}
|
||||
|
||||
bool rtcp_mux() const { return rtcp_mux_; }
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -148,16 +148,12 @@ bool CanAddLocalMediaStream(webrtc::StreamCollectionInterface* current_streams,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MediaContentDirectionHasSend(cricket::MediaContentDirection dir) {
|
||||
return dir == cricket::MD_SENDONLY || dir == cricket::MD_SENDRECV;
|
||||
}
|
||||
|
||||
// If the direction is "recvonly" or "inactive", treat the description
|
||||
// as containing no streams.
|
||||
// See: https://code.google.com/p/webrtc/issues/detail?id=5054
|
||||
std::vector<cricket::StreamParams> GetActiveStreams(
|
||||
const cricket::MediaContentDescription* desc) {
|
||||
return MediaContentDirectionHasSend(desc->direction())
|
||||
return RtpTransceiverDirectionHasSend(desc->direction())
|
||||
? desc->streams()
|
||||
: std::vector<cricket::StreamParams>();
|
||||
}
|
||||
@ -1772,7 +1768,7 @@ void PeerConnection::SetRemoteDescription(
|
||||
} else {
|
||||
bool default_audio_track_needed =
|
||||
!remote_peer_supports_msid_ &&
|
||||
MediaContentDirectionHasSend(audio_desc->direction());
|
||||
RtpTransceiverDirectionHasSend(audio_desc->direction());
|
||||
UpdateRemoteSendersList(GetActiveStreams(audio_desc),
|
||||
default_audio_track_needed, audio_desc->type(),
|
||||
new_streams);
|
||||
@ -1787,7 +1783,7 @@ void PeerConnection::SetRemoteDescription(
|
||||
} else {
|
||||
bool default_video_track_needed =
|
||||
!remote_peer_supports_msid_ &&
|
||||
MediaContentDirectionHasSend(video_desc->direction());
|
||||
RtpTransceiverDirectionHasSend(video_desc->direction());
|
||||
UpdateRemoteSendersList(GetActiveStreams(video_desc),
|
||||
default_video_track_needed, video_desc->type(),
|
||||
new_streams);
|
||||
|
||||
@ -113,7 +113,7 @@ class PeerConnectionMediaTest : public ::testing::Test {
|
||||
return static_cast<const cricket::MediaContentDescription*>(content_desc);
|
||||
}
|
||||
|
||||
cricket::MediaContentDirection GetMediaContentDirection(
|
||||
RtpTransceiverDirection GetMediaContentDirection(
|
||||
const SessionDescriptionInterface* sdesc,
|
||||
const std::string& mid) {
|
||||
auto* media_content = GetMediaContent(sdesc, mid);
|
||||
@ -339,7 +339,7 @@ TEST_F(PeerConnectionMediaTest,
|
||||
class PeerConnectionMediaOfferDirectionTest
|
||||
: public PeerConnectionMediaTest,
|
||||
public ::testing::WithParamInterface<
|
||||
std::tuple<bool, int, cricket::MediaContentDirection>> {
|
||||
std::tuple<bool, int, RtpTransceiverDirection>> {
|
||||
protected:
|
||||
PeerConnectionMediaOfferDirectionTest() {
|
||||
send_media_ = std::get<0>(GetParam());
|
||||
@ -349,7 +349,7 @@ class PeerConnectionMediaOfferDirectionTest
|
||||
|
||||
bool send_media_;
|
||||
int offer_to_receive_;
|
||||
cricket::MediaContentDirection expected_direction_;
|
||||
RtpTransceiverDirection expected_direction_;
|
||||
};
|
||||
|
||||
// Tests that the correct direction is set on the media description according
|
||||
@ -365,7 +365,7 @@ TEST_P(PeerConnectionMediaOfferDirectionTest, VerifyDirection) {
|
||||
auto offer = caller->CreateOffer(options);
|
||||
|
||||
auto* media_content = GetMediaContent(offer.get(), cricket::CN_AUDIO);
|
||||
if (expected_direction_ == cricket::MD_INACTIVE) {
|
||||
if (expected_direction_ == RtpTransceiverDirection::kInactive) {
|
||||
EXPECT_FALSE(media_content);
|
||||
} else {
|
||||
EXPECT_EQ(expected_direction_, media_content->direction());
|
||||
@ -374,19 +374,20 @@ TEST_P(PeerConnectionMediaOfferDirectionTest, VerifyDirection) {
|
||||
|
||||
// Note that in these tests, MD_INACTIVE indicates that no media section is
|
||||
// included in the offer, not that the media direction is inactive.
|
||||
INSTANTIATE_TEST_CASE_P(PeerConnectionMediaTest,
|
||||
PeerConnectionMediaOfferDirectionTest,
|
||||
Values(std::make_tuple(false, -1, cricket::MD_INACTIVE),
|
||||
std::make_tuple(false, 0, cricket::MD_INACTIVE),
|
||||
std::make_tuple(false, 1, cricket::MD_RECVONLY),
|
||||
std::make_tuple(true, -1, cricket::MD_SENDRECV),
|
||||
std::make_tuple(true, 0, cricket::MD_SENDONLY),
|
||||
std::make_tuple(true, 1, cricket::MD_SENDRECV)));
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
PeerConnectionMediaTest,
|
||||
PeerConnectionMediaOfferDirectionTest,
|
||||
Values(std::make_tuple(false, -1, RtpTransceiverDirection::kInactive),
|
||||
std::make_tuple(false, 0, RtpTransceiverDirection::kInactive),
|
||||
std::make_tuple(false, 1, RtpTransceiverDirection::kRecvOnly),
|
||||
std::make_tuple(true, -1, RtpTransceiverDirection::kSendRecv),
|
||||
std::make_tuple(true, 0, RtpTransceiverDirection::kSendOnly),
|
||||
std::make_tuple(true, 1, RtpTransceiverDirection::kSendRecv)));
|
||||
|
||||
class PeerConnectionMediaAnswerDirectionTest
|
||||
: public PeerConnectionMediaTest,
|
||||
public ::testing::WithParamInterface<
|
||||
std::tuple<cricket::MediaContentDirection, bool, int>> {
|
||||
std::tuple<RtpTransceiverDirection, bool, int>> {
|
||||
protected:
|
||||
PeerConnectionMediaAnswerDirectionTest() {
|
||||
offer_direction_ = std::get<0>(GetParam());
|
||||
@ -394,7 +395,7 @@ class PeerConnectionMediaAnswerDirectionTest
|
||||
offer_to_receive_ = std::get<2>(GetParam());
|
||||
}
|
||||
|
||||
cricket::MediaContentDirection offer_direction_;
|
||||
RtpTransceiverDirection offer_direction_;
|
||||
bool send_media_;
|
||||
int offer_to_receive_;
|
||||
};
|
||||
@ -429,19 +430,15 @@ TEST_P(PeerConnectionMediaAnswerDirectionTest, VerifyDirection) {
|
||||
// 1. Send if the answerer has a local track to send.
|
||||
// 2. Receive if the answerer has explicitly set the offer_to_receive to 1 or
|
||||
// if it has been left as default.
|
||||
auto offer_direction =
|
||||
cricket::RtpTransceiverDirectionFromMediaContentDirection(
|
||||
offer_direction_);
|
||||
bool offer_send = RtpTransceiverDirectionHasSend(offer_direction);
|
||||
bool offer_recv = RtpTransceiverDirectionHasRecv(offer_direction);
|
||||
bool offer_send = RtpTransceiverDirectionHasSend(offer_direction_);
|
||||
bool offer_recv = RtpTransceiverDirectionHasRecv(offer_direction_);
|
||||
|
||||
// The negotiated components determine the direction set in the answer.
|
||||
bool negotiate_send = (send_media_ && offer_recv);
|
||||
bool negotiate_recv = ((offer_to_receive_ != 0) && offer_send);
|
||||
|
||||
auto expected_direction =
|
||||
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||
RtpTransceiverDirectionFromSendRecv(negotiate_send, negotiate_recv));
|
||||
RtpTransceiverDirectionFromSendRecv(negotiate_send, negotiate_recv);
|
||||
EXPECT_EQ(expected_direction,
|
||||
GetMediaContentDirection(answer.get(), cricket::CN_AUDIO));
|
||||
}
|
||||
@ -478,10 +475,10 @@ TEST_P(PeerConnectionMediaAnswerDirectionTest, VerifyRejected) {
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(PeerConnectionMediaTest,
|
||||
PeerConnectionMediaAnswerDirectionTest,
|
||||
Combine(Values(cricket::MD_INACTIVE,
|
||||
cricket::MD_SENDONLY,
|
||||
cricket::MD_RECVONLY,
|
||||
cricket::MD_SENDRECV),
|
||||
Combine(Values(RtpTransceiverDirection::kInactive,
|
||||
RtpTransceiverDirection::kSendOnly,
|
||||
RtpTransceiverDirection::kRecvOnly,
|
||||
RtpTransceiverDirection::kSendRecv),
|
||||
Bool(),
|
||||
Values(-1, 0, 1)));
|
||||
|
||||
@ -494,9 +491,9 @@ TEST_F(PeerConnectionMediaTest, OfferHasDifferentDirectionForAudioVideo) {
|
||||
options.offer_to_receive_video = 0;
|
||||
auto offer = caller->CreateOffer(options);
|
||||
|
||||
EXPECT_EQ(cricket::MD_RECVONLY,
|
||||
EXPECT_EQ(RtpTransceiverDirection::kRecvOnly,
|
||||
GetMediaContentDirection(offer.get(), cricket::CN_AUDIO));
|
||||
EXPECT_EQ(cricket::MD_SENDONLY,
|
||||
EXPECT_EQ(RtpTransceiverDirection::kSendOnly,
|
||||
GetMediaContentDirection(offer.get(), cricket::CN_VIDEO));
|
||||
}
|
||||
|
||||
@ -512,9 +509,9 @@ TEST_F(PeerConnectionMediaTest, AnswerHasDifferentDirectionsForAudioVideo) {
|
||||
options.offer_to_receive_video = 0;
|
||||
auto answer = callee->CreateAnswer(options);
|
||||
|
||||
EXPECT_EQ(cricket::MD_RECVONLY,
|
||||
EXPECT_EQ(RtpTransceiverDirection::kRecvOnly,
|
||||
GetMediaContentDirection(answer.get(), cricket::CN_AUDIO));
|
||||
EXPECT_EQ(cricket::MD_SENDONLY,
|
||||
EXPECT_EQ(RtpTransceiverDirection::kSendOnly,
|
||||
GetMediaContentDirection(answer.get(), cricket::CN_VIDEO));
|
||||
}
|
||||
|
||||
|
||||
@ -350,6 +350,7 @@ using webrtc::RTCError;
|
||||
using webrtc::RTCErrorType;
|
||||
using webrtc::RtpReceiverInterface;
|
||||
using webrtc::RtpSenderInterface;
|
||||
using webrtc::RtpTransceiverDirection;
|
||||
using webrtc::SdpParseError;
|
||||
using webrtc::SessionDescriptionInterface;
|
||||
using webrtc::StreamCollection;
|
||||
@ -2203,14 +2204,14 @@ TEST_F(PeerConnectionInterfaceTest, CreateSubsequentRecvOnlyOffer) {
|
||||
const cricket::VideoContentDescription* video_desc =
|
||||
static_cast<const cricket::VideoContentDescription*>(
|
||||
video_content->description);
|
||||
ASSERT_EQ(cricket::MD_RECVONLY, video_desc->direction());
|
||||
ASSERT_EQ(RtpTransceiverDirection::kRecvOnly, video_desc->direction());
|
||||
|
||||
const cricket::ContentInfo* audio_content =
|
||||
cricket::GetFirstAudioContent(offer->description());
|
||||
const cricket::AudioContentDescription* audio_desc =
|
||||
static_cast<const cricket::AudioContentDescription*>(
|
||||
audio_content->description);
|
||||
ASSERT_EQ(cricket::MD_RECVONLY, audio_desc->direction());
|
||||
ASSERT_EQ(RtpTransceiverDirection::kRecvOnly, audio_desc->direction());
|
||||
}
|
||||
|
||||
// Test that if we're receiving (but not sending) a track, and the
|
||||
@ -2240,14 +2241,14 @@ TEST_F(PeerConnectionInterfaceTest, CreateSubsequentInactiveOffer) {
|
||||
const cricket::VideoContentDescription* video_desc =
|
||||
static_cast<const cricket::VideoContentDescription*>(
|
||||
video_content->description);
|
||||
ASSERT_EQ(cricket::MD_INACTIVE, video_desc->direction());
|
||||
ASSERT_EQ(RtpTransceiverDirection::kInactive, video_desc->direction());
|
||||
|
||||
const cricket::ContentInfo* audio_content =
|
||||
cricket::GetFirstAudioContent(offer->description());
|
||||
const cricket::AudioContentDescription* audio_desc =
|
||||
static_cast<const cricket::AudioContentDescription*>(
|
||||
audio_content->description);
|
||||
ASSERT_EQ(cricket::MD_INACTIVE, audio_desc->direction());
|
||||
ASSERT_EQ(RtpTransceiverDirection::kInactive, audio_desc->direction());
|
||||
}
|
||||
|
||||
// Test that we can use SetConfiguration to change the ICE servers of the
|
||||
|
||||
@ -50,4 +50,19 @@ RtpTransceiverDirection RtpTransceiverDirectionReversed(
|
||||
return direction;
|
||||
}
|
||||
|
||||
const char* RtpTransceiverDirectionToString(RtpTransceiverDirection direction) {
|
||||
switch (direction) {
|
||||
case RtpTransceiverDirection::kSendRecv:
|
||||
return "kSendRecv";
|
||||
case RtpTransceiverDirection::kSendOnly:
|
||||
return "kSendOnly";
|
||||
case RtpTransceiverDirection::kRecvOnly:
|
||||
return "kRecvOnly";
|
||||
case RtpTransceiverDirection::kInactive:
|
||||
return "kInactive";
|
||||
}
|
||||
RTC_NOTREACHED();
|
||||
return "";
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -31,6 +31,9 @@ bool RtpTransceiverDirectionHasRecv(RtpTransceiverDirection direction);
|
||||
RtpTransceiverDirection RtpTransceiverDirectionReversed(
|
||||
RtpTransceiverDirection direction);
|
||||
|
||||
// Returns an unspecified string representation of the given direction.
|
||||
const char* RtpTransceiverDirectionToString(RtpTransceiverDirection direction);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // PC_RTPMEDIAUTILS_H_
|
||||
|
||||
@ -1466,16 +1466,16 @@ void BuildRtpContentAttributes(const MediaContentDescription* media_desc,
|
||||
// RFC 3264
|
||||
// a=sendrecv || a=sendonly || a=sendrecv || a=inactive
|
||||
switch (media_desc->direction()) {
|
||||
case cricket::MD_INACTIVE:
|
||||
case RtpTransceiverDirection::kInactive:
|
||||
InitAttrLine(kAttributeInactive, &os);
|
||||
break;
|
||||
case cricket::MD_SENDONLY:
|
||||
case RtpTransceiverDirection::kSendOnly:
|
||||
InitAttrLine(kAttributeSendOnly, &os);
|
||||
break;
|
||||
case cricket::MD_RECVONLY:
|
||||
case RtpTransceiverDirection::kRecvOnly:
|
||||
InitAttrLine(kAttributeRecvOnly, &os);
|
||||
break;
|
||||
case cricket::MD_SENDRECV:
|
||||
case RtpTransceiverDirection::kSendRecv:
|
||||
default:
|
||||
InitAttrLine(kAttributeSendRecv, &os);
|
||||
break;
|
||||
@ -2880,13 +2880,13 @@ bool ParseContent(const std::string& message,
|
||||
return false;
|
||||
}
|
||||
} else if (HasAttribute(line, kAttributeSendOnly)) {
|
||||
media_desc->set_direction(cricket::MD_SENDONLY);
|
||||
media_desc->set_direction(RtpTransceiverDirection::kSendOnly);
|
||||
} else if (HasAttribute(line, kAttributeRecvOnly)) {
|
||||
media_desc->set_direction(cricket::MD_RECVONLY);
|
||||
media_desc->set_direction(RtpTransceiverDirection::kRecvOnly);
|
||||
} else if (HasAttribute(line, kAttributeInactive)) {
|
||||
media_desc->set_direction(cricket::MD_INACTIVE);
|
||||
media_desc->set_direction(RtpTransceiverDirection::kInactive);
|
||||
} else if (HasAttribute(line, kAttributeSendRecv)) {
|
||||
media_desc->set_direction(cricket::MD_SENDRECV);
|
||||
media_desc->set_direction(RtpTransceiverDirection::kSendRecv);
|
||||
} else if (HasAttribute(line, kAttributeExtmap)) {
|
||||
RtpExtension extmap;
|
||||
if (!ParseExtmap(line, &extmap, error)) {
|
||||
|
||||
@ -57,6 +57,7 @@ using webrtc::IceCandidateInterface;
|
||||
using webrtc::JsepIceCandidate;
|
||||
using webrtc::JsepSessionDescription;
|
||||
using webrtc::RtpExtension;
|
||||
using webrtc::RtpTransceiverDirection;
|
||||
using webrtc::SdpParseError;
|
||||
using webrtc::SessionDescriptionInterface;
|
||||
|
||||
@ -825,20 +826,20 @@ static void ExpectParseFailureWithNewLines(const std::string& injectpoint,
|
||||
ExpectParseFailure(bad_sdp, bad_part);
|
||||
}
|
||||
|
||||
static void ReplaceDirection(cricket::MediaContentDirection direction,
|
||||
static void ReplaceDirection(RtpTransceiverDirection direction,
|
||||
std::string* message) {
|
||||
std::string new_direction;
|
||||
switch (direction) {
|
||||
case cricket::MD_INACTIVE:
|
||||
case RtpTransceiverDirection::kInactive:
|
||||
new_direction = "a=inactive";
|
||||
break;
|
||||
case cricket::MD_SENDONLY:
|
||||
case RtpTransceiverDirection::kSendOnly:
|
||||
new_direction = "a=sendonly";
|
||||
break;
|
||||
case cricket::MD_RECVONLY:
|
||||
case RtpTransceiverDirection::kRecvOnly:
|
||||
new_direction = "a=recvonly";
|
||||
break;
|
||||
case cricket::MD_SENDRECV:
|
||||
case RtpTransceiverDirection::kSendRecv:
|
||||
default:
|
||||
new_direction = "a=sendrecv";
|
||||
break;
|
||||
@ -1457,7 +1458,7 @@ class WebRtcSdpTest : public testing::Test {
|
||||
video_desc_->set_cryptos(std::vector<CryptoParams>());
|
||||
}
|
||||
|
||||
bool TestSerializeDirection(cricket::MediaContentDirection direction) {
|
||||
bool TestSerializeDirection(RtpTransceiverDirection direction) {
|
||||
audio_desc_->set_direction(direction);
|
||||
video_desc_->set_direction(direction);
|
||||
std::string new_sdp = kSdpFullString;
|
||||
@ -1534,7 +1535,7 @@ class WebRtcSdpTest : public testing::Test {
|
||||
kDataContentName, TransportDescription(kUfragData, kPwdData))));
|
||||
}
|
||||
|
||||
bool TestDeserializeDirection(cricket::MediaContentDirection direction) {
|
||||
bool TestDeserializeDirection(RtpTransceiverDirection direction) {
|
||||
std::string new_sdp = kSdpFullString;
|
||||
ReplaceDirection(direction, &new_sdp);
|
||||
JsepSessionDescription new_jdesc(kDummyString);
|
||||
@ -1932,15 +1933,15 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithIceOptions) {
|
||||
}
|
||||
|
||||
TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithRecvOnlyContent) {
|
||||
EXPECT_TRUE(TestSerializeDirection(cricket::MD_RECVONLY));
|
||||
EXPECT_TRUE(TestSerializeDirection(RtpTransceiverDirection::kRecvOnly));
|
||||
}
|
||||
|
||||
TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithSendOnlyContent) {
|
||||
EXPECT_TRUE(TestSerializeDirection(cricket::MD_SENDONLY));
|
||||
EXPECT_TRUE(TestSerializeDirection(RtpTransceiverDirection::kSendOnly));
|
||||
}
|
||||
|
||||
TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithInactiveContent) {
|
||||
EXPECT_TRUE(TestSerializeDirection(cricket::MD_INACTIVE));
|
||||
EXPECT_TRUE(TestSerializeDirection(RtpTransceiverDirection::kInactive));
|
||||
}
|
||||
|
||||
TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithAudioRejected) {
|
||||
@ -2330,15 +2331,15 @@ TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithUfragPwd) {
|
||||
}
|
||||
|
||||
TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithRecvOnlyContent) {
|
||||
EXPECT_TRUE(TestDeserializeDirection(cricket::MD_RECVONLY));
|
||||
EXPECT_TRUE(TestDeserializeDirection(RtpTransceiverDirection::kRecvOnly));
|
||||
}
|
||||
|
||||
TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithSendOnlyContent) {
|
||||
EXPECT_TRUE(TestDeserializeDirection(cricket::MD_SENDONLY));
|
||||
EXPECT_TRUE(TestDeserializeDirection(RtpTransceiverDirection::kSendOnly));
|
||||
}
|
||||
|
||||
TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithInactiveContent) {
|
||||
EXPECT_TRUE(TestDeserializeDirection(cricket::MD_INACTIVE));
|
||||
EXPECT_TRUE(TestDeserializeDirection(RtpTransceiverDirection::kInactive));
|
||||
}
|
||||
|
||||
TEST_F(WebRtcSdpTest, DeserializeSessionDescriptionWithRejectedAudio) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user