blob: fc4b289f91471524be4a52eff327bef1a607f340 [file] [log] [blame]
Steve Anton97a9f762017-10-06 10:14:03 -07001/*
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 Anton10542f22019-01-11 09:11:00 -080011#ifndef PC_SDP_UTILS_H_
12#define PC_SDP_UTILS_H_
Steve Anton97a9f762017-10-06 10:14:03 -070013
14#include <functional>
15#include <memory>
Steve Anton36b29d12017-10-30 09:57:42 -070016#include <string>
Steve Anton97a9f762017-10-06 10:14:03 -070017
18#include "api/jsep.h"
Steve Anton10542f22019-01-11 09:11:00 -080019#include "pc/session_description.h"
Mirko Bonadei3ac63752019-11-05 09:56:32 +010020#include "rtc_base/system/rtc_export.h"
Steve Anton97a9f762017-10-06 10:14:03 -070021
22namespace webrtc {
23
24// Returns a copy of the given session description.
Mirko Bonadei3ac63752019-11-05 09:56:32 +010025RTC_EXPORT std::unique_ptr<SessionDescriptionInterface> CloneSessionDescription(
Steve Anton97a9f762017-10-06 10:14:03 -070026 const SessionDescriptionInterface* sdesc);
27
Steve Anton8d3444d2017-10-20 15:30:51 -070028// Returns a copy of the given session description with the type changed.
Mirko Bonadei3ac63752019-11-05 09:56:32 +010029RTC_EXPORT std::unique_ptr<SessionDescriptionInterface>
30CloneSessionDescriptionAsType(const SessionDescriptionInterface* sdesc,
31 SdpType type);
Steve Anton8d3444d2017-10-20 15:30:51 -070032
Steve Anton97a9f762017-10-06 10:14:03 -070033// Function that takes a single session description content with its
34// corresponding transport and produces a boolean.
35typedef 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.
41bool 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.
46bool 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.
51typedef std::function<void(cricket::ContentInfo*, cricket::TransportInfo*)>
52 SdpContentMutator;
53
54// Applies the mutator function over all contents in the given session
55// description.
56void SdpContentsForEach(SdpContentMutator fn,
57 cricket::SessionDescription* desc);
58
59} // namespace webrtc
60
Steve Anton10542f22019-01-11 09:11:00 -080061#endif // PC_SDP_UTILS_H_