Skip to content

Commit

Permalink
Samples: Fit the RTP transceiver rolling buffers to fit the set of sa…
Browse files Browse the repository at this point in the history
…mple 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
  • Loading branch information
sirknightj authored Dec 5, 2024
1 parent 2dca68a commit 12ef84a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions samples/Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ STATUS createSampleStreamingSession(PSampleConfiguration pSampleConfiguration, P
CHK_STATUS(addTransceiver(pSampleStreamingSession->pPeerConnection, &videoTrack, &videoRtpTransceiverInit,
&pSampleStreamingSession->pVideoRtcRtpTransceiver));

CHK_STATUS(configureTransceiverRollingBuffer(pSampleStreamingSession->pVideoRtcRtpTransceiver, &videoTrack,
pSampleConfiguration->videoRollingBufferDurationSec,
pSampleConfiguration->videoRollingBufferBitratebps));

CHK_STATUS(transceiverOnBandwidthEstimation(pSampleStreamingSession->pVideoRtcRtpTransceiver, (UINT64) pSampleStreamingSession,
sampleBandwidthEstimationHandler));

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

CHK_STATUS(configureTransceiverRollingBuffer(pSampleStreamingSession->pAudioRtcRtpTransceiver, &audioTrack,
pSampleConfiguration->audioRollingBufferDurationSec,
pSampleConfiguration->audioRollingBufferBitratebps));

CHK_STATUS(transceiverOnBandwidthEstimation(pSampleStreamingSession->pAudioRtcRtpTransceiver, (UINT64) pSampleStreamingSession,
sampleBandwidthEstimationHandler));
// twcc bandwidth estimation
Expand Down
4 changes: 4 additions & 0 deletions samples/Samples.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ typedef struct {
SIGNALING_CLIENT_HANDLE signalingClientHandle;
RTC_CODEC audioCodec;
RTC_CODEC videoCodec;
DOUBLE videoRollingBufferDurationSec;
DOUBLE videoRollingBufferBitratebps;
DOUBLE audioRollingBufferDurationSec;
DOUBLE audioRollingBufferBitratebps;
PBYTE pAudioFrameBuffer;
UINT32 audioBufferSize;
PBYTE pVideoFrameBuffer;
Expand Down
15 changes: 15 additions & 0 deletions samples/kvsWebRTCClientMaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ INT32 main(INT32 argc, CHAR* argv[])
pSampleConfiguration->audioCodec = audioCodec;
pSampleConfiguration->videoCodec = videoCodec;

// Configure the RTP rolling buffer sizes for the set of sample frames
// to be smaller than the default settings (plus some extra for padding).
if (pSampleConfiguration->videoCodec == RTC_CODEC_H264_PROFILE_42E01F_LEVEL_ASYMMETRY_ALLOWED_PACKETIZATION_MODE) {
pSampleConfiguration->videoRollingBufferDurationSec = 3;
pSampleConfiguration->videoRollingBufferBitratebps = 1.4 * 1024 * 1024;
} else if (pSampleConfiguration->videoCodec == RTC_CODEC_H265) {
pSampleConfiguration->videoRollingBufferDurationSec = 3;
pSampleConfiguration->videoRollingBufferBitratebps = 462 * 1024;
}

if (pSampleConfiguration->audioCodec == RTC_CODEC_OPUS) {
pSampleConfiguration->audioRollingBufferDurationSec = 3;
pSampleConfiguration->audioRollingBufferBitratebps = 512 * 1024;
}

if (argc > 2 && STRNCMP(argv[2], "1", 2) == 0) {
pSampleConfiguration->channelInfo.useMediaStorage = TRUE;
}
Expand Down

0 comments on commit 12ef84a

Please sign in to comment.