diff --git a/media/webrtc/signaling/src/sdp/SdpAttribute.h b/media/webrtc/signaling/src/sdp/SdpAttribute.h index 634c71432b971..b2e8993a8fe0d 100644 --- a/media/webrtc/signaling/src/sdp/SdpAttribute.h +++ b/media/webrtc/signaling/src/sdp/SdpAttribute.h @@ -56,8 +56,8 @@ class SdpAttribute kOtherAttribute }; - SdpAttribute(AttributeType type, std::string typeName) : - mType(type), mTypeName(typeName) {} + SdpAttribute(AttributeType type, const std::string& typeName) + : mType(type), mTypeName(typeName) {} virtual ~SdpAttribute() {} virtual AttributeType GetType() diff --git a/media/webrtc/signaling/src/sdp/SdpAttributeList.h b/media/webrtc/signaling/src/sdp/SdpAttributeList.h index 94baa2f4c4700..d53e670b42064 100644 --- a/media/webrtc/signaling/src/sdp/SdpAttributeList.h +++ b/media/webrtc/signaling/src/sdp/SdpAttributeList.h @@ -18,11 +18,11 @@ namespace mozilla { class SdpAttributeList { public: - virtual unsigned int CountAttributes(sdp::AttributeType type) const = 0; - virtual bool HasAttribute(sdp::AttributeType type) const = 0; + typedef SdpAttribute::AttributeType AttributeType; - virtual UniquePtr - GetAttribute(sdp::AttributeType type) const = 0; + virtual size_t CountAttributes(AttributeType type) const = 0; + virtual bool HasAttribute(AttributeType type) const = 0; + virtual const SdpAttribute& GetAttribute(AttributeType type, size_t index = 0) const = 0; virtual const SdpCandidateAttribute& GetCandidate() const = 0; virtual const SdpConnectionAttribute& GetConnection() const = 0; @@ -36,11 +36,11 @@ class SdpAttributeList 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 uint32_t GetMaxprate() const = 0; + virtual uint32_t GetMaxptime() const = 0; virtual std::string GetMid() const = 0; virtual const SdpMsidAttribute& GetMsid() const = 0; - virtual unsigned int GetPtime() const = 0; + virtual uint32_t GetPtime() const = 0; virtual const SdpRtcpAttribute& GetRtcp() const = 0; virtual const SdpRtcpFbAttribute& GetRtcpFb() const = 0; virtual const SdpRemoteCandidatesAttribute& GetRemoteCandidates() const = 0; diff --git a/media/webrtc/signaling/src/sdp/SipccSdp.cpp b/media/webrtc/signaling/src/sdp/SipccSdp.cpp index 8491643b38f98..d68638e663786 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdp.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdp.cpp @@ -4,6 +4,8 @@ #include "signaling/src/sdp/SipccSdp.h" +#include "mozilla/Assertions.h" + namespace mozilla { SdpOrigin @@ -16,7 +18,7 @@ SipccSdp::GetSessionName() const { return "TODO"; } -const Maybe& +const Maybe SipccSdp::GetBandwidth(const std::string& type) const { if (mBandwidths.count(type) > 0) { return Nothing(); @@ -24,14 +26,21 @@ SipccSdp::GetBandwidth(const std::string& type) const { return Some(mBandwidths[type]); } -const SdpMediaSection & -SipccSdp::GetMediaSection(unsigned int level) const +const SdpMediaSection& +SipccSdp::GetMediaSection(uint16_t level) const { + if (level > mMediaSections.size()) { + MOZ_CRASH(); + } return mMediaSections[level]; } -SdpMediaSection & -SipccSdp::GetMediaSection(unsigned int 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 3299a86036d72..740ce45305aab 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdp.h +++ b/media/webrtc/signaling/src/sdp/SipccSdp.h @@ -26,9 +26,7 @@ class SipccSdp MOZ_FINAL : public Sdp { friend class SipccSdpParser; public: - ~SipccSdp() { - sdp_free_description(mSdp); - } + ~SipccSdp() {} virtual const SdpOrigin& GetOrigin() const MOZ_OVERRIDE { return *mOrigin; @@ -58,9 +56,7 @@ class SipccSdp MOZ_FINAL : public Sdp virtual SdpMediaSection &GetMediaSection(uint16_t level) MOZ_OVERRIDE; private: - explicit SipccSdp(sdp_t* sdp) : - mSdp(sdp), - mAttributeList(sdp, 0) {} + explicit SipccSdp() {} void Load(sdp_t* sdp); diff --git a/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.cpp b/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.cpp index 6c4825ea3887e..1c32b63416203 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.cpp @@ -6,56 +6,58 @@ #include "signaling/src/sdp/SipccSdpAttributeList.h" +#include "mozilla/Assertions.h" + namespace mozilla { unsigned int -SipccSdpAttributeList::CountAttributes(sdp::AttributeType type) const { +SipccSdpAttributeList::CountAttributes(AttributeType type) const { return 0; } bool -SipccSdpAttributeList::HasAttribute(sdp::AttributeType type) const { +SipccSdpAttributeList::HasAttribute(AttributeType type) const { return false; } -UniquePtr -SipccSdpAttributeList::GetAttribute(sdp::AttributeType type) const { - return nullptr; +const Maybe +SipccSdpAttributeList::GetAttribute(AttributeType type, size_t index) const { + return Nothing(); } -UniquePtr +const SdpCandidateAttribute& SipccSdpAttributeList::GetCandidate() const { - return nullptr; + MOZ_CRASH() } -UniquePtr +const SdpConnectionAttribute& SipccSdpAttributeList::GetConnection() const { - return nullptr; + MOZ_CRASH(); } -UniquePtr +const SdpExtmapAttribute& SipccSdpAttributeList::GetExtmap() const { - return nullptr; + MOZ_CRASH() } -UniquePtr +const SdpFingerprintAttribute& SipccSdpAttributeList::GetFingerprint() const { - return nullptr; + MOZ_CRASH() } -UniquePtr +const SdpFmtpAttribute& SipccSdpAttributeList::GetFmtp() const { - return nullptr; + MOZ_CRASH() } -UniquePtr +const SdpGroupAttribute& SipccSdpAttributeList::GetGroup() const { - return nullptr; + MOZ_CRASH() } -UniquePtr +const SdpIceOptionsAttribute& SipccSdpAttributeList::GetIceOptions() const { - return nullptr; + MOZ_CRASH() } std::string @@ -68,14 +70,14 @@ SipccSdpAttributeList::GetIceUfrag() const { return ""; } -UniquePtr +const SdpIdentityAttribute& SipccSdpAttributeList::GetIdentity() const { - return nullptr; + MOZ_CRASH(); } -UniquePtr +const SdpImageattrAttribute& SipccSdpAttributeList::GetImageattr() const { - return nullptr; + MOZ_CRASH(); } std::string @@ -83,12 +85,12 @@ SipccSdpAttributeList::GetLabel() const { return ""; } -unsigned int +uint32_t SipccSdpAttributeList::GetMaxprate() const { return 0; } -unsigned int +uint32_t SipccSdpAttributeList::GetMaxptime() const { return 0; } @@ -98,54 +100,54 @@ SipccSdpAttributeList::GetMid() const { return ""; } -UniquePtr +const SdpMsidAttribute& SipccSdpAttributeList::GetMsid() const { - return nullptr; + MOZ_CRASH(); } -unsigned int +uint32_t SipccSdpAttributeList::GetPtime() const { return 0; } -UniquePtr +const SdpRtcpAttribute& SipccSdpAttributeList::GetRtcp() const { - return nullptr; + MOZ_CRASH(); } -UniquePtr +const SdpRtcpFbAttribute& SipccSdpAttributeList::GetRtcpFb() const { - return nullptr; + MOZ_CRASH(); } -//UniquePtr -//SipccSdpAttributeList::GetRemoteCandidates() const { -// return nullptr; -//} +const SdpRemoteCandidatesAttribute& +SipccSdpAttributeList::GetRemoteCandidates() const { + MOZ_CRASH(); +} -UniquePtr +const SdpRtpmapAttribute& SipccSdpAttributeList::GetRtpmap() const { - return nullptr; + MOZ_CRASH(); } -UniquePtr +const SdpSctpmapAttribute& SipccSdpAttributeList::GetSctpmap() const { - return nullptr; + MOZ_CRASH(); } -UniquePtr +const SdpSetupAttribute& SipccSdpAttributeList::GetSetup() const { - return nullptr; + MOZ_CRASH(); } -UniquePtr +const SdpSsrcAttribute& SipccSdpAttributeList::GetSsrc() const { - return nullptr; + MOZ_CRASH(); } -UniquePtr +const SdpSsrcGroupAttribute& SipccSdpAttributeList::GetSsrcGroup() const { - return nullptr; + MOZ_CRASH(); } void @@ -154,4 +156,3 @@ SipccSdpAttributeList::SetAttribute(const SdpAttribute &) { } // namespace mozilla - diff --git a/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.h b/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.h index 422e8c6655bd1..c8e4f2ef8207a 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.h +++ b/media/webrtc/signaling/src/sdp/SipccSdpAttributeList.h @@ -7,7 +7,7 @@ #ifndef _SIPCCSDPATTRIBUTELIST_H_ #define _SIPCCSDPATTRIBUTELIST_H_ -#include "signaling/src/sdp/SdpAttributeList.h" +#include "signaling/src/sdp/SdpAttribute.h" extern "C" { #include "signaling/src/sdp/sipcc/sdp.h" } @@ -22,11 +22,9 @@ class SipccSdpAttributeList : public SdpAttributeList friend class SipccSdpMediaSection; friend class SipccSdp; public: - virtual unsigned int CountAttributes(sdp::AttributeType type) const MOZ_OVERRIDE; - virtual bool HasAttribute(sdp::AttributeType type) const MOZ_OVERRIDE; - - virtual UniquePtr - GetAttribute(sdp::AttributeType type) const MOZ_OVERRIDE; + virtual size_t CountAttributes(AttributeType type) const MOZ_OVERRIDE; + virtual bool HasAttribute(AttributeType type) const MOZ_OVERRIDE; + virtual const SdpAttribute& GetAttribute(AttributeType type, size_t index = 0) const MOZ_OVERRIDE; virtual const SdpCandidateAttribute& GetCandidate() const MOZ_OVERRIDE; virtual const SdpConnectionAttribute& GetConnection() const MOZ_OVERRIDE; @@ -40,14 +38,14 @@ class SipccSdpAttributeList : public SdpAttributeList 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 uint32_t GetMaxprate() const MOZ_OVERRIDE; + virtual uint32_t GetMaxptime() 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 uint32_t GetPtime() 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 SdpRemoteCandidatesAttribute& 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; diff --git a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp index 72cf5f55d90cb..378e4017c5f6a 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.cpp @@ -18,7 +18,7 @@ SipccSdpMediaSection::GetPortCount() const { return mPortCount; } -sdp::Protocol +Protocol SipccSdpMediaSection::GetProtocol() const { return mProtocol; } diff --git a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h index 91c75c9265e0a..8dda625d574c0 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h +++ b/media/webrtc/signaling/src/sdp/SipccSdpMediaSection.h @@ -35,7 +35,7 @@ class SipccSdpMediaSection MOZ_FINAL : public SdpMediaSection virtual unsigned int GetPort() const MOZ_OVERRIDE; virtual unsigned int GetPortCount() const MOZ_OVERRIDE; - virtual sdp::Protocol GetProtocol() const MOZ_OVERRIDE; + virtual Protocol GetProtocol() const MOZ_OVERRIDE; virtual SdpConnection GetConnection() const MOZ_OVERRIDE; virtual Maybe GetBandwidth(const std::string& type) const MOZ_OVERRIDE; virtual std::vector GetFormats() const MOZ_OVERRIDE; @@ -44,11 +44,7 @@ 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() {} void Load(sdp_t* sdp, uint16_t level); void LoadConnection(sdp_t* sdp, uint16_t level); diff --git a/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp b/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp index 2e8a34510cda8..f48fd12be5c94 100644 --- a/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp +++ b/media/webrtc/signaling/src/sdp/SipccSdpParser.cpp @@ -31,6 +31,7 @@ SipccSdpParser::Parse(const std::string& sdpText) if (result == SDP_SUCCESS) { SipccSdp* sipccSdp = new SipccSdp(); sipccSdp->Load(sdp); + sdp_free_description(sdp); return UniquePtr>(sipccSdp); }