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 "pc/session_description.h"
20 #include "rtc_base/system/rtc_export.h"
21 
22 namespace webrtc {
23 
24 // Returns a copy of the given session description.
25 RTC_EXPORT std::unique_ptr<SessionDescriptionInterface> CloneSessionDescription(
26     const SessionDescriptionInterface* sdesc);
27 
28 // Returns a copy of the given session description with the type changed.
29 RTC_EXPORT std::unique_ptr<SessionDescriptionInterface>
30 CloneSessionDescriptionAsType(const SessionDescriptionInterface* sdesc,
31                               SdpType type);
32 
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 
61 #endif  // PC_SDP_UTILS_H_
62