Source: externs/shaka/abr_manager.js

  1. /**
  2. * @license
  3. * Copyright 2016 Google Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /** @externs */
  18. /**
  19. * An object which selects Streams from a set of possible choices. This also
  20. * watches for system changes to automatically adapt for the current streaming
  21. * requirements. For example, when the network slows down, this class is in
  22. * charge of telling the Player which streams to switch to in order to reduce
  23. * the required bandwidth.
  24. *
  25. * This class is given a set of streams to choose from when the Player starts
  26. * up. This class should store these and use them to make future decisions
  27. * about ABR. It is up to this class how those decisions are made. All the
  28. * Player will do is tell this class what streams to choose from.
  29. *
  30. * @interface
  31. * @exportDoc
  32. */
  33. shakaExtern.AbrManager = function() {};
  34. /**
  35. * A callback into the Player that should be called when the AbrManager decides
  36. * it's time to change to a different variant.
  37. *
  38. * The first argument is a variant to switch to.
  39. *
  40. * The second argument is an optional boolean. If true, all data will be
  41. * from the buffer, which will result in a buffering event.
  42. *
  43. * @typedef {function(shakaExtern.Variant, boolean=)}
  44. * @exportDoc
  45. */
  46. shakaExtern.AbrManager.SwitchCallback;
  47. /**
  48. * A factory for creating the abr manager. This will be called with 'new'.
  49. *
  50. * @typedef {function(new:shakaExtern.AbrManager)}
  51. * @exportDoc
  52. */
  53. shakaExtern.AbrManager.Factory;
  54. /**
  55. * Initializes the AbrManager.
  56. *
  57. * @param {shakaExtern.AbrManager.SwitchCallback} switchCallback
  58. * @exportDoc
  59. */
  60. shakaExtern.AbrManager.prototype.init = function(switchCallback) {};
  61. /**
  62. * Stops any background timers and frees any objects held by this instance.
  63. * This will only be called after a call to init.
  64. *
  65. * @exportDoc
  66. */
  67. shakaExtern.AbrManager.prototype.stop = function() {};
  68. /**
  69. * Updates manager's variants collection.
  70. *
  71. * @param {!Array.<!shakaExtern.Variant>} variants
  72. * @exportDoc
  73. */
  74. shakaExtern.AbrManager.prototype.setVariants = function(variants) {};
  75. /**
  76. * Chooses one variant to switch to. Called by the Player.
  77. * @return {shakaExtern.Variant}
  78. * @exportDoc
  79. */
  80. shakaExtern.AbrManager.prototype.chooseVariant = function() {};
  81. /**
  82. * Enables automatic Variant choices from the last ones passed to setVariants.
  83. * After this, the AbrManager may call switchCallback() at any time.
  84. *
  85. * @exportDoc
  86. */
  87. shakaExtern.AbrManager.prototype.enable = function() {};
  88. /**
  89. * Disables automatic Stream suggestions. After this, the AbrManager may not
  90. * call switchCallback().
  91. *
  92. * @exportDoc
  93. */
  94. shakaExtern.AbrManager.prototype.disable = function() {};
  95. /**
  96. * Notifies the AbrManager that a segment has been downloaded (includes MP4
  97. * SIDX data, WebM Cues data, initialization segments, and media segments).
  98. *
  99. * @param {number} deltaTimeMs The duration, in milliseconds, that the request
  100. * took to complete.
  101. * @param {number} numBytes The total number of bytes transferred.
  102. * @exportDoc
  103. */
  104. shakaExtern.AbrManager.prototype.segmentDownloaded = function(
  105. deltaTimeMs, numBytes) {};
  106. /**
  107. * Gets an estimate of the current bandwidth in bit/sec. This is used by the
  108. * Player to generate stats.
  109. *
  110. * @return {number}
  111. * @exportDoc
  112. */
  113. shakaExtern.AbrManager.prototype.getBandwidthEstimate = function() {};
  114. /**
  115. * Sets the ABR configuration.
  116. *
  117. * It is the responsibility of the AbrManager implementation to implement the
  118. * restrictions behavior described in shakaExtern.AbrConfiguration.
  119. *
  120. * @param {shakaExtern.AbrConfiguration} config
  121. * @exportDoc
  122. */
  123. shakaExtern.AbrManager.prototype.configure = function(config) {};