Steve Anton | 97a9f76 | 2017-10-06 10:14:03 -0700 | [diff] [blame] | 1 | /* |
| 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 Anton | 36b29d1 | 2017-10-30 09:57:42 -0700 | [diff] [blame] | 16 | #include <string> |
Steve Anton | 97a9f76 | 2017-10-06 10:14:03 -0700 | [diff] [blame] | 17 | |
| 18 | #include "api/jsep.h" |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 19 | #include "pc/sessiondescription.h" |
Steve Anton | 97a9f76 | 2017-10-06 10:14:03 -0700 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | // Returns a copy of the given session description. |
| 24 | std::unique_ptr<SessionDescriptionInterface> CloneSessionDescription( |
| 25 | const SessionDescriptionInterface* sdesc); |
| 26 | |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 27 | // Returns a copy of the given session description with the type changed. |
| 28 | std::unique_ptr<SessionDescriptionInterface> CloneSessionDescriptionAsType( |
| 29 | const SessionDescriptionInterface* sdesc, |
Steve Anton | a3a92c2 | 2017-12-07 10:27:41 -0800 | [diff] [blame] | 30 | SdpType type); |
Steve Anton | 8d3444d | 2017-10-20 15:30:51 -0700 | [diff] [blame] | 31 | |
Steve Anton | 97a9f76 | 2017-10-06 10:14:03 -0700 | [diff] [blame] | 32 | // Function that takes a single session description content with its |
| 33 | // corresponding transport and produces a boolean. |
| 34 | typedef 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. |
| 40 | bool 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. |
| 45 | bool 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. |
| 50 | typedef std::function<void(cricket::ContentInfo*, cricket::TransportInfo*)> |
| 51 | SdpContentMutator; |
| 52 | |
| 53 | // Applies the mutator function over all contents in the given session |
| 54 | // description. |
| 55 | void SdpContentsForEach(SdpContentMutator fn, |
| 56 | cricket::SessionDescription* desc); |
| 57 | |
| 58 | } // namespace webrtc |
| 59 | |
| 60 | #endif // PC_SDPUTILS_H_ |