Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Unified Diff: remoting/protocol/sdp_helper_unittest.cc

Issue 2536623003: Add SdpHelper for more reliable codec configuration in WebrtcTransport. (Closed)
Patch Set: . Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/sdp_helper_unittest.cc
diff --git a/remoting/protocol/sdp_helper_unittest.cc b/remoting/protocol/sdp_helper_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e22ebeac837a2094c28fb2cef22074af65576314
--- /dev/null
+++ b/remoting/protocol/sdp_helper_unittest.cc
@@ -0,0 +1,53 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/protocol/sdp_helper.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace remoting {
+namespace protocol {
+
+// Verify that SDP is normalized by removing empty lines and normalizing
+// line-endings to \n.
+TEST(SdpHelpers, Normalize) {
+ SdpHelper sdp_helper("a=foo\n\r\nb=bar");
+ EXPECT_EQ("a=foo\nb=bar\n", sdp_helper.ToString());
+}
+
+TEST(SdpHelpers, AddCodecParameter) {
+ std::string kSourceSdp =
+ "a=group:BUNDLE video\n"
+ "m=video 9 UDP/TLS/RTP/SAVPF 96\n"
+ "a=rtpmap:96 VP8/90000\n"
+ "a=rtcp-fb:96 transport-cc\n";
+ SdpHelper sdp_helper(kSourceSdp);
+ EXPECT_TRUE(sdp_helper.AddCodecParameter("VP8", "test_param=1"));
+ EXPECT_EQ(
+ "a=group:BUNDLE video\n"
+ "m=video 9 UDP/TLS/RTP/SAVPF 96\n"
+ "a=rtpmap:96 VP8/90000\n"
+ "a=fmtp:96 test_param=1\n"
+ "a=rtcp-fb:96 transport-cc\n",
+ sdp_helper.ToString());
+}
+
+TEST(SdpHelpers, AddCodecParameterMissingCodec) {
+ std::string kSourceSdp =
+ "a=group:BUNDLE audio video\n"
+ "m=audio 9 UDP/TLS/RTP/SAVPF 111\n"
+ "a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\n"
+ "a=rtpmap:111 opus/48000/2\n"
+ "a=rtcp-fb:111 transport-cc\n"
+ "m=video 9 UDP/TLS/RTP/SAVPF 96\n"
+ "a=rtpmap:96 VP9/90000\n"
+ "a=rtcp-fb:96 transport-cc\n"
+ "m=application 9 DTLS/SCTP 5000\n";
+ SdpHelper sdp_helper(kSourceSdp);
+ EXPECT_FALSE(sdp_helper.AddCodecParameter("VP8", "test_param=1"));
+ EXPECT_EQ(kSourceSdp, sdp_helper.ToString());
+}
+
+} // namespace protocol
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698