blob: 476ebafbdcf101be84d87d3a8bd676f8ea48e36c [file] [log] [blame]
Amit Hilbucha2012042018-12-03 11:35:05 -08001/*
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
Steve Anton10542f22019-01-11 09:11:00 -080011#ifndef PC_SDP_SERIALIZER_H_
12#define PC_SDP_SERIALIZER_H_
Amit Hilbucha2012042018-12-03 11:35:05 -080013
14#include <string>
15
16#include "absl/strings/string_view.h"
Steve Anton10542f22019-01-11 09:11:00 -080017#include "api/rtc_error.h"
18#include "media/base/rid_description.h"
19#include "pc/session_description.h"
Amit Hilbucha2012042018-12-03 11:35:05 -080020
21namespace webrtc {
22
23// This class should serialize components of the SDP (and not the SDP itself).
24// Example:
25// SimulcastDescription can be serialized and deserialized by this class.
26// The serializer will know how to translate the data to spec-compliant
27// format without knowing about the SDP attribute details (a=simulcast:)
28// Usage:
29// Consider the SDP attribute for simulcast a=simulcast:<configuration>.
30// The SDP serializtion code (webrtcsdp.h) should use |SdpSerializer| to
31// serialize and deserialize the <configuration> section.
32// This class will allow testing the serialization of components without
33// having to serialize the entire SDP while hiding implementation details
34// from callers of sdp serialization (webrtcsdp.h).
35class SdpSerializer {
36 public:
37 // Serialization for the Simulcast description according to
38 // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1
39 std::string SerializeSimulcastDescription(
40 const cricket::SimulcastDescription& simulcast) const;
41
42 // Deserialization for the SimulcastDescription according to
43 // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1
44 RTCErrorOr<cricket::SimulcastDescription> DeserializeSimulcastDescription(
45 absl::string_view string) const;
Amit Hilbuchc57d5732018-12-11 15:30:11 -080046
47 // Serialization for the RID description according to
48 // https://tools.ietf.org/html/draft-ietf-mmusic-rid-15#section-10
49 std::string SerializeRidDescription(
50 const cricket::RidDescription& rid_description) const;
51
52 // Deserialization for the RidDescription according to
53 // https://tools.ietf.org/html/draft-ietf-mmusic-rid-15#section-10
54 RTCErrorOr<cricket::RidDescription> DeserializeRidDescription(
55 absl::string_view string) const;
Amit Hilbucha2012042018-12-03 11:35:05 -080056};
57
58} // namespace webrtc
59
Steve Anton10542f22019-01-11 09:11:00 -080060#endif // PC_SDP_SERIALIZER_H_