henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2011 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 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. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | // This file contain functions for parsing and serializing SDP messages. |
| 12 | // Related RFC/draft including: |
| 13 | // * RFC 4566 - SDP |
| 14 | // * RFC 5245 - ICE |
| 15 | // * RFC 3388 - Grouping of Media Lines in SDP |
| 16 | // * RFC 4568 - SDP Security Descriptions for Media Streams |
| 17 | // * draft-lennox-mmusic-sdp-source-selection-02 - |
| 18 | // Mechanisms for Media Source Selection in SDP |
| 19 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #ifndef PC_WEBRTCSDP_H_ |
| 21 | #define PC_WEBRTCSDP_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 22 | |
| 23 | #include <string> |
| 24 | |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 25 | namespace cricket { |
| 26 | class Candidate; |
| 27 | } // namespace cricket |
tommi | 6f59a4f | 2016-03-11 14:05:09 -0800 | [diff] [blame] | 28 | |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 29 | namespace webrtc { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 30 | class IceCandidateInterface; |
| 31 | class JsepIceCandidate; |
| 32 | class JsepSessionDescription; |
| 33 | struct SdpParseError; |
| 34 | |
| 35 | // Serializes the passed in JsepSessionDescription. |
| 36 | // Serialize SessionDescription including candidates if |
| 37 | // JsepSessionDescription has candidates. |
| 38 | // jdesc - The JsepSessionDescription object to be serialized. |
deadbeef | 9d3584c | 2016-02-16 17:54:10 -0800 | [diff] [blame] | 39 | // unified_plan_sdp - If set to true, include "a=msid" lines where appropriate. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 40 | // return - SDP string serialized from the arguments. |
Steve Anton | e831b8c | 2018-02-01 12:22:16 -0800 | [diff] [blame] | 41 | std::string SdpSerialize(const JsepSessionDescription& jdesc); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 42 | |
| 43 | // Serializes the passed in IceCandidateInterface to a SDP string. |
| 44 | // candidate - The candidate to be serialized. |
| 45 | std::string SdpSerializeCandidate(const IceCandidateInterface& candidate); |
| 46 | |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 47 | // Serializes a cricket Candidate. |
| 48 | // candidate - The candidate to be serialized. |
| 49 | std::string SdpSerializeCandidate(const cricket::Candidate& candidate); |
| 50 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 51 | // Deserializes the passed in SDP string to a JsepSessionDescription. |
| 52 | // message - SDP string to be Deserialized. |
| 53 | // jdesc - The JsepSessionDescription deserialized from the SDP string. |
| 54 | // error - The detail error information when parsing fails. |
| 55 | // return - true on success, false on failure. |
| 56 | bool SdpDeserialize(const std::string& message, |
| 57 | JsepSessionDescription* jdesc, |
| 58 | SdpParseError* error); |
| 59 | |
| 60 | // Deserializes the passed in SDP string to one JsepIceCandidate. |
| 61 | // The first line must be a=candidate line and only the first line will be |
| 62 | // parsed. |
| 63 | // message - The SDP string to be Deserialized. |
| 64 | // candidates - The JsepIceCandidate from the SDP string. |
| 65 | // error - The detail error information when parsing fails. |
| 66 | // return - true on success, false on failure. |
| 67 | bool SdpDeserializeCandidate(const std::string& message, |
| 68 | JsepIceCandidate* candidate, |
| 69 | SdpParseError* error); |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 70 | |
| 71 | // Deserializes the passed in SDP string to a cricket Candidate. |
| 72 | // The first line must be a=candidate line and only the first line will be |
| 73 | // parsed. |
| 74 | // transport_name - The transport name (MID) of the candidate. |
| 75 | // message - The SDP string to be deserialized. |
| 76 | // candidate - The cricket Candidate from the SDP string. |
| 77 | // error - The detail error information when parsing fails. |
| 78 | // return - true on success, false on failure. |
| 79 | bool SdpDeserializeCandidate(const std::string& transport_name, |
| 80 | const std::string& message, |
| 81 | cricket::Candidate* candidate, |
| 82 | SdpParseError* error); |
| 83 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 84 | } // namespace webrtc |
| 85 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 86 | #endif // PC_WEBRTCSDP_H_ |