blob: 3a53a41756893b3c1aa80f72aa2f364d1913dce3 [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
11#ifndef PC_SDPUTILS_H_
12#define PC_SDPUTILS_H_
13
14#include <functional>
15#include <memory>
16
17#include "api/jsep.h"
18#include "p2p/base/sessiondescription.h"
19
20namespace webrtc {
21
22// Returns a copy of the given session description.
23std::unique_ptr<SessionDescriptionInterface> CloneSessionDescription(
24 const SessionDescriptionInterface* sdesc);
25
Steve Anton8d3444d2017-10-20 15:30:51 -070026// Returns a copy of the given session description with the type changed.
27std::unique_ptr<SessionDescriptionInterface> CloneSessionDescriptionAsType(
28 const SessionDescriptionInterface* sdesc,
29 const std::string& type);
30
Steve Anton97a9f762017-10-06 10:14:03 -070031// Function that takes a single session description content with its
32// corresponding transport and produces a boolean.
33typedef std::function<bool(const cricket::ContentInfo*,
34 const cricket::TransportInfo*)>
35 SdpContentPredicate;
36
37// Returns true if the predicate returns true for all contents in the given
38// session description.
39bool SdpContentsAll(SdpContentPredicate pred,
40 const cricket::SessionDescription* desc);
41
42// Returns true if the predicate returns true for none of the contents in the
43// given session description.
44bool SdpContentsNone(SdpContentPredicate pred,
45 const cricket::SessionDescription* desc);
46
47// Function that takes a single session description content with its
48// corresponding transport and can mutate the content and/or the transport.
49typedef std::function<void(cricket::ContentInfo*, cricket::TransportInfo*)>
50 SdpContentMutator;
51
52// Applies the mutator function over all contents in the given session
53// description.
54void SdpContentsForEach(SdpContentMutator fn,
55 cricket::SessionDescription* desc);
56
57} // namespace webrtc
58
59#endif // PC_SDPUTILS_H_