Rename simulcast SDP serializer

which is not a generic SDP serializer but only deals with the
simulcast SDP.

BUG=None

Change-Id: I6bed6ada28ad5b96f07fd7670ad3d635bd4bc732
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/320280
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40761}
This commit is contained in:
Philipp Hancke 2023-09-14 17:23:59 +02:00 committed by WebRTC LUCI CQ
parent 17304c3bf8
commit 96bc094d38
5 changed files with 30 additions and 29 deletions

View file

@ -764,11 +764,11 @@ rtc_source_set("peerconnection") {
":rtp_transmission_manager", ":rtp_transmission_manager",
":sctp_data_channel", ":sctp_data_channel",
":sdp_offer_answer", ":sdp_offer_answer",
":sdp_serializer",
":sdp_state_provider", ":sdp_state_provider",
":sdp_utils", ":sdp_utils",
":session_description", ":session_description",
":simulcast_description", ":simulcast_description",
":simulcast_sdp_serializer",
":stream_collection", ":stream_collection",
":track_media_info_map", ":track_media_info_map",
":transceiver_list", ":transceiver_list",
@ -1259,11 +1259,11 @@ rtc_source_set("peer_connection") {
] ]
} }
rtc_source_set("sdp_serializer") { rtc_source_set("simulcast_sdp_serializer") {
visibility = [ ":*" ] visibility = [ ":*" ]
sources = [ sources = [
"sdp_serializer.cc", "simulcast_sdp_serializer.cc",
"sdp_serializer.h", "simulcast_sdp_serializer.h",
] ]
deps = [ deps = [
":session_description", ":session_description",
@ -1383,9 +1383,9 @@ rtc_source_set("webrtc_sdp") {
deps = [ deps = [
":media_protocol_names", ":media_protocol_names",
":media_session", ":media_session",
":sdp_serializer",
":session_description", ":session_description",
":simulcast_description", ":simulcast_description",
":simulcast_sdp_serializer",
"../api:candidate", "../api:candidate",
"../api:libjingle_peerconnection_api", "../api:libjingle_peerconnection_api",
"../api:rtc_error", "../api:rtc_error",
@ -2341,7 +2341,7 @@ if (rtc_include_tests && !build_with_chromium) {
"rtp_transceiver_unittest.cc", "rtp_transceiver_unittest.cc",
"sctp_utils_unittest.cc", "sctp_utils_unittest.cc",
"sdp_offer_answer_unittest.cc", "sdp_offer_answer_unittest.cc",
"sdp_serializer_unittest.cc", "simulcast_sdp_serializer_unittest.cc",
"test/fake_audio_capture_module_unittest.cc", "test/fake_audio_capture_module_unittest.cc",
"test/test_sdp_strings.h", "test/test_sdp_strings.h",
"track_media_info_map_unittest.cc", "track_media_info_map_unittest.cc",
@ -2383,10 +2383,10 @@ if (rtc_include_tests && !build_with_chromium) {
":sctp_data_channel", ":sctp_data_channel",
":sctp_transport", ":sctp_transport",
":sctp_utils", ":sctp_utils",
":sdp_serializer",
":sdp_utils", ":sdp_utils",
":session_description", ":session_description",
":simulcast_description", ":simulcast_description",
":simulcast_sdp_serializer",
":stream_collection", ":stream_collection",
":track_media_info_map", ":track_media_info_map",
":transport_stats", ":transport_stats",

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "pc/sdp_serializer.h" #include "pc/simulcast_sdp_serializer.h"
#include <map> #include <map>
#include <string> #include <string>
@ -181,7 +181,7 @@ webrtc::RTCError ParseRidPayloadList(const std::string& payload_list,
} // namespace } // namespace
std::string SdpSerializer::SerializeSimulcastDescription( std::string SimulcastSdpSerializer::SerializeSimulcastDescription(
const cricket::SimulcastDescription& simulcast) const { const cricket::SimulcastDescription& simulcast) const {
rtc::StringBuilder sb; rtc::StringBuilder sb;
std::string delimiter; std::string delimiter;
@ -210,7 +210,8 @@ std::string SdpSerializer::SerializeSimulcastDescription(
// sc-id-paused = "~" // sc-id-paused = "~"
// sc-id = [sc-id-paused] rid-id // sc-id = [sc-id-paused] rid-id
// rid-id = 1*(alpha-numeric / "-" / "_") ; see: I-D.ietf-mmusic-rid // rid-id = 1*(alpha-numeric / "-" / "_") ; see: I-D.ietf-mmusic-rid
RTCErrorOr<SimulcastDescription> SdpSerializer::DeserializeSimulcastDescription( RTCErrorOr<SimulcastDescription>
SimulcastSdpSerializer::DeserializeSimulcastDescription(
absl::string_view string) const { absl::string_view string) const {
std::vector<std::string> tokens; std::vector<std::string> tokens;
rtc::tokenize(std::string(string), kDelimiterSpaceChar, &tokens); rtc::tokenize(std::string(string), kDelimiterSpaceChar, &tokens);
@ -264,7 +265,7 @@ RTCErrorOr<SimulcastDescription> SdpSerializer::DeserializeSimulcastDescription(
return std::move(simulcast); return std::move(simulcast);
} }
std::string SdpSerializer::SerializeRidDescription( std::string SimulcastSdpSerializer::SerializeRidDescription(
const RidDescription& rid_description) const { const RidDescription& rid_description) const {
RTC_DCHECK(!rid_description.rid.empty()); RTC_DCHECK(!rid_description.rid.empty());
RTC_DCHECK(rid_description.direction == RidDirection::kSend || RTC_DCHECK(rid_description.direction == RidDirection::kSend ||
@ -319,7 +320,7 @@ std::string SdpSerializer::SerializeRidDescription(
// rid-param = 1*(alpha-numeric / "-") [ "=" param-val ] // rid-param = 1*(alpha-numeric / "-") [ "=" param-val ]
// param-val = *( %x20-58 / %x60-7E ) // param-val = *( %x20-58 / %x60-7E )
// ; Any printable character except semicolon // ; Any printable character except semicolon
RTCErrorOr<RidDescription> SdpSerializer::DeserializeRidDescription( RTCErrorOr<RidDescription> SimulcastSdpSerializer::DeserializeRidDescription(
absl::string_view string) const { absl::string_view string) const {
std::vector<std::string> tokens; std::vector<std::string> tokens;
rtc::tokenize(std::string(string), kDelimiterSpaceChar, &tokens); rtc::tokenize(std::string(string), kDelimiterSpaceChar, &tokens);

View file

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef PC_SDP_SERIALIZER_H_ #ifndef PC_SIMULCAST_SDP_SERIALIZER_H_
#define PC_SDP_SERIALIZER_H_ #define PC_SIMULCAST_SDP_SERIALIZER_H_
#include <string> #include <string>
@ -21,19 +21,19 @@
namespace webrtc { namespace webrtc {
// This class should serialize components of the SDP (and not the SDP itself). // This class serializes simulcast components of the SDP.
// Example: // Example:
// SimulcastDescription can be serialized and deserialized by this class. // SimulcastDescription can be serialized and deserialized by this class.
// The serializer will know how to translate the data to spec-compliant // The serializer will know how to translate the data to spec-compliant
// format without knowing about the SDP attribute details (a=simulcast:) // format without knowing about the SDP attribute details (a=simulcast:)
// Usage: // Usage:
// Consider the SDP attribute for simulcast a=simulcast:<configuration>. // Consider the SDP attribute for simulcast a=simulcast:<configuration>.
// The SDP serializtion code (webrtcsdp.h) should use `SdpSerializer` to // The SDP serializtion code (webrtc_sdp.h) should use `SdpSerializer` to
// serialize and deserialize the <configuration> section. // serialize and deserialize the <configuration> section.
// This class will allow testing the serialization of components without // This class will allow testing the serialization of components without
// having to serialize the entire SDP while hiding implementation details // having to serialize the entire SDP while hiding implementation details
// from callers of sdp serialization (webrtcsdp.h). // from callers of sdp serialization (webrtc_sdp.h).
class SdpSerializer { class SimulcastSdpSerializer {
public: public:
// Serialization for the Simulcast description according to // Serialization for the Simulcast description according to
// https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1 // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-13#section-5.1
@ -58,4 +58,4 @@ class SdpSerializer {
} // namespace webrtc } // namespace webrtc
#endif // PC_SDP_SERIALIZER_H_ #endif // PC_SIMULCAST_SDP_SERIALIZER_H_

View file

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "pc/sdp_serializer.h" #include "pc/simulcast_sdp_serializer.h"
#include <stddef.h> #include <stddef.h>
@ -102,7 +102,7 @@ class SimulcastSdpSerializerTest : public TestWithParam<const char*> {
// `expected` - The expected output Simulcast to compare to. // `expected` - The expected output Simulcast to compare to.
void TestDeserialization(const std::string& str, void TestDeserialization(const std::string& str,
const SimulcastDescription& expected) const { const SimulcastDescription& expected) const {
SdpSerializer deserializer; SimulcastSdpSerializer deserializer;
auto result = deserializer.DeserializeSimulcastDescription(str); auto result = deserializer.DeserializeSimulcastDescription(str);
EXPECT_TRUE(result.ok()); EXPECT_TRUE(result.ok());
ExpectEqual(expected, result.value()); ExpectEqual(expected, result.value());
@ -113,7 +113,7 @@ class SimulcastSdpSerializerTest : public TestWithParam<const char*> {
// `expected` - The expected output string to compare to. // `expected` - The expected output string to compare to.
void TestSerialization(const SimulcastDescription& simulcast, void TestSerialization(const SimulcastDescription& simulcast,
const std::string& expected) const { const std::string& expected) const {
SdpSerializer serializer; SimulcastSdpSerializer serializer;
auto result = serializer.SerializeSimulcastDescription(simulcast); auto result = serializer.SerializeSimulcastDescription(simulcast);
EXPECT_EQ(expected, result); EXPECT_EQ(expected, result);
} }
@ -214,7 +214,7 @@ TEST_F(SimulcastSdpSerializerTest, Deserialize_PausedStreams) {
// Parameterized negative test case for deserialization with invalid inputs. // Parameterized negative test case for deserialization with invalid inputs.
TEST_P(SimulcastSdpSerializerTest, SimulcastDeserializationFailed) { TEST_P(SimulcastSdpSerializerTest, SimulcastDeserializationFailed) {
SdpSerializer deserializer; SimulcastSdpSerializer deserializer;
auto result = deserializer.DeserializeSimulcastDescription(GetParam()); auto result = deserializer.DeserializeSimulcastDescription(GetParam());
EXPECT_FALSE(result.ok()); EXPECT_FALSE(result.ok());
} }
@ -286,7 +286,7 @@ class RidDescriptionSdpSerializerTest : public TestWithParam<const char*> {
// `expected` - The expected output RidDescription to compare to. // `expected` - The expected output RidDescription to compare to.
void TestDeserialization(const std::string& str, void TestDeserialization(const std::string& str,
const RidDescription& expected) const { const RidDescription& expected) const {
SdpSerializer deserializer; SimulcastSdpSerializer deserializer;
auto result = deserializer.DeserializeRidDescription(str); auto result = deserializer.DeserializeRidDescription(str);
EXPECT_TRUE(result.ok()); EXPECT_TRUE(result.ok());
ExpectEqual(expected, result.value()); ExpectEqual(expected, result.value());
@ -297,7 +297,7 @@ class RidDescriptionSdpSerializerTest : public TestWithParam<const char*> {
// `expected` - The expected output string to compare to. // `expected` - The expected output string to compare to.
void TestSerialization(const RidDescription& rid_description, void TestSerialization(const RidDescription& rid_description,
const std::string& expected) const { const std::string& expected) const {
SdpSerializer serializer; SimulcastSdpSerializer serializer;
auto result = serializer.SerializeRidDescription(rid_description); auto result = serializer.SerializeRidDescription(rid_description);
EXPECT_EQ(expected, result); EXPECT_EQ(expected, result);
} }
@ -447,7 +447,7 @@ TEST_F(RidDescriptionSdpSerializerTest, Deserialize_AmbiguousCase) {
// Parameterized negative test case for deserialization with invalid inputs. // Parameterized negative test case for deserialization with invalid inputs.
TEST_P(RidDescriptionSdpSerializerTest, RidDescriptionDeserializationFailed) { TEST_P(RidDescriptionSdpSerializerTest, RidDescriptionDeserializationFailed) {
SdpSerializer deserializer; SimulcastSdpSerializer deserializer;
auto result = deserializer.DeserializeRidDescription(GetParam()); auto result = deserializer.DeserializeRidDescription(GetParam());
EXPECT_FALSE(result.ok()); EXPECT_FALSE(result.ok());
} }

View file

@ -54,9 +54,9 @@
#include "p2p/base/transport_info.h" #include "p2p/base/transport_info.h"
#include "pc/media_protocol_names.h" #include "pc/media_protocol_names.h"
#include "pc/media_session.h" #include "pc/media_session.h"
#include "pc/sdp_serializer.h"
#include "pc/session_description.h" #include "pc/session_description.h"
#include "pc/simulcast_description.h" #include "pc/simulcast_description.h"
#include "pc/simulcast_sdp_serializer.h"
#include "rtc_base/arraysize.h" #include "rtc_base/arraysize.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/helpers.h" #include "rtc_base/helpers.h"
@ -1601,7 +1601,7 @@ void BuildRtpContentAttributes(const MediaContentDescription* media_desc,
const cricket::MediaType media_type, const cricket::MediaType media_type,
int msid_signaling, int msid_signaling,
std::string* message) { std::string* message) {
SdpSerializer serializer; SimulcastSdpSerializer serializer;
rtc::StringBuilder os; rtc::StringBuilder os;
// RFC 8285 // RFC 8285
// a=extmap-allow-mixed // a=extmap-allow-mixed
@ -3049,7 +3049,7 @@ bool ParseContent(absl::string_view message,
std::string ptime_as_string; std::string ptime_as_string;
std::vector<std::string> stream_ids; std::vector<std::string> stream_ids;
std::string track_id; std::string track_id;
SdpSerializer deserializer; SimulcastSdpSerializer deserializer;
std::vector<RidDescription> rids; std::vector<RidDescription> rids;
SimulcastDescription simulcast; SimulcastDescription simulcast;