Skip to content

Commit 12ef84a

Browse files
authored
Samples: Fit the RTP transceiver rolling buffers to fit the set of sample frames (#2089)
* Properly fit the rolling buffers to fit the set of sample frames * Clang-format * Adjust the comment for the rolling buffer configuration for the sample frames
1 parent 2dca68a commit 12ef84a

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

samples/Common.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,10 @@ STATUS createSampleStreamingSession(PSampleConfiguration pSampleConfiguration, P
532532
CHK_STATUS(addTransceiver(pSampleStreamingSession->pPeerConnection, &videoTrack, &videoRtpTransceiverInit,
533533
&pSampleStreamingSession->pVideoRtcRtpTransceiver));
534534

535+
CHK_STATUS(configureTransceiverRollingBuffer(pSampleStreamingSession->pVideoRtcRtpTransceiver, &videoTrack,
536+
pSampleConfiguration->videoRollingBufferDurationSec,
537+
pSampleConfiguration->videoRollingBufferBitratebps));
538+
535539
CHK_STATUS(transceiverOnBandwidthEstimation(pSampleStreamingSession->pVideoRtcRtpTransceiver, (UINT64) pSampleStreamingSession,
536540
sampleBandwidthEstimationHandler));
537541

@@ -544,6 +548,10 @@ STATUS createSampleStreamingSession(PSampleConfiguration pSampleConfiguration, P
544548
CHK_STATUS(addTransceiver(pSampleStreamingSession->pPeerConnection, &audioTrack, &audioRtpTransceiverInit,
545549
&pSampleStreamingSession->pAudioRtcRtpTransceiver));
546550

551+
CHK_STATUS(configureTransceiverRollingBuffer(pSampleStreamingSession->pAudioRtcRtpTransceiver, &audioTrack,
552+
pSampleConfiguration->audioRollingBufferDurationSec,
553+
pSampleConfiguration->audioRollingBufferBitratebps));
554+
547555
CHK_STATUS(transceiverOnBandwidthEstimation(pSampleStreamingSession->pAudioRtcRtpTransceiver, (UINT64) pSampleStreamingSession,
548556
sampleBandwidthEstimationHandler));
549557
// twcc bandwidth estimation

samples/Samples.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ typedef struct {
128128
SIGNALING_CLIENT_HANDLE signalingClientHandle;
129129
RTC_CODEC audioCodec;
130130
RTC_CODEC videoCodec;
131+
DOUBLE videoRollingBufferDurationSec;
132+
DOUBLE videoRollingBufferBitratebps;
133+
DOUBLE audioRollingBufferDurationSec;
134+
DOUBLE audioRollingBufferBitratebps;
131135
PBYTE pAudioFrameBuffer;
132136
UINT32 audioBufferSize;
133137
PBYTE pVideoFrameBuffer;

samples/kvsWebRTCClientMaster.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ INT32 main(INT32 argc, CHAR* argv[])
5050
pSampleConfiguration->audioCodec = audioCodec;
5151
pSampleConfiguration->videoCodec = videoCodec;
5252

53+
// Configure the RTP rolling buffer sizes for the set of sample frames
54+
// to be smaller than the default settings (plus some extra for padding).
55+
if (pSampleConfiguration->videoCodec == RTC_CODEC_H264_PROFILE_42E01F_LEVEL_ASYMMETRY_ALLOWED_PACKETIZATION_MODE) {
56+
pSampleConfiguration->videoRollingBufferDurationSec = 3;
57+
pSampleConfiguration->videoRollingBufferBitratebps = 1.4 * 1024 * 1024;
58+
} else if (pSampleConfiguration->videoCodec == RTC_CODEC_H265) {
59+
pSampleConfiguration->videoRollingBufferDurationSec = 3;
60+
pSampleConfiguration->videoRollingBufferBitratebps = 462 * 1024;
61+
}
62+
63+
if (pSampleConfiguration->audioCodec == RTC_CODEC_OPUS) {
64+
pSampleConfiguration->audioRollingBufferDurationSec = 3;
65+
pSampleConfiguration->audioRollingBufferBitratebps = 512 * 1024;
66+
}
67+
5368
if (argc > 2 && STRNCMP(argv[2], "1", 2) == 0) {
5469
pSampleConfiguration->channelInfo.useMediaStorage = TRUE;
5570
}

0 commit comments

Comments
 (0)