| Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 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 | |
| Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 11 | #ifndef PC_SDP_UTILS_H_ |
| 12 | #define PC_SDP_UTILS_H_ |
| Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 13 | |
| 14 | #include <functional> |
| 15 | #include <memory> |
| Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 16 | |
| Harald Alvestrand | f94ebc7 | 2025-10-08 12:31:10 | [diff] [blame] | 17 | #include "absl/base/macros.h" |
| Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 18 | #include "api/jsep.h" |
| Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 | [diff] [blame] | 19 | #include "p2p/base/transport_info.h" |
| Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 20 | #include "pc/session_description.h" |
| Mirko Bonadei | 3ac6375 | 2019-11-05 08:56:32 | [diff] [blame] | 21 | #include "rtc_base/system/rtc_export.h" |
| Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
| 25 | // Returns a copy of the given session description. |
| Harald Alvestrand | f94ebc7 | 2025-10-08 12:31:10 | [diff] [blame] | 26 | // Deprecated in favor of SessionDescriptionInterface::Clone() |
| 27 | ABSL_DEPRECATE_AND_INLINE() |
| 28 | inline std::unique_ptr<SessionDescriptionInterface> CloneSessionDescription( |
| 29 | const SessionDescriptionInterface* sdesc) { |
| 30 | return sdesc->Clone(); |
| 31 | } |
| Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 32 | |
| Steve Anton | 8d3444d | 2017-10-20 22:30:51 | [diff] [blame] | 33 | // Returns a copy of the given session description with the type changed. |
| Mirko Bonadei | 3ac6375 | 2019-11-05 08:56:32 | [diff] [blame] | 34 | RTC_EXPORT std::unique_ptr<SessionDescriptionInterface> |
| 35 | CloneSessionDescriptionAsType(const SessionDescriptionInterface* sdesc, |
| 36 | SdpType type); |
| Steve Anton | 8d3444d | 2017-10-20 22:30:51 | [diff] [blame] | 37 | |
| Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 38 | // Function that takes a single session description content with its |
| 39 | // corresponding transport and produces a boolean. |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 40 | typedef std::function<bool(const webrtc::ContentInfo*, |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 41 | const webrtc::TransportInfo*)> |
| Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 42 | SdpContentPredicate; |
| 43 | |
| 44 | // Returns true if the predicate returns true for all contents in the given |
| 45 | // session description. |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 46 | bool SdpContentsAll(SdpContentPredicate pred, const SessionDescription* desc); |
| Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 47 | |
| 48 | // Returns true if the predicate returns true for none of the contents in the |
| 49 | // given session description. |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 50 | bool SdpContentsNone(SdpContentPredicate pred, const SessionDescription* desc); |
| Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 51 | |
| 52 | // Function that takes a single session description content with its |
| 53 | // corresponding transport and can mutate the content and/or the transport. |
| Evan Shrubsole | 945e517 | 2025-04-08 14:11:45 | [diff] [blame] | 54 | typedef std::function<void(webrtc::ContentInfo*, webrtc::TransportInfo*)> |
| Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 55 | SdpContentMutator; |
| 56 | |
| 57 | // Applies the mutator function over all contents in the given session |
| 58 | // description. |
| Evan Shrubsole | 080cdac | 2025-03-20 09:34:48 | [diff] [blame] | 59 | void SdpContentsForEach(SdpContentMutator fn, SessionDescription* desc); |
| Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 60 | |
| 61 | } // namespace webrtc |
| 62 | |
| Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 63 | #endif // PC_SDP_UTILS_H_ |