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 | 36b29d1 | 2017-10-30 16:57:42 | [diff] [blame] | 16 | #include <string> |
Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 17 | |
| 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. |
Mirko Bonadei | 3ac6375 | 2019-11-05 08:56:32 | [diff] [blame] | 26 | RTC_EXPORT std::unique_ptr<SessionDescriptionInterface> CloneSessionDescription( |
Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 27 | const SessionDescriptionInterface* sdesc); |
| 28 | |
Steve Anton | 8d3444d | 2017-10-20 22:30:51 | [diff] [blame] | 29 | // Returns a copy of the given session description with the type changed. |
Mirko Bonadei | 3ac6375 | 2019-11-05 08:56:32 | [diff] [blame] | 30 | RTC_EXPORT std::unique_ptr<SessionDescriptionInterface> |
| 31 | CloneSessionDescriptionAsType(const SessionDescriptionInterface* sdesc, |
| 32 | SdpType type); |
Steve Anton | 8d3444d | 2017-10-20 22:30:51 | [diff] [blame] | 33 | |
Steve Anton | 97a9f76 | 2017-10-06 17:14:03 | [diff] [blame] | 34 | // Function that takes a single session description content with its |
| 35 | // corresponding transport and produces a boolean. |
| 36 | typedef std::function<bool(const cricket::ContentInfo*, |
| 37 | const cricket::TransportInfo*)> |
| 38 | SdpContentPredicate; |
| 39 | |
| 40 | // Returns true if the predicate returns true for all contents in the given |
| 41 | // session description. |
| 42 | bool SdpContentsAll(SdpContentPredicate pred, |
| 43 | const cricket::SessionDescription* desc); |
| 44 | |
| 45 | // Returns true if the predicate returns true for none of the contents in the |
| 46 | // given session description. |
| 47 | bool SdpContentsNone(SdpContentPredicate pred, |
| 48 | const cricket::SessionDescription* desc); |
| 49 | |
| 50 | // Function that takes a single session description content with its |
| 51 | // corresponding transport and can mutate the content and/or the transport. |
| 52 | typedef std::function<void(cricket::ContentInfo*, cricket::TransportInfo*)> |
| 53 | SdpContentMutator; |
| 54 | |
| 55 | // Applies the mutator function over all contents in the given session |
| 56 | // description. |
| 57 | void SdpContentsForEach(SdpContentMutator fn, |
| 58 | cricket::SessionDescription* desc); |
| 59 | |
| 60 | } // namespace webrtc |
| 61 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 62 | #endif // PC_SDP_UTILS_H_ |