From a2cf57a24d3bcbb2c6e6409ffe2d1980d28dec78 Mon Sep 17 00:00:00 2001 From: Byron Campen Date: Wed, 17 Sep 2014 09:52:26 -0700 Subject: [PATCH 1/9] Skeleton unit tests --- .../signaling/test/jsep_session_unittest.cpp | 33 +++++++++++++++++++ media/webrtc/signaling/test/moz.build | 4 ++- media/webrtc/signaling/test/sdp_unittests.cpp | 12 +++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 media/webrtc/signaling/test/jsep_session_unittest.cpp diff --git a/media/webrtc/signaling/test/jsep_session_unittest.cpp b/media/webrtc/signaling/test/jsep_session_unittest.cpp new file mode 100644 index 0000000000000..9183e2db7d4e5 --- /dev/null +++ b/media/webrtc/signaling/test/jsep_session_unittest.cpp @@ -0,0 +1,33 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#define GTEST_HAS_RTTI 0 +#include "gtest/gtest.h" +#include "gtest_utils.h" + +#include "signaling/src/jsep/JsepSession.h" +#include "signaling/src/sdp/SdpParser.h" + +using mozilla::JsepSession; +using mozilla::SdpParser; + +namespace test { +class JsepSessionTest : public ::testing::Test { + public: + JsepSessionTest() {} + + JsepSession session_; + SdpParser parser_; +}; + +TEST_F(JsepSessionTest, CreateDestroy) { +} + +} // namespace test + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + diff --git a/media/webrtc/signaling/test/moz.build b/media/webrtc/signaling/test/moz.build index 73a15d6ec0d17..0e22f13c08ddc 100644 --- a/media/webrtc/signaling/test/moz.build +++ b/media/webrtc/signaling/test/moz.build @@ -6,9 +6,10 @@ if CONFIG['OS_TARGET'] != 'WINNT' and CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk': CppUnitTests([ + 'jsep_session_unittest', # 'mediaconduit_unittests', # 'mediapipeline_unittest', -# 'sdp_unittests', + 'sdp_unittests', # 'signaling_unittests', ]) @@ -39,6 +40,7 @@ LOCAL_INCLUDES += [ '/media/mtransport/third_party/nrappkit/src/stats', '/media/mtransport/third_party/nrappkit/src/util/libekr', '/media/webrtc/signaling/include', + '/media/webrtc/signaling/src', '/media/webrtc/signaling/src/common/browser_logging', '/media/webrtc/signaling/src/common/time_profiling', '/media/webrtc/signaling/src/media', diff --git a/media/webrtc/signaling/test/sdp_unittests.cpp b/media/webrtc/signaling/test/sdp_unittests.cpp index 3ae213d303aa5..6858b8121aafd 100644 --- a/media/webrtc/signaling/test/sdp_unittests.cpp +++ b/media/webrtc/signaling/test/sdp_unittests.cpp @@ -26,6 +26,8 @@ MtransportTestUtils *test_utils; nsCOMPtr gThread; +#include "signaling/src/sdp/SdpParser.h" + extern "C" { #include "sdp.h" #include "sdp_private.h" @@ -810,6 +812,16 @@ TEST_F(SdpTest, parseIceLite) { SDP_SESSION_LEVEL, 0)); } +class NewSdpTest : public ::testing::Test { + public: + NewSdpTest() {} + + mozilla::SdpParser parser_; +}; + +TEST_F(NewSdpTest, CreateDestroy) { +} + } // End namespace test. int main(int argc, char **argv) { From 646d12835dcc93b572cfc8463181870594034397 Mon Sep 17 00:00:00 2001 From: Byron Campen Date: Wed, 17 Sep 2014 10:03:36 -0700 Subject: [PATCH 2/9] Fixup include path --- media/webrtc/signaling/test/moz.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/webrtc/signaling/test/moz.build b/media/webrtc/signaling/test/moz.build index 0e22f13c08ddc..5c9ed654a7f9f 100644 --- a/media/webrtc/signaling/test/moz.build +++ b/media/webrtc/signaling/test/moz.build @@ -39,8 +39,8 @@ LOCAL_INCLUDES += [ '/media/mtransport/third_party/nrappkit/src/share', '/media/mtransport/third_party/nrappkit/src/stats', '/media/mtransport/third_party/nrappkit/src/util/libekr', + '/media/webrtc', '/media/webrtc/signaling/include', - '/media/webrtc/signaling/src', '/media/webrtc/signaling/src/common/browser_logging', '/media/webrtc/signaling/src/common/time_profiling', '/media/webrtc/signaling/src/media', From 0e5fefac0502e7cc71b4fc84603023647d323bcc Mon Sep 17 00:00:00 2001 From: Byron Campen Date: Wed, 17 Sep 2014 10:19:41 -0700 Subject: [PATCH 3/9] Convention change. --- media/webrtc/signaling/test/jsep_session_unittest.cpp | 4 ++-- media/webrtc/signaling/test/sdp_unittests.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/media/webrtc/signaling/test/jsep_session_unittest.cpp b/media/webrtc/signaling/test/jsep_session_unittest.cpp index 9183e2db7d4e5..21e6c402fb904 100644 --- a/media/webrtc/signaling/test/jsep_session_unittest.cpp +++ b/media/webrtc/signaling/test/jsep_session_unittest.cpp @@ -17,8 +17,8 @@ class JsepSessionTest : public ::testing::Test { public: JsepSessionTest() {} - JsepSession session_; - SdpParser parser_; + JsepSession mSession; + SdpParser mParser; }; TEST_F(JsepSessionTest, CreateDestroy) { diff --git a/media/webrtc/signaling/test/sdp_unittests.cpp b/media/webrtc/signaling/test/sdp_unittests.cpp index 6858b8121aafd..71517685c505b 100644 --- a/media/webrtc/signaling/test/sdp_unittests.cpp +++ b/media/webrtc/signaling/test/sdp_unittests.cpp @@ -33,6 +33,9 @@ extern "C" { #include "sdp_private.h" } +using mozilla::SdpParser; +using mozilla::Sdp; + namespace test { static bool SetupGlobalThread() { @@ -816,7 +819,7 @@ class NewSdpTest : public ::testing::Test { public: NewSdpTest() {} - mozilla::SdpParser parser_; + SdpParser mParser; }; TEST_F(NewSdpTest, CreateDestroy) { From a7cadad8b7415be6a9a66b54391d56fef25fedb0 Mon Sep 17 00:00:00 2001 From: Byron Campen Date: Wed, 17 Sep 2014 10:41:55 -0700 Subject: [PATCH 4/9] A little fleshing out, trying to make similar to existing sdp test fixture. --- media/webrtc/signaling/test/sdp_unittests.cpp | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/media/webrtc/signaling/test/sdp_unittests.cpp b/media/webrtc/signaling/test/sdp_unittests.cpp index 71517685c505b..675bd746a55fc 100644 --- a/media/webrtc/signaling/test/sdp_unittests.cpp +++ b/media/webrtc/signaling/test/sdp_unittests.cpp @@ -26,7 +26,7 @@ MtransportTestUtils *test_utils; nsCOMPtr gThread; -#include "signaling/src/sdp/SdpParser.h" +#include "signaling/src/sdp/SipccSdpParser.h" extern "C" { #include "sdp.h" @@ -819,12 +819,32 @@ class NewSdpTest : public ::testing::Test { public: NewSdpTest() {} - SdpParser mParser; + void ParseSdp(const std::string &sdp) { + mSdp = mozilla::Move(mParser.Parse(sdp)); + } + + SipccSdpParser mParser; + mozilla::UniquePtr mSdp; }; TEST_F(NewSdpTest, CreateDestroy) { } +TEST_F(NewSdpTest, ParseEmpty) { + ParseSdp(""); + ASSERT_FALSE(mSdp); +} + +TEST_F(NewSdpTest, ParseGarbage) { + ParseSdp("foobajooba"); + ASSERT_FALSE(mSdp); +} + +TEST_F(NewSdpTest, ParseMinimal) { + ParseSdp(kVideoSdp); + ASSERT_TRUE(mSdp); +} + } // End namespace test. int main(int argc, char **argv) { From 73a431bbe91fd3911fcbacf50a58ea2cc20eb549 Mon Sep 17 00:00:00 2001 From: Byron Campen Date: Wed, 17 Sep 2014 13:07:17 -0700 Subject: [PATCH 5/9] More fleshing out of unit test code. --- .../signaling/test/jsep_session_unittest.cpp | 8 +- media/webrtc/signaling/test/sdp_unittests.cpp | 151 +++++++++++++++++- 2 files changed, 152 insertions(+), 7 deletions(-) diff --git a/media/webrtc/signaling/test/jsep_session_unittest.cpp b/media/webrtc/signaling/test/jsep_session_unittest.cpp index 21e6c402fb904..8747408a1fb6a 100644 --- a/media/webrtc/signaling/test/jsep_session_unittest.cpp +++ b/media/webrtc/signaling/test/jsep_session_unittest.cpp @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -7,10 +9,10 @@ #include "gtest_utils.h" #include "signaling/src/jsep/JsepSession.h" -#include "signaling/src/sdp/SdpParser.h" +#include "signaling/src/sdp/SipccSdpParser.h" using mozilla::JsepSession; -using mozilla::SdpParser; +using mozilla::SipccSdpParser; namespace test { class JsepSessionTest : public ::testing::Test { @@ -18,7 +20,7 @@ class JsepSessionTest : public ::testing::Test { JsepSessionTest() {} JsepSession mSession; - SdpParser mParser; + SipccSdpParser mParser; }; TEST_F(JsepSessionTest, CreateDestroy) { diff --git a/media/webrtc/signaling/test/sdp_unittests.cpp b/media/webrtc/signaling/test/sdp_unittests.cpp index 675bd746a55fc..05ea90c23317e 100644 --- a/media/webrtc/signaling/test/sdp_unittests.cpp +++ b/media/webrtc/signaling/test/sdp_unittests.cpp @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -33,8 +35,9 @@ extern "C" { #include "sdp_private.h" } -using mozilla::SdpParser; -using mozilla::Sdp; +using mozilla::sdp::SipccSdpParser; +using mozilla::sdp::Sdp; +using mozilla::sdp::AttributeType; namespace test { @@ -842,8 +845,148 @@ TEST_F(NewSdpTest, ParseGarbage) { TEST_F(NewSdpTest, ParseMinimal) { ParseSdp(kVideoSdp); - ASSERT_TRUE(mSdp); -} + ASSERT_TRUE(mSdp) << "Parse failed: " << mParser.GetErrorsAsStream(); +} + +// SDP from a basic A/V apprtc call FFX/FFX +const std::string kBasicAudioVideoOffer = +"v=0\r\n" +"o=Mozilla-SIPUA-35.0a1 5184 0 IN IP4 0.0.0.0\r\n" +"s=SIP Call\r\n" +"t=0 0\r\n" +"a=ice-ufrag:4a799b2e\r\n" +"a=ice-pwd:e4cc12a910f106a0a744719425510e17\r\n" +"a=fingerprint:sha-256 DF:2E:AC:8A:FD:0A:8E:99:BF:5D:E8:3C:E7:FA:FB:08:3B:3C:54:1D:D7:D4:05:77:A0:72:9B:14:08:6D:0F:4C\r\n" +"m=audio 9 RTP/SAVPF 109 9 0 8 101\r\n" +"c=IN IP4 0.0.0.0\r\n" +"a=rtpmap:109 opus/48000/2\r\n" +"a=ptime:20\r\n" +"a=rtpmap:9 G722/8000\r\n" +"a=rtpmap:0 PCMU/8000\r\n" +"a=rtpmap:8 PCMA/8000\r\n" +"a=rtpmap:101 telephone-event/8000\r\n" +"a=fmtp:101 0-15\r\n" +"a=sendrecv\r\n" +"a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\n" +"a=setup:actpass\r\n" +"a=rtcp-mux\r\n" +"a=candidate:0 1 UDP 2130379007 10.0.0.36 62453 typ host\r\n" +"a=candidate:2 1 UDP 1694236671 24.6.134.204 62453 typ srflx raddr 10.0.0.36 rport 62453\r\n" +"a=candidate:3 1 UDP 100401151 162.222.183.171 49761 typ relay raddr 162.222.183.171 rport 49761\r\n" +"a=candidate:6 1 UDP 16515071 162.222.183.171 51858 typ relay raddr 162.222.183.171 rport 51858\r\n" +"a=candidate:3 2 UDP 100401150 162.222.183.171 62454 typ relay raddr 162.222.183.171 rport 62454\r\n" +"a=candidate:2 2 UDP 1694236670 24.6.134.204 55428 typ srflx raddr 10.0.0.36 rport 55428\r\n" +"a=candidate:6 2 UDP 16515070 162.222.183.171 50340 typ relay raddr 162.222.183.171 rport 50340\r\n" +"a=candidate:0 2 UDP 2130379006 10.0.0.36 55428 typ host\r\n" +"m=video 9 RTP/SAVPF 120\r\n" +"c=IN IP4 0.0.0.0\r\n" +"a=rtpmap:120 VP8/90000\r\n" +"a=sendrecv\r\n" +"a=rtcp-fb:120 nack\r\n" +"a=rtcp-fb:120 nack pli\r\n" +"a=rtcp-fb:120 ccm fir\r\n" +"a=setup:actpass\r\n" +"a=rtcp-mux\r\n" +"a=candidate:0 1 UDP 2130379007 10.0.0.36 59530 typ host\r\n" +"a=candidate:0 2 UDP 2130379006 10.0.0.36 64378 typ host\r\n" +"a=candidate:2 2 UDP 1694236670 24.6.134.204 64378 typ srflx raddr 10.0.0.36 rport 64378\r\n" +"a=candidate:6 2 UDP 16515070 162.222.183.171 64941 typ relay raddr 162.222.183.171 rport 64941\r\n" +"a=candidate:6 1 UDP 16515071 162.222.183.171 64800 typ relay raddr 162.222.183.171 rport 64800\r\n" +"a=candidate:2 1 UDP 1694236671 24.6.134.204 59530 typ srflx raddr 10.0.0.36 rport 59530\r\n" +"a=candidate:3 1 UDP 100401151 162.222.183.171 62935 typ relay raddr 162.222.183.171 rport 62935\r\n" +"a=candidate:3 2 UDP 100401150 162.222.183.171 61026 typ relay raddr 162.222.183.171 rport 61026\r\n"; + +TEST_F(NewSdpTest, BasicAudioVideoSdpParse) { + ParseSdp(kBasicAudioVideoOffer); + ASSERT_TRUE(mSdp) << "Parse failed: " << mParser.GetErrorsAsStream(); +} + +TEST_F(NewSdpTest, CheckIceUfrag) { + ParseSdp(kBasicAudioVideoOffer); + auto ice_ufrag = mSdp.GetIceUfrag(); + ASSERT_TRUE(ice_ufrag) << "No ice-ufrag"; + ASSERT_EQ("4a799b2e", ice_ufrag->Value()) << "Wrong ice-ufrag value"; +} + +TEST_F(NewSdpTest, CheckIcePwd) { + ParseSdp(kBasicAudioVideoOffer); + auto ice_ufrag = mSdp.GetIcePwd(); + ASSERT_TRUE(ice_pwd) << "No ice-pwd"; + ASSERT_EQ("e4cc12a910f106a0a744719425510e17", ice_pwd->Value()) << "Wrong ice-pwd value"; +} + +TEST_F(NewSdpTest, CheckFingerprint) { + ParseSdp(kBasicAudioVideoOffer); + auto fingerprint = mSdp.GetFingerprint(); + ASSERT_TRUE(fingerprint) << "No fingerprint"; + ASSERT_EQ("sha-256", ice_pwd->Algorithm()) << "Wrong algorithm"; + ASSERT_EQ("DF:2E:AC:8A:FD:0A:8E:99:BF:5D:E8:3C:E7:FA:FB:08:3B:3C:54:1D:D7:D4:05:77:A0:72:9B:14:08:6D:0F:4C", ice_pwd->Fingerprint()) << "Wrong fingerprint"; +} + +TEST_F(NewSdpTest, CheckNumberOfMediaSections) { + ParseSdp(kBasicAudioVideoOffer); + ASSERT_EQ(2, mSdp.GetMediaSectionCount()) << "Wrong number of media sections"; +} + +TEST_F(NewSdpTest, CheckMlines) { + ParseSdp(kBasicAudioVideoOffer); + ASSERT_EQ(2, mSdp.GetMediaSectionCount()) << "Wrong number of media sections"; + ASSERT_EQ("audio", mSdp.GetMediaSection(0).GetType()) + << "Wrong type for first media section"; + oSSERT_EQ("RTP/SAVPF", mSdp.GetMediaSection(0).GetProtocol()) + << "Wrong protocol for audio"; + auto audio_formats = mSdp.GetMediaSection(0).GetFormats(); + ASSERT_EQ(5, audio_formats.size()) << "Wrong number of formats for audio"; + ASSERT_EQ("109", audio_formats[0]); + ASSERT_EQ("9", audio_formats[1]); + ASSERT_EQ("0", audio_formats[2]); + ASSERT_EQ("8", audio_formats[3]); + ASSERT_EQ("101", audio_formats[4]); + + ASSERT_EQ("video", mSdp.GetMediaSection(1).GetType()) + << "Wrong type for second media section"; + oSSERT_EQ("RTP/SAVPF", mSdp.GetMediaSection(1).GetProtocol()) + << "Wrong protocol for video"; + auto video_formats = mSdp.GetMediaSection(1).GetFormats(); + ASSERT_EQ(1, video_formats.size()) << "Wrong number of formats for video"; + ASSERT_EQ("120", video_formats[0]); +} + +TEST_F(NewSdpTest, CheckRtpmap) { + ParseSdp(kBasicAudioVideoOffer); + ASSERT_EQ(2, mSdp.GetMediaSectionCount()) + << "Wrong number of media sections"; + + ASSERT_EQ(5, mSdp.GetMediaSection(0).GetNumRtpmap()) + << "Wrong number of rtpmap attributes for audio"; + + // TODO: Write a CheckRtpmap(rtpmap, payloadType, encodingName, rate) + // Need to know name of type + // CheckRtpmap("109", "opus", 48000, mSdp.GetMediaSection(0).GetRtpmap(0)); + // CheckRtpmap("9", "G722", 8000, mSdp.GetMediaSection(0).GetRtpmap(1)); + // CheckRtpmap("0", "PCMU", 8000, mSdp.GetMediaSection(0).GetRtpmap(2)); + // CheckRtpmap("8", "PCMA", 8000, mSdp.GetMediaSection(0).GetRtpmap(3)); + // CheckRtpmap("101", "telephone-event", 8000, mSdp.GetMediaSection(0).GetRtpmap(4)); + + // CheckRtpmap("120", "VP8", 90000, mSdp.GetMediaSection(0).GetRtpmap(0)); +} + +TEST_F(NewSdpTest, CheckFormatParameters) { + ParseSdp(kBasicAudioVideoOffer); + ASSERT_EQ(2, mSdp.GetMediaSectionCount()) + << "Wrong number of media sections"; + + ASSERT_EQ(1, mSdp.GetMediaSection(0).GetAttributeList().Count(kFmtp)); +} + +// TODO: Tests that parse above SDP, and check various things +// For media sections 1 and 2: +// Check fmtp +// Check direction (should be sendrecv) +// Check extmap +// Check setup +// Check rtcp-mux +// Check candidates } // End namespace test. From c28101abc231658465d867f5cd1c358d8b3d4f40 Mon Sep 17 00:00:00 2001 From: Byron Campen Date: Wed, 17 Sep 2014 13:50:18 -0700 Subject: [PATCH 6/9] Small compile fixes, and add modelines. --- media/webrtc/signaling/src/sdp/Sdp.h | 4 +++- media/webrtc/signaling/src/sdp/SdpAttribute.h | 2 ++ media/webrtc/signaling/src/sdp/SdpEnum.h | 2 ++ media/webrtc/signaling/src/sdp/SdpMediaSection.h | 2 ++ media/webrtc/signaling/src/sdp/SipccSdp.cpp | 2 ++ media/webrtc/signaling/src/sdp/SipccSdp.h | 2 ++ media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp | 2 ++ media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h | 2 ++ media/webrtc/signaling/src/sdp/SipccSdpParser.cpp | 5 ++++- media/webrtc/signaling/src/sdp/SipccSdpParser.h | 6 ++++-- 10 files changed, 25 insertions(+), 4 deletions(-) diff --git a/media/webrtc/signaling/src/sdp/Sdp.h b/media/webrtc/signaling/src/sdp/Sdp.h index a919bf8dc4e04..be9f7d6df7460 100644 --- a/media/webrtc/signaling/src/sdp/Sdp.h +++ b/media/webrtc/signaling/src/sdp/Sdp.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -52,6 +54,6 @@ class SdpOrigin virtual std::string GetAddress() const = 0; }; -} +} // namespace mozilla #endif diff --git a/media/webrtc/signaling/src/sdp/SdpAttribute.h b/media/webrtc/signaling/src/sdp/SdpAttribute.h index df15250b84d76..f62a47f167e42 100644 --- a/media/webrtc/signaling/src/sdp/SdpAttribute.h +++ b/media/webrtc/signaling/src/sdp/SdpAttribute.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/media/webrtc/signaling/src/sdp/SdpEnum.h b/media/webrtc/signaling/src/sdp/SdpEnum.h index c446bedc7e9fd..89af50823a4d9 100644 --- a/media/webrtc/signaling/src/sdp/SdpEnum.h +++ b/media/webrtc/signaling/src/sdp/SdpEnum.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/media/webrtc/signaling/src/sdp/SdpMediaSection.h b/media/webrtc/signaling/src/sdp/SdpMediaSection.h index 7e12b510c781a..b85cb685f8ed4 100644 --- a/media/webrtc/signaling/src/sdp/SdpMediaSection.h +++ b/media/webrtc/signaling/src/sdp/SdpMediaSection.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/media/webrtc/signaling/src/sdp/SipccSdp.cpp b/media/webrtc/signaling/src/sdp/SipccSdp.cpp index 34287ac4aff70..eb5736617a8b4 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdp.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdp.cpp @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/media/webrtc/signaling/src/sdp/SipccSdp.h b/media/webrtc/signaling/src/sdp/SipccSdp.h index 5878b5563e120..d4bb7289fade0 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdp.h +++ b/media/webrtc/signaling/src/sdp/SipccSdp.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp index 0a301b555e468..83006ddde7a13 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h index f062ea658b32d..f70439921b43e 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h +++ b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp b/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp index cf7890aab6282..cdb7e0cfd0531 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -57,4 +59,5 @@ sipcc_sdp_parser_error_handler(void *context, uint32_t line, const char *message } -} // namespace +} // namespace mozilla + diff --git a/media/webrtc/signaling/src/sdp/SipccSdpParser.h b/media/webrtc/signaling/src/sdp/SipccSdpParser.h index 33f766f445d4d..6593a715ba64c 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpParser.h +++ b/media/webrtc/signaling/src/sdp/SipccSdpParser.h @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -18,7 +20,7 @@ class SipccSdpParser { public: SipccSdpParser() {} - ~SdpSdpParser() {} + ~SipccSdpParser() {} /** * This parses the provided text into an SDP object. @@ -39,6 +41,6 @@ class SipccSdpParser std::vector > mErrors; }; -} +} // namespace mozilla #endif From 5bb687fddc3d0f65fdad9ec95fb9caa3b96ac691 Mon Sep 17 00:00:00 2001 From: Byron Campen Date: Wed, 17 Sep 2014 13:50:44 -0700 Subject: [PATCH 7/9] Comment out stuff that doesn't compile yet. --- .../signaling/test/jsep_session_unittest.cpp | 4 +- media/webrtc/signaling/test/sdp_unittests.cpp | 154 +++++++++--------- 2 files changed, 82 insertions(+), 76 deletions(-) diff --git a/media/webrtc/signaling/test/jsep_session_unittest.cpp b/media/webrtc/signaling/test/jsep_session_unittest.cpp index 8747408a1fb6a..c3a511453fed3 100644 --- a/media/webrtc/signaling/test/jsep_session_unittest.cpp +++ b/media/webrtc/signaling/test/jsep_session_unittest.cpp @@ -11,7 +11,7 @@ #include "signaling/src/jsep/JsepSession.h" #include "signaling/src/sdp/SipccSdpParser.h" -using mozilla::JsepSession; +//using mozilla::sdp::JsepSession; using mozilla::SipccSdpParser; namespace test { @@ -19,7 +19,7 @@ class JsepSessionTest : public ::testing::Test { public: JsepSessionTest() {} - JsepSession mSession; +// JsepSession mSession; SipccSdpParser mParser; }; diff --git a/media/webrtc/signaling/test/sdp_unittests.cpp b/media/webrtc/signaling/test/sdp_unittests.cpp index 05ea90c23317e..19ce1c0af873f 100644 --- a/media/webrtc/signaling/test/sdp_unittests.cpp +++ b/media/webrtc/signaling/test/sdp_unittests.cpp @@ -35,8 +35,8 @@ extern "C" { #include "sdp_private.h" } -using mozilla::sdp::SipccSdpParser; -using mozilla::sdp::Sdp; +using mozilla::SipccSdpParser; +using mozilla::Sdp; using mozilla::sdp::AttributeType; namespace test { @@ -836,16 +836,22 @@ TEST_F(NewSdpTest, CreateDestroy) { TEST_F(NewSdpTest, ParseEmpty) { ParseSdp(""); ASSERT_FALSE(mSdp); + ASSERT_NE(0, mParser.GetParseErrors().size()) + << "Expected at least one parse error."; } TEST_F(NewSdpTest, ParseGarbage) { ParseSdp("foobajooba"); ASSERT_FALSE(mSdp); + ASSERT_NE(0, mParser.GetParseErrors().size()) + << "Expected at least one parse error."; } TEST_F(NewSdpTest, ParseMinimal) { ParseSdp(kVideoSdp); - ASSERT_TRUE(mSdp) << "Parse failed: " << mParser.GetErrorsAsStream(); + ASSERT_TRUE(mSdp) << "Parse failed: " << mParser.GetParseErrorsAsStream(); + ASSERT_EQ(0, mParser.GetParseErrors().size()) << + "Got parse errors: " << mParser.GetParseErrors(); } // SDP from a basic A/V apprtc call FFX/FFX @@ -898,68 +904,68 @@ const std::string kBasicAudioVideoOffer = TEST_F(NewSdpTest, BasicAudioVideoSdpParse) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(mSdp) << "Parse failed: " << mParser.GetErrorsAsStream(); -} - -TEST_F(NewSdpTest, CheckIceUfrag) { - ParseSdp(kBasicAudioVideoOffer); - auto ice_ufrag = mSdp.GetIceUfrag(); - ASSERT_TRUE(ice_ufrag) << "No ice-ufrag"; - ASSERT_EQ("4a799b2e", ice_ufrag->Value()) << "Wrong ice-ufrag value"; -} - -TEST_F(NewSdpTest, CheckIcePwd) { - ParseSdp(kBasicAudioVideoOffer); - auto ice_ufrag = mSdp.GetIcePwd(); - ASSERT_TRUE(ice_pwd) << "No ice-pwd"; - ASSERT_EQ("e4cc12a910f106a0a744719425510e17", ice_pwd->Value()) << "Wrong ice-pwd value"; -} - -TEST_F(NewSdpTest, CheckFingerprint) { - ParseSdp(kBasicAudioVideoOffer); - auto fingerprint = mSdp.GetFingerprint(); - ASSERT_TRUE(fingerprint) << "No fingerprint"; - ASSERT_EQ("sha-256", ice_pwd->Algorithm()) << "Wrong algorithm"; - ASSERT_EQ("DF:2E:AC:8A:FD:0A:8E:99:BF:5D:E8:3C:E7:FA:FB:08:3B:3C:54:1D:D7:D4:05:77:A0:72:9B:14:08:6D:0F:4C", ice_pwd->Fingerprint()) << "Wrong fingerprint"; -} - -TEST_F(NewSdpTest, CheckNumberOfMediaSections) { - ParseSdp(kBasicAudioVideoOffer); - ASSERT_EQ(2, mSdp.GetMediaSectionCount()) << "Wrong number of media sections"; -} - -TEST_F(NewSdpTest, CheckMlines) { - ParseSdp(kBasicAudioVideoOffer); - ASSERT_EQ(2, mSdp.GetMediaSectionCount()) << "Wrong number of media sections"; - ASSERT_EQ("audio", mSdp.GetMediaSection(0).GetType()) - << "Wrong type for first media section"; - oSSERT_EQ("RTP/SAVPF", mSdp.GetMediaSection(0).GetProtocol()) - << "Wrong protocol for audio"; - auto audio_formats = mSdp.GetMediaSection(0).GetFormats(); - ASSERT_EQ(5, audio_formats.size()) << "Wrong number of formats for audio"; - ASSERT_EQ("109", audio_formats[0]); - ASSERT_EQ("9", audio_formats[1]); - ASSERT_EQ("0", audio_formats[2]); - ASSERT_EQ("8", audio_formats[3]); - ASSERT_EQ("101", audio_formats[4]); - - ASSERT_EQ("video", mSdp.GetMediaSection(1).GetType()) - << "Wrong type for second media section"; - oSSERT_EQ("RTP/SAVPF", mSdp.GetMediaSection(1).GetProtocol()) - << "Wrong protocol for video"; - auto video_formats = mSdp.GetMediaSection(1).GetFormats(); - ASSERT_EQ(1, video_formats.size()) << "Wrong number of formats for video"; - ASSERT_EQ("120", video_formats[0]); -} - -TEST_F(NewSdpTest, CheckRtpmap) { - ParseSdp(kBasicAudioVideoOffer); - ASSERT_EQ(2, mSdp.GetMediaSectionCount()) - << "Wrong number of media sections"; - - ASSERT_EQ(5, mSdp.GetMediaSection(0).GetNumRtpmap()) - << "Wrong number of rtpmap attributes for audio"; - + ASSERT_TRUE(mSdp) << "Parse failed: " << mParser.GetParseErrorsAsStream(); +} + +//TEST_F(NewSdpTest, CheckIceUfrag) { +// ParseSdp(kBasicAudioVideoOffer); +// auto ice_ufrag = mSdp.GetIceUfrag(); +// ASSERT_TRUE(ice_ufrag) << "No ice-ufrag"; +// ASSERT_EQ("4a799b2e", ice_ufrag->Value()) << "Wrong ice-ufrag value"; +//} + +//TEST_F(NewSdpTest, CheckIcePwd) { +// ParseSdp(kBasicAudioVideoOffer); +// auto ice_ufrag = mSdp.GetIcePwd(); +// ASSERT_TRUE(ice_pwd) << "No ice-pwd"; +// ASSERT_EQ("e4cc12a910f106a0a744719425510e17", ice_pwd->Value()) << "Wrong ice-pwd value"; +//} + +//TEST_F(NewSdpTest, CheckFingerprint) { +// ParseSdp(kBasicAudioVideoOffer); +// auto fingerprint = mSdp.GetFingerprint(); +// ASSERT_TRUE(fingerprint) << "No fingerprint"; +// ASSERT_EQ("sha-256", ice_pwd->Algorithm()) << "Wrong algorithm"; +// ASSERT_EQ("DF:2E:AC:8A:FD:0A:8E:99:BF:5D:E8:3C:E7:FA:FB:08:3B:3C:54:1D:D7:D4:05:77:A0:72:9B:14:08:6D:0F:4C", ice_pwd->Fingerprint()) << "Wrong fingerprint"; +//} + +//TEST_F(NewSdpTest, CheckNumberOfMediaSections) { +// ParseSdp(kBasicAudioVideoOffer); +// ASSERT_EQ(2, mSdp.GetMediaSectionCount()) << "Wrong number of media sections"; +//} + +//TEST_F(NewSdpTest, CheckMlines) { +// ParseSdp(kBasicAudioVideoOffer); +// ASSERT_EQ(2, mSdp.GetMediaSectionCount()) << "Wrong number of media sections"; +// ASSERT_EQ("audio", mSdp.GetMediaSection(0).GetType()) +// << "Wrong type for first media section"; +// oSSERT_EQ("RTP/SAVPF", mSdp.GetMediaSection(0).GetProtocol()) +// << "Wrong protocol for audio"; +// auto audio_formats = mSdp.GetMediaSection(0).GetFormats(); +// ASSERT_EQ(5, audio_formats.size()) << "Wrong number of formats for audio"; +// ASSERT_EQ("109", audio_formats[0]); +// ASSERT_EQ("9", audio_formats[1]); +// ASSERT_EQ("0", audio_formats[2]); +// ASSERT_EQ("8", audio_formats[3]); +// ASSERT_EQ("101", audio_formats[4]); +// +// ASSERT_EQ("video", mSdp.GetMediaSection(1).GetType()) +// << "Wrong type for second media section"; +// oSSERT_EQ("RTP/SAVPF", mSdp.GetMediaSection(1).GetProtocol()) +// << "Wrong protocol for video"; +// auto video_formats = mSdp.GetMediaSection(1).GetFormats(); +// ASSERT_EQ(1, video_formats.size()) << "Wrong number of formats for video"; +// ASSERT_EQ("120", video_formats[0]); +//} + +//TEST_F(NewSdpTest, CheckRtpmap) { +// ParseSdp(kBasicAudioVideoOffer); +// ASSERT_EQ(2, mSdp.GetMediaSectionCount()) +// << "Wrong number of media sections"; +// +// ASSERT_EQ(5, mSdp.GetMediaSection(0).GetNumRtpmap()) +// << "Wrong number of rtpmap attributes for audio"; +// // TODO: Write a CheckRtpmap(rtpmap, payloadType, encodingName, rate) // Need to know name of type // CheckRtpmap("109", "opus", 48000, mSdp.GetMediaSection(0).GetRtpmap(0)); @@ -969,15 +975,15 @@ TEST_F(NewSdpTest, CheckRtpmap) { // CheckRtpmap("101", "telephone-event", 8000, mSdp.GetMediaSection(0).GetRtpmap(4)); // CheckRtpmap("120", "VP8", 90000, mSdp.GetMediaSection(0).GetRtpmap(0)); -} - -TEST_F(NewSdpTest, CheckFormatParameters) { - ParseSdp(kBasicAudioVideoOffer); - ASSERT_EQ(2, mSdp.GetMediaSectionCount()) - << "Wrong number of media sections"; - - ASSERT_EQ(1, mSdp.GetMediaSection(0).GetAttributeList().Count(kFmtp)); -} +//} + +//TEST_F(NewSdpTest, CheckFormatParameters) { +// ParseSdp(kBasicAudioVideoOffer); +// ASSERT_EQ(2, mSdp.GetMediaSectionCount()) +// << "Wrong number of media sections"; +// +// ASSERT_EQ(1, mSdp.GetMediaSection(0).GetAttributeList().Count(kFmtp)); +//} // TODO: Tests that parse above SDP, and check various things // For media sections 1 and 2: From 21a635a42383198a8f55b8dd4f5218f03d54158d Mon Sep 17 00:00:00 2001 From: Byron Campen Date: Wed, 17 Sep 2014 15:21:40 -0700 Subject: [PATCH 8/9] Fixing build some. --- media/webrtc/signaling/test/moz.build | 1 + media/webrtc/signaling/test/sdp_unittests.cpp | 42 ++++++++++++------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/media/webrtc/signaling/test/moz.build b/media/webrtc/signaling/test/moz.build index 5c9ed654a7f9f..ed88ecdb385e3 100644 --- a/media/webrtc/signaling/test/moz.build +++ b/media/webrtc/signaling/test/moz.build @@ -47,6 +47,7 @@ LOCAL_INCLUDES += [ '/media/webrtc/signaling/src/media-conduit', '/media/webrtc/signaling/src/mediapipeline', '/media/webrtc/signaling/src/peerconnection', + '/media/webrtc/signaling/src/sdp/sipcc', '/media/webrtc/trunk', '/media/webrtc/trunk/testing/gtest/include', '/xpcom/base', diff --git a/media/webrtc/signaling/test/sdp_unittests.cpp b/media/webrtc/signaling/test/sdp_unittests.cpp index 19ce1c0af873f..94f244d0067fa 100644 --- a/media/webrtc/signaling/test/sdp_unittests.cpp +++ b/media/webrtc/signaling/test/sdp_unittests.cpp @@ -9,6 +9,7 @@ #include "CSFLog.h" #include +#include #define GTEST_HAS_RTTI 0 #include "gtest/gtest.h" @@ -31,8 +32,8 @@ nsCOMPtr gThread; #include "signaling/src/sdp/SipccSdpParser.h" extern "C" { -#include "sdp.h" -#include "sdp_private.h" +#include "signaling/src/sdp/sipcc/sdp.h" +#include "signaling/src/sdp/sipcc/sdp_private.h" } using mozilla::SipccSdpParser; @@ -826,6 +827,17 @@ class NewSdpTest : public ::testing::Test { mSdp = mozilla::Move(mParser.Parse(sdp)); } + // For streaming parse errors + std::string GetParseErrors() { + std::stringstream output; + for (auto e = mParser.GetParseErrors().begin(); + e != mParser.GetParseErrors().end(); + ++e) { + output << e->first << ": " << e->second << std::endl; + } + return output.str(); + } + SipccSdpParser mParser; mozilla::UniquePtr mSdp; }; @@ -836,22 +848,22 @@ TEST_F(NewSdpTest, CreateDestroy) { TEST_F(NewSdpTest, ParseEmpty) { ParseSdp(""); ASSERT_FALSE(mSdp); - ASSERT_NE(0, mParser.GetParseErrors().size()) + ASSERT_NE(0U, mParser.GetParseErrors().size()) << "Expected at least one parse error."; } TEST_F(NewSdpTest, ParseGarbage) { ParseSdp("foobajooba"); ASSERT_FALSE(mSdp); - ASSERT_NE(0, mParser.GetParseErrors().size()) + ASSERT_NE(0U, mParser.GetParseErrors().size()) << "Expected at least one parse error."; } TEST_F(NewSdpTest, ParseMinimal) { ParseSdp(kVideoSdp); - ASSERT_TRUE(mSdp) << "Parse failed: " << mParser.GetParseErrorsAsStream(); - ASSERT_EQ(0, mParser.GetParseErrors().size()) << - "Got parse errors: " << mParser.GetParseErrors(); + ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors(); + ASSERT_EQ(0U, mParser.GetParseErrors().size()) << + "Got parse errors: " << GetParseErrors(); } // SDP from a basic A/V apprtc call FFX/FFX @@ -904,7 +916,7 @@ const std::string kBasicAudioVideoOffer = TEST_F(NewSdpTest, BasicAudioVideoSdpParse) { ParseSdp(kBasicAudioVideoOffer); - ASSERT_TRUE(mSdp) << "Parse failed: " << mParser.GetParseErrorsAsStream(); + ASSERT_TRUE(mSdp) << "Parse failed: " << GetParseErrors(); } //TEST_F(NewSdpTest, CheckIceUfrag) { @@ -936,13 +948,13 @@ TEST_F(NewSdpTest, BasicAudioVideoSdpParse) { //TEST_F(NewSdpTest, CheckMlines) { // ParseSdp(kBasicAudioVideoOffer); -// ASSERT_EQ(2, mSdp.GetMediaSectionCount()) << "Wrong number of media sections"; +// ASSERT_EQ(2U, mSdp.GetMediaSectionCount()) << "Wrong number of media sections"; // ASSERT_EQ("audio", mSdp.GetMediaSection(0).GetType()) // << "Wrong type for first media section"; // oSSERT_EQ("RTP/SAVPF", mSdp.GetMediaSection(0).GetProtocol()) // << "Wrong protocol for audio"; // auto audio_formats = mSdp.GetMediaSection(0).GetFormats(); -// ASSERT_EQ(5, audio_formats.size()) << "Wrong number of formats for audio"; +// ASSERT_EQ(5U, audio_formats.size()) << "Wrong number of formats for audio"; // ASSERT_EQ("109", audio_formats[0]); // ASSERT_EQ("9", audio_formats[1]); // ASSERT_EQ("0", audio_formats[2]); @@ -954,16 +966,16 @@ TEST_F(NewSdpTest, BasicAudioVideoSdpParse) { // oSSERT_EQ("RTP/SAVPF", mSdp.GetMediaSection(1).GetProtocol()) // << "Wrong protocol for video"; // auto video_formats = mSdp.GetMediaSection(1).GetFormats(); -// ASSERT_EQ(1, video_formats.size()) << "Wrong number of formats for video"; +// ASSERT_EQ(1U, video_formats.size()) << "Wrong number of formats for video"; // ASSERT_EQ("120", video_formats[0]); //} //TEST_F(NewSdpTest, CheckRtpmap) { // ParseSdp(kBasicAudioVideoOffer); -// ASSERT_EQ(2, mSdp.GetMediaSectionCount()) +// ASSERT_EQ(2U, mSdp.GetMediaSectionCount()) // << "Wrong number of media sections"; // -// ASSERT_EQ(5, mSdp.GetMediaSection(0).GetNumRtpmap()) +// ASSERT_EQ(5U, mSdp.GetMediaSection(0).GetNumRtpmap()) // << "Wrong number of rtpmap attributes for audio"; // // TODO: Write a CheckRtpmap(rtpmap, payloadType, encodingName, rate) @@ -979,10 +991,10 @@ TEST_F(NewSdpTest, BasicAudioVideoSdpParse) { //TEST_F(NewSdpTest, CheckFormatParameters) { // ParseSdp(kBasicAudioVideoOffer); -// ASSERT_EQ(2, mSdp.GetMediaSectionCount()) +// ASSERT_EQ(2U, mSdp.GetMediaSectionCount()) // << "Wrong number of media sections"; // -// ASSERT_EQ(1, mSdp.GetMediaSection(0).GetAttributeList().Count(kFmtp)); +// ASSERT_EQ(1U, mSdp.GetMediaSection(0).GetAttributeList().Count(kFmtp)); //} // TODO: Tests that parse above SDP, and check various things From a8a93cc4076ee691a7452e7ed12c99177347bd5e Mon Sep 17 00:00:00 2001 From: Byron Campen Date: Wed, 17 Sep 2014 16:15:13 -0700 Subject: [PATCH 9/9] Add some stub impl. --- media/webrtc/signaling/src/sdp/SipccSdp.cpp | 22 +++++++++++++++ media/webrtc/signaling/src/sdp/SipccSdp.h | 30 +++++++++++---------- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/media/webrtc/signaling/src/sdp/SipccSdp.cpp b/media/webrtc/signaling/src/sdp/SipccSdp.cpp index eb5736617a8b4..9523fc4ad4a91 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdp.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdp.cpp @@ -8,14 +8,36 @@ namespace mozilla { +SdpOrigin +SipccSdp::GetOrigin() const { + return SdpOrigin(); +} + +std::string +SipccSdp::GetSessionName() const { + return "TODO"; +} + +std::string +SipccSdp::GetBandwidth(std::string type) const { + return "TODO"; +} + const SdpMediaSection & SipccSdp::GetMediaSection(uint16_t level) const { + if (level >= mMediaSections.size()) { + MOZ_CRASH(); + } return mMediaSections[level]; } + SdpMediaSection & SipccSdp::GetMediaSection(uint16_t level) { + if (level >= mMediaSections.size()) { + MOZ_CRASH(); + } return mMediaSections[level]; } diff --git a/media/webrtc/signaling/src/sdp/SipccSdp.h b/media/webrtc/signaling/src/sdp/SipccSdp.h index d4bb7289fade0..a6fd79a516fe6 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdp.h +++ b/media/webrtc/signaling/src/sdp/SipccSdp.h @@ -30,26 +30,28 @@ class SipccSdp MOZ_FINAL : public Sdp sdp_free_description(mSdp); } - const SdpAttributeList& GetAttributeList() const { - return mAttributeList; + virtual SdpOrigin GetOrigin() const MOZ_OVERRIDE; + virtual std::string GetSessionName() const MOZ_OVERRIDE; + // Note: connection information is always retrieved from media sections + virtual std::string GetBandwidth(std::string type) const MOZ_OVERRIDE; + + virtual uint16_t GetMediaSectionCount() const MOZ_OVERRIDE { + return static_cast(mMediaSections.size()); } - SdpAttributeList& GetAttributeList() { + + virtual const SdpAttributeList &GetAttributeList() const MOZ_OVERRIDE { return mAttributeList; } - const SdpMediaSection &GetMediaSection(uint16_t level) const { - if (level >= mMediaSections.length()) { - MOZ_CRASH(); - } - return mMediaSections[level]; - } - SdpMediaSection &GetMediaSection(uint16_t level) { - if (level >= mMediaSections.length()) { - MOZ_CRASH(); - } - return mMediaSections[level]; + virtual SdpAttributeList &GetAttributeList() MOZ_OVERRIDE { + return mAttributeList; } + virtual const SdpMediaSection &GetMediaSection( + uint16_t level) const MOZ_OVERRIDE; + + virtual SdpMediaSection &GetMediaSection(uint16_t level) MOZ_OVERRIDE; + private: SipccSdp(sdp_t* sdp) : mSdp(sdp) {}