1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #ifndef PC_RTP_MEDIA_UTILS_H_ 12*d9f75844SAndroid Build Coastguard Worker #define PC_RTP_MEDIA_UTILS_H_ 13*d9f75844SAndroid Build Coastguard Worker 14*d9f75844SAndroid Build Coastguard Worker #include <ostream> // no-presubmit-check TODO(webrtc:8982) 15*d9f75844SAndroid Build Coastguard Worker 16*d9f75844SAndroid Build Coastguard Worker #include "api/rtp_transceiver_direction.h" 17*d9f75844SAndroid Build Coastguard Worker 18*d9f75844SAndroid Build Coastguard Worker namespace webrtc { 19*d9f75844SAndroid Build Coastguard Worker 20*d9f75844SAndroid Build Coastguard Worker // Returns the RtpTransceiverDirection that satisfies specified send and receive 21*d9f75844SAndroid Build Coastguard Worker // conditions. 22*d9f75844SAndroid Build Coastguard Worker RtpTransceiverDirection RtpTransceiverDirectionFromSendRecv(bool send, 23*d9f75844SAndroid Build Coastguard Worker bool recv); 24*d9f75844SAndroid Build Coastguard Worker 25*d9f75844SAndroid Build Coastguard Worker // Returns true only if the direction will send media. 26*d9f75844SAndroid Build Coastguard Worker bool RtpTransceiverDirectionHasSend(RtpTransceiverDirection direction); 27*d9f75844SAndroid Build Coastguard Worker 28*d9f75844SAndroid Build Coastguard Worker // Returns true only if the direction will receive media. 29*d9f75844SAndroid Build Coastguard Worker bool RtpTransceiverDirectionHasRecv(RtpTransceiverDirection direction); 30*d9f75844SAndroid Build Coastguard Worker 31*d9f75844SAndroid Build Coastguard Worker // Returns the RtpTransceiverDirection which is the reverse of the given 32*d9f75844SAndroid Build Coastguard Worker // direction. 33*d9f75844SAndroid Build Coastguard Worker RtpTransceiverDirection RtpTransceiverDirectionReversed( 34*d9f75844SAndroid Build Coastguard Worker RtpTransceiverDirection direction); 35*d9f75844SAndroid Build Coastguard Worker 36*d9f75844SAndroid Build Coastguard Worker // Returns the RtpTransceiverDirection with its send component set to `send`. 37*d9f75844SAndroid Build Coastguard Worker RtpTransceiverDirection RtpTransceiverDirectionWithSendSet( 38*d9f75844SAndroid Build Coastguard Worker RtpTransceiverDirection direction, 39*d9f75844SAndroid Build Coastguard Worker bool send = true); 40*d9f75844SAndroid Build Coastguard Worker 41*d9f75844SAndroid Build Coastguard Worker // Returns the RtpTransceiverDirection with its recv component set to `recv`. 42*d9f75844SAndroid Build Coastguard Worker RtpTransceiverDirection RtpTransceiverDirectionWithRecvSet( 43*d9f75844SAndroid Build Coastguard Worker RtpTransceiverDirection direction, 44*d9f75844SAndroid Build Coastguard Worker bool recv = true); 45*d9f75844SAndroid Build Coastguard Worker 46*d9f75844SAndroid Build Coastguard Worker // Returns an unspecified string representation of the given direction. 47*d9f75844SAndroid Build Coastguard Worker const char* RtpTransceiverDirectionToString(RtpTransceiverDirection direction); 48*d9f75844SAndroid Build Coastguard Worker 49*d9f75844SAndroid Build Coastguard Worker // Returns the intersection of the directions of two transceivers. 50*d9f75844SAndroid Build Coastguard Worker RtpTransceiverDirection RtpTransceiverDirectionIntersection( 51*d9f75844SAndroid Build Coastguard Worker RtpTransceiverDirection lhs, 52*d9f75844SAndroid Build Coastguard Worker RtpTransceiverDirection rhs); 53*d9f75844SAndroid Build Coastguard Worker 54*d9f75844SAndroid Build Coastguard Worker #ifdef WEBRTC_UNIT_TEST 55*d9f75844SAndroid Build Coastguard Worker inline std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982) 56*d9f75844SAndroid Build Coastguard Worker std::ostream& os, // no-presubmit-check TODO(webrtc:8982) 57*d9f75844SAndroid Build Coastguard Worker RtpTransceiverDirection direction) { 58*d9f75844SAndroid Build Coastguard Worker return os << RtpTransceiverDirectionToString(direction); 59*d9f75844SAndroid Build Coastguard Worker } 60*d9f75844SAndroid Build Coastguard Worker #endif // WEBRTC_UNIT_TEST 61*d9f75844SAndroid Build Coastguard Worker 62*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc 63*d9f75844SAndroid Build Coastguard Worker 64*d9f75844SAndroid Build Coastguard Worker #endif // PC_RTP_MEDIA_UTILS_H_ 65