2017-11-27 14:30:09 -08:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "pc/rtp_media_utils.h"
|
2017-11-27 14:30:09 -08:00
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
|
2017-11-27 14:30:09 -08:00
|
|
|
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:
|
2020-08-11 09:54:02 +02:00
|
|
|
case RtpTransceiverDirection::kStopped:
|
2017-11-27 14:30:09 -08:00
|
|
|
return direction;
|
|
|
|
|
case RtpTransceiverDirection::kSendOnly:
|
|
|
|
|
return RtpTransceiverDirection::kRecvOnly;
|
|
|
|
|
case RtpTransceiverDirection::kRecvOnly:
|
|
|
|
|
return RtpTransceiverDirection::kSendOnly;
|
2020-03-11 10:51:13 +01:00
|
|
|
default:
|
2021-11-15 16:57:07 +01:00
|
|
|
RTC_DCHECK_NOTREACHED();
|
2020-03-11 10:51:13 +01:00
|
|
|
return direction;
|
2017-11-27 14:30:09 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-25 13:58:07 -08:00
|
|
|
RtpTransceiverDirection RtpTransceiverDirectionWithSendSet(
|
|
|
|
|
RtpTransceiverDirection direction,
|
|
|
|
|
bool send) {
|
|
|
|
|
return RtpTransceiverDirectionFromSendRecv(
|
|
|
|
|
send, RtpTransceiverDirectionHasRecv(direction));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RtpTransceiverDirection RtpTransceiverDirectionWithRecvSet(
|
|
|
|
|
RtpTransceiverDirection direction,
|
|
|
|
|
bool recv) {
|
|
|
|
|
return RtpTransceiverDirectionFromSendRecv(
|
|
|
|
|
RtpTransceiverDirectionHasSend(direction), recv);
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-28 14:57:10 -08:00
|
|
|
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";
|
2020-03-11 10:51:13 +01:00
|
|
|
case RtpTransceiverDirection::kStopped:
|
|
|
|
|
return "kStopped";
|
2017-11-28 14:57:10 -08:00
|
|
|
}
|
2021-11-15 16:57:07 +01:00
|
|
|
RTC_DCHECK_NOTREACHED();
|
2017-11-28 14:57:10 -08:00
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-16 12:24:14 +02:00
|
|
|
RtpTransceiverDirection RtpTransceiverDirectionIntersection(
|
|
|
|
|
RtpTransceiverDirection lhs,
|
|
|
|
|
RtpTransceiverDirection rhs) {
|
|
|
|
|
return RtpTransceiverDirectionFromSendRecv(
|
|
|
|
|
RtpTransceiverDirectionHasSend(lhs) &&
|
|
|
|
|
RtpTransceiverDirectionHasSend(rhs),
|
|
|
|
|
RtpTransceiverDirectionHasRecv(lhs) &&
|
|
|
|
|
RtpTransceiverDirectionHasRecv(rhs));
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-27 14:30:09 -08:00
|
|
|
} // namespace webrtc
|