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