From a8adedcf641f206c08b9a9dd7d34ae0c57a0794e Mon Sep 17 00:00:00 2001 From: Martin Thomson Date: Wed, 17 Sep 2014 16:43:06 -0700 Subject: [PATCH 1/3] Moving enums and init around --- media/webrtc/signaling/src/sdp/SdpEnum.h | 9 ------ .../signaling/src/sdp/SdpMediaSection.h | 15 ++++++++-- media/webrtc/signaling/src/sdp/SipccSdp.cpp | 23 +++++--------- media/webrtc/signaling/src/sdp/SipccSdp.h | 4 +-- .../src/sdp/SipccSdpMediaSection.cpp | 30 +++++++++++-------- .../signaling/src/sdp/SipccSdpMediaSection.h | 18 ++++------- .../signaling/src/sdp/SipccSdpParser.cpp | 5 ++-- 7 files changed, 46 insertions(+), 58 deletions(-) diff --git a/media/webrtc/signaling/src/sdp/SdpEnum.h b/media/webrtc/signaling/src/sdp/SdpEnum.h index 89af50823a4d9..8439aa2e8831c 100644 --- a/media/webrtc/signaling/src/sdp/SdpEnum.h +++ b/media/webrtc/signaling/src/sdp/SdpEnum.h @@ -19,15 +19,6 @@ enum AddrType { kIPv6 }; -enum MediaType { - kAudio, - kVideo, - kText, - kApplication, - kMessage, - kUnknownMediaType -}; - enum Protocol { kRtpAvp, // RTP/AVP [RFC4566] kUdp, // udp [RFC4566] diff --git a/media/webrtc/signaling/src/sdp/SdpMediaSection.h b/media/webrtc/signaling/src/sdp/SdpMediaSection.h index 160e768e7b15f..05d73e0645c7a 100644 --- a/media/webrtc/signaling/src/sdp/SdpMediaSection.h +++ b/media/webrtc/signaling/src/sdp/SdpMediaSection.h @@ -22,9 +22,18 @@ class SdpConnection; class SdpMediaSection { public: - virtual sdp::MediaType GetMediaType() const; - virtual unsigned int GetPort() const; - virtual unsigned int GetPortCount() const; + enum MediaType { + kAudio, + kVideo, + kText, + kApplication, + kMessage, + kUnknownMediaType + }; + + virtual MediaType GetMediaType() const = 0; + virtual unsigned int GetPort() const = 0; + virtual unsigned int GetPortCount() const = 0; virtual sdp::Protocol GetProtocol() const = 0; virtual SdpConnection GetConnection() const = 0; virtual Maybe GetBandwidth(const std::string& type) const = 0; diff --git a/media/webrtc/signaling/src/sdp/SipccSdp.cpp b/media/webrtc/signaling/src/sdp/SipccSdp.cpp index 2f4b967c4f1f5..afbb029b42a93 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdp.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdp.cpp @@ -1,5 +1,3 @@ -/* -*- 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/. */ @@ -24,34 +22,29 @@ SipccSdp::GetBandwidth(std::string type) const { } const SdpMediaSection & -SipccSdp::GetMediaSection(uint16_t level) const +SipccSdp::GetMediaSection(unsigned int level) const { - if (level >= mMediaSections.size()) { - MOZ_CRASH(); - } return mMediaSections[level]; } - SdpMediaSection & -SipccSdp::GetMediaSection(uint16_t level) +SipccSdp::GetMediaSection(unsigned int level) { - if (level >= mMediaSections.size()) { - MOZ_CRASH(); - } return mMediaSections[level]; } void -SipccSdp::Load() { +SipccSdp::Load(sdp_t* sdp, uint16_t level) { if (!mMediaSections.empty()) { return; } - for (int i = 0; i < sdp_get_num_media_lines(mSdp); ++i) { + mAttributeList.Load(sdp, 0); + + for (int i = 0; i < sdp_get_num_media_lines(sdp); ++i) { // note that we pass a "level" here that is one higher // sipcc counts media sections from 1, using 0 as the "session" - SipccSdpMediaSection section(mSdp, i + 1); - section.Load(); + SipccSdpMediaSection section(); + section.Load(sdp, i + 1); mMediaSections.push_back(section); } } diff --git a/media/webrtc/signaling/src/sdp/SipccSdp.h b/media/webrtc/signaling/src/sdp/SipccSdp.h index 6742002d2cef9..f259c22ddc118 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdp.h +++ b/media/webrtc/signaling/src/sdp/SipccSdp.h @@ -54,9 +54,9 @@ class SipccSdp MOZ_FINAL : public Sdp virtual SdpMediaSection &GetMediaSection(uint16_t level) MOZ_OVERRIDE; private: - SipccSdp(sdp_t* sdp) : mSdp(sdp) {} + SipccSdp() {} - void Load(); + void Load(sdp_t* sdp); sdp_t *mSdp; std::vector mMediaSections; diff --git a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp index 08b78502a25c8..50e88e963adbe 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp @@ -28,7 +28,7 @@ SipccSdpMediaSection::GetConnection() const { return SdpConnection(sdp::kInternet, sdp::kIPv4, "0.0.0.0"); } -Maybe +const Maybe& SipccSdpMediaSection::GetBandwidth(const std::string& type) const { return Maybe(); } @@ -49,39 +49,43 @@ SipccSdpMediaSection::GetAttributeList() { } void -SipccSdpMediaSection::Load() +SipccSdpMediaSection::Load(sdp_t* sdp, uint16_t level) { - switch (sdp_get_media_type(mSdp, mLevel)) { + switch (sdp_get_media_type(sdp, level)) { case SDP_MEDIA_AUDIO: - mMediaType = sdp::kAudio; + mMediaType = kAudio; break; case SDP_MEDIA_VIDEO: - mMediaType = sdp::kVideo; + mMediaType = kVideo; break; case SDP_MEDIA_APPLICATION: - mMediaType = sdp::kApplication; + mMediaType = kApplication; break; case SDP_MEDIA_TEXT: - mMediaType = sdp::kText; + mMediaType = kText; break; case SDP_MEDIA_DATA: - mMediaType = sdp::kMessage; + mMediaType = kMessage; break; default: // TODO: log this - mMediaType = sdp::kUnknownMediaType; + mMediaType = kUnknownMediaType; break; } - mPort = sdp_get_media_portnum(mSdp, mLevel); - mPortCount = sdp_get_media_portcount(mSdp, mLevel); + mPort = sdp_get_media_portnum(sdp, level); + mPortCount = sdp_get_media_portcount(sdp, level); - switch (sdp_get_media_transport(mSdp, mLevel)) { + switch (sdp_get_media_transport(sdp, level)) { // TODO add right protocols to sipcc default: - mProtocol = sdp::kUnknownProtocol; + mProtocol = kUnknownProtocol; } } +void SipccSdpMediaSection::LoadConnection(sdp_t* sdp, uint16_t level) +{ + // TODO } +} diff --git a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h index c08d26a079c56..bb8ecdb103110 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h +++ b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h @@ -24,7 +24,7 @@ class SipccSdpMediaSection MOZ_FINAL : public SdpMediaSection { friend class SipccSdp; public: - virtual sdp::MediaType + virtual MediaType GetMediaType() const MOZ_OVERRIDE { return mMediaType; @@ -41,19 +41,11 @@ class SipccSdpMediaSection MOZ_FINAL : public SdpMediaSection virtual SdpAttributeList &GetAttributeList() MOZ_OVERRIDE; private: - SipccSdpMediaSection(sdp_t* sdp, uint16_t level) - : mSdp(sdp), - mLevel(level), - mAttributes(sdp, level), - mConnection(sdp::kInternet, sdp::kIPv4, "0.0.0.0") {} + SipccSdpMediaSection() {} ~SipccSdpMediaSection() {} - void Load(); - - // this is just on loan, so we don't delete on destruct; - // this doesn't live beyond the SipccSdp instance that owns this - sdp_t* mSdp; - uint16_t mLevel; + void Load(sdp_t* sdp, uint16_t level); + void LoadConnection(sdp_t* sdp, uint16_t level); // the following values are cached on first get sdp::MediaType mMediaType; @@ -63,7 +55,7 @@ class SipccSdpMediaSection MOZ_FINAL : public SdpMediaSection std::vector mFormats; SipccSdpAttributeList mAttributes; - SdpConnection mConnection; + UniquePtr mConnection; }; } diff --git a/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp b/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp index aa97782868625..3c420562818fa 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp @@ -29,8 +29,8 @@ SipccSdpParser::Parse(const std::string& sdpText) const char* rawString = sdpText.c_str(); sdp_result_e result = sdp_parse(sdp, rawString, sdpText.length()); if (result == SDP_SUCCESS) { - SipccSdp* sipccSdp = new SipccSdp(sdp); - sipccSdp->Load(); + SipccSdp* sipccSdp = new SipccSdp(); + sipccSdp->Load(sdp); return UniquePtr(sipccSdp); } @@ -60,4 +60,3 @@ sipcc_sdp_parser_error_handler(void *context, uint32_t line, const char *message } } // namespace mozilla - From 151566e97c8c4601a2240d7b6853a24c1b5f300d Mon Sep 17 00:00:00 2001 From: Martin Thomson Date: Wed, 17 Sep 2014 16:54:05 -0700 Subject: [PATCH 2/3] Moving to load functions universally --- .../signaling/src/sdp/SipccSdpAttributeList.h | 52 ++++++++++--------- .../src/sdp/SipccSdpMediaSection.cpp | 8 ++- .../signaling/src/sdp/SipccSdpMediaSection.h | 3 ++ 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.h b/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.h index 5bf30e0895889..8d95381abf995 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.h +++ b/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.h @@ -14,6 +14,7 @@ extern "C" { namespace mozilla { +class SipccSdp; class SipccSdpMediaSection; class SipccSdpAttributeList : public SdpAttributeList @@ -26,36 +27,39 @@ class SipccSdpAttributeList : public SdpAttributeList virtual UniquePtr GetAttribute(sdp::AttributeType type) const MOZ_OVERRIDE; - virtual UniquePtr GetCandidate() const MOZ_OVERRIDE; - virtual UniquePtr GetConnection() const MOZ_OVERRIDE; - virtual UniquePtr GetExtmap() const MOZ_OVERRIDE; - virtual UniquePtr GetFingerprint() const MOZ_OVERRIDE; - virtual UniquePtr GetFmtp() const MOZ_OVERRIDE; - virtual UniquePtr GetGroup() const MOZ_OVERRIDE; - virtual UniquePtr GetIceOptions() const MOZ_OVERRIDE; - virtual std::string GetIcePwd() const MOZ_OVERRIDE; - virtual std::string GetIceUfrag() const MOZ_OVERRIDE; - virtual UniquePtr GetIdentity() const MOZ_OVERRIDE; - virtual UniquePtr GetImageattr() const MOZ_OVERRIDE; - virtual std::string GetLabel() const MOZ_OVERRIDE; + virtual const SdpCandidateAttribute& GetCandidate() const MOZ_OVERRIDE; + virtual const SdpConnectionAttribute& GetConnection() const MOZ_OVERRIDE; + virtual const SdpExtmapAttribute& GetExtmap() const MOZ_OVERRIDE; + virtual const SdpFingerprintAttribute& GetFingerprint() const MOZ_OVERRIDE; + virtual const SdpFmtpAttribute& GetFmtp() const MOZ_OVERRIDE; + virtual const SdpGroupAttribute& GetGroup() const MOZ_OVERRIDE; + virtual const SdpIceOptionsAttribute& GetIceOptions() const MOZ_OVERRIDE; + virtual const std::string& GetIcePwd() const MOZ_OVERRIDE; + virtual const std::string& GetIceUfrag() const MOZ_OVERRIDE; + virtual const SdpIdentityAttribute& GetIdentity() const MOZ_OVERRIDE; + virtual const SdpImageattrAttribute& GetImageattr() const MOZ_OVERRIDE; + virtual const std::string& GetLabel() const MOZ_OVERRIDE; virtual unsigned int GetMaxprate() const MOZ_OVERRIDE; virtual unsigned int GetMaxptime() const MOZ_OVERRIDE; - virtual std::string GetMid() const MOZ_OVERRIDE; - virtual UniquePtr GetMsid() const MOZ_OVERRIDE; + virtual const std::string& GetMid() const MOZ_OVERRIDE; + virtual const SdpMsidAttribute& GetMsid() const MOZ_OVERRIDE; virtual unsigned int GetPtime() const MOZ_OVERRIDE; - virtual UniquePtr GetRtcp() const MOZ_OVERRIDE; - virtual UniquePtr GetRtcpFb() const MOZ_OVERRIDE; -// virtual UniquePtr GetRemoteCandidates() const MOZ_OVERRIDE; - virtual UniquePtr GetRtpmap() const MOZ_OVERRIDE; - virtual UniquePtr GetSctpmap() const MOZ_OVERRIDE; - virtual UniquePtr GetSetup() const MOZ_OVERRIDE; - virtual UniquePtr GetSsrc() const MOZ_OVERRIDE; - virtual UniquePtr GetSsrcGroup() const MOZ_OVERRIDE; + virtual const SdpRtcpAttribute& GetRtcp() const MOZ_OVERRIDE; + virtual const SdpRtcpFbAttribute& GetRtcpFb() const MOZ_OVERRIDE; +// virtual const SdpRtcpRemoteCandidates& GetRemoteCandidates() const MOZ_OVERRIDE; + virtual const SdpRtpmapAttribute& GetRtpmap() const MOZ_OVERRIDE; + virtual const SdpSctpmapAttribute& GetSctpmap() const MOZ_OVERRIDE; + virtual const SdpSetupAttribute& GetSetup() const MOZ_OVERRIDE; + virtual const SdpSsrcAttribute& GetSsrc() const MOZ_OVERRIDE; + virtual const SdpSsrcGroupAttribute& GetSsrcGroup() const MOZ_OVERRIDE; virtual void SetAttribute(const SdpAttribute &) MOZ_OVERRIDE; + virtual ~SipccSdpAttributeList() {} + private: - SipccSdpAttributeList(sdp_t* sdp, uint16_t level) - : mSdp(sdp), mLevel(level) {} + SipccSdpAttributeList() {} + + void Load(sdp_t* sdp, uint16_t levelmSdp, i + 1); sdp_t* mSdp; uint16_t mLevel; diff --git a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp index 50e88e963adbe..72cf5f55d90cb 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp @@ -81,10 +81,14 @@ SipccSdpMediaSection::Load(sdp_t* sdp, uint16_t level) default: mProtocol = kUnknownProtocol; } + + mAttributeList.Load(sdp, level); + + LoadConnection(sdp, level); } -void SipccSdpMediaSection::LoadConnection(sdp_t* sdp, uint16_t level) -{ +void +SipccSdpMediaSection::LoadConnection(sdp_t* sdp, uint16_t level) { // TODO } diff --git a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h index bb8ecdb103110..6df3d832e77bb 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h +++ b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h @@ -8,6 +8,7 @@ #define _SIPCCSDPMEDIASECTION_H_ #include "mozilla/Attributes.h" +#include "mozilla/UniquePtr.h" #include "signaling/src/sdp/SdpMediaSection.h" #include "signaling/src/sdp/SdpEnum.h" #include "signaling/src/sdp/SipccSdpAttributeList.h" @@ -56,6 +57,8 @@ class SipccSdpMediaSection MOZ_FINAL : public SdpMediaSection SipccSdpAttributeList mAttributes; UniquePtr mConnection; + + SipccSdpAttributeList mAttributeList; }; } From e0eb5c895d1d6797dc256dd28b0efebb4e9eb2c6 Mon Sep 17 00:00:00 2001 From: Martin Thomson Date: Wed, 17 Sep 2014 17:41:11 -0700 Subject: [PATCH 3/3] Moving to const refs --- media/webrtc/signaling/src/sdp/Sdp.h | 7 +- media/webrtc/signaling/src/sdp/SdpAttribute.h | 83 ++++++++++++++----- .../signaling/src/sdp/SdpAttributeList.h | 40 ++++----- media/webrtc/signaling/src/sdp/SdpEnum.h | 77 ----------------- .../signaling/src/sdp/SdpMediaSection.h | 48 +++++++++-- media/webrtc/signaling/src/sdp/SipccSdp.cpp | 17 ++-- media/webrtc/signaling/src/sdp/SipccSdp.h | 22 +++-- .../signaling/src/sdp/SipccSdpAttributeList.h | 2 +- .../signaling/src/sdp/SipccSdpMediaSection.h | 4 +- .../signaling/src/sdp/SipccSdpParser.cpp | 2 +- 10 files changed, 155 insertions(+), 147 deletions(-) diff --git a/media/webrtc/signaling/src/sdp/Sdp.h b/media/webrtc/signaling/src/sdp/Sdp.h index 06b4e9b34e328..a1dc13143a62b 100644 --- a/media/webrtc/signaling/src/sdp/Sdp.h +++ b/media/webrtc/signaling/src/sdp/Sdp.h @@ -27,10 +27,11 @@ class Sdp public: Sdp(); - virtual SdpOrigin GetOrigin() const = 0; - virtual std::string GetSessionName() const = 0; + virtual const SdpOrigin& GetOrigin() const = 0; + virtual const std::string& GetSessionName() const = 0; // Note: connection information is always retrieved from media sections - virtual Maybe GetBandwidth(const std::string& type) const = 0; + virtual const Maybe& + GetBandwidth(const std::string& type) const = 0; virtual const SdpAttributeList &GetAttributeList() const = 0; virtual SdpAttributeList &GetAttributeList() = 0; diff --git a/media/webrtc/signaling/src/sdp/SdpAttribute.h b/media/webrtc/signaling/src/sdp/SdpAttribute.h index 533f879b4ce26..e4566892550c7 100644 --- a/media/webrtc/signaling/src/sdp/SdpAttribute.h +++ b/media/webrtc/signaling/src/sdp/SdpAttribute.h @@ -17,10 +17,49 @@ namespace mozilla { class SdpAttribute { public: - SdpAttribute(sdp::AttributeType type, std::string typeName) : + enum AttributeType { + kBundleOnlyAttribute, + kCandidateAttribute, + kConnectionAttribute, + kDtlsFingerprintAttribute, + kExtmapAttribute, + kFingerprintAttribute, + kFmtpAttribute, + kGroupAttribute, + kIceLiteAttribute, + kIceMismatchAttribute, + kIceOptionsAttribute, + kIcePwdAttribute, + kIceUfragAttribute, + kIdentityAttribute, + kImageattrAttribute, + kInactiveAttribute, + kLabelAttribute, + kMaxprateAttribute, + kMaxptimeAttribute, + kMidAttribute, + kMsidAttribute, + kPtimeAttribute, + kRecvonlyAttribute, + kRemoteCandidatesAttribute, + kRtcpAttribute, + kRtcpFbAttribute, + kRtcpMuxAttribute, + kRtcpRsizeAttribute, + kRtpmapAttribute, + kSctpmapAttribute, + kSendonlyAttribute, + kSendrecvAttribute, + kSetupAttribute, + kSsrcAttribute, + kSsrcGroupAttribute, + kOtherAttribute + }; + + SdpAttribute(AttributeType type, std::string typeName) : mType(type), mTypeName(typeName) {} - virtual sdp::AttributeType GetType() + virtual AttributeType GetType() { return mType; } @@ -34,7 +73,7 @@ class SdpAttribute virtual ~SdpAttribute() {} private: - sdp::AttributeType mType; + AttributeType mType; std::string mTypeName; }; @@ -54,7 +93,7 @@ class SdpCandidateAttribute : public SdpAttribute { public: SdpCandidateAttribute() : - SdpAttribute(sdp::kCandidateAttribute, "candidate") {} + SdpAttribute(kCandidateAttribute, "candidate") {} }; // RFC4145 @@ -69,7 +108,7 @@ class SdpConnectionAttribute : public SdpAttribute }; SdpConnectionAttribute(SdpConnectionAttribute::ConnValue value) : - SdpAttribute(sdp::kConnectionAttribute, "connection"), + SdpAttribute(kConnectionAttribute, "connection"), mValue(value) {} enum ConnValue mValue; @@ -97,7 +136,7 @@ class SdpExtmapAttribute : public SdpAttribute { public: SdpExtmapAttribute() : - SdpAttribute(sdp::kExtmapAttribute, "extmap") {} + SdpAttribute(kExtmapAttribute, "extmap") {} }; @@ -119,7 +158,7 @@ class SdpFingerprintAttribute : public SdpAttribute { public: SdpFingerprintAttribute() : - SdpAttribute(sdp::kFingerprintAttribute, "fingerprint") {} + SdpAttribute(kFingerprintAttribute, "fingerprint") {} }; // RFC4566, RFC5576 @@ -128,7 +167,7 @@ class SdpFmtpAttribute : public SdpAttribute { public: SdpFmtpAttribute() : - SdpAttribute(sdp::kFmtpAttribute, "fmtp") {} + SdpAttribute(kFmtpAttribute, "fmtp") {} }; // RFC5888 @@ -140,7 +179,7 @@ class SdpGroupAttribute : public SdpAttribute { public: SdpGroupAttribute() : - SdpAttribute(sdp::kGroupAttribute, "group") {} + SdpAttribute(kGroupAttribute, "group") {} }; // RFC5245 @@ -151,7 +190,7 @@ class SdpIceOptionsAttribute : public SdpAttribute { public: SdpIceOptionsAttribute() : - SdpAttribute(sdp::kIceOptionsAttribute, "ice-options") {} + SdpAttribute(kIceOptionsAttribute, "ice-options") {} }; // draft-ietf-rtcweb-security-arch @@ -168,7 +207,7 @@ class SdpIdentityAttribute : public SdpAttribute { public: SdpIdentityAttribute() : - SdpAttribute(sdp::kIdentityAttribute, "identity") {} + SdpAttribute(kIdentityAttribute, "identity") {} }; // RFC6236 @@ -241,7 +280,7 @@ class SdpImageattrAttribute : public SdpAttribute { public: SdpImageattrAttribute() : - SdpAttribute(sdp::kImageattrAttribute, "imageattr") {} + SdpAttribute(kImageattrAttribute, "imageattr") {} }; // draft-ietf-mmusic-msid @@ -252,7 +291,7 @@ class SdpMsidAttribute : public SdpAttribute { public: SdpMsidAttribute() : - SdpAttribute(sdp::kMsidAttribute, "msid") {} + SdpAttribute(kMsidAttribute, "msid") {} }; // RFC5245 @@ -263,7 +302,7 @@ class SdpRemoteCandidatesAttribute : public SdpAttribute { public: SdpRemoteCandidatesAttribute() : - SdpAttribute(sdp::kRemoteCandidatesAttribute, "remote-candidates") {} + SdpAttribute(kRemoteCandidatesAttribute, "remote-candidates") {} }; // RFC3605 @@ -273,7 +312,7 @@ class SdpRtcpAttribute : public SdpAttribute { public: SdpRtcpAttribute() : - SdpAttribute(sdp::kRtcpAttribute, "rtcp") {} + SdpAttribute(kRtcpAttribute, "rtcp") {} }; // RFC4585 @@ -308,7 +347,7 @@ class SdpRtcpFbAttribute : public SdpAttribute { public: SdpRtcpFbAttribute() : - SdpAttribute(sdp::kRtcpFbAttribute, "rtcp-fb") {} + SdpAttribute(kRtcpFbAttribute, "rtcp-fb") {} }; // RFC4566 @@ -317,7 +356,7 @@ class SdpRtpmapAttribute : public SdpAttribute { public: SdpRtpmapAttribute() : - SdpAttribute(sdp::kRtpmapAttribute, "rtpmap") {} + SdpAttribute(kRtpmapAttribute, "rtpmap") {} }; // draft-ietf-mmusic-sctp-sdp-06 @@ -333,7 +372,7 @@ class SdpSctpmapAttribute : public SdpAttribute { public: SdpSctpmapAttribute() : - SdpAttribute(sdp::kSctpmapAttribute, "sctpmap") {} + SdpAttribute(kSctpmapAttribute, "sctpmap") {} }; // RFC4145 @@ -343,7 +382,7 @@ class SdpSetupAttribute : public SdpAttribute { public: SdpSetupAttribute() : - SdpAttribute(sdp::kSetupAttribute, "setup") {} + SdpAttribute(kSetupAttribute, "setup") {} }; // RFC5576 @@ -356,7 +395,7 @@ class SdpSsrcAttribute : public SdpAttribute { public: SdpSsrcAttribute() : - SdpAttribute(sdp::kSsrcAttribute, "ssrc") {} + SdpAttribute(kSsrcAttribute, "ssrc") {} }; // RFC5576 @@ -369,7 +408,7 @@ class SdpSsrcGroupAttribute : public SdpAttribute { public: SdpSsrcGroupAttribute() : - SdpAttribute(sdp::kSsrcGroupAttribute, "ssrc-group") {} + SdpAttribute(kSsrcGroupAttribute, "ssrc-group") {} }; // Used for any other kind of attribute not otherwise specialized @@ -377,7 +416,7 @@ class SdpOtherAttribute : public SdpAttribute { public: SdpOtherAttribute(std::string typeName, std::string value = "") : - SdpAttribute(sdp::kOtherAttribute, typeName), + SdpAttribute(kOtherAttribute, typeName), mValue(value) {} std::string const getValue() diff --git a/media/webrtc/signaling/src/sdp/SdpAttributeList.h b/media/webrtc/signaling/src/sdp/SdpAttributeList.h index 8cd68f75f4792..47ae64bfc0ec3 100644 --- a/media/webrtc/signaling/src/sdp/SdpAttributeList.h +++ b/media/webrtc/signaling/src/sdp/SdpAttributeList.h @@ -24,31 +24,31 @@ class SdpAttributeList virtual UniquePtr GetAttribute(sdp::AttributeType type) const = 0; - virtual UniquePtr GetCandidate() const = 0; - virtual UniquePtr GetConnection() const = 0; - virtual UniquePtr GetExtmap() const = 0; - virtual UniquePtr GetFingerprint() const = 0; - virtual UniquePtr GetFmtp() const = 0; - virtual UniquePtr GetGroup() const = 0; - virtual UniquePtr GetIceOptions() const = 0; - virtual std::string GetIcePwd() const = 0; - virtual std::string GetIceUfrag() const = 0; - virtual UniquePtr GetIdentity() const = 0; - virtual UniquePtr GetImageattr() const = 0; + virtual const SdpCandidateAttribute& GetCandidate() const = 0; + virtual const SdpConnectionAttribute& GetConnection() const = 0; + virtual const SdpExtmapAttribute& GetExtmap() const = 0; + virtual const SdpFingerprintAttribute& GetFingerprint() const = 0; + virtual const SdpFmtpAttribute& GetFmtp() const = 0; + virtual const SdpGroupAttribute& GetGroup() const = 0; + virtual const SdpIceOptionsAttribute& GetIceOptions() const = 0; + virtual const std::string& GetIcePwd() const = 0; + virtual const std::string& GetIceUfrag() const = 0; + virtual const SdpIdentityAttribute& GetIdentity() const = 0; + virtual const SdpImageattrAttribute& GetImageattr() const = 0; virtual std::string GetLabel() const = 0; virtual unsigned int GetMaxprate() const = 0; virtual unsigned int GetMaxptime() const = 0; virtual std::string GetMid() const = 0; - virtual UniquePtr GetMsid() const = 0; + virtual const SdpMsidAttribute& GetMsid() const = 0; virtual unsigned int GetPtime() const = 0; - virtual UniquePtr GetRtcp() const = 0; - virtual UniquePtr GetRtcpFb() const = 0; - // virtual UniquePtr GetRemoteCandidates() const = 0; - virtual UniquePtr GetRtpmap() const = 0; - virtual UniquePtr GetSctpmap() const = 0; - virtual UniquePtr GetSetup() const = 0; - virtual UniquePtr GetSsrc() const = 0; - virtual UniquePtr GetSsrcGroup() const = 0; + virtual const SdpRtcpAttribute& GetRtcp() const = 0; + virtual const SdpRtcpFbAttribute& GetRtcpFb() const = 0; + virtual const SdpRtcpRemoteCandidates& GetRemoteCandidates() const = 0; + virtual const SdpRtpmapAttribute& GetRtpmap() const = 0; + virtual const SdpSctpmapAttribute& GetSctpmap() const = 0; + virtual const SdpSetupAttribute& GetSetup() const = 0; + virtual const SdpSsrcAttribute& GetSsrc() const = 0; + virtual const SdpSsrcGroupAttribute& GetSsrcGroup() const = 0; virtual void SetAttribute(const SdpAttribute &) = 0; }; diff --git a/media/webrtc/signaling/src/sdp/SdpEnum.h b/media/webrtc/signaling/src/sdp/SdpEnum.h index 8439aa2e8831c..5c12e88c00d0d 100644 --- a/media/webrtc/signaling/src/sdp/SdpEnum.h +++ b/media/webrtc/signaling/src/sdp/SdpEnum.h @@ -19,83 +19,6 @@ enum AddrType { kIPv6 }; -enum Protocol { - kRtpAvp, // RTP/AVP [RFC4566] - kUdp, // udp [RFC4566] - kVat, // vat [historic] - kRtp, // rtp [historic] - kUdptl, // udptl [ITU-T] - kTcp, // TCP [RFC4145] - kRtpAvpf, // RTP/AVPF [RFC4585] - kTcpRtpAvp, // TCP/RTP/AVP [RFC4571] - kRtpSavp, // RTP/SAVP [RFC3711] - kTcpBfcp, // TCP/BFCP [RFC4583] - kTcpTlsBfcp, // TCP/TLS/BFCP [RFC4583] - kTcpTls, // TCP/TLS [RFC4572] - kFluteUdp, // FLUTE/UDP [RFC-mehta-rmt-flute-sdp-05] - kTcpMsrp, // TCP/MSRP [RFC4975] - kTcpTlsMsrp, // TCP/TLS/MSRP [RFC4975] - kDccp, // DCCP [RFC5762] - kDccpRtpAvp, // DCCP/RTP/AVP [RFC5762] - kDccpRtpSavp, // DCCP/RTP/SAVP [RFC5762] - kDccpRtpAvpf, // DCCP/RTP/AVPF [RFC5762] - kDccpRtpSavpf, // DCCP/RTP/SAVPF [RFC5762] - kRtpSavpf, // RTP/SAVPF [RFC5124] - kUdpTlsRtpSavp, // UDP/TLS/RTP/SAVP [RFC5764] - kDccpTlsRtpSavp, // DCCP/TLS/RTP/SAVP [RFC5764] - kUdpTlsRtpSavpf, // UDP/TLS/RTP/SAVPF [RFC5764] - kDccpTlsRtpSavpf, // DCCP/TLS/RTP/SAVPF [RFC5764] - kUdpMbmsFecRtpAvp, // UDP/MBMS-FEC/RTP/AVP [RFC6064] - kUdpMbmsFecRtpSavp, // UDP/MBMS-FEC/RTP/SAVP [RFC6064] - kUdpMbmsRepair, // UDP/MBMS-REPAIR [RFC6064] - kFecUdp, // FEC/UDP [RFC6364] - kUdpFec, // UDP/FEC [RFC6364] - kTcpMrcpv2, // TCP/MRCPv2 [RFC6787] - kTcpTlsMrcpv2, // TCP/TLS/MRCPv2 [RFC6787] - kPstn, // PSTN [RFC7195] - kUdpTlsUdptl, // UDP/TLS/UDPTL [RFC7345] - kUnknownProtocol -}; - -enum AttributeType { - kBundleOnlyAttribute, - kCandidateAttribute, - kConnectionAttribute, - kDtlsFingerprintAttribute, - kExtmapAttribute, - kFingerprintAttribute, - kFmtpAttribute, - kGroupAttribute, - kIceLiteAttribute, - kIceMismatchAttribute, - kIceOptionsAttribute, - kIcePwdAttribute, - kIceUfragAttribute, - kIdentityAttribute, - kImageattrAttribute, - kInactiveAttribute, - kLabelAttribute, - kMaxprateAttribute, - kMaxptimeAttribute, - kMidAttribute, - kMsidAttribute, - kPtimeAttribute, - kRecvonlyAttribute, - kRemoteCandidatesAttribute, - kRtcpAttribute, - kRtcpFbAttribute, - kRtcpMuxAttribute, - kRtcpRsizeAttribute, - kRtpmapAttribute, - kSctpmapAttribute, - kSendonlyAttribute, - kSendrecvAttribute, - kSetupAttribute, - kSsrcAttribute, - kSsrcGroupAttribute, - kOtherAttribute -}; - } } diff --git a/media/webrtc/signaling/src/sdp/SdpMediaSection.h b/media/webrtc/signaling/src/sdp/SdpMediaSection.h index 05d73e0645c7a..dde6a5d421728 100644 --- a/media/webrtc/signaling/src/sdp/SdpMediaSection.h +++ b/media/webrtc/signaling/src/sdp/SdpMediaSection.h @@ -31,13 +31,51 @@ class SdpMediaSection kUnknownMediaType }; + enum Protocol { + kRtpAvp, // RTP/AVP [RFC4566] + kUdp, // udp [RFC4566] + kVat, // vat [historic] + kRtp, // rtp [historic] + kUdptl, // udptl [ITU-T] + kTcp, // TCP [RFC4145] + kRtpAvpf, // RTP/AVPF [RFC4585] + kTcpRtpAvp, // TCP/RTP/AVP [RFC4571] + kRtpSavp, // RTP/SAVP [RFC3711] + kTcpBfcp, // TCP/BFCP [RFC4583] + kTcpTlsBfcp, // TCP/TLS/BFCP [RFC4583] + kTcpTls, // TCP/TLS [RFC4572] + kFluteUdp, // FLUTE/UDP [RFC-mehta-rmt-flute-sdp-05] + kTcpMsrp, // TCP/MSRP [RFC4975] + kTcpTlsMsrp, // TCP/TLS/MSRP [RFC4975] + kDccp, // DCCP [RFC5762] + kDccpRtpAvp, // DCCP/RTP/AVP [RFC5762] + kDccpRtpSavp, // DCCP/RTP/SAVP [RFC5762] + kDccpRtpAvpf, // DCCP/RTP/AVPF [RFC5762] + kDccpRtpSavpf, // DCCP/RTP/SAVPF [RFC5762] + kRtpSavpf, // RTP/SAVPF [RFC5124] + kUdpTlsRtpSavp, // UDP/TLS/RTP/SAVP [RFC5764] + kDccpTlsRtpSavp, // DCCP/TLS/RTP/SAVP [RFC5764] + kUdpTlsRtpSavpf, // UDP/TLS/RTP/SAVPF [RFC5764] + kDccpTlsRtpSavpf, // DCCP/TLS/RTP/SAVPF [RFC5764] + kUdpMbmsFecRtpAvp, // UDP/MBMS-FEC/RTP/AVP [RFC6064] + kUdpMbmsFecRtpSavp, // UDP/MBMS-FEC/RTP/SAVP [RFC6064] + kUdpMbmsRepair, // UDP/MBMS-REPAIR [RFC6064] + kFecUdp, // FEC/UDP [RFC6364] + kUdpFec, // UDP/FEC [RFC6364] + kTcpMrcpv2, // TCP/MRCPv2 [RFC6787] + kTcpTlsMrcpv2, // TCP/TLS/MRCPv2 [RFC6787] + kPstn, // PSTN [RFC7195] + kUdpTlsUdptl, // UDP/TLS/UDPTL [RFC7345] + kUnknownProtocol + }; + virtual MediaType GetMediaType() const = 0; virtual unsigned int GetPort() const = 0; virtual unsigned int GetPortCount() const = 0; - virtual sdp::Protocol GetProtocol() const = 0; - virtual SdpConnection GetConnection() const = 0; - virtual Maybe GetBandwidth(const std::string& type) const = 0; - virtual std::vector GetFormats() const = 0; + virtual Protocol GetProtocol() const = 0; + virtual const SdpConnection& GetConnection() const = 0; + virtual const Maybe& GetBandwidth(const std::string& type) const = 0; + virtual const std::vector& GetFormats() const = 0; virtual const SdpAttributeList &GetAttributeList() const = 0; virtual SdpAttributeList &GetAttributeList() = 0; @@ -62,7 +100,7 @@ class SdpConnection private: sdp::NetType mNetType; sdp::AddrType mAddrType; - std::string mAddr; + const std::string mAddr; int16_t mTtl; // 0-255; -1 for unset uint32_t mCount; }; diff --git a/media/webrtc/signaling/src/sdp/SipccSdp.cpp b/media/webrtc/signaling/src/sdp/SipccSdp.cpp index afbb029b42a93..8491643b38f98 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdp.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdp.cpp @@ -16,9 +16,12 @@ SipccSdp::GetSessionName() const { return "TODO"; } -Maybe -SipccSdp::GetBandwidth(std::string type) const { - return Maybe(); +const Maybe& +SipccSdp::GetBandwidth(const std::string& type) const { + if (mBandwidths.count(type) > 0) { + return Nothing(); + } + return Some(mBandwidths[type]); } const SdpMediaSection & @@ -33,13 +36,11 @@ SipccSdp::GetMediaSection(unsigned int level) } void -SipccSdp::Load(sdp_t* sdp, uint16_t level) { - if (!mMediaSections.empty()) { - return; - } - +SipccSdp::Load(sdp_t* sdp) { mAttributeList.Load(sdp, 0); + // TODO load other session-level stuff + for (int i = 0; i < sdp_get_num_media_lines(sdp); ++i) { // note that we pass a "level" here that is one higher // sipcc counts media sections from 1, using 0 as the "session" diff --git a/media/webrtc/signaling/src/sdp/SipccSdp.h b/media/webrtc/signaling/src/sdp/SipccSdp.h index f259c22ddc118..5a56a24a5bc21 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdp.h +++ b/media/webrtc/signaling/src/sdp/SipccSdp.h @@ -30,25 +30,29 @@ class SipccSdp MOZ_FINAL : public Sdp sdp_free_description(mSdp); } - virtual SdpOrigin GetOrigin() const MOZ_OVERRIDE; - virtual std::string GetSessionName() const MOZ_OVERRIDE; + virtual const SdpOrigin& GetOrigin() const MOZ_OVERRIDE { + return *mOrigin; + } + virtual const std::string& GetSessionName() const MOZ_OVERRIDE { + return mSessionName; + } // Note: connection information is always retrieved from media sections - virtual Maybe GetBandwidth( - const std::string& type) const MOZ_OVERRIDE; + virtual const Maybe& + GetBandwidth(const std::string& type) const MOZ_OVERRIDE; virtual uint16_t GetMediaSectionCount() const MOZ_OVERRIDE { return static_cast(mMediaSections.size()); } - virtual const SdpAttributeList &GetAttributeList() const MOZ_OVERRIDE { + virtual const SdpAttributeList& GetAttributeList() const MOZ_OVERRIDE { return mAttributeList; } - virtual SdpAttributeList &GetAttributeList() MOZ_OVERRIDE { + virtual SdpAttributeList& GetAttributeList() MOZ_OVERRIDE { return mAttributeList; } - virtual const SdpMediaSection &GetMediaSection( + virtual const SdpMediaSection& GetMediaSection( uint16_t level) const MOZ_OVERRIDE; virtual SdpMediaSection &GetMediaSection(uint16_t level) MOZ_OVERRIDE; @@ -58,9 +62,11 @@ class SipccSdp MOZ_FINAL : public Sdp void Load(sdp_t* sdp); - sdp_t *mSdp; std::vector mMediaSections; SipccSdpAttributeList mAttributeList; + std::map mBandwidths; + std::string mSessionName; + UniquePtr mOrigin; }; } // namespace mozilla diff --git a/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.h b/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.h index 8d95381abf995..a95ddc20f8e14 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.h +++ b/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.h @@ -59,7 +59,7 @@ class SipccSdpAttributeList : public SdpAttributeList private: SipccSdpAttributeList() {} - void Load(sdp_t* sdp, uint16_t levelmSdp, i + 1); + void Load(sdp_t* sdp, uint16_t level); sdp_t* mSdp; uint16_t mLevel; diff --git a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h index 6df3d832e77bb..d3955d2ec875e 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h +++ b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h @@ -49,10 +49,10 @@ class SipccSdpMediaSection MOZ_FINAL : public SdpMediaSection void LoadConnection(sdp_t* sdp, uint16_t level); // the following values are cached on first get - sdp::MediaType mMediaType; + MediaType mMediaType; uint16_t mPort; uint16_t mPortCount; - sdp::Protocol mProtocol; + Protocol mProtocol; std::vector mFormats; SipccSdpAttributeList mAttributes; diff --git a/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp b/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp index 3c420562818fa..2e8a34510cda8 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp @@ -31,7 +31,7 @@ SipccSdpParser::Parse(const std::string& sdpText) if (result == SDP_SUCCESS) { SipccSdp* sipccSdp = new SipccSdp(); sipccSdp->Load(sdp); - return UniquePtr(sipccSdp); + return UniquePtr>(sipccSdp); } sdp_free_description(sdp);