Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. void SegmentManager::adapt(unsigned int* n, int speed, int stream_type, DASH_Context* dash_context)
  2. {
  3. unsigned int i = 0;
  4. unsigned int reservoir = 12;
  5. unsigned int cushion = 24;
  6. unsigned int upper_reservoir = 12;
  7. unsigned int up_limit;
  8. unsigned int down_limit;
  9. if(stream_type == STREAM_TYPE_VIDEO)
  10. {
  11. m_numberOfVideoSegmentsCurrRep++;
  12. if(m_numberOfVideoSegmentsCurrRep < MINIMUM_REQUIRED_NUMBER_OF_SEGMENTS)
  13. {
  14. return;
  15. }
  16. }
  17. if(stream_type == STREAM_TYPE_AUDIO)
  18. {
  19. m_numberOfAudioSegmentsCurrRep++;
  20. if(m_numberOfAudioSegmentsCurrRep < MINIMUM_REQUIRED_NUMBER_OF_SEGMENTS)
  21. {
  22. return;
  23. }
  24. }
  25. if(stream_type == STREAM_TYPE_SUBTITLE)
  26. {
  27. m_numberOfSubtitleSegmentsCurrRep++;
  28. if(m_numberOfSubtitleSegmentsCurrRep < MINIMUM_REQUIRED_NUMBER_OF_SEGMENTS)
  29. {
  30. return;
  31. }
  32. }
  33. if(*n >= (dash_context->bandsVideo.size()- 1))
  34. {
  35. up_limit = dash_context->bandsVideo.size()- 1;
  36. }
  37. else
  38. {
  39. up_limit = *n + 1;
  40. }
  41. if(*n == 0)
  42. {
  43. down_limit = 0;
  44. }
  45. else
  46. {
  47. down_limit = *n-1;
  48. }
  49. int map_buffer_to_rate = ((dash_context->videoBufferFullness - reservoir) * ((double)(dash_context->bandsVideo.size() - 1)/cushion));
  50. if(dash_context->videoBufferFullness <= reservoir)
  51. {
  52. *n = 0;
  53. }
  54. else if(dash_context->videoBufferFullness >= (reservoir + cushion))
  55. {
  56. *n = dash_context->bandsVideo.size()-1;
  57. }
  58. else if(map_buffer_to_rate >= up_limit)
  59. {
  60. *n = map_buffer_to_rate - 1;
  61. }
  62. else if(map_buffer_to_rate <= down_limit)
  63. {
  64. *n = map_buffer_to_rate + 1;
  65. }
  66. else
  67. {
  68. DBG_VERBOSE("quality same as previous\n");
  69. }
  70. DBG_VERBOSE("BUFFER = %lf\n", dash_context->videoBufferFullness);
  71. DBG_VERBOSE("SPEED = %d\n", speed * 8);
  72. DBG_VERBOSE("QUALITY = %d\n", *n);
  73. if(dash_context->videoBufferFullness >= (reservoir + cushion))
  74. {
  75. usleep(1000 * 1000 * (dash_context->videoBufferFullness - (reservoir + cushion)));
  76. }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement