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