blob: f88861c3204f86ccbc909ad03f7eb2582f2be215 [file] [log] [blame]
Steve Anton1d03a752017-11-27 14:30:09 -08001/*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "pc/rtpmediautils.h"
12
13namespace webrtc {
14
15RtpTransceiverDirection RtpTransceiverDirectionFromSendRecv(bool send,
16 bool recv) {
17 if (send && recv) {
18 return RtpTransceiverDirection::kSendRecv;
19 } else if (send && !recv) {
20 return RtpTransceiverDirection::kSendOnly;
21 } else if (!send && recv) {
22 return RtpTransceiverDirection::kRecvOnly;
23 } else {
24 return RtpTransceiverDirection::kInactive;
25 }
26}
27
28bool RtpTransceiverDirectionHasSend(RtpTransceiverDirection direction) {
29 return direction == RtpTransceiverDirection::kSendRecv ||
30 direction == RtpTransceiverDirection::kSendOnly;
31}
32
33bool RtpTransceiverDirectionHasRecv(RtpTransceiverDirection direction) {
34 return direction == RtpTransceiverDirection::kSendRecv ||
35 direction == RtpTransceiverDirection::kRecvOnly;
36}
37
38RtpTransceiverDirection RtpTransceiverDirectionReversed(
39 RtpTransceiverDirection direction) {
40 switch (direction) {
41 case RtpTransceiverDirection::kSendRecv:
42 case RtpTransceiverDirection::kInactive:
43 return direction;
44 case RtpTransceiverDirection::kSendOnly:
45 return RtpTransceiverDirection::kRecvOnly;
46 case RtpTransceiverDirection::kRecvOnly:
47 return RtpTransceiverDirection::kSendOnly;
48 }
49 RTC_NOTREACHED();
50 return direction;
51}
52
Steve Anton4e70a722017-11-28 14:57:10 -080053const char* RtpTransceiverDirectionToString(RtpTransceiverDirection direction) {
54 switch (direction) {
55 case RtpTransceiverDirection::kSendRecv:
56 return "kSendRecv";
57 case RtpTransceiverDirection::kSendOnly:
58 return "kSendOnly";
59 case RtpTransceiverDirection::kRecvOnly:
60 return "kRecvOnly";
61 case RtpTransceiverDirection::kInactive:
62 return "kInactive";
63 }
64 RTC_NOTREACHED();
65 return "";
66}
67
Steve Anton1d03a752017-11-27 14:30:09 -080068} // namespace webrtc