Source: externs/shaka/manifest.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. * presentationTimeline: !shaka.media.PresentationTimeline,
  21. * periods: !Array.<!shakaExtern.Period>,
  22. * offlineSessionIds: !Array.<string>,
  23. * minBufferTime: number
  24. * }}
  25. *
  26. * @description
  27. * <p>
  28. * A Manifest object describes a collection of streams (segmented audio, video,
  29. * or text data) that share a common timeline. We call the collection of
  30. * streams "the presentation" and their timeline "the presentation timeline".
  31. * A Manifest describes one of two types of presentations: live and
  32. * video-on-demand.
  33. * </p>
  34. *
  35. * <p>
  36. * A live presentation begins at some point in time and either continues
  37. * indefinitely or ends when the presentation stops broadcasting. For a live
  38. * presentation, wall-clock time maps onto the presentation timeline, and the
  39. * current wall-clock time maps to the live-edge (AKA "the current presentation
  40. * time"). In contrast, a video-on-demand presentation exists entirely
  41. * independent of wall-clock time.
  42. * </p>
  43. *
  44. * <p>
  45. * The presentation timeline is divided into one or more Periods, and each of
  46. * these Periods contains its own collection of Variants and text streams.
  47. * Variant is a combination of an audio and a video streams that can be played
  48. * together.
  49. * </p>
  50. *
  51. * <p>
  52. * A stream has the same logical content as another stream if the only
  53. * difference between the two is their quality. For example, an SD video stream
  54. * and an HD video stream that depict the same scene have the same logical
  55. * content; whereas an English audio stream and a French audio stream have
  56. * different logical content. The player can automatically switch between
  57. * streams which have the same logical content to adapt to network conditions.
  58. * </p>
  59. *
  60. * @property {!shaka.media.PresentationTimeline} presentationTimeline
  61. * <i>Required.</i> <br>
  62. * The presentation timeline.
  63. * @property {!Array.<!shakaExtern.Period>} periods
  64. * <i>Required.</i> <br>
  65. * The presentation's Periods. There must be at least one Period.
  66. * @property {!Array.<string>} offlineSessionIds
  67. * <i>Defaults to [].</i> <br>
  68. * An array of EME sessions to load for offline playback.
  69. * @property {number} minBufferTime
  70. * <i>Defaults to 0.</i> <br>
  71. * The minimum number of seconds of content that must be buffered before
  72. * playback can begin. Can be overridden by a higher value from the Player
  73. * configuration.
  74. *
  75. * @exportDoc
  76. */
  77. shakaExtern.Manifest;
  78. /**
  79. * @typedef {{
  80. * startTime: number,
  81. * variants: !Array.<shakaExtern.Variant>,
  82. * textStreams: !Array.<shakaExtern.Stream>
  83. * }}
  84. *
  85. * @description
  86. * A Period object contains the Streams for part of the presentation.
  87. *
  88. * @property {number} startTime
  89. * <i>Required.</i> <br>
  90. * The Period's start time, in seconds, relative to the start of the
  91. * presentation. The first Period must begin at the start of the
  92. * presentation. The Period ends immediately before the next Period's start
  93. * time or exactly at the end of the presentation timeline. Periods which
  94. * begin after the end of the presentation timeline are ignored.
  95. * @property {!Array.<shakaExtern.Variant>} variants
  96. * <i>Required.</i> <br>
  97. * The Period's Variants. There must be at least one Variant.
  98. * @property {!Array.<shakaExtern.Stream>} textStreams
  99. * <i>Required.</i> <br>
  100. * The Period's text streams.
  101. *
  102. * @exportDoc
  103. */
  104. shakaExtern.Period;
  105. /**
  106. * @typedef {{
  107. * initData: !Uint8Array,
  108. * initDataType: string,
  109. * keyId: ?string
  110. * }}
  111. *
  112. * @description
  113. * Explicit initialization data, which override any initialization data in the
  114. * content. The initDataType values and the formats that they correspond to
  115. * are specified {@link https://goo.gl/TNjYwn here}.
  116. *
  117. * @property {!Uint8Array} initData
  118. * Initialization data in the format indicated by initDataType.
  119. * @property {string} initDataType
  120. * A string to indicate what format initData is in.
  121. * @property {?string} keyId
  122. * The key Id that corresponds to this initData.
  123. *
  124. * @exportDoc
  125. */
  126. shakaExtern.InitDataOverride;
  127. /**
  128. * @typedef {{
  129. * keySystem: string,
  130. * licenseServerUri: string,
  131. * distinctiveIdentifierRequired: boolean,
  132. * persistentStateRequired: boolean,
  133. * audioRobustness: string,
  134. * videoRobustness: string,
  135. * serverCertificate: Uint8Array,
  136. * initData: Array.<!shakaExtern.InitDataOverride>,
  137. * keyIds: Array.<string>
  138. * }}
  139. *
  140. * @description
  141. * DRM configuration for a single key system.
  142. *
  143. * @property {string} keySystem
  144. * <i>Required.</i> <br>
  145. * The key system, e.g., "com.widevine.alpha".
  146. * @property {string} licenseServerUri
  147. * <i>Filled in by DRM config if missing.</i> <br>
  148. * The license server URI.
  149. * @property {boolean} distinctiveIdentifierRequired
  150. * <i>Defaults to false. Can be filled in by advanced DRM config.</i> <br>
  151. * True if the application requires the key system to support distinctive
  152. * identifiers.
  153. * @property {boolean} persistentStateRequired
  154. * <i>Defaults to false. Can be filled in by advanced DRM config.</i> <br>
  155. * True if the application requires the key system to support persistent
  156. * state, e.g., for persistent license storage.
  157. * @property {string} audioRobustness
  158. * <i>Defaults to '', e.g., no specific robustness required. Can be filled in
  159. * by advanced DRM config.</i> <br>
  160. * A key-system-specific string that specifies a required security level.
  161. * @property {string} videoRobustness
  162. * <i>Defaults to '', e.g., no specific robustness required. Can be filled in
  163. * by advanced DRM config.</i> <br>
  164. * A key-system-specific string that specifies a required security level.
  165. * @property {Uint8Array} serverCertificate
  166. * <i>Defaults to null, e.g., certificate will be requested from the license
  167. * server if required. Can be filled in by advanced DRM config.</i> <br>
  168. * A key-system-specific server certificate used to encrypt license requests.
  169. * Its use is optional and is meant as an optimization to avoid a round-trip
  170. * to request a certificate.
  171. * @property {Array.<!shakaExtern.InitDataOverride>} initData
  172. * <i>Defaults to [], e.g., no override.</i> <br>
  173. * A list of initialization data which override any initialization data found
  174. * in the content. See also shakaExtern.InitDataOverride.
  175. * @property {Array.<string>} keyIds
  176. * <i>Defaults to []</i> <br>
  177. * If not empty, contains the default key IDs for this key system, as
  178. * lowercase hex strings.
  179. * @exportDoc
  180. */
  181. shakaExtern.DrmInfo;
  182. /**
  183. * @typedef {{
  184. * id: number,
  185. * language: string,
  186. * primary: boolean,
  187. * audio: ?shakaExtern.Stream,
  188. * video: ?shakaExtern.Stream,
  189. * bandwidth: number,
  190. * drmInfos: !Array.<!shakaExtern.DrmInfo>,
  191. * allowedByApplication: boolean,
  192. * allowedByKeySystem: boolean
  193. * }}
  194. *
  195. * @description
  196. * A Variant describes a combination of an audio and video streams which
  197. * could be played together. It's possible to have a video/audio only
  198. * variant.
  199. *
  200. * @property {number} id
  201. * <i>Required.</i> <br>
  202. * A unique ID among all Variant objects within the same Manifest.
  203. * @property {string} language
  204. * <i>Defaults to '' (i.e., unknown).</i> <br>
  205. * The Variant's language, specified as a language code. <br>
  206. * See {@link https://tools.ietf.org/html/rfc5646} <br>
  207. * See {@link http://www.iso.org/iso/home/standards/language_codes.htm}
  208. * @property {boolean} primary
  209. * <i>Defaults to false.</i> <br>
  210. * True indicates that the player should use this Variant over others of
  211. * the in the same Period. However, the player may use another
  212. * Variant to meet application preferences.
  213. * @property {?shakaExtern.Stream} audio
  214. * The audio stream of the variant.
  215. * @property {?shakaExtern.Stream} video
  216. * The video stream of the variant.
  217. * @property {number} bandwidth
  218. * The variant's required bandwidth in bits per second.
  219. * @property {!Array.<!shakaExtern.DrmInfo>} drmInfos
  220. * <i>Defaults to [] (i.e., no DRM).</i> <br>
  221. * An array of DrmInfo objects which describe DRM schemes are compatible with
  222. * the content.
  223. * @property {boolean} allowedByApplication
  224. * <i>Defaults to true.</i><br>
  225. * Set by the Player to indicate whether the variant is allowed to be played
  226. * by the application.
  227. * @property {boolean} allowedByKeySystem
  228. * <i>Defaults to true.</i><br>
  229. * Set by the Player to indicate whether the variant is allowed to be played
  230. * by the key system.
  231. *
  232. * @exportDoc
  233. */
  234. shakaExtern.Variant;
  235. /**
  236. * Creates a SegmentIndex; returns a Promise that resolves after the
  237. * SegmentIndex has been created.
  238. *
  239. * @typedef {function(): !Promise}
  240. * @exportDoc
  241. */
  242. shakaExtern.CreateSegmentIndexFunction;
  243. /**
  244. * Finds the position of the segment for the given time, in seconds, relative
  245. * to the start of a particular Period; returns null if the position of the
  246. * segment could not be determined. Note: the position of a segment is unique
  247. * only among segments within the same Period.
  248. *
  249. * @typedef {function(number): ?number}
  250. * @exportDoc
  251. */
  252. shakaExtern.FindSegmentPositionFunction;
  253. /**
  254. * Gets the SegmentReference for the segment at the given position; returns
  255. * null if no such SegmentReference exists. Note: the position of a segment is
  256. * unique only among segments within the same Period.
  257. * @typedef {function(number): shaka.media.SegmentReference}
  258. * @exportDoc
  259. */
  260. shakaExtern.GetSegmentReferenceFunction;
  261. /**
  262. * @typedef {{
  263. * id: number,
  264. * createSegmentIndex: shakaExtern.CreateSegmentIndexFunction,
  265. * findSegmentPosition: shakaExtern.FindSegmentPositionFunction,
  266. * getSegmentReference: shakaExtern.GetSegmentReferenceFunction,
  267. * initSegmentReference: shaka.media.InitSegmentReference,
  268. * presentationTimeOffset: (number|undefined),
  269. * mimeType: string,
  270. * codecs: string,
  271. * frameRate: (number|undefined),
  272. * bandwidth: (number|undefined),
  273. * width: (number|undefined),
  274. * height: (number|undefined),
  275. * kind: (string|undefined),
  276. * encrypted: boolean,
  277. * keyId: ?string,
  278. * language: string,
  279. * label: ?string,
  280. * type: string,
  281. * primary: boolean,
  282. * trickModeVideo: ?shakaExtern.Stream,
  283. * containsEmsgBoxes: boolean,
  284. * roles: !Array.<string>,
  285. * channelsCount: ?number
  286. * }}
  287. *
  288. * @description
  289. * A Stream object describes a single stream (segmented media data).
  290. *
  291. * @property {number} id
  292. * <i>Required.</i> <br>
  293. * A unique ID among all Stream objects within the same Manifest.
  294. * @property {shakaExtern.CreateSegmentIndexFunction} createSegmentIndex
  295. * <i>Required.</i> <br>
  296. * Creates the Stream's SegmentIndex (asynchronously).
  297. * @property {shakaExtern.FindSegmentPositionFunction} findSegmentPosition
  298. * <i>Required.</i> <br>
  299. * Finds the position of the segment for the given time. The caller must call
  300. * createSegmentIndex() and wait until the returned Promise resolves before
  301. * calling this function.
  302. * @property {shakaExtern.GetSegmentReferenceFunction} getSegmentReference
  303. * <i>Required.</i> <br>
  304. * Gets the SegmentReference for the segment at the given position. The
  305. * caller must call createSegmentIndex() and wait until the returned Promise
  306. * resolves before calling this function.
  307. * @property {shaka.media.InitSegmentReference} initSegmentReference
  308. * The Stream's initialization segment metadata, or null if the segments are
  309. * self-initializing.
  310. * @property {(number|undefined)} presentationTimeOffset
  311. * <i>Defaults to 0.</i> <br>
  312. * The amount of time, in seconds, that the stream's presentation timestamps
  313. * are offset from the start of the Stream's Period, i.e., this value should
  314. * equal the first presentation timestamp of the first frame/sample in the
  315. * period. <br>
  316. * <br>
  317. * For example, for MP4 based streams, this value should equal the first
  318. * segment's tfdt box's 'baseMediaDecodeTime' field (after it has been
  319. * converted to seconds).
  320. * @property {string} mimeType
  321. * <i>Required.</i> <br>
  322. * The Stream's MIME type, e.g., 'audio/mp4', 'video/webm', or 'text/vtt'.
  323. * @property {string} codecs
  324. * <i>Defaults to '' (i.e., unknown / not needed).</i> <br>
  325. * The Stream's codecs, e.g., 'avc1.4d4015' or 'vp9', which must be
  326. * compatible with the Stream's MIME type. <br>
  327. * See {@link https://tools.ietf.org/html/rfc6381}
  328. * @property {(number|undefined)} frameRate
  329. * <i>Video streams only.</i> <br>
  330. * The Stream's framerate in frames per second
  331. * @property {(number|undefined)} bandwidth
  332. * <i>Audio and video streams only.</i> <br>
  333. * The stream's required bandwidth in bits per second.
  334. * @property {(number|undefined)} width
  335. * <i>Video streams only.</i> <br>
  336. * The stream's width in pixels.
  337. * @property {(number|undefined)} height
  338. * <i>Video streams only.</i> <br>
  339. * The stream's height in pixels.
  340. * @property {(string|undefined)} kind
  341. * <i>Text streams only.</i> <br>
  342. * The kind of text stream. For example, 'caption' or 'subtitle'.
  343. * @see https://goo.gl/k1HWA6
  344. * @property {boolean} encrypted
  345. * <i>Defaults to false.</i><br>
  346. * True if the stream is encrypted.
  347. * @property {?string} keyId
  348. * <i>Defaults to null (i.e., unencrypted or key ID unknown).</i> <br>
  349. * The stream's key ID as a lowercase hex string. This key ID identifies the
  350. * encryption key that the browser (key system) can use to decrypt the
  351. * stream.
  352. * @property {string} language
  353. * The Stream's language, specified as a language code. <br>
  354. * Audio stream's language must be identical to the language of the containing
  355. * Variant.
  356. * @property {?string} label
  357. * The Stream's label, unique text that should describe the audio/text track.
  358. * @property {string} type
  359. * <i>Required.</i> <br>
  360. * Content type (e.g. 'video', 'audio' or 'text')
  361. * @property {boolean} primary
  362. * <i>Defaults to false.</i> <br>
  363. * True indicates that the player should prefer this Stream over others
  364. * in the same Period. However, the player may use another
  365. * Stream to meet application preferences.
  366. * @property {?shakaExtern.Stream} trickModeVideo
  367. * <i>Video streams only.</i> <br>
  368. * An alternate video stream to use for trick mode playback.
  369. * @property {boolean} containsEmsgBoxes
  370. * <i>Defaults to false.</i><br>
  371. * Whether the stream contains embedded 'emsg' boxes that should result in
  372. * Player events.
  373. * @property {!Array.<string>} roles
  374. * The roles of the stream as they appear on the manifest,
  375. * e.g. 'main', 'caption', or 'commentary'.
  376. * @property {?number} channelsCount
  377. * The channel count information for the audio stream.
  378. * @exportDoc
  379. */
  380. shakaExtern.Stream;