зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1628630 - Add Support for RTX in WebRTC SDP CAPI;r=dminor
Differential Revision: https://phabricator.services.mozilla.com/D70330 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4f8f4fd418
Коммит
5e3d3c4d85
|
@ -680,6 +680,9 @@ std::tuple<SdpRtpmapAttributeList::CodecType, FmtDefaults> strToCodecType(
|
|||
} else if (!nsCRT::strcasecmp(name.c_str(), "telephone-event")) {
|
||||
codec = SdpRtpmapAttributeList::kTelephoneEvent;
|
||||
defaults = {1};
|
||||
} else if (!nsCRT::strcasecmp(name.c_str(), "rtx")) {
|
||||
codec = SdpRtpmapAttributeList::kRtx;
|
||||
defaults = {0};
|
||||
}
|
||||
return std::make_tuple(codec, defaults);
|
||||
}
|
||||
|
@ -777,11 +780,17 @@ void RsdparsaSdpAttributeList::LoadFmtp(RustAttributeList* attributeList) {
|
|||
|
||||
fmtpParameters.reset(
|
||||
new SdpFmtpAttributeList::RedParameters(std::move(redParameters)));
|
||||
} else if (codecName == "RTX") {
|
||||
Maybe<uint32_t> rtx_time = Nothing();
|
||||
if (rustFmtpParameters.rtx.has_rtx_time) {
|
||||
rtx_time = Some(rustFmtpParameters.rtx.rtx_time);
|
||||
}
|
||||
fmtpParameters.reset(new SdpFmtpAttributeList::RtxParameters(
|
||||
rustFmtpParameters.rtx.apt, rtx_time));
|
||||
} else {
|
||||
// The parameter set is unknown so skip it
|
||||
continue;
|
||||
}
|
||||
|
||||
fmtpList->PushEntry(std::to_string(payloadType), std::move(fmtpParameters));
|
||||
}
|
||||
SetAttribute(fmtpList.release());
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#define _RUSTSDPINC_H_
|
||||
|
||||
#include "nsError.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -193,6 +194,12 @@ struct RustSdpAttributeImageAttr {
|
|||
RustSdpAttributeImageAttrSetList recv;
|
||||
};
|
||||
|
||||
struct RustRtxFmtpParameters {
|
||||
uint8_t apt;
|
||||
bool has_rtx_time;
|
||||
uint32_t rtx_time;
|
||||
};
|
||||
|
||||
struct RustSdpAttributeFmtpParameters {
|
||||
// H264
|
||||
uint32_t packetization_mode;
|
||||
|
@ -218,6 +225,9 @@ struct RustSdpAttributeFmtpParameters {
|
|||
// telephone-event
|
||||
StringView dtmf_tones;
|
||||
|
||||
// RTX
|
||||
RustRtxFmtpParameters rtx;
|
||||
|
||||
// Red codecs
|
||||
U8Vec* encodings;
|
||||
|
||||
|
|
|
@ -1046,6 +1046,7 @@ static bool ShouldSerializeChannels(SdpRtpmapAttributeList::CodecType type) {
|
|||
case SdpRtpmapAttributeList::kRed:
|
||||
case SdpRtpmapAttributeList::kUlpfec:
|
||||
case SdpRtpmapAttributeList::kTelephoneEvent:
|
||||
case SdpRtpmapAttributeList::kRtx:
|
||||
return false;
|
||||
case SdpRtpmapAttributeList::kOtherCodec:
|
||||
return true;
|
||||
|
|
|
@ -1071,6 +1071,7 @@ class SdpRtpmapAttributeList : public SdpAttribute {
|
|||
kRed,
|
||||
kUlpfec,
|
||||
kTelephoneEvent,
|
||||
kRtx,
|
||||
kOtherCodec
|
||||
};
|
||||
|
||||
|
@ -1153,6 +1154,9 @@ inline std::ostream& operator<<(std::ostream& os,
|
|||
case SdpRtpmapAttributeList::kTelephoneEvent:
|
||||
os << "telephone-event";
|
||||
break;
|
||||
case SdpRtpmapAttributeList::kRtx:
|
||||
os << "rtx";
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT(false);
|
||||
os << "?";
|
||||
|
@ -1208,6 +1212,36 @@ class SdpFmtpAttributeList : public SdpAttribute {
|
|||
std::vector<uint8_t> encodings;
|
||||
};
|
||||
|
||||
class RtxParameters : public Parameters {
|
||||
public:
|
||||
uint8_t apt;
|
||||
Maybe<uint32_t> rtx_time;
|
||||
|
||||
RtxParameters(const uint8_t aApt, const Maybe<uint32_t>& aRtxTime)
|
||||
: Parameters(SdpRtpmapAttributeList::kRtx),
|
||||
apt(aApt),
|
||||
rtx_time(aRtxTime) {}
|
||||
|
||||
virtual ~RtxParameters() {}
|
||||
|
||||
virtual Parameters* Clone() const override {
|
||||
return new RtxParameters(*this);
|
||||
}
|
||||
|
||||
virtual void Serialize(std::ostream& os) const override {
|
||||
os << "apt=" << apt;
|
||||
rtx_time.apply([&](const auto& time) { os << ";rtx-time=" << time; });
|
||||
}
|
||||
|
||||
virtual bool CompareEq(const Parameters& aOther) const override {
|
||||
if (aOther.codec_type != codec_type) {
|
||||
return false;
|
||||
}
|
||||
auto other = static_cast<const RtxParameters&>(aOther);
|
||||
return other.apt == apt && other.rtx_time == rtx_time;
|
||||
}
|
||||
};
|
||||
|
||||
class H264Parameters : public Parameters {
|
||||
public:
|
||||
static const uint32_t kDefaultProfileLevelId = 0x420010;
|
||||
|
|
|
@ -398,6 +398,14 @@ pub unsafe extern "C" fn sdp_get_rtpmaps(
|
|||
rtpmaps.copy_from_slice(attrs.as_slice());
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct RustRtxFmtpParameters {
|
||||
pub apt: u8,
|
||||
pub has_rtx_time: bool,
|
||||
pub rtx_time: u32,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct RustSdpAttributeFmtpParameters {
|
||||
|
@ -425,6 +433,9 @@ pub struct RustSdpAttributeFmtpParameters {
|
|||
// telephone-event
|
||||
pub dtmf_tones: StringView,
|
||||
|
||||
// RTX
|
||||
pub rtx: RustRtxFmtpParameters,
|
||||
|
||||
// Red
|
||||
pub encodings: *const Vec<u8>,
|
||||
|
||||
|
@ -434,6 +445,20 @@ pub struct RustSdpAttributeFmtpParameters {
|
|||
|
||||
impl<'a> From<&'a SdpAttributeFmtpParameters> for RustSdpAttributeFmtpParameters {
|
||||
fn from(other: &SdpAttributeFmtpParameters) -> Self {
|
||||
let rtx = if let Some(rtx) = other.rtx {
|
||||
RustRtxFmtpParameters {
|
||||
apt: rtx.apt,
|
||||
has_rtx_time: rtx.rtx_time.is_some(),
|
||||
rtx_time: rtx.rtx_time.unwrap_or(0),
|
||||
}
|
||||
} else {
|
||||
RustRtxFmtpParameters {
|
||||
apt: 0,
|
||||
has_rtx_time: false,
|
||||
rtx_time: 0,
|
||||
}
|
||||
};
|
||||
|
||||
RustSdpAttributeFmtpParameters {
|
||||
packetization_mode: other.packetization_mode,
|
||||
level_asymmetry_allowed: other.level_asymmetry_allowed,
|
||||
|
@ -450,6 +475,7 @@ impl<'a> From<&'a SdpAttributeFmtpParameters> for RustSdpAttributeFmtpParameters
|
|||
max_fr: other.max_fr,
|
||||
maxplaybackrate: other.maxplaybackrate,
|
||||
dtmf_tones: StringView::from(other.dtmf_tones.as_str()),
|
||||
rtx,
|
||||
encodings: &other.encodings,
|
||||
unknown_tokens: &other.unknown_tokens,
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче