Skip to content

Commit

Permalink
Properly fit the rolling buffers to fit the set of sample frames
Browse files Browse the repository at this point in the history
  • Loading branch information
sirknightj committed Dec 4, 2024
1 parent 8c49c94 commit 2c3a466
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions samples/Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,9 @@ 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 +547,9 @@ 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
14 changes: 14 additions & 0 deletions samples/kvsWebRTCClientMaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ INT32 main(INT32 argc, CHAR* argv[])
pSampleConfiguration->audioCodec = audioCodec;
pSampleConfiguration->videoCodec = videoCodec;

// Configure the RTP rolling buffer sizes for the set of pre-canned sample frames (add a bit 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 2c3a466

Please sign in to comment.