Bug 1473967: Added C++/Rust glue code for maxptime, r=dminor
Added the C++/Rust glue code for maxptime.
Added the C++ unit test CheckMaxPtime.
MozReview-Commit-ID: 58Qbrpktxwx
--- a/media/webrtc/signaling/gtest/sdp_unittests.cpp
+++ b/media/webrtc/signaling/gtest/sdp_unittests.cpp
@@ -3272,16 +3272,28 @@ TEST_P(NewSdpTest, CheckSctpmap) {
// Need to know name of type
CheckSctpmap("5000",
"webrtc-datachannel",
16,
appsec.GetFormats()[0],
sctpmap);
}
+TEST_P(NewSdpTest, CheckMaxPtime) {
+ ParseSdp(kBasicAudioVideoOffer);
+ ASSERT_TRUE(!!mSdp) << "Parse failed: " << GetParseErrors();
+ ASSERT_EQ(3U, mSdp->GetMediaSectionCount())
+ << "Wrong number of media sections";
+
+ ASSERT_TRUE(mSdp->GetMediaSection(0)
+ .GetAttributeList()
+ .HasAttribute(SdpAttribute::kMaxptimeAttribute));
+ ASSERT_EQ(mSdp->GetMediaSection(0).GetAttributeList().GetMaxptime(), 20U);
+}
+
const std::string kNewSctpportOfferDraft21 =
"v=0" CRLF
"o=Mozilla-SIPUA-35.0a1 27987 0 IN IP4 0.0.0.0" CRLF
"s=SIP Call" CRLF
"t=0 0" CRLF
"a=ice-ufrag:8a39d2ae" CRLF
"a=ice-pwd:601d53aba51a318351b3ecf5ee00048f" CRLF
"a=fingerprint:sha-256 30:FF:8E:2B:AC:9D:ED:70:18:10:67:C8:AE:9E:68:F3:86:53:51:B0:AC:31:B7:BE:6D:CF:A4:2E:D3:6E:B4:28" CRLF
--- a/media/webrtc/signaling/src/sdp/RsdparsaSdpAttributeList.cpp
+++ b/media/webrtc/signaling/src/sdp/RsdparsaSdpAttributeList.cpp
@@ -475,20 +475,22 @@ RsdparsaSdpAttributeList::LoadAttribute(
LoadSctpPort(attributeList);
return ;
case SdpAttribute::kExtmapAttribute:
LoadExtmap(attributeList);
return;
case SdpAttribute::kSimulcastAttribute:
LoadSimulcast(attributeList);
return;
+ case SdpAttribute::kMaxptimeAttribute:
+ LoadMaxPtime(attributeList);
+ return;
case SdpAttribute::kDtlsMessageAttribute:
case SdpAttribute::kLabelAttribute:
- case SdpAttribute::kMaxptimeAttribute:
case SdpAttribute::kSsrcGroupAttribute:
case SdpAttribute::kRtcpRsizeAttribute:
case SdpAttribute::kCandidateAttribute:
case SdpAttribute::kConnectionAttribute:
case SdpAttribute::kIceMismatchAttribute:
// TODO: Not implemented, or not applicable.
// Sort this out in Bug 1437165.
return;
@@ -1170,16 +1172,26 @@ RsdparsaSdpAttributeList::LoadExtmap(Rus
std::string extensionAttributes;
extensionAttributes = convertStringView(rustExtmap.extensionAttributes);
extmaps->PushEntry((uint16_t) rustExtmap.id, direction,
directionSpecified, name, extensionAttributes);
}
SetAttribute(extmaps.release());
}
+void
+RsdparsaSdpAttributeList::LoadMaxPtime(RustAttributeList* attributeList)
+{
+ uint64_t maxPtime = 0;
+ nsresult nr = sdp_get_maxptime(attributeList, &maxPtime);
+ if (NS_SUCCEEDED(nr)) {
+ SetAttribute(new SdpNumberAttribute(SdpAttribute::kMaxptimeAttribute,
+ maxPtime));
+ }
+}
bool
RsdparsaSdpAttributeList::IsAllowedHere(SdpAttribute::AttributeType type)
{
if (AtSessionLevel() && !SdpAttribute::IsAllowedAtSessionLevel(type)) {
return false;
}
--- a/media/webrtc/signaling/src/sdp/RsdparsaSdpAttributeList.h
+++ b/media/webrtc/signaling/src/sdp/RsdparsaSdpAttributeList.h
@@ -139,16 +139,17 @@ private:
void LoadSctpPort(RustAttributeList* attributeList);
void LoadSimulcast(RustAttributeList* attributeList);
void LoadImageattr(RustAttributeList* attributeList);
void LoadSctpmaps(RustAttributeList* attributeList);
void LoadDirection(RustAttributeList* attributeList);
void LoadRemoteCandidates(RustAttributeList* attributeList);
void LoadRids(RustAttributeList* attributeList);
void LoadExtmap(RustAttributeList* attributeList);
+ void LoadMaxPtime(RustAttributeList* attributeList);
void WarnAboutMisplacedAttribute(SdpAttribute::AttributeType type,
uint32_t lineNumber,
SdpErrorHolder& errorHolder);
SdpAttribute* mAttributes[kNumAttributeTypes];
--- a/media/webrtc/signaling/src/sdp/RsdparsaSdpInc.h
+++ b/media/webrtc/signaling/src/sdp/RsdparsaSdpInc.h
@@ -330,16 +330,17 @@ void sdp_get_rtpmaps(const RustAttribute
size_t sdp_get_fmtp_count(const RustAttributeList* aList);
size_t sdp_get_fmtp(const RustAttributeList* aList, size_t listSize,
RustSdpAttributeFmtp* ret);
int64_t sdp_get_ptime(const RustAttributeList* aList);
int64_t sdp_get_max_msg_size(const RustAttributeList* aList);
int64_t sdp_get_sctp_port(const RustAttributeList* aList);
+nsresult sdp_get_maxptime(const RustAttributeList* aList, uint64_t* aMaxPtime);
RustSdpAttributeFlags sdp_get_attribute_flags(const RustAttributeList* aList);
nsresult sdp_get_mid(const RustAttributeList* aList, StringView* ret);
size_t sdp_get_msid_count(const RustAttributeList* aList);
void sdp_get_msids(const RustAttributeList* aList, size_t listSize,
RustSdpAttributeMsid* ret);
--- a/media/webrtc/signaling/src/sdp/rsdparsa_capi/src/attribute.rs
+++ b/media/webrtc/signaling/src/sdp/rsdparsa_capi/src/attribute.rs
@@ -1,10 +1,10 @@
use std::slice;
-use libc::{size_t, uint8_t, uint16_t, uint32_t, int64_t};
+use libc::{size_t, uint8_t, uint16_t, uint32_t, int64_t, uint64_t};
use rsdparsa::SdpSession;
use rsdparsa::attribute_type::*;
use nserror::{nsresult, NS_OK, NS_ERROR_INVALID_ARG};
use types::StringView;
use network::RustIpAddr;
@@ -177,16 +177,26 @@ pub unsafe extern "C" fn sdp_get_iceopti
let attr = get_attribute((*attributes).as_slice(), RustSdpAttributeType::IceOptions);
if let Some(&SdpAttribute::IceOptions(ref options)) = attr {
*ret = options;
return NS_OK;
}
NS_ERROR_INVALID_ARG
}
+#[no_mangle]
+pub unsafe extern "C" fn sdp_get_maxptime(attributes: *const Vec<SdpAttribute>, ret: *mut uint64_t) -> nsresult {
+ let attr = get_attribute((*attributes).as_slice(), RustSdpAttributeType::MaxPtime);
+ if let Some(&SdpAttribute::MaxPtime(ref max_ptime)) = attr {
+ *ret = *max_ptime;
+ return NS_OK;
+ }
+ NS_ERROR_INVALID_ARG
+}
+
#[repr(C)]
#[derive(Clone, Copy)]
pub struct RustSdpAttributeFingerprint {
hash_algorithm: StringView,
fingerprint: StringView
}
impl<'a> From<&'a SdpAttributeFingerprint> for RustSdpAttributeFingerprint {