sdp_utils.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_SDP_UTILS_H_
  11. #define PC_SDP_UTILS_H_
  12. #include <functional>
  13. #include <memory>
  14. #include <string>
  15. #include "api/jsep.h"
  16. #include "pc/session_description.h"
  17. #include "rtc_base/system/rtc_export.h"
  18. namespace webrtc {
  19. // Returns a copy of the given session description.
  20. RTC_EXPORT std::unique_ptr<SessionDescriptionInterface> CloneSessionDescription(
  21. const SessionDescriptionInterface* sdesc);
  22. // Returns a copy of the given session description with the type changed.
  23. RTC_EXPORT std::unique_ptr<SessionDescriptionInterface>
  24. CloneSessionDescriptionAsType(const SessionDescriptionInterface* sdesc,
  25. SdpType type);
  26. // Function that takes a single session description content with its
  27. // corresponding transport and produces a boolean.
  28. typedef std::function<bool(const cricket::ContentInfo*,
  29. const cricket::TransportInfo*)>
  30. SdpContentPredicate;
  31. // Returns true if the predicate returns true for all contents in the given
  32. // session description.
  33. bool SdpContentsAll(SdpContentPredicate pred,
  34. const cricket::SessionDescription* desc);
  35. // Returns true if the predicate returns true for none of the contents in the
  36. // given session description.
  37. bool SdpContentsNone(SdpContentPredicate pred,
  38. const cricket::SessionDescription* desc);
  39. // Function that takes a single session description content with its
  40. // corresponding transport and can mutate the content and/or the transport.
  41. typedef std::function<void(cricket::ContentInfo*, cricket::TransportInfo*)>
  42. SdpContentMutator;
  43. // Applies the mutator function over all contents in the given session
  44. // description.
  45. void SdpContentsForEach(SdpContentMutator fn,
  46. cricket::SessionDescription* desc);
  47. } // namespace webrtc
  48. #endif // PC_SDP_UTILS_H_