Source: externs/shaka/offline.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. * @typedef {{
  20. * basic: boolean,
  21. * encrypted: !Object.<string, boolean>
  22. * }}
  23. *
  24. * @property {boolean} basic
  25. * True if offline is usable at all.
  26. * @property {!Object.<string, boolean>} encrypted
  27. * A map of key system name to whether it supports offline playback.
  28. * @exportDoc
  29. */
  30. shakaExtern.OfflineSupport;
  31. /**
  32. * @typedef {{
  33. * trackSelectionCallback:
  34. * function(!Array.<shakaExtern.Track>):!Array.<shakaExtern.Track>,
  35. * progressCallback: function(shakaExtern.StoredContent,number),
  36. * usePersistentLicense: boolean
  37. * }}
  38. *
  39. * @property {function(!Array.<shakaExtern.Track>):!Array.<shakaExtern.Track>}
  40. * trackSelectionCallback
  41. * Called inside store() to determine which tracks to save from a manifest.
  42. * It is passed an array of Tracks from the manifest and it should return
  43. * an array of the tracks to store. This is called for each Period in the
  44. * manifest (in order).
  45. * @property {function(shakaExtern.StoredContent,number)} progressCallback
  46. * Called inside store() to give progress info back to the app. It is given
  47. * the current manifest being stored and the progress of it being stored.
  48. * @property {boolean} usePersistentLicense
  49. * If true, store protected content with a persistent license so that no
  50. * network is required to view.
  51. * If false, store protected content without a persistent license. A network
  52. * will be required to retrieve a temporary license to view.
  53. * Defaults to true.
  54. * @exportDoc
  55. */
  56. shakaExtern.OfflineConfiguration;
  57. /**
  58. * @typedef {{
  59. * offlineUri: string,
  60. * originalManifestUri: string,
  61. * duration: number,
  62. * size: number,
  63. * expiration: number,
  64. * tracks: !Array.<shakaExtern.Track>,
  65. * appMetadata: Object
  66. * }}
  67. *
  68. * @property {string} offlineUri
  69. * An offline URI to access the content. This can be passed directly to
  70. * Player.
  71. * @property {string} originalManifestUri
  72. * The original manifest URI of the content stored.
  73. * @property {number} duration
  74. * The duration of the content, in seconds.
  75. * @property {number} size
  76. * The size of the content, in bytes.
  77. * @property {number} expiration
  78. * The time that the encrypted license expires, in milliseconds. If the media
  79. * is clear or the license never expires, this will equal Infinity.
  80. * @property {!Array.<shakaExtern.Track>} tracks
  81. * The tracks that are stored. This only lists those found in the first
  82. * Period.
  83. * @property {Object} appMetadata
  84. * The metadata passed to store().
  85. * @exportDoc
  86. */
  87. shakaExtern.StoredContent;
  88. /**
  89. * @typedef {{
  90. * key: number,
  91. * originalManifestUri: string,
  92. * duration: number,
  93. * size: number,
  94. * expiration: number,
  95. * periods: !Array.<shakaExtern.PeriodDB>,
  96. * sessionIds: !Array.<string>,
  97. * drmInfo: ?shakaExtern.DrmInfo,
  98. * appMetadata: Object
  99. * }}
  100. *
  101. * @property {number} key
  102. * The key that uniquely identifies the manifest.
  103. * @property {string} originalManifestUri
  104. * The URI that the manifest was originally loaded from.
  105. * @property {number} duration
  106. * The total duration of the media, in seconds.
  107. * @property {number} size
  108. * The total size of all stored segments, in bytes.
  109. * @property {number} expiration
  110. * The license expiration, in milliseconds; or Infinity if not applicable.
  111. * @property {!Array.<shakaExtern.PeriodDB>} periods
  112. * The Periods that are stored.
  113. * @property {!Array.<string>} sessionIds
  114. * The DRM offline session IDs for the media.
  115. * @property {?shakaExtern.DrmInfo} drmInfo
  116. * The DRM info used to initialize EME.
  117. * @property {Object} appMetadata
  118. * A metadata object passed from the application.
  119. */
  120. shakaExtern.ManifestDB;
  121. /**
  122. * @typedef {{
  123. * startTime: number,
  124. * streams: !Array.<shakaExtern.StreamDB>
  125. * }}
  126. *
  127. * @property {number} startTime
  128. * The start time of the period, in seconds.
  129. * @property {!Array.<shakaExtern.StreamDB>} streams
  130. * The streams that define the Period.
  131. */
  132. shakaExtern.PeriodDB;
  133. /**
  134. * @typedef {{
  135. * id: number,
  136. * primary: boolean,
  137. * presentationTimeOffset: number,
  138. * contentType: string,
  139. * mimeType: string,
  140. * codecs: string,
  141. * frameRate: (number|undefined),
  142. * kind: (string|undefined),
  143. * language: string,
  144. * label: ?string,
  145. * width: ?number,
  146. * height: ?number,
  147. * initSegmentUri: ?string,
  148. * encrypted: boolean,
  149. * keyId: ?string,
  150. * segments: !Array.<shakaExtern.SegmentDB>,
  151. * variantIds: ?Array.<number>
  152. * }}
  153. *
  154. * @property {number} id
  155. * The unique id of the stream.
  156. * @property {boolean} primary
  157. * Whether the stream set was primary.
  158. * @property {number} presentationTimeOffset
  159. * The presentation time offset of the stream.
  160. * @property {string} contentType
  161. * The type of the stream, 'audio', 'text', or 'video'.
  162. * @property {string} mimeType
  163. * The MIME type of the stream.
  164. * @property {string} codecs
  165. * The codecs of the stream.
  166. * @property {(number|undefined)} frameRate
  167. * The Stream's framerate in frames per second
  168. * @property {(string|undefined)} kind
  169. * The kind of text stream; undefined for audio/video.
  170. * @property {string} language
  171. * The language of the stream; '' for video.
  172. * @property {?string} label
  173. * The label of the stream; '' for video.
  174. * @property {?number} width
  175. * The width of the stream; null for audio/text.
  176. * @property {?number} height
  177. * The height of the stream; null for audio/text.
  178. * @property {?string} initSegmentUri
  179. * The offline URI where the init segment is found; null if no init segment.
  180. * @property {boolean} encrypted
  181. * Whether this stream is encrypted.
  182. * @property {?string} keyId
  183. * The key ID this stream is encrypted with.
  184. * @property {!Array.<shakaExtern.SegmentDB>} segments
  185. * An array of segments that make up the stream
  186. * @property {?Array.<number>} variantIds
  187. * An array of ids of variants the stream is a part of.
  188. */
  189. shakaExtern.StreamDB;
  190. /**
  191. * @typedef {{
  192. * startTime: number,
  193. * endTime: number,
  194. * uri: string
  195. * }}
  196. *
  197. * @property {number} startTime
  198. * The start time of the segment, in seconds from the start of the Period.
  199. * @property {number} endTime
  200. * The end time of the segment, in seconds from the start of the Period.
  201. * @property {string} uri
  202. * The offline URI where the segment is found.
  203. */
  204. shakaExtern.SegmentDB;
  205. /**
  206. * @typedef {{
  207. * key: number,
  208. * data: ArrayBuffer,
  209. * manifestKey: number,
  210. * streamNumber: number,
  211. * segmentNumber: number
  212. * }}
  213. *
  214. * @property {number} key
  215. * A key that uniquely describes the segment.
  216. * @property {ArrayBuffer} data
  217. * The data contents of the segment.
  218. * @property {number} manifestKey
  219. * The key of the manifest this belongs to.
  220. * @property {number} streamNumber
  221. * The index of the stream this belongs to.
  222. * @property {number} segmentNumber
  223. * The index of the segment within the stream.
  224. */
  225. shakaExtern.SegmentDataDB;