xref: /aosp_15_r20/external/webrtc/pc/sdp_utils.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright 2017 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker 
11*d9f75844SAndroid Build Coastguard Worker #ifndef PC_SDP_UTILS_H_
12*d9f75844SAndroid Build Coastguard Worker #define PC_SDP_UTILS_H_
13*d9f75844SAndroid Build Coastguard Worker 
14*d9f75844SAndroid Build Coastguard Worker #include <functional>
15*d9f75844SAndroid Build Coastguard Worker #include <memory>
16*d9f75844SAndroid Build Coastguard Worker #include <string>
17*d9f75844SAndroid Build Coastguard Worker 
18*d9f75844SAndroid Build Coastguard Worker #include "api/jsep.h"
19*d9f75844SAndroid Build Coastguard Worker #include "p2p/base/transport_info.h"
20*d9f75844SAndroid Build Coastguard Worker #include "pc/session_description.h"
21*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/system/rtc_export.h"
22*d9f75844SAndroid Build Coastguard Worker 
23*d9f75844SAndroid Build Coastguard Worker namespace webrtc {
24*d9f75844SAndroid Build Coastguard Worker 
25*d9f75844SAndroid Build Coastguard Worker // Returns a copy of the given session description.
26*d9f75844SAndroid Build Coastguard Worker RTC_EXPORT std::unique_ptr<SessionDescriptionInterface> CloneSessionDescription(
27*d9f75844SAndroid Build Coastguard Worker     const SessionDescriptionInterface* sdesc);
28*d9f75844SAndroid Build Coastguard Worker 
29*d9f75844SAndroid Build Coastguard Worker // Returns a copy of the given session description with the type changed.
30*d9f75844SAndroid Build Coastguard Worker RTC_EXPORT std::unique_ptr<SessionDescriptionInterface>
31*d9f75844SAndroid Build Coastguard Worker CloneSessionDescriptionAsType(const SessionDescriptionInterface* sdesc,
32*d9f75844SAndroid Build Coastguard Worker                               SdpType type);
33*d9f75844SAndroid Build Coastguard Worker 
34*d9f75844SAndroid Build Coastguard Worker // Function that takes a single session description content with its
35*d9f75844SAndroid Build Coastguard Worker // corresponding transport and produces a boolean.
36*d9f75844SAndroid Build Coastguard Worker typedef std::function<bool(const cricket::ContentInfo*,
37*d9f75844SAndroid Build Coastguard Worker                            const cricket::TransportInfo*)>
38*d9f75844SAndroid Build Coastguard Worker     SdpContentPredicate;
39*d9f75844SAndroid Build Coastguard Worker 
40*d9f75844SAndroid Build Coastguard Worker // Returns true if the predicate returns true for all contents in the given
41*d9f75844SAndroid Build Coastguard Worker // session description.
42*d9f75844SAndroid Build Coastguard Worker bool SdpContentsAll(SdpContentPredicate pred,
43*d9f75844SAndroid Build Coastguard Worker                     const cricket::SessionDescription* desc);
44*d9f75844SAndroid Build Coastguard Worker 
45*d9f75844SAndroid Build Coastguard Worker // Returns true if the predicate returns true for none of the contents in the
46*d9f75844SAndroid Build Coastguard Worker // given session description.
47*d9f75844SAndroid Build Coastguard Worker bool SdpContentsNone(SdpContentPredicate pred,
48*d9f75844SAndroid Build Coastguard Worker                      const cricket::SessionDescription* desc);
49*d9f75844SAndroid Build Coastguard Worker 
50*d9f75844SAndroid Build Coastguard Worker // Function that takes a single session description content with its
51*d9f75844SAndroid Build Coastguard Worker // corresponding transport and can mutate the content and/or the transport.
52*d9f75844SAndroid Build Coastguard Worker typedef std::function<void(cricket::ContentInfo*, cricket::TransportInfo*)>
53*d9f75844SAndroid Build Coastguard Worker     SdpContentMutator;
54*d9f75844SAndroid Build Coastguard Worker 
55*d9f75844SAndroid Build Coastguard Worker // Applies the mutator function over all contents in the given session
56*d9f75844SAndroid Build Coastguard Worker // description.
57*d9f75844SAndroid Build Coastguard Worker void SdpContentsForEach(SdpContentMutator fn,
58*d9f75844SAndroid Build Coastguard Worker                         cricket::SessionDescription* desc);
59*d9f75844SAndroid Build Coastguard Worker 
60*d9f75844SAndroid Build Coastguard Worker }  // namespace webrtc
61*d9f75844SAndroid Build Coastguard Worker 
62*d9f75844SAndroid Build Coastguard Worker #endif  // PC_SDP_UTILS_H_
63