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

Add webrtc transport-cc feedback mechanism #1115

Open
wants to merge 3 commits into
base: v3
Choose a base branch
from

Conversation

kingqn0321
Copy link

@kingqn0321 kingqn0321 commented Jul 10, 2023

Details

1、improve the accuracy of gcc bwe when uplink network exists a big propagate jitter(eg: 100ms)
2、this optimization logic is ported from google webrtc(see: RemoteEstimatorProxy)

Rationale

1、mediasoup transport-cc feedback performance badly when uplink(webrtc-client--->mediasoup) network exists a big propagate jitter,will result in a very low GCC estimate for the webrtc-client,due to not considering disorder.
2、this optimization logic is ported from google webrtc(see: RemoteEstimatorProxy) which use a packetArrivalTimes(Map unwrapped seq -> time) buffer to send missing(arrived late due to disorder) recv delta feedback after a reordering.
3、Network simulation using Linux tc. eg: netem delay 50ms 50ms

1、improve the accuracy of gcc bwe when uplink network exists a big propagate jitter(eg: 100ms)
2、this optimization logic is ported from google webrtc(see: RemoteEstimatorProxy)
@nazar-pc
Copy link
Collaborator

Please leave review rather than individual comments, too many notifications otherwise 🙏

@ibc
Copy link
Member

ibc commented Jul 10, 2023

Please leave review rather than individual comments, too many notifications otherwise 🙏

I thought I was doing that but definitely I did it wrong. Sorry.

@ibc ibc requested a review from jmillan July 10, 2023 15:46
@kingqn0321 kingqn0321 force-pushed the v3_update_webrtc_transport_cc_feedback branch from c8076b2 to b810ab0 Compare July 11, 2023 03:59
@kingqn0321 kingqn0321 force-pushed the v3_update_webrtc_transport_cc_feedback branch from b810ab0 to 01ca264 Compare July 11, 2023 04:51
@kingqn0321 kingqn0321 requested a review from ibc July 12, 2023 02:38
@ibc
Copy link
Member

ibc commented Jul 12, 2023

Thanks @kingqn0321. Please let's review this on next days. We have busy days at work and many things to work on.

@Romantic-LiXuefeng
Copy link

It's maybe similar with this pull request. #1088

@kingqn0321
Copy link
Author

@ibc @jmillan sorry to interrupt,have you had time to review this code lately

@ibc
Copy link
Member

ibc commented Sep 18, 2023

We are super busy at work. We don't forget about this, we'll check in next days hopefully.

Comment on lines +66 to +67
static_assert(std::is_unsigned<T>::value,
"Type must be an unsigned integer.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logs in mediasoup (even in libwebrtc imported code) must adhere to the project syntax (must start with lowcase letter and must not include dot at the end). This change must be done in many files in this PR:

Suggested change
static_assert(std::is_unsigned<T>::value,
"Type must be an unsigned integer.");
static_assert(std::is_unsigned<T>::value, "type must be an unsigned integer");

Comment on lines +64 to +70
void OnPacketArrival(uint16_t sequence_number, uint64_t arrival_time);
void SendPeriodicFeedbacks();
int64_t BuildFeedbackPacket(
int64_t base_sequence_number,
std::map<int64_t, uint64_t>::const_iterator begin_iterator, // |begin_iterator| is inclusive.
std::map<int64_t, uint64_t>::const_iterator end_iterator // |end_iterator| is exclusive.
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In mediasoup we use camelCase for variables and function arguments.

  • sequence_number => sequenceNumber
  • etc

absl::optional<int64_t> periodicWindowStartSeq;
// Map unwrapped seq -> time.
std::map<int64_t, uint64_t> packetArrivalTimes;
// Use buffer policy similar to webrtc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dot at the end of comments.

Suggested change
// Use buffer policy similar to webrtc
// Use buffer policy similar to webrtc.

Comment on lines +115 to +116
void TransportCongestionControlServer::OnPacketArrival(uint16_t sequence_number, uint64_t arrival_time)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All methods and functions in mediasoup CPP files must start with MS_TRACE().

Comment on lines +158 to +161
this->packetArrivalTimes[seq] = arrival_time;
// Limit the range of sequence numbers to send feedback for.
auto first_arrival_time_to_keep = this->packetArrivalTimes.lower_bound(
this->packetArrivalTimes.rbegin()->first - kMaxNumberOfPackets);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this->packetArrivalTimes[seq] = arrival_time;
// Limit the range of sequence numbers to send feedback for.
auto first_arrival_time_to_keep = this->packetArrivalTimes.lower_bound(
this->packetArrivalTimes.rbegin()->first - kMaxNumberOfPackets);
this->packetArrivalTimes[seq] = arrival_time;
// Limit the range of sequence numbers to send feedback for.
auto first_arrival_time_to_keep = this->packetArrivalTimes.lower_bound(
this->packetArrivalTimes.rbegin()->first - kMaxNumberOfPackets);

std::map<int64_t, uint64_t>::const_iterator begin_iterator,
std::map<int64_t, uint64_t>::const_iterator end_iterator)
{
// Set base sequence numer and reference time(arrival time of first received packet in the feedback).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Set base sequence numer and reference time(arrival time of first received packet in the feedback).
// Set base sequence number and reference time(arrival time of first received packet in
// the feedback).

ref_timestamp_ms,
this->maxRtcpPacketLen);

// RTC_DCHECK(begin_iterator != end_iterator);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use MS_ASSERT().

{
// If we can't even add the first seq to the feedback packet, we won't be
// able to build it at all.
// RTC_CHECK(begin_iterator != it);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use MS_ASSERT()

Comment on lines +235 to +236
"add fail! result:%" PRIu32 ", cur-seq:%" PRId64 ", next-seq:%" PRId64
", base-seq:%" PRId64 "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't write this kind of logs anywhere.

Suggested change
"add fail! result:%" PRIu32 ", cur-seq:%" PRId64 ", next-seq:%" PRId64
", base-seq:%" PRId64 "",
"failed [result:%" PRIu32 ", curSeq:%" PRId64 ", nextSeq:%" PRId64", baseSeq:%" PRId64 "]",

Comment on lines +222 to +224
int64_t next_sequence_number = base_sequence_number;

for (auto it = begin_iterator; it != end_iterator; ++it)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase. Here and everywhere (we just allow them within libwebrtc files).

@jmillan
Copy link
Member

jmillan commented Jan 2, 2024

Indeed this and #1088 add the same functionality, right?

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

Successfully merging this pull request may close these issues.

5 participants