1/* 2 * libjingle 3 * Copyright 2011, Google Inc. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * 3. The name of the author may not be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28// This file contain functions for parsing and serializing SDP messages. 29// Related RFC/draft including: 30// * RFC 4566 - SDP 31// * RFC 5245 - ICE 32// * RFC 3388 - Grouping of Media Lines in SDP 33// * RFC 4568 - SDP Security Descriptions for Media Streams 34// * draft-lennox-mmusic-sdp-source-selection-02 - 35// Mechanisms for Media Source Selection in SDP 36 37#ifndef TALK_APP_WEBRTC_WEBRTCSDP_H_ 38#define TALK_APP_WEBRTC_WEBRTCSDP_H_ 39 40#include <string> 41 42namespace webrtc { 43 44class IceCandidateInterface; 45class JsepIceCandidate; 46class JsepSessionDescription; 47struct SdpParseError; 48 49// Serializes the passed in JsepSessionDescription. 50// Serialize SessionDescription including candidates if 51// JsepSessionDescription has candidates. 52// jdesc - The JsepSessionDescription object to be serialized. 53// return - SDP string serialized from the arguments. 54std::string SdpSerialize(const JsepSessionDescription& jdesc); 55 56// Serializes the passed in IceCandidateInterface to a SDP string. 57// candidate - The candidate to be serialized. 58std::string SdpSerializeCandidate(const IceCandidateInterface& candidate); 59 60// Deserializes the passed in SDP string to a JsepSessionDescription. 61// message - SDP string to be Deserialized. 62// jdesc - The JsepSessionDescription deserialized from the SDP string. 63// error - The detail error information when parsing fails. 64// return - true on success, false on failure. 65bool SdpDeserialize(const std::string& message, 66 JsepSessionDescription* jdesc, 67 SdpParseError* error); 68 69// Deserializes the passed in SDP string to one JsepIceCandidate. 70// The first line must be a=candidate line and only the first line will be 71// parsed. 72// message - The SDP string to be Deserialized. 73// candidates - The JsepIceCandidate from the SDP string. 74// error - The detail error information when parsing fails. 75// return - true on success, false on failure. 76bool SdpDeserializeCandidate(const std::string& message, 77 JsepIceCandidate* candidate, 78 SdpParseError* error); 79} // namespace webrtc 80 81#endif // TALK_APP_WEBRTC_WEBRTCSDP_H_ 82