Remove cricket::RtpTransceiverDirection
Replaces cricket::RtpTransceiverDirection with webrtc::RtpTransceiverDirection, which is part of the public API. Bug: webrtc:8558 Change-Id: Ibfc9373e25187e98fb969e7ac937a1371c8fa4c7 Reviewed-on: https://webrtc-review.googlesource.com/24129 Commit-Queue: Steve Anton <steveanton@webrtc.org> Reviewed-by: Peter Thatcher <pthatcher@webrtc.org> Reviewed-by: Zhi Huang <zhihuang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20899}
This commit is contained in:
@ -22,6 +22,7 @@
|
|||||||
#include "ortc/ortcrtpsenderadapter.h"
|
#include "ortc/ortcrtpsenderadapter.h"
|
||||||
#include "ortc/rtpparametersconversion.h"
|
#include "ortc/rtpparametersconversion.h"
|
||||||
#include "ortc/rtptransportadapter.h"
|
#include "ortc/rtptransportadapter.h"
|
||||||
|
#include "pc/rtpmediautils.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -314,18 +315,21 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyAudioSenderParameters(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cricket::RtpTransceiverDirection local_direction =
|
auto local_direction =
|
||||||
cricket::RtpTransceiverDirection::FromMediaContentDirection(
|
cricket::RtpTransceiverDirectionFromMediaContentDirection(
|
||||||
local_audio_description_.direction());
|
local_audio_description_.direction());
|
||||||
|
bool local_send = RtpTransceiverDirectionHasSend(local_direction);
|
||||||
|
bool local_recv = RtpTransceiverDirectionHasRecv(local_direction);
|
||||||
int bandwidth = cricket::kAutoBandwidth;
|
int bandwidth = cricket::kAutoBandwidth;
|
||||||
if (parameters.encodings.size() == 1u) {
|
if (parameters.encodings.size() == 1u) {
|
||||||
if (parameters.encodings[0].max_bitrate_bps) {
|
if (parameters.encodings[0].max_bitrate_bps) {
|
||||||
bandwidth = *parameters.encodings[0].max_bitrate_bps;
|
bandwidth = *parameters.encodings[0].max_bitrate_bps;
|
||||||
}
|
}
|
||||||
local_direction.send = parameters.encodings[0].active;
|
local_send = parameters.encodings[0].active;
|
||||||
} else {
|
} else {
|
||||||
local_direction.send = false;
|
local_send = false;
|
||||||
}
|
}
|
||||||
|
local_direction = RtpTransceiverDirectionFromSendRecv(local_send, local_recv);
|
||||||
if (primary_ssrc && !stream_params_result.value().empty()) {
|
if (primary_ssrc && !stream_params_result.value().empty()) {
|
||||||
*primary_ssrc = stream_params_result.value()[0].first_ssrc();
|
*primary_ssrc = stream_params_result.value()[0].first_ssrc();
|
||||||
}
|
}
|
||||||
@ -347,9 +351,11 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyAudioSenderParameters(
|
|||||||
local_audio_description_.mutable_streams() = stream_params_result.MoveValue();
|
local_audio_description_.mutable_streams() = stream_params_result.MoveValue();
|
||||||
// Direction set based on encoding "active" flag.
|
// Direction set based on encoding "active" flag.
|
||||||
local_audio_description_.set_direction(
|
local_audio_description_.set_direction(
|
||||||
local_direction.ToMediaContentDirection());
|
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
|
local_direction));
|
||||||
remote_audio_description_.set_direction(
|
remote_audio_description_.set_direction(
|
||||||
local_direction.Reversed().ToMediaContentDirection());
|
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
|
RtpTransceiverDirectionReversed(local_direction)));
|
||||||
|
|
||||||
// Set remote content first, to ensure the stream is created with the correct
|
// Set remote content first, to ensure the stream is created with the correct
|
||||||
// codec.
|
// codec.
|
||||||
@ -403,18 +409,21 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyVideoSenderParameters(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cricket::RtpTransceiverDirection local_direction =
|
auto local_direction =
|
||||||
cricket::RtpTransceiverDirection::FromMediaContentDirection(
|
cricket::RtpTransceiverDirectionFromMediaContentDirection(
|
||||||
local_video_description_.direction());
|
local_audio_description_.direction());
|
||||||
|
bool local_send = RtpTransceiverDirectionHasSend(local_direction);
|
||||||
|
bool local_recv = RtpTransceiverDirectionHasRecv(local_direction);
|
||||||
int bandwidth = cricket::kAutoBandwidth;
|
int bandwidth = cricket::kAutoBandwidth;
|
||||||
if (parameters.encodings.size() == 1u) {
|
if (parameters.encodings.size() == 1u) {
|
||||||
if (parameters.encodings[0].max_bitrate_bps) {
|
if (parameters.encodings[0].max_bitrate_bps) {
|
||||||
bandwidth = *parameters.encodings[0].max_bitrate_bps;
|
bandwidth = *parameters.encodings[0].max_bitrate_bps;
|
||||||
}
|
}
|
||||||
local_direction.send = parameters.encodings[0].active;
|
local_send = parameters.encodings[0].active;
|
||||||
} else {
|
} else {
|
||||||
local_direction.send = false;
|
local_send = false;
|
||||||
}
|
}
|
||||||
|
local_direction = RtpTransceiverDirectionFromSendRecv(local_send, local_recv);
|
||||||
if (primary_ssrc && !stream_params_result.value().empty()) {
|
if (primary_ssrc && !stream_params_result.value().empty()) {
|
||||||
*primary_ssrc = stream_params_result.value()[0].first_ssrc();
|
*primary_ssrc = stream_params_result.value()[0].first_ssrc();
|
||||||
}
|
}
|
||||||
@ -436,9 +445,11 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyVideoSenderParameters(
|
|||||||
local_video_description_.mutable_streams() = stream_params_result.MoveValue();
|
local_video_description_.mutable_streams() = stream_params_result.MoveValue();
|
||||||
// Direction set based on encoding "active" flag.
|
// Direction set based on encoding "active" flag.
|
||||||
local_video_description_.set_direction(
|
local_video_description_.set_direction(
|
||||||
local_direction.ToMediaContentDirection());
|
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
|
local_direction));
|
||||||
remote_video_description_.set_direction(
|
remote_video_description_.set_direction(
|
||||||
local_direction.Reversed().ToMediaContentDirection());
|
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
|
RtpTransceiverDirectionReversed(local_direction)));
|
||||||
|
|
||||||
// Set remote content first, to ensure the stream is created with the correct
|
// Set remote content first, to ensure the stream is created with the correct
|
||||||
// codec.
|
// codec.
|
||||||
@ -471,9 +482,6 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyAudioReceiverParameters(
|
|||||||
return extensions_result.MoveError();
|
return extensions_result.MoveError();
|
||||||
}
|
}
|
||||||
|
|
||||||
cricket::RtpTransceiverDirection local_direction =
|
|
||||||
cricket::RtpTransceiverDirection::FromMediaContentDirection(
|
|
||||||
local_audio_description_.direction());
|
|
||||||
auto stream_params_result = ToCricketStreamParamsVec(parameters.encodings);
|
auto stream_params_result = ToCricketStreamParamsVec(parameters.encodings);
|
||||||
if (!stream_params_result.ok()) {
|
if (!stream_params_result.ok()) {
|
||||||
return stream_params_result.MoveError();
|
return stream_params_result.MoveError();
|
||||||
@ -492,8 +500,13 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyAudioReceiverParameters(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local_direction.recv =
|
bool local_send = RtpTransceiverDirectionHasSend(
|
||||||
|
cricket::RtpTransceiverDirectionFromMediaContentDirection(
|
||||||
|
local_audio_description_.direction()));
|
||||||
|
bool local_recv =
|
||||||
!parameters.encodings.empty() && parameters.encodings[0].active;
|
!parameters.encodings.empty() && parameters.encodings[0].active;
|
||||||
|
auto local_direction =
|
||||||
|
RtpTransceiverDirectionFromSendRecv(local_send, local_recv);
|
||||||
|
|
||||||
// Validation is done, so we can attempt applying the descriptions. Received
|
// Validation is done, so we can attempt applying the descriptions. Received
|
||||||
// codecs and header extensions go in local description, streams go in
|
// codecs and header extensions go in local description, streams go in
|
||||||
@ -512,9 +525,11 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyAudioReceiverParameters(
|
|||||||
stream_params_result.MoveValue();
|
stream_params_result.MoveValue();
|
||||||
// Direction set based on encoding "active" flag.
|
// Direction set based on encoding "active" flag.
|
||||||
local_audio_description_.set_direction(
|
local_audio_description_.set_direction(
|
||||||
local_direction.ToMediaContentDirection());
|
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
|
local_direction));
|
||||||
remote_audio_description_.set_direction(
|
remote_audio_description_.set_direction(
|
||||||
local_direction.Reversed().ToMediaContentDirection());
|
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
|
RtpTransceiverDirectionReversed(local_direction)));
|
||||||
|
|
||||||
if (!voice_channel_->SetLocalContent(&local_audio_description_,
|
if (!voice_channel_->SetLocalContent(&local_audio_description_,
|
||||||
cricket::CA_OFFER, nullptr)) {
|
cricket::CA_OFFER, nullptr)) {
|
||||||
@ -545,9 +560,6 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyVideoReceiverParameters(
|
|||||||
return extensions_result.MoveError();
|
return extensions_result.MoveError();
|
||||||
}
|
}
|
||||||
|
|
||||||
cricket::RtpTransceiverDirection local_direction =
|
|
||||||
cricket::RtpTransceiverDirection::FromMediaContentDirection(
|
|
||||||
local_video_description_.direction());
|
|
||||||
int bandwidth = cricket::kAutoBandwidth;
|
int bandwidth = cricket::kAutoBandwidth;
|
||||||
auto stream_params_result = ToCricketStreamParamsVec(parameters.encodings);
|
auto stream_params_result = ToCricketStreamParamsVec(parameters.encodings);
|
||||||
if (!stream_params_result.ok()) {
|
if (!stream_params_result.ok()) {
|
||||||
@ -567,8 +579,13 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyVideoReceiverParameters(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local_direction.recv =
|
bool local_send = RtpTransceiverDirectionHasSend(
|
||||||
|
cricket::RtpTransceiverDirectionFromMediaContentDirection(
|
||||||
|
local_video_description_.direction()));
|
||||||
|
bool local_recv =
|
||||||
!parameters.encodings.empty() && parameters.encodings[0].active;
|
!parameters.encodings.empty() && parameters.encodings[0].active;
|
||||||
|
auto local_direction =
|
||||||
|
RtpTransceiverDirectionFromSendRecv(local_send, local_recv);
|
||||||
|
|
||||||
// Validation is done, so we can attempt applying the descriptions. Received
|
// Validation is done, so we can attempt applying the descriptions. Received
|
||||||
// codecs and header extensions go in local description, streams go in
|
// codecs and header extensions go in local description, streams go in
|
||||||
@ -588,9 +605,11 @@ RTCError RtpTransportControllerAdapter::ValidateAndApplyVideoReceiverParameters(
|
|||||||
stream_params_result.MoveValue();
|
stream_params_result.MoveValue();
|
||||||
// Direction set based on encoding "active" flag.
|
// Direction set based on encoding "active" flag.
|
||||||
local_video_description_.set_direction(
|
local_video_description_.set_direction(
|
||||||
local_direction.ToMediaContentDirection());
|
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
|
local_direction));
|
||||||
remote_video_description_.set_direction(
|
remote_video_description_.set_direction(
|
||||||
local_direction.Reversed().ToMediaContentDirection());
|
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
|
RtpTransceiverDirectionReversed(local_direction)));
|
||||||
|
|
||||||
if (!video_channel_->SetLocalContent(&local_video_description_,
|
if (!video_channel_->SetLocalContent(&local_video_description_,
|
||||||
cricket::CA_OFFER, nullptr)) {
|
cricket::CA_OFFER, nullptr)) {
|
||||||
|
@ -48,6 +48,8 @@ rtc_static_library("rtc_pc_base") {
|
|||||||
"mediasession.h",
|
"mediasession.h",
|
||||||
"rtcpmuxfilter.cc",
|
"rtcpmuxfilter.cc",
|
||||||
"rtcpmuxfilter.h",
|
"rtcpmuxfilter.h",
|
||||||
|
"rtpmediautils.cc",
|
||||||
|
"rtpmediautils.h",
|
||||||
"rtptransport.cc",
|
"rtptransport.cc",
|
||||||
"rtptransport.h",
|
"rtptransport.h",
|
||||||
"rtptransportinternal.h",
|
"rtptransportinternal.h",
|
||||||
@ -400,6 +402,7 @@ if (rtc_include_tests) {
|
|||||||
"proxy_unittest.cc",
|
"proxy_unittest.cc",
|
||||||
"rtcstats_integrationtest.cc",
|
"rtcstats_integrationtest.cc",
|
||||||
"rtcstatscollector_unittest.cc",
|
"rtcstatscollector_unittest.cc",
|
||||||
|
"rtpmediautils_unittest.cc",
|
||||||
"rtpsenderreceiver_unittest.cc",
|
"rtpsenderreceiver_unittest.cc",
|
||||||
"sctputils_unittest.cc",
|
"sctputils_unittest.cc",
|
||||||
"statscollector_unittest.cc",
|
"statscollector_unittest.cc",
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "media/base/mediaconstants.h"
|
#include "media/base/mediaconstants.h"
|
||||||
#include "p2p/base/p2pconstants.h"
|
#include "p2p/base/p2pconstants.h"
|
||||||
#include "pc/channelmanager.h"
|
#include "pc/channelmanager.h"
|
||||||
|
#include "pc/rtpmediautils.h"
|
||||||
#include "pc/srtpfilter.h"
|
#include "pc/srtpfilter.h"
|
||||||
#include "rtc_base/base64.h"
|
#include "rtc_base/base64.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
@ -33,6 +34,9 @@
|
|||||||
#include "rtc_base/stringutils.h"
|
#include "rtc_base/stringutils.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using webrtc::RtpTransceiverDirection;
|
||||||
|
|
||||||
const char kInline[] = "inline:";
|
const char kInline[] = "inline:";
|
||||||
|
|
||||||
void GetSupportedSdesCryptoSuiteNames(void (*func)(const rtc::CryptoOptions&,
|
void GetSupportedSdesCryptoSuiteNames(void (*func)(const rtc::CryptoOptions&,
|
||||||
@ -97,30 +101,47 @@ static bool IsSctp(const std::string& protocol) {
|
|||||||
return IsPlainSctp(protocol) || IsDtlsSctp(protocol);
|
return IsPlainSctp(protocol) || IsDtlsSctp(protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
RtpTransceiverDirection RtpTransceiverDirection::FromMediaContentDirection(
|
RtpTransceiverDirection RtpTransceiverDirectionFromMediaContentDirection(
|
||||||
MediaContentDirection md) {
|
MediaContentDirection direction) {
|
||||||
const bool send = (md == MD_SENDRECV || md == MD_SENDONLY);
|
switch (direction) {
|
||||||
const bool recv = (md == MD_SENDRECV || md == MD_RECVONLY);
|
case MD_SENDRECV:
|
||||||
return RtpTransceiverDirection(send, recv);
|
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 RtpTransceiverDirection::ToMediaContentDirection() const {
|
MediaContentDirection MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
if (send && recv) {
|
RtpTransceiverDirection direction) {
|
||||||
|
switch (direction) {
|
||||||
|
case RtpTransceiverDirection::kSendRecv:
|
||||||
return MD_SENDRECV;
|
return MD_SENDRECV;
|
||||||
} else if (send) {
|
case RtpTransceiverDirection::kSendOnly:
|
||||||
return MD_SENDONLY;
|
return MD_SENDONLY;
|
||||||
} else if (recv) {
|
case RtpTransceiverDirection::kRecvOnly:
|
||||||
return MD_RECVONLY;
|
return MD_RECVONLY;
|
||||||
|
case RtpTransceiverDirection::kInactive:
|
||||||
|
return MD_INACTIVE;
|
||||||
}
|
}
|
||||||
|
RTC_NOTREACHED();
|
||||||
return MD_INACTIVE;
|
return MD_INACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtpTransceiverDirection
|
static RtpTransceiverDirection NegotiateRtpTransceiverDirection(
|
||||||
NegotiateRtpTransceiverDirection(RtpTransceiverDirection offer,
|
RtpTransceiverDirection offer,
|
||||||
RtpTransceiverDirection wants) {
|
RtpTransceiverDirection wants) {
|
||||||
return RtpTransceiverDirection(offer.recv && wants.send,
|
bool offer_send = webrtc::RtpTransceiverDirectionHasSend(offer);
|
||||||
offer.send && wants.recv);
|
bool offer_recv = webrtc::RtpTransceiverDirectionHasRecv(offer);
|
||||||
|
bool wants_send = webrtc::RtpTransceiverDirectionHasSend(wants);
|
||||||
|
bool wants_recv = webrtc::RtpTransceiverDirectionHasRecv(wants);
|
||||||
|
return webrtc::RtpTransceiverDirectionFromSendRecv(offer_recv && wants_send,
|
||||||
|
offer_send && wants_recv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsMediaContentOfType(const ContentInfo* content,
|
static bool IsMediaContentOfType(const ContentInfo* content,
|
||||||
@ -1156,11 +1177,12 @@ static bool CreateMediaContentAnswer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto offer_rtd =
|
auto offer_rtd =
|
||||||
RtpTransceiverDirection::FromMediaContentDirection(offer->direction());
|
RtpTransceiverDirectionFromMediaContentDirection(offer->direction());
|
||||||
|
|
||||||
answer->set_direction(NegotiateRtpTransceiverDirection(
|
answer->set_direction(
|
||||||
offer_rtd, media_description_options.direction)
|
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
.ToMediaContentDirection());
|
NegotiateRtpTransceiverDirection(
|
||||||
|
offer_rtd, media_description_options.direction)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1569,34 +1591,37 @@ SessionDescription* MediaSessionDescriptionFactory::CreateAnswer(
|
|||||||
|
|
||||||
const AudioCodecs& MediaSessionDescriptionFactory::GetAudioCodecsForOffer(
|
const AudioCodecs& MediaSessionDescriptionFactory::GetAudioCodecsForOffer(
|
||||||
const RtpTransceiverDirection& direction) const {
|
const RtpTransceiverDirection& direction) const {
|
||||||
|
switch (direction) {
|
||||||
// If stream is inactive - generate list as if sendrecv.
|
// If stream is inactive - generate list as if sendrecv.
|
||||||
if (direction.send == direction.recv) {
|
case RtpTransceiverDirection::kSendRecv:
|
||||||
|
case RtpTransceiverDirection::kInactive:
|
||||||
return audio_sendrecv_codecs_;
|
return audio_sendrecv_codecs_;
|
||||||
} else if (direction.send) {
|
case RtpTransceiverDirection::kSendOnly:
|
||||||
return audio_send_codecs_;
|
return audio_send_codecs_;
|
||||||
} else {
|
case RtpTransceiverDirection::kRecvOnly:
|
||||||
return audio_recv_codecs_;
|
return audio_recv_codecs_;
|
||||||
}
|
}
|
||||||
|
RTC_NOTREACHED();
|
||||||
|
return audio_sendrecv_codecs_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AudioCodecs& MediaSessionDescriptionFactory::GetAudioCodecsForAnswer(
|
const AudioCodecs& MediaSessionDescriptionFactory::GetAudioCodecsForAnswer(
|
||||||
const RtpTransceiverDirection& offer,
|
const RtpTransceiverDirection& offer,
|
||||||
const RtpTransceiverDirection& answer) const {
|
const RtpTransceiverDirection& answer) const {
|
||||||
|
switch (answer) {
|
||||||
// For inactive and sendrecv answers, generate lists as if we were to accept
|
// For inactive and sendrecv answers, generate lists as if we were to accept
|
||||||
// the offer's direction. See RFC 3264 Section 6.1.
|
// the offer's direction. See RFC 3264 Section 6.1.
|
||||||
if (answer.send == answer.recv) {
|
case RtpTransceiverDirection::kSendRecv:
|
||||||
if (offer.send == offer.recv) {
|
case RtpTransceiverDirection::kInactive:
|
||||||
|
return GetAudioCodecsForOffer(
|
||||||
|
webrtc::RtpTransceiverDirectionReversed(offer));
|
||||||
|
case RtpTransceiverDirection::kSendOnly:
|
||||||
|
return audio_send_codecs_;
|
||||||
|
case RtpTransceiverDirection::kRecvOnly:
|
||||||
|
return audio_recv_codecs_;
|
||||||
|
}
|
||||||
|
RTC_NOTREACHED();
|
||||||
return audio_sendrecv_codecs_;
|
return audio_sendrecv_codecs_;
|
||||||
} else if (offer.send) {
|
|
||||||
return audio_recv_codecs_;
|
|
||||||
} else {
|
|
||||||
return audio_send_codecs_;
|
|
||||||
}
|
|
||||||
} else if (answer.send) {
|
|
||||||
return audio_send_codecs_;
|
|
||||||
} else {
|
|
||||||
return audio_recv_codecs_;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MergeCodecsFromDescription(const SessionDescription* description,
|
void MergeCodecsFromDescription(const SessionDescription* description,
|
||||||
@ -1908,7 +1933,8 @@ bool MediaSessionDescriptionFactory::AddAudioContentForOffer(
|
|||||||
SetMediaProtocol(secure_transport, audio.get());
|
SetMediaProtocol(secure_transport, audio.get());
|
||||||
|
|
||||||
audio->set_direction(
|
audio->set_direction(
|
||||||
media_description_options.direction.ToMediaContentDirection());
|
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
|
media_description_options.direction));
|
||||||
|
|
||||||
desc->AddContent(media_description_options.mid, NS_JINGLE_RTP,
|
desc->AddContent(media_description_options.mid, NS_JINGLE_RTP,
|
||||||
media_description_options.stopped, audio.release());
|
media_description_options.stopped, audio.release());
|
||||||
@ -1979,7 +2005,8 @@ bool MediaSessionDescriptionFactory::AddVideoContentForOffer(
|
|||||||
SetMediaProtocol(secure_transport, video.get());
|
SetMediaProtocol(secure_transport, video.get());
|
||||||
|
|
||||||
video->set_direction(
|
video->set_direction(
|
||||||
media_description_options.direction.ToMediaContentDirection());
|
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
|
media_description_options.direction));
|
||||||
|
|
||||||
desc->AddContent(media_description_options.mid, NS_JINGLE_RTP,
|
desc->AddContent(media_description_options.mid, NS_JINGLE_RTP,
|
||||||
media_description_options.stopped, video.release());
|
media_description_options.stopped, video.release());
|
||||||
@ -2098,7 +2125,7 @@ bool MediaSessionDescriptionFactory::AddAudioContentForAnswer(
|
|||||||
// and the selected direction in the answer.
|
// and the selected direction in the answer.
|
||||||
// Note these will be filtered one final time in CreateMediaContentAnswer.
|
// Note these will be filtered one final time in CreateMediaContentAnswer.
|
||||||
auto wants_rtd = media_description_options.direction;
|
auto wants_rtd = media_description_options.direction;
|
||||||
auto offer_rtd = RtpTransceiverDirection::FromMediaContentDirection(
|
auto offer_rtd = RtpTransceiverDirectionFromMediaContentDirection(
|
||||||
offer_audio_description->direction());
|
offer_audio_description->direction());
|
||||||
auto answer_rtd = NegotiateRtpTransceiverDirection(offer_rtd, wants_rtd);
|
auto answer_rtd = NegotiateRtpTransceiverDirection(offer_rtd, wants_rtd);
|
||||||
AudioCodecs supported_audio_codecs =
|
AudioCodecs supported_audio_codecs =
|
||||||
|
@ -20,13 +20,14 @@
|
|||||||
|
|
||||||
#include "api/cryptoparams.h"
|
#include "api/cryptoparams.h"
|
||||||
#include "api/mediatypes.h"
|
#include "api/mediatypes.h"
|
||||||
|
#include "api/rtptransceiverinterface.h"
|
||||||
#include "media/base/codec.h"
|
#include "media/base/codec.h"
|
||||||
#include "media/base/mediachannel.h"
|
#include "media/base/mediachannel.h"
|
||||||
#include "media/base/mediaconstants.h"
|
#include "media/base/mediaconstants.h"
|
||||||
#include "media/base/mediaengine.h" // For DataChannelType
|
#include "media/base/mediaengine.h" // For DataChannelType
|
||||||
#include "media/base/streamparams.h"
|
#include "media/base/streamparams.h"
|
||||||
#include "p2p/base/sessiondescription.h"
|
|
||||||
#include "p2p/base/jseptransport.h"
|
#include "p2p/base/jseptransport.h"
|
||||||
|
#include "p2p/base/sessiondescription.h"
|
||||||
#include "p2p/base/transportdescriptionfactory.h"
|
#include "p2p/base/transportdescriptionfactory.h"
|
||||||
|
|
||||||
namespace cricket {
|
namespace cricket {
|
||||||
@ -73,33 +74,11 @@ const int kAutoBandwidth = -1;
|
|||||||
// Default RTCP CNAME for unit tests.
|
// Default RTCP CNAME for unit tests.
|
||||||
const char kDefaultRtcpCname[] = "DefaultRtcpCname";
|
const char kDefaultRtcpCname[] = "DefaultRtcpCname";
|
||||||
|
|
||||||
struct RtpTransceiverDirection {
|
webrtc::RtpTransceiverDirection
|
||||||
bool send;
|
RtpTransceiverDirectionFromMediaContentDirection(
|
||||||
bool recv;
|
MediaContentDirection direction);
|
||||||
|
MediaContentDirection MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
RtpTransceiverDirection(bool send, bool recv) : send(send), recv(recv) {}
|
webrtc::RtpTransceiverDirection direction);
|
||||||
|
|
||||||
bool operator==(const RtpTransceiverDirection& o) const {
|
|
||||||
return send == o.send && recv == o.recv;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(const RtpTransceiverDirection& o) const {
|
|
||||||
return !(*this == o);
|
|
||||||
}
|
|
||||||
|
|
||||||
static RtpTransceiverDirection FromMediaContentDirection(
|
|
||||||
MediaContentDirection md);
|
|
||||||
|
|
||||||
MediaContentDirection ToMediaContentDirection() const;
|
|
||||||
|
|
||||||
RtpTransceiverDirection Reversed() const {
|
|
||||||
return RtpTransceiverDirection(recv, send);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
RtpTransceiverDirection
|
|
||||||
NegotiateRtpTransceiverDirection(RtpTransceiverDirection offer,
|
|
||||||
RtpTransceiverDirection wants);
|
|
||||||
|
|
||||||
// Options for an RtpSender contained with an media description/"m=" section.
|
// Options for an RtpSender contained with an media description/"m=" section.
|
||||||
struct SenderOptions {
|
struct SenderOptions {
|
||||||
@ -114,7 +93,7 @@ struct SenderOptions {
|
|||||||
struct MediaDescriptionOptions {
|
struct MediaDescriptionOptions {
|
||||||
MediaDescriptionOptions(MediaType type,
|
MediaDescriptionOptions(MediaType type,
|
||||||
const std::string& mid,
|
const std::string& mid,
|
||||||
RtpTransceiverDirection direction,
|
webrtc::RtpTransceiverDirection direction,
|
||||||
bool stopped)
|
bool stopped)
|
||||||
: type(type), mid(mid), direction(direction), stopped(stopped) {}
|
: type(type), mid(mid), direction(direction), stopped(stopped) {}
|
||||||
|
|
||||||
@ -132,7 +111,7 @@ struct MediaDescriptionOptions {
|
|||||||
|
|
||||||
MediaType type;
|
MediaType type;
|
||||||
std::string mid;
|
std::string mid;
|
||||||
RtpTransceiverDirection direction;
|
webrtc::RtpTransceiverDirection direction;
|
||||||
bool stopped;
|
bool stopped;
|
||||||
TransportOptions transport_options;
|
TransportOptions transport_options;
|
||||||
// Note: There's no equivalent "RtpReceiverOptions" because only send
|
// Note: There's no equivalent "RtpReceiverOptions" because only send
|
||||||
@ -467,10 +446,10 @@ class MediaSessionDescriptionFactory {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const AudioCodecs& GetAudioCodecsForOffer(
|
const AudioCodecs& GetAudioCodecsForOffer(
|
||||||
const RtpTransceiverDirection& direction) const;
|
const webrtc::RtpTransceiverDirection& direction) const;
|
||||||
const AudioCodecs& GetAudioCodecsForAnswer(
|
const AudioCodecs& GetAudioCodecsForAnswer(
|
||||||
const RtpTransceiverDirection& offer,
|
const webrtc::RtpTransceiverDirection& offer,
|
||||||
const RtpTransceiverDirection& answer) const;
|
const webrtc::RtpTransceiverDirection& answer) const;
|
||||||
void GetCodecsForOffer(const SessionDescription* current_description,
|
void GetCodecsForOffer(const SessionDescription* current_description,
|
||||||
AudioCodecs* audio_codecs,
|
AudioCodecs* audio_codecs,
|
||||||
VideoCodecs* video_codecs,
|
VideoCodecs* video_codecs,
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "p2p/base/transportdescription.h"
|
#include "p2p/base/transportdescription.h"
|
||||||
#include "p2p/base/transportinfo.h"
|
#include "p2p/base/transportinfo.h"
|
||||||
#include "pc/mediasession.h"
|
#include "pc/mediasession.h"
|
||||||
|
#include "pc/rtpmediautils.h"
|
||||||
#include "pc/srtpfilter.h"
|
#include "pc/srtpfilter.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/fakesslidentity.h"
|
#include "rtc_base/fakesslidentity.h"
|
||||||
@ -66,7 +67,6 @@ using cricket::MEDIA_TYPE_DATA;
|
|||||||
using cricket::SEC_DISABLED;
|
using cricket::SEC_DISABLED;
|
||||||
using cricket::SEC_ENABLED;
|
using cricket::SEC_ENABLED;
|
||||||
using cricket::SEC_REQUIRED;
|
using cricket::SEC_REQUIRED;
|
||||||
using cricket::RtpTransceiverDirection;
|
|
||||||
using rtc::CS_AES_CM_128_HMAC_SHA1_32;
|
using rtc::CS_AES_CM_128_HMAC_SHA1_32;
|
||||||
using rtc::CS_AES_CM_128_HMAC_SHA1_80;
|
using rtc::CS_AES_CM_128_HMAC_SHA1_80;
|
||||||
using rtc::CS_AEAD_AES_128_GCM;
|
using rtc::CS_AEAD_AES_128_GCM;
|
||||||
@ -276,7 +276,7 @@ static void AddMediaSection(MediaType type,
|
|||||||
MediaSessionOptions* opts) {
|
MediaSessionOptions* opts) {
|
||||||
opts->media_description_options.push_back(MediaDescriptionOptions(
|
opts->media_description_options.push_back(MediaDescriptionOptions(
|
||||||
type, mid,
|
type, mid,
|
||||||
cricket::RtpTransceiverDirection::FromMediaContentDirection(direction),
|
cricket::RtpTransceiverDirectionFromMediaContentDirection(direction),
|
||||||
stopped));
|
stopped));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3608,7 +3608,7 @@ void TestAudioCodecsOffer(MediaContentDirection direction) {
|
|||||||
MediaSessionOptions opts;
|
MediaSessionOptions opts;
|
||||||
AddMediaSection(MEDIA_TYPE_AUDIO, "audio", direction, kActive, &opts);
|
AddMediaSection(MEDIA_TYPE_AUDIO, "audio", direction, kActive, &opts);
|
||||||
|
|
||||||
if (RtpTransceiverDirection::FromMediaContentDirection(direction).send) {
|
if (direction == cricket::MD_SENDRECV || direction == cricket::MD_SENDONLY) {
|
||||||
AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1,
|
AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1,
|
||||||
{kMediaStream1}, 1, &opts);
|
{kMediaStream1}, 1, &opts);
|
||||||
}
|
}
|
||||||
@ -3707,8 +3707,8 @@ void TestAudioCodecsAnswer(MediaContentDirection offer_direction,
|
|||||||
AddMediaSection(MEDIA_TYPE_AUDIO, "audio", offer_direction, kActive,
|
AddMediaSection(MEDIA_TYPE_AUDIO, "audio", offer_direction, kActive,
|
||||||
&offer_opts);
|
&offer_opts);
|
||||||
|
|
||||||
if (RtpTransceiverDirection::FromMediaContentDirection(offer_direction)
|
if (webrtc::RtpTransceiverDirectionHasSend(
|
||||||
.send) {
|
RtpTransceiverDirectionFromMediaContentDirection(offer_direction))) {
|
||||||
AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1,
|
AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1,
|
||||||
{kMediaStream1}, 1, &offer_opts);
|
{kMediaStream1}, 1, &offer_opts);
|
||||||
}
|
}
|
||||||
@ -3721,8 +3721,8 @@ void TestAudioCodecsAnswer(MediaContentDirection offer_direction,
|
|||||||
AddMediaSection(MEDIA_TYPE_AUDIO, "audio", answer_direction, kActive,
|
AddMediaSection(MEDIA_TYPE_AUDIO, "audio", answer_direction, kActive,
|
||||||
&answer_opts);
|
&answer_opts);
|
||||||
|
|
||||||
if (RtpTransceiverDirection::FromMediaContentDirection(answer_direction)
|
if (webrtc::RtpTransceiverDirectionHasSend(
|
||||||
.send) {
|
RtpTransceiverDirectionFromMediaContentDirection(answer_direction))) {
|
||||||
AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1,
|
AttachSenderToMediaSection("audio", MEDIA_TYPE_AUDIO, kAudioTrack1,
|
||||||
{kMediaStream1}, 1, &answer_opts);
|
{kMediaStream1}, 1, &answer_opts);
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "pc/mediastream.h"
|
#include "pc/mediastream.h"
|
||||||
#include "pc/mediastreamobserver.h"
|
#include "pc/mediastreamobserver.h"
|
||||||
#include "pc/remoteaudiosource.h"
|
#include "pc/remoteaudiosource.h"
|
||||||
|
#include "pc/rtpmediautils.h"
|
||||||
#include "pc/rtpreceiver.h"
|
#include "pc/rtpreceiver.h"
|
||||||
#include "pc/rtpsender.h"
|
#include "pc/rtpsender.h"
|
||||||
#include "pc/sctputils.h"
|
#include "pc/sctputils.h"
|
||||||
@ -2527,9 +2528,9 @@ void PeerConnection::GetOptionsForOffer(
|
|||||||
if (local_description()) {
|
if (local_description()) {
|
||||||
GenerateMediaDescriptionOptions(
|
GenerateMediaDescriptionOptions(
|
||||||
local_description(),
|
local_description(),
|
||||||
cricket::RtpTransceiverDirection(send_audio, recv_audio),
|
RtpTransceiverDirectionFromSendRecv(send_audio, recv_audio),
|
||||||
cricket::RtpTransceiverDirection(send_video, recv_video), &audio_index,
|
RtpTransceiverDirectionFromSendRecv(send_video, recv_video),
|
||||||
&video_index, &data_index, session_options);
|
&audio_index, &video_index, &data_index, session_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add audio/video/data m= sections to the end if needed.
|
// Add audio/video/data m= sections to the end if needed.
|
||||||
@ -2537,21 +2538,23 @@ void PeerConnection::GetOptionsForOffer(
|
|||||||
session_options->media_description_options.push_back(
|
session_options->media_description_options.push_back(
|
||||||
cricket::MediaDescriptionOptions(
|
cricket::MediaDescriptionOptions(
|
||||||
cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO,
|
cricket::MEDIA_TYPE_AUDIO, cricket::CN_AUDIO,
|
||||||
cricket::RtpTransceiverDirection(send_audio, recv_audio), false));
|
RtpTransceiverDirectionFromSendRecv(send_audio, recv_audio),
|
||||||
|
false));
|
||||||
audio_index = session_options->media_description_options.size() - 1;
|
audio_index = session_options->media_description_options.size() - 1;
|
||||||
}
|
}
|
||||||
if (!video_index && offer_new_video_description) {
|
if (!video_index && offer_new_video_description) {
|
||||||
session_options->media_description_options.push_back(
|
session_options->media_description_options.push_back(
|
||||||
cricket::MediaDescriptionOptions(
|
cricket::MediaDescriptionOptions(
|
||||||
cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO,
|
cricket::MEDIA_TYPE_VIDEO, cricket::CN_VIDEO,
|
||||||
cricket::RtpTransceiverDirection(send_video, recv_video), false));
|
RtpTransceiverDirectionFromSendRecv(send_video, recv_video),
|
||||||
|
false));
|
||||||
video_index = session_options->media_description_options.size() - 1;
|
video_index = session_options->media_description_options.size() - 1;
|
||||||
}
|
}
|
||||||
if (!data_index && offer_new_data_description) {
|
if (!data_index && offer_new_data_description) {
|
||||||
session_options->media_description_options.push_back(
|
session_options->media_description_options.push_back(
|
||||||
cricket::MediaDescriptionOptions(
|
cricket::MediaDescriptionOptions(
|
||||||
cricket::MEDIA_TYPE_DATA, cricket::CN_DATA,
|
cricket::MEDIA_TYPE_DATA, cricket::CN_DATA,
|
||||||
cricket::RtpTransceiverDirection(true, true), false));
|
RtpTransceiverDirection::kSendRecv, false));
|
||||||
data_index = session_options->media_description_options.size() - 1;
|
data_index = session_options->media_description_options.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2623,9 +2626,9 @@ void PeerConnection::GetOptionsForAnswer(
|
|||||||
// direction with the offered direction.
|
// direction with the offered direction.
|
||||||
GenerateMediaDescriptionOptions(
|
GenerateMediaDescriptionOptions(
|
||||||
remote_description(),
|
remote_description(),
|
||||||
cricket::RtpTransceiverDirection(send_audio, recv_audio),
|
RtpTransceiverDirectionFromSendRecv(send_audio, recv_audio),
|
||||||
cricket::RtpTransceiverDirection(send_video, recv_video), &audio_index,
|
RtpTransceiverDirectionFromSendRecv(send_video, recv_video),
|
||||||
&video_index, &data_index, session_options);
|
&audio_index, &video_index, &data_index, session_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
cricket::MediaDescriptionOptions* audio_media_description_options =
|
cricket::MediaDescriptionOptions* audio_media_description_options =
|
||||||
@ -2662,8 +2665,8 @@ void PeerConnection::GetOptionsForAnswer(
|
|||||||
|
|
||||||
void PeerConnection::GenerateMediaDescriptionOptions(
|
void PeerConnection::GenerateMediaDescriptionOptions(
|
||||||
const SessionDescriptionInterface* session_desc,
|
const SessionDescriptionInterface* session_desc,
|
||||||
cricket::RtpTransceiverDirection audio_direction,
|
RtpTransceiverDirection audio_direction,
|
||||||
cricket::RtpTransceiverDirection video_direction,
|
RtpTransceiverDirection video_direction,
|
||||||
rtc::Optional<size_t>* audio_index,
|
rtc::Optional<size_t>* audio_index,
|
||||||
rtc::Optional<size_t>* video_index,
|
rtc::Optional<size_t>* video_index,
|
||||||
rtc::Optional<size_t>* data_index,
|
rtc::Optional<size_t>* data_index,
|
||||||
@ -2676,12 +2679,12 @@ void PeerConnection::GenerateMediaDescriptionOptions(
|
|||||||
session_options->media_description_options.push_back(
|
session_options->media_description_options.push_back(
|
||||||
cricket::MediaDescriptionOptions(
|
cricket::MediaDescriptionOptions(
|
||||||
cricket::MEDIA_TYPE_AUDIO, content.name,
|
cricket::MEDIA_TYPE_AUDIO, content.name,
|
||||||
cricket::RtpTransceiverDirection(false, false), true));
|
RtpTransceiverDirection::kInactive, true));
|
||||||
} else {
|
} else {
|
||||||
session_options->media_description_options.push_back(
|
session_options->media_description_options.push_back(
|
||||||
cricket::MediaDescriptionOptions(
|
cricket::MediaDescriptionOptions(
|
||||||
cricket::MEDIA_TYPE_AUDIO, content.name, audio_direction,
|
cricket::MEDIA_TYPE_AUDIO, content.name, audio_direction,
|
||||||
!audio_direction.send && !audio_direction.recv));
|
audio_direction == RtpTransceiverDirection::kInactive));
|
||||||
*audio_index = session_options->media_description_options.size() - 1;
|
*audio_index = session_options->media_description_options.size() - 1;
|
||||||
}
|
}
|
||||||
} else if (IsVideoContent(&content)) {
|
} else if (IsVideoContent(&content)) {
|
||||||
@ -2690,12 +2693,12 @@ void PeerConnection::GenerateMediaDescriptionOptions(
|
|||||||
session_options->media_description_options.push_back(
|
session_options->media_description_options.push_back(
|
||||||
cricket::MediaDescriptionOptions(
|
cricket::MediaDescriptionOptions(
|
||||||
cricket::MEDIA_TYPE_VIDEO, content.name,
|
cricket::MEDIA_TYPE_VIDEO, content.name,
|
||||||
cricket::RtpTransceiverDirection(false, false), true));
|
RtpTransceiverDirection::kInactive, true));
|
||||||
} else {
|
} else {
|
||||||
session_options->media_description_options.push_back(
|
session_options->media_description_options.push_back(
|
||||||
cricket::MediaDescriptionOptions(
|
cricket::MediaDescriptionOptions(
|
||||||
cricket::MEDIA_TYPE_VIDEO, content.name, video_direction,
|
cricket::MEDIA_TYPE_VIDEO, content.name, video_direction,
|
||||||
!video_direction.send && !video_direction.recv));
|
video_direction == RtpTransceiverDirection::kInactive));
|
||||||
*video_index = session_options->media_description_options.size() - 1;
|
*video_index = session_options->media_description_options.size() - 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2705,14 +2708,14 @@ void PeerConnection::GenerateMediaDescriptionOptions(
|
|||||||
session_options->media_description_options.push_back(
|
session_options->media_description_options.push_back(
|
||||||
cricket::MediaDescriptionOptions(
|
cricket::MediaDescriptionOptions(
|
||||||
cricket::MEDIA_TYPE_DATA, content.name,
|
cricket::MEDIA_TYPE_DATA, content.name,
|
||||||
cricket::RtpTransceiverDirection(false, false), true));
|
RtpTransceiverDirection::kInactive, true));
|
||||||
} else {
|
} else {
|
||||||
session_options->media_description_options.push_back(
|
session_options->media_description_options.push_back(
|
||||||
cricket::MediaDescriptionOptions(
|
cricket::MediaDescriptionOptions(
|
||||||
cricket::MEDIA_TYPE_DATA, content.name,
|
cricket::MEDIA_TYPE_DATA, content.name,
|
||||||
// Direction for data sections is meaningless, but legacy
|
// Direction for data sections is meaningless, but legacy
|
||||||
// endpoints might expect sendrecv.
|
// endpoints might expect sendrecv.
|
||||||
cricket::RtpTransceiverDirection(true, true), false));
|
RtpTransceiverDirection::kSendRecv, false));
|
||||||
*data_index = session_options->media_description_options.size() - 1;
|
*data_index = session_options->media_description_options.size() - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,8 +394,8 @@ class PeerConnection : public PeerConnectionInterface,
|
|||||||
// local description or remote description.
|
// local description or remote description.
|
||||||
void GenerateMediaDescriptionOptions(
|
void GenerateMediaDescriptionOptions(
|
||||||
const SessionDescriptionInterface* session_desc,
|
const SessionDescriptionInterface* session_desc,
|
||||||
cricket::RtpTransceiverDirection audio_direction,
|
RtpTransceiverDirection audio_direction,
|
||||||
cricket::RtpTransceiverDirection video_direction,
|
RtpTransceiverDirection video_direction,
|
||||||
rtc::Optional<size_t>* audio_index,
|
rtc::Optional<size_t>* audio_index,
|
||||||
rtc::Optional<size_t>* video_index,
|
rtc::Optional<size_t>* video_index,
|
||||||
rtc::Optional<size_t>* data_index,
|
rtc::Optional<size_t>* data_index,
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "p2p/base/fakeportallocator.h"
|
#include "p2p/base/fakeportallocator.h"
|
||||||
#include "pc/mediasession.h"
|
#include "pc/mediasession.h"
|
||||||
#include "pc/peerconnectionwrapper.h"
|
#include "pc/peerconnectionwrapper.h"
|
||||||
|
#include "pc/rtpmediautils.h"
|
||||||
#include "pc/sdputils.h"
|
#include "pc/sdputils.h"
|
||||||
#ifdef WEBRTC_ANDROID
|
#ifdef WEBRTC_ANDROID
|
||||||
#include "pc/test/androidtestinitializer.h"
|
#include "pc/test/androidtestinitializer.h"
|
||||||
@ -429,16 +430,18 @@ TEST_P(PeerConnectionMediaAnswerDirectionTest, VerifyDirection) {
|
|||||||
// 2. Receive if the answerer has explicitly set the offer_to_receive to 1 or
|
// 2. Receive if the answerer has explicitly set the offer_to_receive to 1 or
|
||||||
// if it has been left as default.
|
// if it has been left as default.
|
||||||
auto offer_direction =
|
auto offer_direction =
|
||||||
cricket::RtpTransceiverDirection::FromMediaContentDirection(
|
cricket::RtpTransceiverDirectionFromMediaContentDirection(
|
||||||
offer_direction_);
|
offer_direction_);
|
||||||
|
bool offer_send = RtpTransceiverDirectionHasSend(offer_direction);
|
||||||
|
bool offer_recv = RtpTransceiverDirectionHasRecv(offer_direction);
|
||||||
|
|
||||||
// The negotiated components determine the direction set in the answer.
|
// The negotiated components determine the direction set in the answer.
|
||||||
bool negotiate_send = (send_media_ && offer_direction.recv);
|
bool negotiate_send = (send_media_ && offer_recv);
|
||||||
bool negotiate_recv = ((offer_to_receive_ != 0) && offer_direction.send);
|
bool negotiate_recv = ((offer_to_receive_ != 0) && offer_send);
|
||||||
|
|
||||||
auto expected_direction =
|
auto expected_direction =
|
||||||
cricket::RtpTransceiverDirection(negotiate_send, negotiate_recv)
|
cricket::MediaContentDirectionFromRtpTransceiverDirection(
|
||||||
.ToMediaContentDirection();
|
RtpTransceiverDirectionFromSendRecv(negotiate_send, negotiate_recv));
|
||||||
EXPECT_EQ(expected_direction,
|
EXPECT_EQ(expected_direction,
|
||||||
GetMediaContentDirection(answer.get(), cricket::CN_AUDIO));
|
GetMediaContentDirection(answer.get(), cricket::CN_AUDIO));
|
||||||
}
|
}
|
||||||
|
53
pc/rtpmediautils.cc
Normal file
53
pc/rtpmediautils.cc
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 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 "pc/rtpmediautils.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
RtpTransceiverDirection RtpTransceiverDirectionFromSendRecv(bool send,
|
||||||
|
bool recv) {
|
||||||
|
if (send && recv) {
|
||||||
|
return RtpTransceiverDirection::kSendRecv;
|
||||||
|
} else if (send && !recv) {
|
||||||
|
return RtpTransceiverDirection::kSendOnly;
|
||||||
|
} else if (!send && recv) {
|
||||||
|
return RtpTransceiverDirection::kRecvOnly;
|
||||||
|
} else {
|
||||||
|
return RtpTransceiverDirection::kInactive;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RtpTransceiverDirectionHasSend(RtpTransceiverDirection direction) {
|
||||||
|
return direction == RtpTransceiverDirection::kSendRecv ||
|
||||||
|
direction == RtpTransceiverDirection::kSendOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RtpTransceiverDirectionHasRecv(RtpTransceiverDirection direction) {
|
||||||
|
return direction == RtpTransceiverDirection::kSendRecv ||
|
||||||
|
direction == RtpTransceiverDirection::kRecvOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
RtpTransceiverDirection RtpTransceiverDirectionReversed(
|
||||||
|
RtpTransceiverDirection direction) {
|
||||||
|
switch (direction) {
|
||||||
|
case RtpTransceiverDirection::kSendRecv:
|
||||||
|
case RtpTransceiverDirection::kInactive:
|
||||||
|
return direction;
|
||||||
|
case RtpTransceiverDirection::kSendOnly:
|
||||||
|
return RtpTransceiverDirection::kRecvOnly;
|
||||||
|
case RtpTransceiverDirection::kRecvOnly:
|
||||||
|
return RtpTransceiverDirection::kSendOnly;
|
||||||
|
}
|
||||||
|
RTC_NOTREACHED();
|
||||||
|
return direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace webrtc
|
36
pc/rtpmediautils.h
Normal file
36
pc/rtpmediautils.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PC_RTPMEDIAUTILS_H_
|
||||||
|
#define PC_RTPMEDIAUTILS_H_
|
||||||
|
|
||||||
|
#include "api/rtptransceiverinterface.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
// Returns the RtpTransceiverDirection that satisfies specified send and receive
|
||||||
|
// conditions.
|
||||||
|
RtpTransceiverDirection RtpTransceiverDirectionFromSendRecv(bool send,
|
||||||
|
bool recv);
|
||||||
|
|
||||||
|
// Returns true only if the direction will send media.
|
||||||
|
bool RtpTransceiverDirectionHasSend(RtpTransceiverDirection direction);
|
||||||
|
|
||||||
|
// Returns true only if the direction will receive media.
|
||||||
|
bool RtpTransceiverDirectionHasRecv(RtpTransceiverDirection direction);
|
||||||
|
|
||||||
|
// Returns the RtpTransceiverDirection which is the reverse of the given
|
||||||
|
// direction.
|
||||||
|
RtpTransceiverDirection RtpTransceiverDirectionReversed(
|
||||||
|
RtpTransceiverDirection direction);
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // PC_RTPMEDIAUTILS_H_
|
59
pc/rtpmediautils_unittest.cc
Normal file
59
pc/rtpmediautils_unittest.cc
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 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 "pc/rtpmediautils.h"
|
||||||
|
#include "test/gtest.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
using ::testing::Values;
|
||||||
|
|
||||||
|
class EnumerateAllDirectionsTest
|
||||||
|
: public ::testing::Test,
|
||||||
|
public ::testing::WithParamInterface<RtpTransceiverDirection> {};
|
||||||
|
|
||||||
|
// Test that converting the direction to send/recv and back again results in the
|
||||||
|
// same direction.
|
||||||
|
TEST_P(EnumerateAllDirectionsTest, TestIdentity) {
|
||||||
|
RtpTransceiverDirection direction = GetParam();
|
||||||
|
|
||||||
|
bool send = RtpTransceiverDirectionHasSend(direction);
|
||||||
|
bool recv = RtpTransceiverDirectionHasRecv(direction);
|
||||||
|
|
||||||
|
EXPECT_EQ(direction, RtpTransceiverDirectionFromSendRecv(send, recv));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that reversing the direction is equivalent to swapping send/recv.
|
||||||
|
TEST_P(EnumerateAllDirectionsTest, TestReversedSwapped) {
|
||||||
|
RtpTransceiverDirection direction = GetParam();
|
||||||
|
|
||||||
|
bool send = RtpTransceiverDirectionHasSend(direction);
|
||||||
|
bool recv = RtpTransceiverDirectionHasRecv(direction);
|
||||||
|
|
||||||
|
EXPECT_EQ(RtpTransceiverDirectionFromSendRecv(recv, send),
|
||||||
|
RtpTransceiverDirectionReversed(direction));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that reversing the direction twice results in the same direction.
|
||||||
|
TEST_P(EnumerateAllDirectionsTest, TestReversedIdentity) {
|
||||||
|
RtpTransceiverDirection direction = GetParam();
|
||||||
|
|
||||||
|
EXPECT_EQ(direction, RtpTransceiverDirectionReversed(
|
||||||
|
RtpTransceiverDirectionReversed(direction)));
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(RtpTransceiverDirectionTest,
|
||||||
|
EnumerateAllDirectionsTest,
|
||||||
|
Values(RtpTransceiverDirection::kSendRecv,
|
||||||
|
RtpTransceiverDirection::kSendOnly,
|
||||||
|
RtpTransceiverDirection::kRecvOnly,
|
||||||
|
RtpTransceiverDirection::kInactive));
|
||||||
|
|
||||||
|
} // namespace webrtc
|
Reference in New Issue
Block a user