jsep_unittest.cc (2062B)
1 /* 2 * Copyright 2024 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 11 #include "api/jsep.h" 12 13 #include <memory> 14 #include <string> 15 16 #include "absl/strings/str_cat.h" 17 #include "rtc_base/logging.h" 18 #include "test/gmock.h" 19 #include "test/gtest.h" 20 21 namespace webrtc { 22 23 using ::testing::HasSubstr; 24 25 TEST(JsepTest, AbslStringifySdp) { 26 std::string sdp = 27 "v=0\r\n" 28 "o=- 0 3 IN IP4 127.0.0.1\r\n" 29 "s=-\r\n" 30 "t=0 0\r\n" 31 "a=group:BUNDLE 0 1\r\n" 32 "a=fingerprint:sha-1 " 33 "4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB\r\n" 34 "a=setup:actpass\r\n" 35 "a=ice-ufrag:ETEn\r\n" 36 "a=ice-pwd:OtSK0WpNtpUjkY4+86js7Z/l\r\n" 37 "m=audio 9 UDP/TLS/RTP/SAVPF 111\r\n" 38 "c=IN IP4 0.0.0.0\r\n" 39 "a=rtcp-mux\r\n" 40 "a=sendonly\r\n" 41 "a=mid:0\r\n" 42 "a=rtpmap:111 opus/48000/2\r\n" 43 "m=video 9 UDP/TLS/RTP/SAVPF 111\r\n" 44 "c=IN IP4 0.0.0.0\r\n" 45 "a=rtcp-mux\r\n" 46 "a=sendonly\r\n" 47 "a=mid:1\r\n" 48 "a=rtpmap:111 H264/90000\r\n" 49 "a=fmtp:111 " 50 "level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=" 51 "42e01f\r\n"; 52 53 std::unique_ptr<SessionDescriptionInterface> some_sdp = 54 CreateSessionDescription(SdpType::kOffer, sdp); 55 // Verify that sending the SDP to the log compiles. 56 RTC_LOG(LS_VERBOSE) << "The SDP is " << *some_sdp; 57 // Since create/stringify mangles order of fields, we only test 58 // some substrings. 59 EXPECT_THAT(absl::StrCat(*some_sdp), HasSubstr("a=rtpmap:111 opus/48000")); 60 EXPECT_THAT( 61 absl::StrCat(*some_sdp), 62 HasSubstr( 63 "a=fingerprint:sha-1 " 64 "4A:AD:B9:B1:3F:82:18:3B:54:02:12:DF:3E:5D:49:6B:19:E5:7C:AB\r\n")); 65 } 66 67 } // namespace webrtc