blob: 240274fe05682d84251b6773de7aaf74a9dbc503 [file] [log] [blame]
Steve Anton1d03a752017-11-27 22:30:091/*
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 17:11:0011#ifndef PC_RTP_MEDIA_UTILS_H_
12#define PC_RTP_MEDIA_UTILS_H_
Steve Anton1d03a752017-11-27 22:30:0913
Harald Alvestrandc24a2182022-02-23 13:44:5914#include <ostream> // no-presubmit-check TODO(webrtc:8982)
15
Harald Alvestrand5761e7b2021-01-29 14:45:0816#include "api/rtp_transceiver_direction.h"
Steve Anton1d03a752017-11-27 22:30:0917
18namespace webrtc {
19
20// Returns the RtpTransceiverDirection that satisfies specified send and receive
21// conditions.
22RtpTransceiverDirection RtpTransceiverDirectionFromSendRecv(bool send,
23 bool recv);
24
25// Returns true only if the direction will send media.
26bool RtpTransceiverDirectionHasSend(RtpTransceiverDirection direction);
27
28// Returns true only if the direction will receive media.
29bool RtpTransceiverDirectionHasRecv(RtpTransceiverDirection direction);
30
31// Returns the RtpTransceiverDirection which is the reverse of the given
32// direction.
33RtpTransceiverDirection RtpTransceiverDirectionReversed(
34 RtpTransceiverDirection direction);
35
Artem Titov880fa812021-07-30 20:30:2336// Returns the RtpTransceiverDirection with its send component set to `send`.
Steve Anton22da89f2018-01-25 21:58:0737RtpTransceiverDirection RtpTransceiverDirectionWithSendSet(
38 RtpTransceiverDirection direction,
39 bool send = true);
40
Artem Titov880fa812021-07-30 20:30:2341// Returns the RtpTransceiverDirection with its recv component set to `recv`.
Steve Anton22da89f2018-01-25 21:58:0742RtpTransceiverDirection RtpTransceiverDirectionWithRecvSet(
43 RtpTransceiverDirection direction,
44 bool recv = true);
45
Steve Anton4e70a722017-11-28 22:57:1046// Returns an unspecified string representation of the given direction.
47const char* RtpTransceiverDirectionToString(RtpTransceiverDirection direction);
48
Guido Urdaneta70c2db12019-04-16 10:24:1449// Returns the intersection of the directions of two transceivers.
50RtpTransceiverDirection RtpTransceiverDirectionIntersection(
51 RtpTransceiverDirection lhs,
52 RtpTransceiverDirection rhs);
53
Andrey Logvinb95d90b2020-12-09 12:49:3954#ifdef WEBRTC_UNIT_TEST
Jonas Olsson3e18c822018-04-18 08:11:0755inline std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982)
56 std::ostream& os, // no-presubmit-check TODO(webrtc:8982)
57 RtpTransceiverDirection direction) {
58 return os << RtpTransceiverDirectionToString(direction);
59}
Andrey Logvinb95d90b2020-12-09 12:49:3960#endif // WEBRTC_UNIT_TEST
Jonas Olsson3e18c822018-04-18 08:11:0761
Steve Anton1d03a752017-11-27 22:30:0962} // namespace webrtc
63
Steve Anton10542f22019-01-11 17:11:0064#endif // PC_RTP_MEDIA_UTILS_H_