blob: 5c61f5b1d6d7a18fc3ab2b3354d9a4a36ae50caa [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
Steve Anton10542f22019-01-11 09:11:00 -080011#ifndef PC_RTP_MEDIA_UTILS_H_
12#define PC_RTP_MEDIA_UTILS_H_
Steve Anton1d03a752017-11-27 14:30:09 -080013
Harald Alvestrandc24a2182022-02-23 13:44:59 +000014#include <ostream> // no-presubmit-check TODO(webrtc:8982)
15
Harald Alvestrand5761e7b2021-01-29 14:45:08 +000016#include "api/rtp_transceiver_direction.h"
Steve Anton10542f22019-01-11 09:11:00 -080017#include "api/rtp_transceiver_interface.h"
Steve Anton1d03a752017-11-27 14:30:09 -080018
19namespace webrtc {
20
21// Returns the RtpTransceiverDirection that satisfies specified send and receive
22// conditions.
23RtpTransceiverDirection RtpTransceiverDirectionFromSendRecv(bool send,
24 bool recv);
25
26// Returns true only if the direction will send media.
27bool RtpTransceiverDirectionHasSend(RtpTransceiverDirection direction);
28
29// Returns true only if the direction will receive media.
30bool RtpTransceiverDirectionHasRecv(RtpTransceiverDirection direction);
31
32// Returns the RtpTransceiverDirection which is the reverse of the given
33// direction.
34RtpTransceiverDirection RtpTransceiverDirectionReversed(
35 RtpTransceiverDirection direction);
36
Artem Titov880fa812021-07-30 22:30:23 +020037// Returns the RtpTransceiverDirection with its send component set to `send`.
Steve Anton22da89f2018-01-25 13:58:07 -080038RtpTransceiverDirection RtpTransceiverDirectionWithSendSet(
39 RtpTransceiverDirection direction,
40 bool send = true);
41
Artem Titov880fa812021-07-30 22:30:23 +020042// Returns the RtpTransceiverDirection with its recv component set to `recv`.
Steve Anton22da89f2018-01-25 13:58:07 -080043RtpTransceiverDirection RtpTransceiverDirectionWithRecvSet(
44 RtpTransceiverDirection direction,
45 bool recv = true);
46
Steve Anton4e70a722017-11-28 14:57:10 -080047// Returns an unspecified string representation of the given direction.
48const char* RtpTransceiverDirectionToString(RtpTransceiverDirection direction);
49
Guido Urdaneta70c2db12019-04-16 12:24:14 +020050// Returns the intersection of the directions of two transceivers.
51RtpTransceiverDirection RtpTransceiverDirectionIntersection(
52 RtpTransceiverDirection lhs,
53 RtpTransceiverDirection rhs);
54
Andrey Logvinb95d90b2020-12-09 12:49:39 +000055#ifdef WEBRTC_UNIT_TEST
Jonas Olsson3e18c822018-04-18 10:11:07 +020056inline std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982)
57 std::ostream& os, // no-presubmit-check TODO(webrtc:8982)
58 RtpTransceiverDirection direction) {
59 return os << RtpTransceiverDirectionToString(direction);
60}
Andrey Logvinb95d90b2020-12-09 12:49:39 +000061#endif // WEBRTC_UNIT_TEST
Jonas Olsson3e18c822018-04-18 10:11:07 +020062
Steve Anton1d03a752017-11-27 14:30:09 -080063} // namespace webrtc
64
Steve Anton10542f22019-01-11 09:11:00 -080065#endif // PC_RTP_MEDIA_UTILS_H_