blob: effd7cd0348ead3ba4093ffd07db20f58642a0ea [file] [log] [blame]
Steve Anton97a9f762017-10-06 17:14:031/*
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 17:11:0011#ifndef PC_SDP_UTILS_H_
12#define PC_SDP_UTILS_H_
Steve Anton97a9f762017-10-06 17:14:0313
14#include <functional>
15#include <memory>
Steve Anton36b29d12017-10-30 16:57:4216#include <string>
Steve Anton97a9f762017-10-06 17:14:0317
18#include "api/jsep.h"
Harald Alvestrand5761e7b2021-01-29 14:45:0819#include "p2p/base/transport_info.h"
Steve Anton10542f22019-01-11 17:11:0020#include "pc/session_description.h"
Mirko Bonadei3ac63752019-11-05 08:56:3221#include "rtc_base/system/rtc_export.h"
Steve Anton97a9f762017-10-06 17:14:0322
23namespace webrtc {
24
25// Returns a copy of the given session description.
Mirko Bonadei3ac63752019-11-05 08:56:3226RTC_EXPORT std::unique_ptr<SessionDescriptionInterface> CloneSessionDescription(
Steve Anton97a9f762017-10-06 17:14:0327 const SessionDescriptionInterface* sdesc);
28
Steve Anton8d3444d2017-10-20 22:30:5129// Returns a copy of the given session description with the type changed.
Mirko Bonadei3ac63752019-11-05 08:56:3230RTC_EXPORT std::unique_ptr<SessionDescriptionInterface>
31CloneSessionDescriptionAsType(const SessionDescriptionInterface* sdesc,
32 SdpType type);
Steve Anton8d3444d2017-10-20 22:30:5133
Steve Anton97a9f762017-10-06 17:14:0334// Function that takes a single session description content with its
35// corresponding transport and produces a boolean.
36typedef 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.
42bool 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.
47bool 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.
52typedef std::function<void(cricket::ContentInfo*, cricket::TransportInfo*)>
53 SdpContentMutator;
54
55// Applies the mutator function over all contents in the given session
56// description.
57void SdpContentsForEach(SdpContentMutator fn,
58 cricket::SessionDescription* desc);
59
60} // namespace webrtc
61
Steve Anton10542f22019-01-11 17:11:0062#endif // PC_SDP_UTILS_H_