提交 21b4edc8 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Add dtx to RtpEncodingParameters and do not run the RTP inactivity timer in…

Add dtx to RtpEncodingParameters and do not run the RTP inactivity timer in RtpStreamRecv if DTX is enabled
上级 4c380e1a
......@@ -23,8 +23,7 @@ const mediaCodecs =
channels : 2,
parameters :
{
useinbandfec : 0,
foo : 'bar'
foo : 'bar'
}
},
{
......@@ -62,6 +61,7 @@ const audioProducerParameters =
parameters :
{
useinbandfec : 1,
usedtx : 1,
foo : 222.222,
bar : '333'
}
......@@ -299,6 +299,7 @@ test('transport.consume() succeeds', async () =>
parameters :
{
useinbandfec : 1,
usedtx : 1,
foo : 222.222,
bar : '333'
},
......@@ -484,6 +485,7 @@ test('consumer.dump() succeeds', async () =>
.toEqual(
{
useinbandfec : 1,
usedtx : 1,
foo : 222.222,
bar : '333'
});
......
......@@ -21,8 +21,7 @@ const mediaCodecs =
channels : 2,
parameters :
{
useinbandfec : 0,
foo : '111'
foo : '111'
}
},
{
......@@ -83,6 +82,7 @@ test('webRtcTransport.produce() succeeds', async () =>
parameters :
{
useinbandfec : 1,
usedtx : 1,
foo : 222.222,
bar : '333'
}
......@@ -99,7 +99,7 @@ test('webRtcTransport.produce() succeeds', async () =>
id : 12
}
],
encodings : [ { ssrc: 11111111 } ],
encodings : [ { ssrc: 11111111, dtx: true } ],
rtcp :
{
cname : 'audio-1'
......@@ -472,6 +472,7 @@ test('producer.dump() succeeds', async () =>
.toEqual(
{
useinbandfec : 1,
usedtx : 1,
foo : 222.222,
bar : '333'
});
......@@ -497,7 +498,7 @@ test('producer.dump() succeeds', async () =>
expect(data.rtpParameters.encodings.length).toBe(1);
expect(data.rtpParameters.encodings).toEqual(
[
{ codecPayloadType: 111, ssrc: 11111111 }
{ codecPayloadType: 111, ssrc: 11111111, dtx: true }
]);
expect(data.type).toBe('simple');
......
......@@ -204,6 +204,7 @@ namespace RTC
bool hasRtx{ false };
uint32_t maxBitrate{ 0 };
double maxFramerate{ 0 };
bool dtx{ false };
};
class RtpHeaderExtensionParameters
......
......@@ -47,6 +47,7 @@ namespace RTC
bool usePli{ false };
bool useFir{ false };
bool useInBandFec{ false };
bool useDtx{ false };
};
public:
......
......@@ -59,7 +59,7 @@ namespace RTC
uint32_t jitter{ 0 };
uint8_t firSeqNumber{ 0 };
uint32_t reportedPacketLost{ 0 };
bool inactive{ false }; // Stream is inactive.
bool inactive{ false }; // Stream is inactive.
std::unique_ptr<RTC::NackGenerator> nackGenerator;
Timer* inactivityCheckPeriodicTimer{ nullptr };
};
......
......@@ -267,15 +267,33 @@ namespace RTC
params.clockRate = mediaCodec->clockRate;
params.cname = this->rtpParameters.rtcp.cname;
// Check in band FEC in codec parameters.
if (mediaCodec->parameters.HasInteger("useinbandfec") && mediaCodec->parameters.GetInteger("useinbandfec") == 1)
{
MS_DEBUG_TAG(rtcp, "in band FEC supported");
MS_DEBUG_TAG(rtcp, "in band FEC enabled");
params.useInBandFec = true;
}
// Check DTX in codec parameters.
if (mediaCodec->parameters.HasInteger("usedtx") && mediaCodec->parameters.GetInteger("usedtx") == 1)
{
MS_DEBUG_TAG(rtcp, "DTX enabled");
params.useDtx = true;
}
// Check DTX in the encoding.
if (encoding.dtx)
{
MS_DEBUG_TAG(rtcp, "DTX enabled");
params.useDtx = true;
}
for (auto& fb : mediaCodec->rtcpFeedback)
{
// NOTE: Do not consider NACK in PipeConsumer.
if (!params.usePli && fb.type == "nack" && fb.parameter == "pli")
{
MS_DEBUG_TAG(rtcp, "PLI supported");
......
......@@ -770,13 +770,30 @@ namespace RTC
params.rid = encoding.rid;
params.cname = this->rtpParameters.rtcp.cname;
// Check in band FEC in codec parameters.
if (mediaCodec.parameters.HasInteger("useinbandfec") && mediaCodec.parameters.GetInteger("useinbandfec") == 1)
{
MS_DEBUG_TAG(rtcp, "in band FEC supported");
MS_DEBUG_TAG(rtcp, "in band FEC enabled");
params.useInBandFec = true;
}
// Check DTX in codec parameters.
if (mediaCodec.parameters.HasInteger("usedtx") && mediaCodec.parameters.GetInteger("usedtx") == 1)
{
MS_DEBUG_TAG(rtcp, "DTX enabled");
params.useDtx = true;
}
// Check DTX in the encoding.
if (encoding.dtx)
{
MS_DEBUG_TAG(rtcp, "DTX enabled");
params.useDtx = true;
}
for (auto& fb : mediaCodec.rtcpFeedback)
{
if (!params.useNack && fb.type == "nack" && fb.parameter == "")
......
......@@ -22,6 +22,7 @@ namespace RTC
auto jsonRtxIt = data.find("rtx");
auto jsonMaxBitrateIt = data.find("maxBitrate");
auto jsonMaxFramerateIt = data.find("maxFramerate");
auto jsonDtxIt = data.find("dtx");
// ssrc is optional.
if (jsonSsrcIt != data.end() && jsonSsrcIt->is_number_unsigned())
......@@ -53,6 +54,10 @@ namespace RTC
// maxFramerate is optional.
if (jsonMaxFramerateIt != data.end() && jsonMaxFramerateIt->is_number())
this->maxFramerate = jsonMaxFramerateIt->get<double>();
// dtx is optional.
if (jsonDtxIt != data.end() && jsonDtxIt->is_boolean())
this->dtx = jsonDtxIt->get<bool>();
}
void RtpEncodingParameters::FillJson(json& jsonObject) const
......@@ -85,5 +90,9 @@ namespace RTC
// Add maxFramerate.
if (this->maxFramerate > 0)
jsonObject["maxFramerate"] = this->maxFramerate;
// Add dtx.
if (this->dtx)
jsonObject["dtx"] = this->dtx;
}
} // namespace RTC
......@@ -321,5 +321,6 @@ namespace RTC
jsonObject["usePli"] = this->usePli;
jsonObject["useFir"] = this->useFir;
jsonObject["useInBandFec"] = this->useInBandFec;
jsonObject["useDtx"] = this->useDtx;
}
} // namespace RTC
......@@ -25,7 +25,12 @@ namespace RTC
// Set the incactivity check periodic timer.
this->inactivityCheckPeriodicTimer = new Timer(this);
this->inactivityCheckPeriodicTimer->Start(InactivityCheckPeriod, InactivityCheckPeriod);
// Run the RTP inactivity timer (unless DTX is enabled).
if (!this->params.useDtx)
{
this->inactive = false;
this->inactivityCheckPeriodicTimer->Start(InactivityCheckPeriod, InactivityCheckPeriod);
}
}
RtpStreamRecv::~RtpStreamRecv()
......@@ -69,8 +74,8 @@ namespace RTC
if (this->params.useNack)
this->nackGenerator->ReceivePacket(packet);
// Ensure the inactivityCheckPeriodicTimer runs.
if (!this->inactivityCheckPeriodicTimer->IsActive())
// Ensure the inactivityCheckPeriodicTimer runs (unless DTX is enabled).
if (!this->params.useDtx && !this->inactivityCheckPeriodicTimer->IsActive())
{
this->inactive = false;
this->inactivityCheckPeriodicTimer->Restart();
......@@ -315,8 +320,12 @@ namespace RTC
{
MS_TRACE();
this->inactive = false;
this->inactivityCheckPeriodicTimer->Restart();
// Restart the RTP inactivity timer (unless DTX is enabled).
if (!this->params.useDtx)
{
this->inactive = false;
this->inactivityCheckPeriodicTimer->Restart();
}
}
void RtpStreamRecv::CalculateJitter(uint32_t rtpTimestamp)
......
......@@ -379,13 +379,30 @@ namespace RTC
params.clockRate = mediaCodec->clockRate;
params.cname = this->rtpParameters.rtcp.cname;
// Check in band FEC in codec parameters.
if (mediaCodec->parameters.HasInteger("useinbandfec") && mediaCodec->parameters.GetInteger("useinbandfec") == 1)
{
MS_DEBUG_TAG(rtcp, "in band FEC supported");
MS_DEBUG_TAG(rtcp, "in band FEC enabled");
params.useInBandFec = true;
}
// Check DTX in codec parameters.
if (mediaCodec->parameters.HasInteger("usedtx") && mediaCodec->parameters.GetInteger("usedtx") == 1)
{
MS_DEBUG_TAG(rtcp, "DTX enabled");
params.useDtx = true;
}
// Check DTX in the encoding.
if (encoding.dtx)
{
MS_DEBUG_TAG(rtcp, "DTX enabled");
params.useDtx = true;
}
for (auto& fb : mediaCodec->rtcpFeedback)
{
if (!params.useNack && fb.type == "nack" && fb.parameter == "")
......
......@@ -478,13 +478,30 @@ namespace RTC
params.clockRate = mediaCodec->clockRate;
params.cname = this->rtpParameters.rtcp.cname;
// Check in band FEC in codec parameters.
if (mediaCodec->parameters.HasInteger("useinbandfec") && mediaCodec->parameters.GetInteger("useinbandfec") == 1)
{
MS_DEBUG_TAG(rtcp, "in band FEC supported");
MS_DEBUG_TAG(rtcp, "in band FEC enabled");
params.useInBandFec = true;
}
// Check DTX in codec parameters.
if (mediaCodec->parameters.HasInteger("usedtx") && mediaCodec->parameters.GetInteger("usedtx") == 1)
{
MS_DEBUG_TAG(rtcp, "DTX enabled");
params.useDtx = true;
}
// Check DTX in the encoding.
if (encoding.dtx)
{
MS_DEBUG_TAG(rtcp, "DTX enabled");
params.useDtx = true;
}
for (auto& fb : mediaCodec->rtcpFeedback)
{
if (!params.useNack && fb.type == "nack" && fb.parameter == "")
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论