1 /* 2 * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 * 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. 9 */ 10 11 #ifndef PC_SDP_SERIALIZER_H_ 12 #define PC_SDP_SERIALIZER_H_ 13 14 #include <string> 15 16 #include "absl/strings/string_view.h" 17 #include "api/rtc_error.h" 18 #include "media/base/rid_description.h" 19 #include "pc/session_description.h" 20 #include "pc/simulcast_description.h" 21 22 namespace webrtc { 23 24 // This class should serialize components of the SDP (and not the SDP itself). 25 // Example: 26 // SimulcastDescription can be serialized and deserialized by this class. 27 // The serializer will know how to translate the data to spec-compliant 28 // format without knowing about the SDP attribute details (a=simulcast:) 29 // Usage: 30 // Consider the SDP attribute for simulcast a=simulcast:<configuration>. 31 // The SDP serializtion code (webrtcsdp.h) should use |SdpSerializer| to 32 // serialize and deserialize the <configuration> section. 33 // This class will allow testing the serialization of components without 34 // having to serialize the entire SDP while hiding implementation details 35 // from callers of sdp serialization (webrtcsdp.h). 36 class SdpSerializer { 37 public: 38 // Serialization for the Simulcast description according to 39 // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1 40 std::string SerializeSimulcastDescription( 41 const cricket::SimulcastDescription& simulcast) const; 42 43 // Deserialization for the SimulcastDescription according to 44 // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1 45 RTCErrorOr<cricket::SimulcastDescription> DeserializeSimulcastDescription( 46 absl::string_view string) const; 47 48 // Serialization for the RID description according to 49 // https://tools.ietf.org/html/draft-ietf-mmusic-rid-15#section-10 50 std::string SerializeRidDescription( 51 const cricket::RidDescription& rid_description) const; 52 53 // Deserialization for the RidDescription according to 54 // https://tools.ietf.org/html/draft-ietf-mmusic-rid-15#section-10 55 RTCErrorOr<cricket::RidDescription> DeserializeRidDescription( 56 absl::string_view string) const; 57 }; 58 59 } // namespace webrtc 60 61 #endif // PC_SDP_SERIALIZER_H_ 62