Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rtpStream->maxPacketTs in a specific scenario #659

Open
oppolixiang opened this issue Sep 18, 2021 · 1 comment
Open

Update rtpStream->maxPacketTs in a specific scenario #659

oppolixiang opened this issue Sep 18, 2021 · 1 comment
Labels
Milestone

Comments

@oppolixiang
Copy link

oppolixiang commented Sep 18, 2021

i found this issue when i test a long video conference.
once i lock the screen, the producer will not send any rtp packet, for example, the last rtp packet timestamp is 1000000000, seq is 100.
after a night, i unlock the screen and the producer start to send rtp packet seq 101 、102 、103。but their timestamp maybe lower then the packet of seq 100(cause of a ts reverse), for example 100000000.

in this condition ,if the consumer nack for the packet 101, FillRetransmissionContainer will calcarate the diffMs>2000ms then consumer nack will become invalid for a long while. (in this case, the calculation of the diffMs may also be inaccurate).
diffMs = diffTs * 1000 / this->params.clockRate; ==> diffMs = diffTs / (this->params.clockRate/1000);

should update rtpStream->maxPacketTs of RtpStreamRecv and RtpStreamSend in this scenario.

bool RtpStream::UpdateSeq(RTC::RtpPacket* packet)
{
	MS_TRACE();

	uint16_t seq    = packet->GetSequenceNumber();
	uint16_t udelta = seq - this->maxSeq;

	// If the new packet sequence number is greater than the max seen but not
	// "so much bigger", accept it.
	// NOTE: udelta also handles the case of a new cycle, this is:
	//    maxSeq:65536, seq:0 => udelta:1
	if (udelta < MaxDropout)
	{
		// In order, with permissible gap.
		if (seq < this->maxSeq)
		{
			// Sequence number wrapped: count another 64K cycle.
			this->cycles += RtpSeqMod;
		}

		this->maxSeq = seq;

		// ts reverse with in order seq.(cause by producer inactive for a long time(for example a night))
		if (RTC::SeqManager<uint32_t>::IsSeqLowerThan(packet->GetTimestamp(), this->maxPacketTs))
		{
			MS_WARN_TAG(rtp, "update RtpStream maxPacketTs old %u new %u", this->maxPacketTs, packet->GetTimestamp());
			this->maxPacketTs = packet->GetTimestamp();
			this->maxPacketMs = DepLibUV::GetTimeMs();
		}
	}
}
@oppolixiang oppolixiang changed the title Update rtpStream->maxPacketTs when rtpStreamRecv inactive change from true to false Update rtpStream->maxPacketTs in a specific scenario Oct 9, 2021
@ibc ibc added this to the v3 updates milestone Jan 5, 2023
@ibc
Copy link
Member

ibc commented Dec 30, 2023

Can this be reproducible with a worker test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants