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