зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1225722 - Make the MediaType in JsepCodecDescription instances static. r=bwc
Differential Revision: https://phabricator.services.mozilla.com/D136625
This commit is contained in:
Родитель
ec4ddc911d
Коммит
f9b9fbaf47
|
@ -669,7 +669,7 @@ class ConfigureCodec {
|
|||
}
|
||||
|
||||
void operator()(UniquePtr<JsepCodecDescription>& codec) const {
|
||||
switch (codec->mType) {
|
||||
switch (codec->Type()) {
|
||||
case SdpMediaSection::kAudio: {
|
||||
JsepAudioCodecDescription& audioCodec =
|
||||
static_cast<JsepAudioCodecDescription&>(*codec);
|
||||
|
@ -769,7 +769,7 @@ class ConfigureRedCodec {
|
|||
}
|
||||
|
||||
void operator()(UniquePtr<JsepCodecDescription>& codec) const {
|
||||
if (codec->mType == SdpMediaSection::kVideo && codec->mEnabled == false) {
|
||||
if (codec->Type() == SdpMediaSection::kVideo && !codec->mEnabled) {
|
||||
uint8_t pt = (uint8_t)strtoul(codec->mDefaultPt.c_str(), nullptr, 10);
|
||||
// don't search for the codec payload type unless we have a valid
|
||||
// conversion (non-zero)
|
||||
|
@ -906,11 +906,11 @@ nsresult PeerConnectionImpl::GetDatachannelParameters(
|
|||
}
|
||||
|
||||
for (const auto& codec : encoding.GetCodecs()) {
|
||||
if (codec->mType != SdpMediaSection::kApplication) {
|
||||
if (codec->Type() != SdpMediaSection::kApplication) {
|
||||
CSFLogError(LOGTAG,
|
||||
"%s: Codec type for m=application was %u, this "
|
||||
"is a bug.",
|
||||
__FUNCTION__, static_cast<unsigned>(codec->mType));
|
||||
__FUNCTION__, static_cast<unsigned>(codec->Type()));
|
||||
MOZ_ASSERT(false, "Codec for m=application was not \"application\"");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -734,8 +734,8 @@ RefPtr<MediaPipelineTransmit> TransceiverImpl::GetSendPipeline() {
|
|||
|
||||
static nsresult JsepCodecDescToAudioCodecConfig(
|
||||
const JsepCodecDescription& aCodec, Maybe<AudioCodecConfig>* aConfig) {
|
||||
MOZ_ASSERT(aCodec.mType == SdpMediaSection::kAudio);
|
||||
if (aCodec.mType != SdpMediaSection::kAudio) return NS_ERROR_INVALID_ARG;
|
||||
MOZ_ASSERT(aCodec.Type() == SdpMediaSection::kAudio);
|
||||
if (aCodec.Type() != SdpMediaSection::kAudio) return NS_ERROR_INVALID_ARG;
|
||||
|
||||
const JsepAudioCodecDescription& desc =
|
||||
static_cast<const JsepAudioCodecDescription&>(aCodec);
|
||||
|
@ -857,8 +857,8 @@ nsresult TransceiverImpl::UpdateAudioConduit() {
|
|||
|
||||
static nsresult JsepCodecDescToVideoCodecConfig(
|
||||
const JsepCodecDescription& aCodec, Maybe<VideoCodecConfig>* aConfig) {
|
||||
MOZ_ASSERT(aCodec.mType == SdpMediaSection::kVideo);
|
||||
if (aCodec.mType != SdpMediaSection::kVideo) {
|
||||
MOZ_ASSERT(aCodec.Type() == SdpMediaSection::kVideo);
|
||||
if (aCodec.Type() != SdpMediaSection::kVideo) {
|
||||
MOZ_ASSERT(false, "JsepCodecDescription has wrong type");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
|
|
@ -19,11 +19,9 @@ namespace mozilla {
|
|||
// A single entry in our list of known codecs.
|
||||
class JsepCodecDescription {
|
||||
public:
|
||||
JsepCodecDescription(mozilla::SdpMediaSection::MediaType type,
|
||||
const std::string& defaultPt, const std::string& name,
|
||||
JsepCodecDescription(const std::string& defaultPt, const std::string& name,
|
||||
uint32_t clock, uint32_t channels, bool enabled)
|
||||
: mType(type),
|
||||
mDefaultPt(defaultPt),
|
||||
: mDefaultPt(defaultPt),
|
||||
mName(name),
|
||||
mClock(clock),
|
||||
mChannels(channels),
|
||||
|
@ -32,6 +30,8 @@ class JsepCodecDescription {
|
|||
mDirection(sdp::kSend) {}
|
||||
virtual ~JsepCodecDescription() {}
|
||||
|
||||
virtual SdpMediaSection::MediaType Type() const = 0;
|
||||
|
||||
virtual JsepCodecDescription* Clone() const = 0;
|
||||
|
||||
bool GetPtAsInt(uint16_t* ptOutparam) const {
|
||||
|
@ -41,7 +41,7 @@ class JsepCodecDescription {
|
|||
virtual bool Matches(const std::string& fmt,
|
||||
const SdpMediaSection& remoteMsection) const {
|
||||
// note: fmt here is remote fmt (to go with remoteMsection)
|
||||
if (mType != remoteMsection.GetMediaType()) {
|
||||
if (Type() != remoteMsection.GetMediaType()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ class JsepCodecDescription {
|
|||
}
|
||||
|
||||
virtual void AddToMediaSection(SdpMediaSection& msection) const {
|
||||
if (mEnabled && msection.GetMediaType() == mType) {
|
||||
if (mEnabled && msection.GetMediaType() == Type()) {
|
||||
if (mDirection == sdp::kRecv) {
|
||||
msection.AddCodec(mDefaultPt, mName, mClock, mChannels);
|
||||
}
|
||||
|
@ -129,7 +129,6 @@ class JsepCodecDescription {
|
|||
return false;
|
||||
}
|
||||
|
||||
mozilla::SdpMediaSection::MediaType mType;
|
||||
std::string mDefaultPt;
|
||||
std::string mName;
|
||||
uint32_t mClock;
|
||||
|
@ -146,8 +145,7 @@ class JsepAudioCodecDescription : public JsepCodecDescription {
|
|||
JsepAudioCodecDescription(const std::string& defaultPt,
|
||||
const std::string& name, uint32_t clock,
|
||||
uint32_t channels, bool enabled = true)
|
||||
: JsepCodecDescription(mozilla::SdpMediaSection::kAudio, defaultPt, name,
|
||||
clock, channels, enabled),
|
||||
: JsepCodecDescription(defaultPt, name, clock, channels, enabled),
|
||||
mMaxPlaybackRate(0),
|
||||
mForceMono(false),
|
||||
mFECEnabled(false),
|
||||
|
@ -159,6 +157,10 @@ class JsepAudioCodecDescription : public JsepCodecDescription {
|
|||
mMaxFrameSizeMs(0),
|
||||
mCbrEnabled(false) {}
|
||||
|
||||
static constexpr SdpMediaSection::MediaType type = SdpMediaSection::kAudio;
|
||||
|
||||
SdpMediaSection::MediaType Type() const override { return type; }
|
||||
|
||||
JSEP_CODEC_CLONE(JsepAudioCodecDescription)
|
||||
|
||||
SdpFmtpAttributeList::OpusParameters GetOpusParameters(
|
||||
|
@ -276,8 +278,7 @@ class JsepVideoCodecDescription : public JsepCodecDescription {
|
|||
JsepVideoCodecDescription(const std::string& defaultPt,
|
||||
const std::string& name, uint32_t clock,
|
||||
bool enabled = true)
|
||||
: JsepCodecDescription(mozilla::SdpMediaSection::kVideo, defaultPt, name,
|
||||
clock, 0, enabled),
|
||||
: JsepCodecDescription(defaultPt, name, clock, 0, enabled),
|
||||
mTmmbrEnabled(false),
|
||||
mRembEnabled(false),
|
||||
mFECEnabled(false),
|
||||
|
@ -291,6 +292,10 @@ class JsepVideoCodecDescription : public JsepCodecDescription {
|
|||
mCcmFbTypes.push_back(SdpRtcpFbAttributeList::fir);
|
||||
}
|
||||
|
||||
static constexpr SdpMediaSection::MediaType type = SdpMediaSection::kVideo;
|
||||
|
||||
SdpMediaSection::MediaType Type() const override { return type; }
|
||||
|
||||
virtual void EnableTmmbr() {
|
||||
// EnableTmmbr can be called multiple times due to multiple calls to
|
||||
// PeerConnectionImpl::ConfigureJsepSessionCodecs
|
||||
|
@ -826,8 +831,7 @@ class JsepVideoCodecDescription : public JsepCodecDescription {
|
|||
virtual void UpdateRedundantEncodings(
|
||||
const std::vector<UniquePtr<JsepCodecDescription>>& codecs) {
|
||||
for (const auto& codec : codecs) {
|
||||
if (codec->mType == SdpMediaSection::kVideo && codec->mEnabled &&
|
||||
codec->mName != "red") {
|
||||
if (codec->Type() == type && codec->mEnabled && codec->mName != "red") {
|
||||
uint16_t pt;
|
||||
if (!SdpHelper::GetPtAsInt(codec->mDefaultPt, &pt)) {
|
||||
continue;
|
||||
|
@ -877,20 +881,24 @@ class JsepApplicationCodecDescription : public JsepCodecDescription {
|
|||
uint16_t localPort,
|
||||
uint32_t localMaxMessageSize,
|
||||
bool enabled = true)
|
||||
: JsepCodecDescription(mozilla::SdpMediaSection::kApplication, "", name,
|
||||
0, channels, enabled),
|
||||
: JsepCodecDescription("", name, 0, channels, enabled),
|
||||
mLocalPort(localPort),
|
||||
mLocalMaxMessageSize(localMaxMessageSize),
|
||||
mRemotePort(0),
|
||||
mRemoteMaxMessageSize(0),
|
||||
mRemoteMMSSet(false) {}
|
||||
|
||||
static constexpr SdpMediaSection::MediaType type =
|
||||
SdpMediaSection::kApplication;
|
||||
|
||||
SdpMediaSection::MediaType Type() const override { return type; }
|
||||
|
||||
JSEP_CODEC_CLONE(JsepApplicationCodecDescription)
|
||||
|
||||
// Override, uses sctpport or sctpmap instead of rtpmap
|
||||
virtual bool Matches(const std::string& fmt,
|
||||
const SdpMediaSection& remoteMsection) const override {
|
||||
if (mType != remoteMsection.GetMediaType()) {
|
||||
if (type != remoteMsection.GetMediaType()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -914,7 +922,7 @@ class JsepApplicationCodecDescription : public JsepCodecDescription {
|
|||
}
|
||||
|
||||
virtual void AddToMediaSection(SdpMediaSection& msection) const override {
|
||||
if (mEnabled && msection.GetMediaType() == mType) {
|
||||
if (mEnabled && msection.GetMediaType() == type) {
|
||||
if (mDirection == sdp::kRecv) {
|
||||
msection.AddDataChannel(mName, mLocalPort, mChannels,
|
||||
mLocalMaxMessageSize);
|
||||
|
|
|
@ -64,7 +64,7 @@ void JsepTrack::PopulateCodecs(
|
|||
const std::vector<UniquePtr<JsepCodecDescription>>& prototype) {
|
||||
mPrototypeCodecs.clear();
|
||||
for (const auto& prototypeCodec : prototype) {
|
||||
if (prototypeCodec->mType == mType) {
|
||||
if (prototypeCodec->Type() == mType) {
|
||||
mPrototypeCodecs.emplace_back(prototypeCodec->Clone());
|
||||
mPrototypeCodecs.back()->mDirection = mDirection;
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ void JsepTrack::PruneSsrcs(size_t aNumSsrcs) {
|
|||
bool JsepTrack::IsRtxEnabled(
|
||||
const std::vector<UniquePtr<JsepCodecDescription>>& codecs) const {
|
||||
for (const auto& codec : codecs) {
|
||||
if (codec->mType == SdpMediaSection::kVideo &&
|
||||
if (codec->Type() == SdpMediaSection::kVideo &&
|
||||
static_cast<const JsepVideoCodecDescription*>(codec.get())
|
||||
->mRtxEnabled) {
|
||||
return true;
|
||||
|
@ -414,7 +414,7 @@ std::vector<UniquePtr<JsepCodecDescription>> JsepTrack::NegotiateCodecs(
|
|||
codec->mDefaultPt = fmt;
|
||||
|
||||
// Remember whether we negotiated rtx and the associated pt for later.
|
||||
if (codec->mType == SdpMediaSection::kVideo) {
|
||||
if (codec->Type() == SdpMediaSection::kVideo) {
|
||||
JsepVideoCodecDescription* videoCodec =
|
||||
static_cast<JsepVideoCodecDescription*>(codec.get());
|
||||
JsepVideoCodecDescription* cloneVideoCodec =
|
||||
|
|
|
@ -732,13 +732,13 @@ class JsepSessionTest : public JsepSessionTestBase,
|
|||
void EnsureNegotiationFailure(SdpMediaSection::MediaType type,
|
||||
const std::string& codecName) {
|
||||
for (auto& codec : mSessionOff->Codecs()) {
|
||||
if (codec->mType == type && codec->mName != codecName) {
|
||||
if (codec->Type() == type && codec->mName != codecName) {
|
||||
codec->mEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& codec : mSessionAns->Codecs()) {
|
||||
if (codec->mType == type && codec->mName == codecName) {
|
||||
if (codec->Type() == type && codec->mName == codecName) {
|
||||
codec->mEnabled = false;
|
||||
}
|
||||
}
|
||||
|
@ -7055,7 +7055,7 @@ TEST_F(JsepSessionTest, TestAnswerPTAsymmetryRtxApt) {
|
|||
|
||||
TEST_F(JsepSessionTest, TestOfferNoRtx) {
|
||||
for (auto& codec : mSessionOff->Codecs()) {
|
||||
if (codec->mType == SdpMediaSection::kVideo) {
|
||||
if (codec->Type() == SdpMediaSection::kVideo) {
|
||||
JsepVideoCodecDescription* videoCodec =
|
||||
static_cast<JsepVideoCodecDescription*>(codec.get());
|
||||
videoCodec->mRtxEnabled = false;
|
||||
|
@ -7091,7 +7091,7 @@ TEST_F(JsepSessionTest, TestOfferNoRtx) {
|
|||
|
||||
TEST_F(JsepSessionTest, TestOneWayRtx) {
|
||||
for (auto& codec : mSessionAns->Codecs()) {
|
||||
if (codec->mType == SdpMediaSection::kVideo) {
|
||||
if (codec->Type() == SdpMediaSection::kVideo) {
|
||||
JsepVideoCodecDescription* videoCodec =
|
||||
static_cast<JsepVideoCodecDescription*>(codec.get());
|
||||
videoCodec->mRtxEnabled = false;
|
||||
|
@ -7185,7 +7185,7 @@ TEST_F(JsepSessionTest, TestOfferRtxNoMsid) {
|
|||
|
||||
TEST_F(JsepSessionTest, TestDuplicatePayloadTypes) {
|
||||
for (auto& codec : mSessionOff->Codecs()) {
|
||||
if (codec->mType == SdpMediaSection::kVideo) {
|
||||
if (codec->Type() == SdpMediaSection::kVideo) {
|
||||
JsepVideoCodecDescription* videoCodec =
|
||||
static_cast<JsepVideoCodecDescription*>(codec.get());
|
||||
videoCodec->mRtxPayloadType = "97";
|
||||
|
|
|
@ -234,7 +234,7 @@ class JsepTrackTest : public JsepTrackTestBase {
|
|||
// it should not be possible for codecs to have a different type
|
||||
// than the track, but we'll check the codec here just in case.
|
||||
if (codecs.size() != expectedSize || codecIndex >= expectedSize ||
|
||||
codecs[codecIndex]->mType != type) {
|
||||
codecs[codecIndex]->Type() != type) {
|
||||
return nullptr;
|
||||
}
|
||||
return UniquePtr<JsepCodecDescription>(codecs[codecIndex]->Clone());
|
||||
|
@ -281,8 +281,8 @@ class JsepTrackTest : public JsepTrackTestBase {
|
|||
#define MSG \
|
||||
"For codecs " << a.mName << " (" << a.mDirection << ") and " << b.mName \
|
||||
<< " (" << b.mDirection << ")"
|
||||
ASSERT_EQ(a.mType, b.mType) << MSG;
|
||||
if (a.mType != SdpMediaSection::kApplication) {
|
||||
ASSERT_EQ(a.Type(), b.Type()) << MSG;
|
||||
if (a.Type() != SdpMediaSection::kApplication) {
|
||||
ASSERT_EQ(a.mDefaultPt, b.mDefaultPt) << MSG;
|
||||
}
|
||||
ASSERT_EQ(a.mName, b.mName);
|
||||
|
@ -293,7 +293,7 @@ class JsepTrackTest : public JsepTrackTestBase {
|
|||
ASSERT_EQ(a.mConstraints, b.mConstraints) << MSG;
|
||||
#undef MSG
|
||||
|
||||
if (a.mType == SdpMediaSection::kVideo) {
|
||||
if (a.Type() == SdpMediaSection::kVideo) {
|
||||
SanityCheckRtcpFbs(static_cast<const JsepVideoCodecDescription&>(a),
|
||||
static_cast<const JsepVideoCodecDescription&>(b));
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ class CheckForCodecType {
|
|||
: mResult(result), mType(type) {}
|
||||
|
||||
void operator()(const UniquePtr<JsepCodecDescription>& codec) {
|
||||
if (codec->mType == mType) {
|
||||
if (codec->Type() == mType) {
|
||||
*mResult = true;
|
||||
}
|
||||
}
|
||||
|
@ -1469,7 +1469,7 @@ TEST_F(JsepTrackTest, RtcpFbWithPayloadTypeAsymmetry) {
|
|||
|
||||
// On offerer, configure to support remb and transport-cc on video codecs
|
||||
for (auto& codec : mOffCodecs) {
|
||||
if (codec->mType == SdpMediaSection::kVideo) {
|
||||
if (codec->Type() == SdpMediaSection::kVideo) {
|
||||
auto& videoCodec = static_cast<JsepVideoCodecDescription&>(*codec);
|
||||
videoCodec.EnableRemb();
|
||||
videoCodec.EnableTransportCC();
|
||||
|
|
Загрузка…
Ссылка в новой задаче