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 11 #ifndef PC_RTP_MEDIA_UTILS_H_ 12 #define PC_RTP_MEDIA_UTILS_H_ 13 14 #include "api/rtp_transceiver_interface.h" 15 16 namespace webrtc { 17 18 // Returns the RtpTransceiverDirection that satisfies specified send and receive 19 // conditions. 20 RtpTransceiverDirection RtpTransceiverDirectionFromSendRecv(bool send, 21 bool recv); 22 23 // Returns true only if the direction will send media. 24 bool RtpTransceiverDirectionHasSend(RtpTransceiverDirection direction); 25 26 // Returns true only if the direction will receive media. 27 bool RtpTransceiverDirectionHasRecv(RtpTransceiverDirection direction); 28 29 // Returns the RtpTransceiverDirection which is the reverse of the given 30 // direction. 31 RtpTransceiverDirection RtpTransceiverDirectionReversed( 32 RtpTransceiverDirection direction); 33 34 // Returns the RtpTransceiverDirection with its send component set to |send|. 35 RtpTransceiverDirection RtpTransceiverDirectionWithSendSet( 36 RtpTransceiverDirection direction, 37 bool send = true); 38 39 // Returns the RtpTransceiverDirection with its recv component set to |recv|. 40 RtpTransceiverDirection RtpTransceiverDirectionWithRecvSet( 41 RtpTransceiverDirection direction, 42 bool recv = true); 43 44 // Returns an unspecified string representation of the given direction. 45 const char* RtpTransceiverDirectionToString(RtpTransceiverDirection direction); 46 47 // Returns the intersection of the directions of two transceivers. 48 RtpTransceiverDirection RtpTransceiverDirectionIntersection( 49 RtpTransceiverDirection lhs, 50 RtpTransceiverDirection rhs); 51 52 #ifdef UNIT_TEST 53 inline std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) 54 std::ostream& os, // no-presubmit-check TODO(webrtc:8982) 55 RtpTransceiverDirection direction) { 56 return os << RtpTransceiverDirectionToString(direction); 57 } 58 #endif // UNIT_TEST 59 60 } // namespace webrtc 61 62 #endif // PC_RTP_MEDIA_UTILS_H_ 63