sdp_serializer.h 2.4 KB

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