blob: ef86c0a346f780d3528e5225d6618e08ee5cf428 [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
53} // namespace webrtc