Advertisement
Guest User

Untitled

a guest
Jan 13th, 2015
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. // safe start
  2. if (totalStreamTime < 15000 && !bCongestionStarted && maxStrain > 50)
  3. {
  4.     currentBitRate = (int)(defaultBitRate * (4.0 / 7.0));
  5.  
  6.     App->GetVideoEncoder()->SetBitRate(currentBitRate, -1);
  7.     lastAdjustmentTime = renderStartTimeMS;
  8.  
  9.     bCongestionStarted = true;
  10. }
  11. // lower if congested
  12. else if (totalStreamTime > 15000 && (avgStrain > 50 || maxStrain > 99))
  13. {
  14.     if (renderStartTimeMS - lastAdjustmentTime > 10000)
  15.     {
  16.         if (currentBitRate > defaultBitRate * (4.0 / 7.0))
  17.         {
  18.             currentBitRate = (int)(currentBitRate - pow(currentBitRate / (double)defaultBitRate, 4) * defaultBitRate * 0.1);
  19.  
  20.             App->GetVideoEncoder()->SetBitRate(currentBitRate, -1);
  21.             lastAdjustmentTime = renderStartTimeMS;
  22.         }
  23.     }
  24. }
  25. // increase if stable
  26. else if (totalStreamTime > 15000 && currentBitRate < defaultBitRate && avgStrain < 5 && maxStrain < 15)
  27. {
  28.     if (renderStartTimeMS - lastAdjustmentTime > 10000)
  29.     {
  30.         if (currentBitRate < defaultBitRate)
  31.         {
  32.             currentBitRate += (int)((1 - pow(currentBitRate / (double)defaultBitRate, 4)) * defaultBitRate * 0.05);
  33.             if (currentBitRate > defaultBitRate)
  34.                 currentBitRate = defaultBitRate;
  35.  
  36.             App->GetVideoEncoder()->SetBitRate(currentBitRate, -1);
  37.             lastAdjustmentTime = renderStartTimeMS;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement