blob: 83cc7688a352e8d4dc104cbac8eab09712f781af [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2011 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellanderb24317b2016-02-10 07:54:43 -08004 * 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.org28e20752013-07-10 00:45:36 +00009 */
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 Bonadei92ea95e2017-09-15 06:47:31 +020020#ifndef PC_WEBRTCSDP_H_
21#define PC_WEBRTCSDP_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000022
23#include <string>
24
Honghai Zhang7fb69db2016-03-14 11:59:18 -070025namespace cricket {
26class Candidate;
27} // namespace cricket
tommi6f59a4f2016-03-11 14:05:09 -080028
Honghai Zhang7fb69db2016-03-14 11:59:18 -070029namespace webrtc {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000030class IceCandidateInterface;
31class JsepIceCandidate;
32class JsepSessionDescription;
33struct 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.
deadbeef9d3584c2016-02-16 17:54:10 -080039// unified_plan_sdp - If set to true, include "a=msid" lines where appropriate.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000040// return - SDP string serialized from the arguments.
deadbeef9d3584c2016-02-16 17:54:10 -080041std::string SdpSerialize(const JsepSessionDescription& jdesc,
42 bool unified_plan_sdp);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000043
44// Serializes the passed in IceCandidateInterface to a SDP string.
45// candidate - The candidate to be serialized.
46std::string SdpSerializeCandidate(const IceCandidateInterface& candidate);
47
Honghai Zhang7fb69db2016-03-14 11:59:18 -070048// Serializes a cricket Candidate.
49// candidate - The candidate to be serialized.
50std::string SdpSerializeCandidate(const cricket::Candidate& candidate);
51
henrike@webrtc.org28e20752013-07-10 00:45:36 +000052// Deserializes the passed in SDP string to a JsepSessionDescription.
53// message - SDP string to be Deserialized.
54// jdesc - The JsepSessionDescription deserialized from the SDP string.
55// error - The detail error information when parsing fails.
56// return - true on success, false on failure.
57bool SdpDeserialize(const std::string& message,
58 JsepSessionDescription* jdesc,
59 SdpParseError* error);
60
61// Deserializes the passed in SDP string to one JsepIceCandidate.
62// The first line must be a=candidate line and only the first line will be
63// parsed.
64// message - The SDP string to be Deserialized.
65// candidates - The JsepIceCandidate from the SDP string.
66// error - The detail error information when parsing fails.
67// return - true on success, false on failure.
68bool SdpDeserializeCandidate(const std::string& message,
69 JsepIceCandidate* candidate,
70 SdpParseError* error);
Honghai Zhang7fb69db2016-03-14 11:59:18 -070071
72// Deserializes the passed in SDP string to a cricket Candidate.
73// The first line must be a=candidate line and only the first line will be
74// parsed.
75// transport_name - The transport name (MID) of the candidate.
76// message - The SDP string to be deserialized.
77// candidate - The cricket Candidate from the SDP string.
78// error - The detail error information when parsing fails.
79// return - true on success, false on failure.
80bool SdpDeserializeCandidate(const std::string& transport_name,
81 const std::string& message,
82 cricket::Candidate* candidate,
83 SdpParseError* error);
84
henrike@webrtc.org28e20752013-07-10 00:45:36 +000085} // namespace webrtc
86
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020087#endif // PC_WEBRTCSDP_H_