Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // safe start
- if (totalStreamTime < 15000 && !bCongestionStarted && maxStrain > 50)
- {
- currentBitRate = (int)(defaultBitRate * (4.0 / 7.0));
- App->GetVideoEncoder()->SetBitRate(currentBitRate, -1);
- lastAdjustmentTime = renderStartTimeMS;
- bCongestionStarted = true;
- }
- // lower if congested
- else if (totalStreamTime > 15000 && (avgStrain > 50 || maxStrain > 99))
- {
- if (renderStartTimeMS - lastAdjustmentTime > 10000)
- {
- if (currentBitRate > defaultBitRate * (4.0 / 7.0))
- {
- currentBitRate = (int)(currentBitRate - pow(currentBitRate / (double)defaultBitRate, 4) * defaultBitRate * 0.1);
- App->GetVideoEncoder()->SetBitRate(currentBitRate, -1);
- lastAdjustmentTime = renderStartTimeMS;
- }
- }
- }
- // increase if stable
- else if (totalStreamTime > 15000 && currentBitRate < defaultBitRate && avgStrain < 5 && maxStrain < 15)
- {
- if (renderStartTimeMS - lastAdjustmentTime > 10000)
- {
- if (currentBitRate < defaultBitRate)
- {
- currentBitRate += (int)((1 - pow(currentBitRate / (double)defaultBitRate, 4)) * defaultBitRate * 0.05);
- if (currentBitRate > defaultBitRate)
- currentBitRate = defaultBitRate;
- App->GetVideoEncoder()->SetBitRate(currentBitRate, -1);
- lastAdjustmentTime = renderStartTimeMS;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement