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