提交 b221f1eb authored 作者: José Luis Millán's avatar José Luis Millán

Consumer: Do not override RTP TS on simple and pipe consumers

上级 a9b59ae4
...@@ -51,7 +51,6 @@ namespace RTC ...@@ -51,7 +51,6 @@ namespace RTC
bool keyFrameSupported{ false }; bool keyFrameSupported{ false };
std::unordered_map<RTC::RtpStreamSend*, bool> mapRtpStreamSyncRequired; std::unordered_map<RTC::RtpStreamSend*, bool> mapRtpStreamSyncRequired;
std::unordered_map<RTC::RtpStreamSend*, RTC::SeqManager<uint16_t>> mapRtpStreamRtpSeqManager; std::unordered_map<RTC::RtpStreamSend*, RTC::SeqManager<uint16_t>> mapRtpStreamRtpSeqManager;
std::unordered_map<RTC::RtpStreamSend*, RTC::SeqManager<uint32_t>> mapRtpStreamRtpTimestampManager;
}; };
// Inline methods. // Inline methods.
......
...@@ -54,7 +54,6 @@ namespace RTC ...@@ -54,7 +54,6 @@ namespace RTC
bool keyFrameSupported{ false }; bool keyFrameSupported{ false };
bool syncRequired{ false }; bool syncRequired{ false };
RTC::SeqManager<uint16_t> rtpSeqManager; RTC::SeqManager<uint16_t> rtpSeqManager;
RTC::SeqManager<uint32_t> rtpTimestampManager;
}; };
/* Inline methods. */ /* Inline methods. */
......
...@@ -147,7 +147,6 @@ namespace RTC ...@@ -147,7 +147,6 @@ namespace RTC
auto* rtpStream = this->mapMappedSsrcRtpStream.at(packet->GetSsrc()); auto* rtpStream = this->mapMappedSsrcRtpStream.at(packet->GetSsrc());
auto& syncRequired = this->mapRtpStreamSyncRequired.at(rtpStream); auto& syncRequired = this->mapRtpStreamSyncRequired.at(rtpStream);
auto& rtpSeqManager = this->mapRtpStreamRtpSeqManager.at(rtpStream); auto& rtpSeqManager = this->mapRtpStreamRtpSeqManager.at(rtpStream);
auto& rtpTimestampManager = this->mapRtpStreamRtpTimestampManager.at(rtpStream);
// If we need to sync, support key frames and this is not a key frame, ignore // If we need to sync, support key frames and this is not a key frame, ignore
// the packet. // the packet.
...@@ -164,48 +163,32 @@ namespace RTC ...@@ -164,48 +163,32 @@ namespace RTC
MS_DEBUG_TAG(rtp, "sync key frame received"); MS_DEBUG_TAG(rtp, "sync key frame received");
rtpSeqManager.Sync(packet->GetSequenceNumber()); rtpSeqManager.Sync(packet->GetSequenceNumber());
rtpTimestampManager.Sync(packet->GetTimestamp());
// Calculate RTP timestamp diff between now and last sent RTP packet.
if (rtpStream->GetMaxPacketMs() != 0u)
{
auto now = DepLibUV::GetTime();
auto diffMs = now - rtpStream->GetMaxPacketMs();
auto diffTs = diffMs * rtpStream->GetClockRate() / 1000;
rtpTimestampManager.Offset(diffTs);
}
syncRequired = false; syncRequired = false;
} }
// Update RTP seq number and timestamp. // Update RTP seq number and timestamp.
uint16_t seq; uint16_t seq;
uint32_t timestamp;
rtpSeqManager.Input(packet->GetSequenceNumber(), seq); rtpSeqManager.Input(packet->GetSequenceNumber(), seq);
rtpTimestampManager.Input(packet->GetTimestamp(), timestamp);
// Save original packet fields. // Save original packet fields.
auto origSeq = packet->GetSequenceNumber(); auto origSeq = packet->GetSequenceNumber();
auto origTimestamp = packet->GetTimestamp();
// Rewrite packet. // Rewrite packet.
// NOTE: Do not override the ssrc because we want to honor the consumable ssrcs. // NOTE: Do not override the ssrc because we want to honor the consumable ssrcs.
packet->SetSequenceNumber(seq); packet->SetSequenceNumber(seq);
packet->SetTimestamp(timestamp);
if (isSyncPacket) if (isSyncPacket)
{ {
MS_DEBUG_TAG( MS_DEBUG_TAG(
rtp, rtp,
"sending sync packet [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32 "sending sync packet [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32
"] from original [seq:%" PRIu16 ", ts:%" PRIu32 "]", "] from original [seq:%" PRIu16 "]",
packet->GetSsrc(), packet->GetSsrc(),
packet->GetSequenceNumber(), packet->GetSequenceNumber(),
packet->GetTimestamp(), packet->GetTimestamp(),
origSeq, origSeq);
origTimestamp);
} }
// Process the packet. // Process the packet.
...@@ -219,17 +202,15 @@ namespace RTC ...@@ -219,17 +202,15 @@ namespace RTC
MS_WARN_TAG( MS_WARN_TAG(
rtp, rtp,
"failed to send packet [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32 "failed to send packet [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32
"] from original [seq:%" PRIu16 ", ts:%" PRIu32 "]", "] from original [seq:%" PRIu16 "]",
packet->GetSsrc(), packet->GetSsrc(),
packet->GetSequenceNumber(), packet->GetSequenceNumber(),
packet->GetTimestamp(), packet->GetTimestamp(),
origSeq, origSeq);
origTimestamp);
} }
// Restore packet fields. // Restore packet fields.
packet->SetSequenceNumber(origSeq); packet->SetSequenceNumber(origSeq);
packet->SetTimestamp(origTimestamp);
} }
void PipeConsumer::GetRtcp( void PipeConsumer::GetRtcp(
...@@ -478,7 +459,6 @@ namespace RTC ...@@ -478,7 +459,6 @@ namespace RTC
this->rtpStreams.push_back(rtpStream); this->rtpStreams.push_back(rtpStream);
this->mapRtpStreamSyncRequired[rtpStream] = false; this->mapRtpStreamSyncRequired[rtpStream] = false;
this->mapRtpStreamRtpSeqManager[rtpStream]; this->mapRtpStreamRtpSeqManager[rtpStream];
this->mapRtpStreamRtpTimestampManager[rtpStream];
} }
} }
......
...@@ -157,49 +157,33 @@ namespace RTC ...@@ -157,49 +157,33 @@ namespace RTC
MS_DEBUG_TAG(rtp, "sync key frame received"); MS_DEBUG_TAG(rtp, "sync key frame received");
this->rtpSeqManager.Sync(packet->GetSequenceNumber()); this->rtpSeqManager.Sync(packet->GetSequenceNumber());
this->rtpTimestampManager.Sync(packet->GetTimestamp());
// Calculate RTP timestamp diff between now and last sent RTP packet.
if (this->rtpStream->GetMaxPacketMs() != 0u)
{
auto now = DepLibUV::GetTime();
auto diffMs = now - this->rtpStream->GetMaxPacketMs();
auto diffTs = diffMs * this->rtpStream->GetClockRate() / 1000;
this->rtpTimestampManager.Offset(diffTs);
}
this->syncRequired = false; this->syncRequired = false;
} }
// Update RTP seq number and timestamp. // Update RTP seq number and timestamp.
uint16_t seq; uint16_t seq;
uint32_t timestamp;
this->rtpSeqManager.Input(packet->GetSequenceNumber(), seq); this->rtpSeqManager.Input(packet->GetSequenceNumber(), seq);
this->rtpTimestampManager.Input(packet->GetTimestamp(), timestamp);
// Save original packet fields. // Save original packet fields.
auto origSsrc = packet->GetSsrc(); auto origSsrc = packet->GetSsrc();
auto origSeq = packet->GetSequenceNumber(); auto origSeq = packet->GetSequenceNumber();
auto origTimestamp = packet->GetTimestamp();
// Rewrite packet. // Rewrite packet.
packet->SetSsrc(this->rtpParameters.encodings[0].ssrc); packet->SetSsrc(this->rtpParameters.encodings[0].ssrc);
packet->SetSequenceNumber(seq); packet->SetSequenceNumber(seq);
packet->SetTimestamp(timestamp);
if (isSyncPacket) if (isSyncPacket)
{ {
MS_DEBUG_TAG( MS_DEBUG_TAG(
rtp, rtp,
"sending sync packet [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32 "sending sync packet [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32
"] from original [seq:%" PRIu16 ", ts:%" PRIu32 "]", "] from original [seq:%" PRIu16 "]",
packet->GetSsrc(), packet->GetSsrc(),
packet->GetSequenceNumber(), packet->GetSequenceNumber(),
packet->GetTimestamp(), packet->GetTimestamp(),
origSeq, origSeq);
origTimestamp);
} }
// Process the packet. // Process the packet.
...@@ -213,18 +197,16 @@ namespace RTC ...@@ -213,18 +197,16 @@ namespace RTC
MS_WARN_TAG( MS_WARN_TAG(
rtp, rtp,
"failed to send packet [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32 "failed to send packet [ssrc:%" PRIu32 ", seq:%" PRIu16 ", ts:%" PRIu32
"] from original [seq:%" PRIu16 ", ts:%" PRIu32 "]", "] from original [seq:%" PRIu16 "]",
packet->GetSsrc(), packet->GetSsrc(),
packet->GetSequenceNumber(), packet->GetSequenceNumber(),
packet->GetTimestamp(), packet->GetTimestamp(),
origSeq, origSeq);
origTimestamp);
} }
// Restore packet fields. // Restore packet fields.
packet->SetSsrc(origSsrc); packet->SetSsrc(origSsrc);
packet->SetSequenceNumber(origSeq); packet->SetSequenceNumber(origSeq);
packet->SetTimestamp(origTimestamp);
} }
void SimpleConsumer::GetRtcp( void SimpleConsumer::GetRtcp(
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论