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

Implement REMB Handling #201

Merged
merged 1 commit into from
Feb 21, 2020
Merged

Implement REMB Handling #201

merged 1 commit into from
Feb 21, 2020

Conversation

Sean-Der
Copy link
Contributor

Add new callback to RtcRtpTransceiver 'onBandwidthEstimation'.
This is now fired everytime we get an REMB packet. In the future we will
also fire this for sender side estimation, but at this time nothing is
implemented.

Resolves #114

@Sean-Der Sean-Der force-pushed the issue-114 branch 2 times, most recently from d1ea31c to d734710 Compare February 20, 2020 21:43
@codecov-io
Copy link

codecov-io commented Feb 20, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@cafebc8). Click here to learn what that means.
The diff coverage is 46.77%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #201   +/-   ##
=========================================
  Coverage          ?   86.64%           
=========================================
  Files             ?       33           
  Lines             ?     7772           
  Branches          ?        0           
=========================================
  Hits              ?     6734           
  Misses            ?     1038           
  Partials          ?        0
Impacted Files Coverage Δ
src/source/PeerConnection/Rtp.c 72.66% <0%> (ø)
src/source/Rtcp/RtcpPacket.c 100% <100%> (ø)
src/source/PeerConnection/Rtcp.c 28.94% <3.7%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cafebc8...9aeaea1. Read the comment docs.

Copy link
Contributor

@MushMal MushMal left a comment

Choose a reason for hiding this comment

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

Mostly minor comments but please take a look at the BO issue

@@ -383,6 +383,10 @@ STATUS createSampleStreamingSession(PSampleConfiguration pSampleConfiguration, P
NULL,
&pSampleStreamingSession->pVideoRtcRtpTransceiver));

CHK_STATUS(transceiverOnBandwidthEstimation(pSampleStreamingSession->pVideoRtcRtpTransceiver,
Copy link
Contributor

Choose a reason for hiding this comment

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

MINOR: Suggest to think through how the bandwidth handler could differentiate between the transceivers. Either have different handlers for audio and video or in this simple case customData could be the differentiator (bad).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think users will pass a handle to their encoders as customData, and go from there. If I was doing GStreamer I would pass a *GSTElement and have it configure everytime.

* RtcOnBandwidthEstimation is a KVS specific method
*
*/
typedef VOID (*RtcOnBandwidthEstimation)(UINT64, DOUBLE);
Copy link
Contributor

Choose a reason for hiding this comment

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

One more important question. Can the comment contain the link or something to the RFC describing the DOUBLE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In https://tools.ietf.org/html/draft-alvestrand-rmcat-remb-00#section-2.2 it is given as a mantissa + exponent. I chose DOUBLE just because of the return value of ldexp

@@ -15,6 +15,11 @@ STATUS onRtcpPacket(PKvsPeerConnection pKvsPeerConnection, PBYTE pBuff, UINT32 b

if (rtcpPacket.header.packetType == RTCP_PACKET_TYPE_GENERIC_RTP_FEEDBACK && rtcpPacket.header.receptionReportCount == RTCP_FEEDBACK_MESSAGE_TYPE_NACK) {
CHK_STATUS(resendPacketOnNack(&rtcpPacket, pKvsPeerConnection));
} else if (rtcpPacket.header.packetType == RTCP_PACKET_TYPE_PAYLOAD_SPECIFIC_FEEDBACK &&
rtcpPacket.header.receptionReportCount == RTCP_FEEDBACK_MESSAGE_TYPE_APPLICATION_LAYER_FEEDBACK &&
isRembPacket(rtcpPacket.payload, rtcpPacket.payloadLength) == STATUS_SUCCESS)
Copy link
Contributor

Choose a reason for hiding this comment

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

CHK_STATUS(isRembPacket(...))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want it to set the return value. We can have some packets that are this value, and then we just want to skip (but not actually an error). I want to keep iterating the compound packet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, of course. You could use STATUS_SUCCEEDED(isRembPacket(...)). Not a big issue

src/source/PeerConnection/Rtcp.c Show resolved Hide resolved
src/source/PeerConnection/Rtcp.c Show resolved Hide resolved
UINT64 item;

CHK_STATUS(rembValueGet(pRtcpPacket->payload, pRtcpPacket->payloadLength, &maximumBitRate, NULL, &ssrcListLen));
CHK(NULL != (pSsrcList = (PUINT32) MEMCALLOC(1, SIZEOF(UINT32) * ssrcListLen)), STATUS_STORE_OUT_OF_MEMORY);
Copy link
Contributor

Choose a reason for hiding this comment

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

How big do you expect the buffer to be? If this is anything less than 100K you can simply use stack buffer without dynamic alloc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

255 * uint32_t

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You ok with me doing a uint32_t ssrcList[255] = {}?

}

CleanUp:
SAFE_MEMFREE(pSsrcList);
Copy link
Contributor

Choose a reason for hiding this comment

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

In case of on-the-stack buffer you don't need this line

src/source/PeerConnection/Rtcp.h Outdated Show resolved Hide resolved
src/source/Rtcp/RtcpPacket.c Outdated Show resolved Hide resolved
mantissa &= RTCP_PACKET_REMB_MANTISSA_BITMASK;

exponent = pPayload[RTCP_PACKET_REMB_IDENTIFIER_OFFSET + 5] >> 2;
maximumBitRate = ldexp(mantissa, exponent);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should think of adding these things to PICs #commondefs

src/source/Rtcp/RtcpPacket.c Outdated Show resolved Hide resolved
@Sean-Der Sean-Der force-pushed the issue-114 branch 2 times, most recently from 5cd45dc to 8aba01d Compare February 20, 2020 22:48
Add new callback to RtcRtpTransceiver 'onBandwidthEstimation'.
This is now fired everytime we get an REMB packet. In the future we will
also fire this for sender side estimation, but at this time nothing is
implemented.

Resolves #114
@@ -15,6 +15,11 @@ STATUS onRtcpPacket(PKvsPeerConnection pKvsPeerConnection, PBYTE pBuff, UINT32 b

if (rtcpPacket.header.packetType == RTCP_PACKET_TYPE_GENERIC_RTP_FEEDBACK && rtcpPacket.header.receptionReportCount == RTCP_FEEDBACK_MESSAGE_TYPE_NACK) {
CHK_STATUS(resendPacketOnNack(&rtcpPacket, pKvsPeerConnection));
} else if (rtcpPacket.header.packetType == RTCP_PACKET_TYPE_PAYLOAD_SPECIFIC_FEEDBACK &&
rtcpPacket.header.receptionReportCount == RTCP_FEEDBACK_MESSAGE_TYPE_APPLICATION_LAYER_FEEDBACK &&
isRembPacket(rtcpPacket.payload, rtcpPacket.payloadLength) == STATUS_SUCCESS)
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, of course. You could use STATUS_SUCCEEDED(isRembPacket(...)). Not a big issue

@alexw91
Copy link
Member

alexw91 commented Feb 20, 2020

Codecov Report

Merging #201 into master will decrease coverage by 0.31%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #201      +/-   ##
==========================================
- Coverage   86.95%   86.64%   -0.32%     
==========================================
  Files          33       33              
  Lines        7698     7773      +75     
==========================================
+ Hits         6694     6735      +41     
- Misses       1004     1038      +34     
Impacted Files Coverage Δ
src/source/Ice/Network.c 70.89% <0.00%> (ø) ⬆️
src/source/Ice/TurnConnection.c 91.82% <0.00%> (ø) ⬆️
src/source/Ice/ConnectionListener.c 90.50% <0.00%> (ø) ⬆️
src/source/Ice/IceAgent.c 93.70% <0.00%> (-0.11%) ⬇️
src/source/Ice/IceUtils.c 96.80% <0.00%> (ø) ⬆️
src/source/Ice/IceAgentStateMachine.c 83.33% <0.00%> (+0.67%) ⬆️
src/source/PeerConnection/PeerConnection.c 93.69% <0.00%> (+0.42%) ⬆️
src/source/PeerConnection/Rtp.c 72.66% <0.00%> (-2.70%) ⬇️
src/source/Ice/SocketConnection.c 82.68% <0.00%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cafebc8...9aeaea1. Read the comment docs.

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@cafebc8). Click here to learn what that means.
The diff coverage is 47.45%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #201   +/-   ##
=========================================
  Coverage          ?   86.67%           
=========================================
  Files             ?       33           
  Lines             ?     7769           
  Branches          ?        0           
=========================================
  Hits              ?     6734           
  Misses            ?     1035           
  Partials          ?        0
Impacted Files Coverage Δ
src/source/PeerConnection/Rtp.c 72.66% <0%> (ø)
src/source/Rtcp/RtcpPacket.c 100% <100%> (ø)
src/source/PeerConnection/Rtcp.c 30.55% <4%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cafebc8...9aeaea1. Read the comment docs.

@Sean-Der Sean-Der merged commit 2a690f1 into master Feb 21, 2020
@Sean-Der Sean-Der deleted the issue-114 branch February 21, 2020 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement congestion control
4 participants