blob: 3ba5c7f2be128a1724cb58f9bb912f8b10858b10 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:361/*
kjellanderb24317b2016-02-10 15:54:432 * Copyright 2011 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:363 *
kjellanderb24317b2016-02-10 15:54:434 * 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:369 */
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
Steve Anton10542f22019-01-11 17:11:0020#ifndef PC_WEBRTC_SDP_H_
21#define PC_WEBRTC_SDP_H_
henrike@webrtc.org28e20752013-07-10 00:45:3622
23#include <string>
24
Mirko Bonadei977b46a2018-10-24 14:22:0425#include "rtc_base/system/rtc_export.h"
26
Honghai Zhang7fb69db2016-03-14 18:59:1827namespace cricket {
28class Candidate;
29} // namespace cricket
tommi6f59a4f2016-03-11 22:05:0930
Honghai Zhang7fb69db2016-03-14 18:59:1831namespace webrtc {
henrike@webrtc.org28e20752013-07-10 00:45:3632class IceCandidateInterface;
33class JsepIceCandidate;
34class JsepSessionDescription;
35struct SdpParseError;
36
37// Serializes the passed in JsepSessionDescription.
38// Serialize SessionDescription including candidates if
39// JsepSessionDescription has candidates.
40// jdesc - The JsepSessionDescription object to be serialized.
deadbeef9d3584c2016-02-17 01:54:1041// unified_plan_sdp - If set to true, include "a=msid" lines where appropriate.
henrike@webrtc.org28e20752013-07-10 00:45:3642// return - SDP string serialized from the arguments.
Steve Antone831b8c2018-02-01 20:22:1643std::string SdpSerialize(const JsepSessionDescription& jdesc);
henrike@webrtc.org28e20752013-07-10 00:45:3644
45// Serializes the passed in IceCandidateInterface to a SDP string.
46// candidate - The candidate to be serialized.
47std::string SdpSerializeCandidate(const IceCandidateInterface& candidate);
48
Honghai Zhang7fb69db2016-03-14 18:59:1849// Serializes a cricket Candidate.
50// candidate - The candidate to be serialized.
Mirko Bonadei977b46a2018-10-24 14:22:0451RTC_EXPORT std::string SdpSerializeCandidate(
52 const cricket::Candidate& candidate);
Honghai Zhang7fb69db2016-03-14 18:59:1853
henrike@webrtc.org28e20752013-07-10 00:45:3654// Deserializes the passed in SDP string to a JsepSessionDescription.
55// message - SDP string to be Deserialized.
56// jdesc - The JsepSessionDescription deserialized from the SDP string.
57// error - The detail error information when parsing fails.
58// return - true on success, false on failure.
59bool SdpDeserialize(const std::string& message,
60 JsepSessionDescription* jdesc,
61 SdpParseError* error);
62
63// Deserializes the passed in SDP string to one JsepIceCandidate.
64// The first line must be a=candidate line and only the first line will be
65// parsed.
66// message - The SDP string to be Deserialized.
67// candidates - The JsepIceCandidate from the SDP string.
68// error - The detail error information when parsing fails.
69// return - true on success, false on failure.
70bool SdpDeserializeCandidate(const std::string& message,
71 JsepIceCandidate* candidate,
72 SdpParseError* error);
Honghai Zhang7fb69db2016-03-14 18:59:1873
74// Deserializes the passed in SDP string to a cricket Candidate.
75// The first line must be a=candidate line and only the first line will be
76// parsed.
77// transport_name - The transport name (MID) of the candidate.
78// message - The SDP string to be deserialized.
79// candidate - The cricket Candidate from the SDP string.
80// error - The detail error information when parsing fails.
81// return - true on success, false on failure.
Mirko Bonadei977b46a2018-10-24 14:22:0482RTC_EXPORT bool SdpDeserializeCandidate(const std::string& transport_name,
83 const std::string& message,
84 cricket::Candidate* candidate,
85 SdpParseError* error);
Honghai Zhang7fb69db2016-03-14 18:59:1886
Guido Urdanetada374732019-01-25 09:36:4387// Parses |message| according to the grammar defined in RFC 5245, Section 15.1
88// and, if successful, stores the result in |candidate| and returns true.
89// If unsuccessful, returns false and stores error information in |error| if
90// |error| is not null.
91// If |is_raw| is false, |message| is expected to be prefixed with "a=".
92// If |is_raw| is true, no prefix is expected in |messaage|.
93RTC_EXPORT bool ParseCandidate(const std::string& message,
94 cricket::Candidate* candidate,
95 SdpParseError* error,
96 bool is_raw);
97
henrike@webrtc.org28e20752013-07-10 00:45:3698} // namespace webrtc
99
Steve Anton10542f22019-01-11 17:11:00100#endif // PC_WEBRTC_SDP_H_