| 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 | // 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 |
| 20 | #ifndef PC_WEBRTC_SDP_H_ |
| 21 | #define PC_WEBRTC_SDP_H_ |
| 22 |
| 23 | #include <string> |
| 24 |
| 25 | #include "absl/strings/string_view.h" |
| 26 | #include "api/candidate.h" |
| 27 | #include "api/jsep.h" |
| 28 | #include "api/jsep_ice_candidate.h" |
| 29 | #include "api/jsep_session_description.h" |
| 30 | #include "media/base/codec.h" |
| 31 | #include "rtc_base/strings/string_builder.h" |
| 32 | #include "rtc_base/system/rtc_export.h" |
| 33 |
| 34 | namespace cricket { |
| 35 | class Candidate; |
| 36 | } // namespace cricket |
| 37 |
| 38 | namespace rtc { |
| 39 | class StringBuilder; |
| 40 | } // namespace rtc |
| 41 |
| 42 | namespace webrtc { |
| 43 | class IceCandidateInterface; |
| 44 | class JsepIceCandidate; |
| 45 | class JsepSessionDescription; |
| 46 | struct SdpParseError; |
| 47 |
| 48 | // Serializes the passed in JsepSessionDescription. |
| 49 | // Serialize SessionDescription including candidates if |
| 50 | // JsepSessionDescription has candidates. |
| 51 | // jdesc - The JsepSessionDescription object to be serialized. |
| 52 | // return - SDP string serialized from the arguments. |
| 53 | std::string SdpSerialize(const JsepSessionDescription& jdesc); |
| 54 |
| 55 | // Serializes the passed in IceCandidateInterface to a SDP string. |
| 56 | // candidate - The candidate to be serialized. |
| 57 | std::string SdpSerializeCandidate(const IceCandidateInterface& candidate); |
| 58 |
| 59 | // Serializes a cricket Candidate. |
| 60 | // candidate - The candidate to be serialized. |
| 61 | RTC_EXPORT std::string SdpSerializeCandidate( |
| 62 | const cricket::Candidate& candidate); |
| 63 |
| 64 | // Deserializes the passed in SDP string to a JsepSessionDescription. |
| 65 | // message - SDP string to be Deserialized. |
| 66 | // jdesc - The JsepSessionDescription deserialized from the SDP string. |
| 67 | // error - The detail error information when parsing fails. |
| 68 | // return - true on success, false on failure. |
| 69 | bool SdpDeserialize(absl::string_view message, |
| 70 | JsepSessionDescription* jdesc, |
| 71 | SdpParseError* error); |
| 72 |
| 73 | // Deserializes the passed in SDP string to one JsepIceCandidate. |
| 74 | // The first line must be a=candidate line and only the first line will be |
| 75 | // parsed. |
| 76 | // message - The SDP string to be Deserialized. |
| 77 | // candidates - The JsepIceCandidate from the SDP string. |
| 78 | // error - The detail error information when parsing fails. |
| 79 | // return - true on success, false on failure. |
| 80 | RTC_EXPORT bool SdpDeserializeCandidate(absl::string_view message, |
| 81 | JsepIceCandidate* candidate, |
| 82 | SdpParseError* error); |
| 83 |
| 84 | // Deserializes the passed in SDP string to a cricket Candidate. |
| 85 | // The first line must be a=candidate line and only the first line will be |
| 86 | // parsed. |
| 87 | // transport_name - The transport name (MID) of the candidate. |
| 88 | // message - The SDP string to be deserialized. |
| 89 | // candidate - The cricket Candidate from the SDP string. |
| 90 | // error - The detail error information when parsing fails. |
| 91 | // return - true on success, false on failure. |
| 92 | RTC_EXPORT bool SdpDeserializeCandidate(absl::string_view transport_name, |
| 93 | absl::string_view message, |
| 94 | cricket::Candidate* candidate, |
| 95 | SdpParseError* error); |
| 96 |
| 97 | // Parses `message` according to the grammar defined in RFC 5245, Section 15.1 |
| 98 | // and, if successful, stores the result in `candidate` and returns true. |
| 99 | // If unsuccessful, returns false and stores error information in `error` if |
| 100 | // `error` is not null. |
| 101 | // If `is_raw` is false, `message` is expected to be prefixed with "a=". |
| 102 | // If `is_raw` is true, no prefix is expected in `messaage`. |
| 103 | RTC_EXPORT bool ParseCandidate(absl::string_view message, |
| 104 | cricket::Candidate* candidate, |
| 105 | SdpParseError* error, |
| 106 | bool is_raw); |
| 107 |
| 108 | // Generates an FMTP line based on `parameters`. Please note that some |
| 109 | // parameters are not considered to be part of the FMTP line, see the function |
| 110 | // IsFmtpParam(). Returns true if the set of FMTP parameters is nonempty, false |
| 111 | // otherwise. |
| 112 | bool WriteFmtpParameters(const webrtc::CodecParameterMap& parameters, |
| 113 | rtc::StringBuilder* os); |
| 114 |
| 115 | } // namespace webrtc |
| 116 |
| 117 | #endif // PC_WEBRTC_SDP_H_ |
| 118 |