Steve Anton | 1d03a75 | 2017-11-27 14:30:09 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef PC_RTP_MEDIA_UTILS_H_ |
| 12 | #define PC_RTP_MEDIA_UTILS_H_ |
Steve Anton | 1d03a75 | 2017-11-27 14:30:09 -0800 | [diff] [blame] | 13 | |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 14 | #include "api/rtp_transceiver_direction.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 15 | #include "api/rtp_transceiver_interface.h" |
Steve Anton | 1d03a75 | 2017-11-27 14:30:09 -0800 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | // Returns the RtpTransceiverDirection that satisfies specified send and receive |
| 20 | // conditions. |
| 21 | RtpTransceiverDirection RtpTransceiverDirectionFromSendRecv(bool send, |
| 22 | bool recv); |
| 23 | |
| 24 | // Returns true only if the direction will send media. |
| 25 | bool RtpTransceiverDirectionHasSend(RtpTransceiverDirection direction); |
| 26 | |
| 27 | // Returns true only if the direction will receive media. |
| 28 | bool RtpTransceiverDirectionHasRecv(RtpTransceiverDirection direction); |
| 29 | |
| 30 | // Returns the RtpTransceiverDirection which is the reverse of the given |
| 31 | // direction. |
| 32 | RtpTransceiverDirection RtpTransceiverDirectionReversed( |
| 33 | RtpTransceiverDirection direction); |
| 34 | |
Björn Terelius | fd05d6f | 2021-07-27 22:09:55 +0000 | [diff] [blame] | 35 | // Returns the RtpTransceiverDirection with its send component set to |send|. |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 36 | RtpTransceiverDirection RtpTransceiverDirectionWithSendSet( |
| 37 | RtpTransceiverDirection direction, |
| 38 | bool send = true); |
| 39 | |
Björn Terelius | fd05d6f | 2021-07-27 22:09:55 +0000 | [diff] [blame] | 40 | // Returns the RtpTransceiverDirection with its recv component set to |recv|. |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 41 | RtpTransceiverDirection RtpTransceiverDirectionWithRecvSet( |
| 42 | RtpTransceiverDirection direction, |
| 43 | bool recv = true); |
| 44 | |
Steve Anton | 4e70a72 | 2017-11-28 14:57:10 -0800 | [diff] [blame] | 45 | // Returns an unspecified string representation of the given direction. |
| 46 | const char* RtpTransceiverDirectionToString(RtpTransceiverDirection direction); |
| 47 | |
Guido Urdaneta | 70c2db1 | 2019-04-16 12:24:14 +0200 | [diff] [blame] | 48 | // Returns the intersection of the directions of two transceivers. |
| 49 | RtpTransceiverDirection RtpTransceiverDirectionIntersection( |
| 50 | RtpTransceiverDirection lhs, |
| 51 | RtpTransceiverDirection rhs); |
| 52 | |
Andrey Logvin | b95d90b | 2020-12-09 12:49:39 +0000 | [diff] [blame] | 53 | #ifdef WEBRTC_UNIT_TEST |
Jonas Olsson | 3e18c82 | 2018-04-18 10:11:07 +0200 | [diff] [blame] | 54 | inline std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) |
| 55 | std::ostream& os, // no-presubmit-check TODO(webrtc:8982) |
| 56 | RtpTransceiverDirection direction) { |
| 57 | return os << RtpTransceiverDirectionToString(direction); |
| 58 | } |
Andrey Logvin | b95d90b | 2020-12-09 12:49:39 +0000 | [diff] [blame] | 59 | #endif // WEBRTC_UNIT_TEST |
Jonas Olsson | 3e18c82 | 2018-04-18 10:11:07 +0200 | [diff] [blame] | 60 | |
Steve Anton | 1d03a75 | 2017-11-27 14:30:09 -0800 | [diff] [blame] | 61 | } // namespace webrtc |
| 62 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 63 | #endif // PC_RTP_MEDIA_UTILS_H_ |