Source: externs/shaka/manifest_parser.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. * Parses media manifests and handles manifest updates.
  20. *
  21. * Given a URI where the initial manifest is found, a parser will request the
  22. * manifest, parse it, and return the resulting Manifest object.
  23. *
  24. * If the manifest requires updates (e.g. for live media), the parser will use
  25. * background timers to update the same Manifest object.
  26. *
  27. * @interface
  28. * @exportDoc
  29. */
  30. shakaExtern.ManifestParser = function() {};
  31. /**
  32. * @typedef {{
  33. * networkingEngine: !shaka.net.NetworkingEngine,
  34. * filterNewPeriod: function(shakaExtern.Period),
  35. * filterAllPeriods: function(!Array.<!shakaExtern.Period>),
  36. * onTimelineRegionAdded: function(shakaExtern.TimelineRegionInfo),
  37. * onEvent: function(!Event),
  38. * onError: function(!shaka.util.Error)
  39. * }}
  40. *
  41. * @description
  42. * Defines the interface of the Player to the manifest parser. This defines
  43. * fields and callback methods that the parser will use to interact with the
  44. * Player. The callback methods do not to be called as member functions (i.e.
  45. * they can be called as "free" functions).
  46. *
  47. * @property {!shaka.net.NetworkingEngine} networkingEngine
  48. * The networking engine to use for network requests.
  49. * @property {function(shakaExtern.Period)} filterNewPeriod
  50. * Should be called on a new Period so that it can be filtered.
  51. * @property {function(!Array.<!shakaExtern.Period>)} filterAllPeriods
  52. * Should be called on all Periods so that they can be filtered.
  53. * @property {function(shakaExtern.TimelineRegionInfo)} onTimelineRegionAdded
  54. * Should be called when a new timeline region is added.
  55. * @property {function(!Event)} onEvent
  56. * Should be called to raise events.
  57. * @property {function(!shaka.util.Error)} onError
  58. * Should be called when an error occurs.
  59. * @exportDoc
  60. */
  61. shakaExtern.ManifestParser.PlayerInterface;
  62. /**
  63. * A factory for creating the manifest parser. This will be called with 'new'.
  64. * This function is registered with shaka.media.ManifestParser to create parser
  65. * instances.
  66. *
  67. * @typedef {function(new:shakaExtern.ManifestParser)}
  68. * @exportDoc
  69. */
  70. shakaExtern.ManifestParser.Factory;
  71. /**
  72. * Called by the Player to provide an updated configuration any time the
  73. * configuration changes. Will be called at least once before start().
  74. *
  75. * @param {shakaExtern.ManifestConfiguration} config
  76. * @exportDoc
  77. */
  78. shakaExtern.ManifestParser.prototype.configure = function(config) {};
  79. /**
  80. * Parses the given manifest data into a Manifest object and starts any
  81. * background timers that are needed. This will only be called once.
  82. *
  83. * @param {string} uri The URI of the manifest.
  84. * @param {shakaExtern.ManifestParser.PlayerInterface} playerInterface Contains
  85. * the interface to the Player.
  86. * @return {!Promise.<shakaExtern.Manifest>}
  87. * @exportDoc
  88. */
  89. shakaExtern.ManifestParser.prototype.start = function(uri, playerInterface) {};
  90. /**
  91. * Stops any background timers and frees any objects held by this instance.
  92. * This will only be called after a successful call to start. This will only
  93. * be called once.
  94. *
  95. * @return {!Promise}
  96. * @exportDoc
  97. */
  98. shakaExtern.ManifestParser.prototype.stop = function() {};
  99. /**
  100. * Tells the parser to do a manual manifest update. Implementing this is
  101. * optional and is only called when 'emsg' boxes are present.
  102. * @exportDoc
  103. */
  104. shakaExtern.ManifestParser.prototype.update = function() {};
  105. /**
  106. * Tells the parser that the expiration time of an EME session has changed.
  107. * Implementing this is optional.
  108. *
  109. * @param {string} sessionId
  110. * @param {number} expiration
  111. * @exportDoc
  112. */
  113. shakaExtern.ManifestParser.prototype.onExpirationUpdated = function(
  114. sessionId, expiration) {};