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 11 #ifndef PC_SDP_UTILS_H_ 12 #define PC_SDP_UTILS_H_ 13 14 #include <functional> 15 #include <memory> 16 #include <string> 17 18 #include "api/jsep.h" 19 #include "p2p/base/transport_info.h" 20 #include "pc/session_description.h" 21 #include "rtc_base/system/rtc_export.h" 22 23 namespace webrtc { 24 25 // Returns a copy of the given session description. 26 RTC_EXPORT std::unique_ptr<SessionDescriptionInterface> CloneSessionDescription( 27 const SessionDescriptionInterface* sdesc); 28 29 // Returns a copy of the given session description with the type changed. 30 RTC_EXPORT std::unique_ptr<SessionDescriptionInterface> 31 CloneSessionDescriptionAsType(const SessionDescriptionInterface* sdesc, 32 SdpType type); 33 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 62 #endif // PC_SDP_UTILS_H_ 63