rtp_media_utils.h 2.3 KB

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