Source: externs/shaka/player.js

  1. /*! @license
  2. * Shaka Player
  3. * Copyright 2016 Google LLC
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @externs
  8. */
  9. /**
  10. * @typedef {{
  11. * timestamp: number,
  12. * id: number,
  13. * type: string,
  14. * fromAdaptation: boolean,
  15. * bandwidth: ?number
  16. * }}
  17. *
  18. * @property {number} timestamp
  19. * The timestamp the choice was made, in seconds since 1970
  20. * (i.e. <code>Date.now() / 1000</code>).
  21. * @property {number} id
  22. * The id of the track that was chosen.
  23. * @property {string} type
  24. * The type of track chosen (<code>'variant'</code> or <code>'text'</code>).
  25. * @property {boolean} fromAdaptation
  26. * <code>true</code> if the choice was made by AbrManager for adaptation;
  27. * <code>false</code> if it was made by the application through
  28. * <code>selectTrack</code>.
  29. * @property {?number} bandwidth
  30. * The bandwidth of the chosen track (<code>null</code> for text).
  31. * @exportDoc
  32. */
  33. shaka.extern.TrackChoice;
  34. /**
  35. * @typedef {{
  36. * timestamp: number,
  37. * state: string,
  38. * duration: number
  39. * }}
  40. *
  41. * @property {number} timestamp
  42. * The timestamp the state was entered, in seconds since 1970
  43. * (i.e. <code>Date.now() / 1000</code>).
  44. * @property {string} state
  45. * The state the player entered. This could be <code>'buffering'</code>,
  46. * <code>'playing'</code>, <code>'paused'</code>, or <code>'ended'</code>.
  47. * @property {number} duration
  48. * The number of seconds the player was in this state. If this is the last
  49. * entry in the list, the player is still in this state, so the duration will
  50. * continue to increase.
  51. * @exportDoc
  52. */
  53. shaka.extern.StateChange;
  54. /**
  55. * @typedef {{
  56. * width: number,
  57. * height: number,
  58. * streamBandwidth: number,
  59. *
  60. * decodedFrames: number,
  61. * droppedFrames: number,
  62. * corruptedFrames: number,
  63. * estimatedBandwidth: number,
  64. *
  65. * completionPercent: number,
  66. * loadLatency: number,
  67. * manifestTimeSeconds: number,
  68. * drmTimeSeconds: number,
  69. * playTime: number,
  70. * pauseTime: number,
  71. * bufferingTime: number,
  72. * licenseTime: number,
  73. * liveLatency: number,
  74. *
  75. * maxSegmentDuration: number,
  76. *
  77. * switchHistory: !Array.<shaka.extern.TrackChoice>,
  78. * stateHistory: !Array.<shaka.extern.StateChange>
  79. * }}
  80. *
  81. * @description
  82. * Contains statistics and information about the current state of the player.
  83. * This is meant for applications that want to log quality-of-experience (QoE)
  84. * or other stats. These values will reset when <code>load()</code> is called
  85. * again.
  86. *
  87. * @property {number} width
  88. * The width of the current video track.
  89. * @property {number} height
  90. * The height of the current video track.
  91. * @property {number} streamBandwidth
  92. * The bandwidth required for the current streams (total, in bit/sec).
  93. * It takes into account the playbackrate.
  94. *
  95. * @property {number} decodedFrames
  96. * The total number of frames decoded by the Player. This may be
  97. * <code>NaN</code> if this is not supported by the browser.
  98. * @property {number} droppedFrames
  99. * The total number of frames dropped by the Player. This may be
  100. * <code>NaN</code> if this is not supported by the browser.
  101. * @property {number} corruptedFrames
  102. * The total number of corrupted frames dropped by the browser. This may be
  103. * <code>NaN</code> if this is not supported by the browser.
  104. * @property {number} estimatedBandwidth
  105. * The current estimated network bandwidth (in bit/sec).
  106. *
  107. * @property {number} completionPercent
  108. * This is the greatest completion percent that the user has experienced in
  109. * playback. Also known as the "high water mark". Is NaN when there is no
  110. * known duration, such as for livestreams.
  111. * @property {number} loadLatency
  112. * This is the number of seconds it took for the video element to have enough
  113. * data to begin playback. This is measured from the time load() is called to
  114. * the time the <code>'loadeddata'</code> event is fired by the media element.
  115. * @property {number} manifestTimeSeconds
  116. * The amount of time it took to download and parse the manifest.
  117. * @property {number} drmTimeSeconds
  118. * The amount of time it took to download the first drm key.
  119. * @property {number} playTime
  120. * The total time spent in a playing state in seconds.
  121. * @property {number} pauseTime
  122. * The total time spent in a paused state in seconds.
  123. * @property {number} bufferingTime
  124. * The total time spent in a buffering state in seconds.
  125. * @property {number} licenseTime
  126. * The time spent on license requests during this session in seconds, or NaN.
  127. * @property {number} liveLatency
  128. * The time between the capturing of a frame and the end user having it
  129. * displayed on their screen.
  130. *
  131. * @property {number} maxSegmentDuration
  132. * The presentation's max segment duration in seconds, or NaN.
  133. *
  134. * @property {!Array.<shaka.extern.TrackChoice>} switchHistory
  135. * A history of the stream changes.
  136. * @property {!Array.<shaka.extern.StateChange>} stateHistory
  137. * A history of the state changes.
  138. * @exportDoc
  139. */
  140. shaka.extern.Stats;
  141. /**
  142. * @typedef {{
  143. * start: number,
  144. * end: number
  145. * }}
  146. *
  147. * @description
  148. * Contains the times of a range of buffered content.
  149. *
  150. * @property {number} start
  151. * The start time of the range, in seconds.
  152. * @property {number} end
  153. * The end time of the range, in seconds.
  154. * @exportDoc
  155. */
  156. shaka.extern.BufferedRange;
  157. /**
  158. * @typedef {{
  159. * total: !Array.<shaka.extern.BufferedRange>,
  160. * audio: !Array.<shaka.extern.BufferedRange>,
  161. * video: !Array.<shaka.extern.BufferedRange>,
  162. * text: !Array.<shaka.extern.BufferedRange>
  163. * }}
  164. *
  165. * @description
  166. * Contains information about the current buffered ranges.
  167. *
  168. * @property {!Array.<shaka.extern.BufferedRange>} total
  169. * The combined audio/video buffered ranges, reported by
  170. * <code>video.buffered</code>.
  171. * @property {!Array.<shaka.extern.BufferedRange>} audio
  172. * The buffered ranges for audio content.
  173. * @property {!Array.<shaka.extern.BufferedRange>} video
  174. * The buffered ranges for video content.
  175. * @property {!Array.<shaka.extern.BufferedRange>} text
  176. * The buffered ranges for text content.
  177. * @exportDoc
  178. */
  179. shaka.extern.BufferedInfo;
  180. /**
  181. * @typedef {{
  182. * id: number,
  183. * active: boolean,
  184. *
  185. * type: string,
  186. * bandwidth: number,
  187. *
  188. * language: string,
  189. * label: ?string,
  190. * kind: ?string,
  191. * width: ?number,
  192. * height: ?number,
  193. * frameRate: ?number,
  194. * pixelAspectRatio: ?string,
  195. * hdr: ?string,
  196. * mimeType: ?string,
  197. * codecs: ?string,
  198. * audioCodec: ?string,
  199. * videoCodec: ?string,
  200. * primary: boolean,
  201. * roles: !Array.<string>,
  202. * audioRoles: Array.<string>,
  203. * forced: boolean,
  204. * videoId: ?number,
  205. * audioId: ?number,
  206. * channelsCount: ?number,
  207. * audioSamplingRate: ?number,
  208. * tilesLayout: ?string,
  209. * audioBandwidth: ?number,
  210. * videoBandwidth: ?number,
  211. * spatialAudio: boolean,
  212. * originalVideoId: ?string,
  213. * originalAudioId: ?string,
  214. * originalTextId: ?string,
  215. * originalImageId: ?string
  216. * }}
  217. *
  218. * @description
  219. * An object describing a media track. This object should be treated as
  220. * read-only as changing any values does not have any effect. This is the
  221. * public view of an audio/video paring (variant type) or text track (text
  222. * type) or image track (image type).
  223. *
  224. * @property {number} id
  225. * The unique ID of the track.
  226. * @property {boolean} active
  227. * If true, this is the track being streamed (another track may be
  228. * visible/audible in the buffer).
  229. *
  230. * @property {string} type
  231. * The type of track, either <code>'variant'</code> or <code>'text'</code>
  232. * or <code>'image'</code>.
  233. * @property {number} bandwidth
  234. * The bandwidth required to play the track, in bits/sec.
  235. *
  236. * @property {string} language
  237. * The language of the track, or <code>'und'</code> if not given. This is the
  238. * exact value provided in the manifest; it may need to be normalized.
  239. * @property {?string} label
  240. * The track label, which is unique text that should describe the track.
  241. * @property {?string} kind
  242. * (only for text tracks) The kind of text track, either
  243. * <code>'caption'</code> or <code>'subtitle'</code>.
  244. * @property {?number} width
  245. * The video width provided in the manifest, if present.
  246. * @property {?number} height
  247. * The video height provided in the manifest, if present.
  248. * @property {?number} frameRate
  249. * The video framerate provided in the manifest, if present.
  250. * @property {?string} pixelAspectRatio
  251. * The video pixel aspect ratio provided in the manifest, if present.
  252. * @property {?string} hdr
  253. * The video HDR provided in the manifest, if present.
  254. * @property {?string} mimeType
  255. * The MIME type of the content provided in the manifest.
  256. * @property {?string} codecs
  257. * The audio/video codecs string provided in the manifest, if present.
  258. * @property {?string} audioCodec
  259. * The audio codecs string provided in the manifest, if present.
  260. * @property {?string} videoCodec
  261. * The video codecs string provided in the manifest, if present.
  262. * @property {boolean} primary
  263. * True indicates that this in the primary language for the content.
  264. * This flag is based on signals from the manifest.
  265. * This can be a useful hint about which language should be the default, and
  266. * indicates which track Shaka will use when the user's language preference
  267. * cannot be satisfied.
  268. * @property {!Array.<string>} roles
  269. * The roles of the track, e.g. <code>'main'</code>, <code>'caption'</code>,
  270. * or <code>'commentary'</code>.
  271. * @property {Array.<string>} audioRoles
  272. * The roles of the audio in the track, e.g. <code>'main'</code> or
  273. * <code>'commentary'</code>. Will be null for text tracks or variant tracks
  274. * without audio.
  275. * @property {boolean} forced
  276. * True indicates that this in the forced text language for the content.
  277. * This flag is based on signals from the manifest.
  278. * @property {?number} videoId
  279. * (only for variant tracks) The video stream id.
  280. * @property {?number} audioId
  281. * (only for variant tracks) The audio stream id.
  282. * @property {?number} channelsCount
  283. * The count of the audio track channels.
  284. * @property {?number} audioSamplingRate
  285. * Specifies the maximum sampling rate of the content.
  286. * @property {?string} tilesLayout
  287. * The value is a grid-item-dimension consisting of two positive decimal
  288. * integers in the format: column-x-row ('4x3'). It describes the arrangement
  289. * of Images in a Grid. The minimum valid LAYOUT is '1x1'.
  290. * @property {boolean} spatialAudio
  291. * True indicates that the content has spatial audio.
  292. * This flag is based on signals from the manifest.
  293. * @property {?number} audioBandwidth
  294. * (only for variant tracks) The audio stream's bandwidth if known.
  295. * @property {?number} videoBandwidth
  296. * (only for variant tracks) The video stream's bandwidth if known.
  297. * @property {?string} originalVideoId
  298. * (variant tracks only) The original ID of the video part of the track, if
  299. * any, as it appeared in the original manifest.
  300. * @property {?string} originalAudioId
  301. * (variant tracks only) The original ID of the audio part of the track, if
  302. * any, as it appeared in the original manifest.
  303. * @property {?string} originalTextId
  304. * (text tracks only) The original ID of the text track, if any, as it
  305. * appeared in the original manifest.
  306. * @property {?string} originalImageId
  307. * (image tracks only) The original ID of the image track, if any, as it
  308. * appeared in the original manifest.
  309. * @exportDoc
  310. */
  311. shaka.extern.Track;
  312. /**
  313. * @typedef {!Array.<!shaka.extern.Track>}
  314. */
  315. shaka.extern.TrackList;
  316. /**
  317. * @typedef {{
  318. * minWidth: number,
  319. * maxWidth: number,
  320. * minHeight: number,
  321. * maxHeight: number,
  322. * minPixels: number,
  323. * maxPixels: number,
  324. *
  325. * minFrameRate: number,
  326. * maxFrameRate: number,
  327. *
  328. * minBandwidth: number,
  329. * maxBandwidth: number
  330. * }}
  331. *
  332. * @description
  333. * An object describing application restrictions on what tracks can play. All
  334. * restrictions must be fulfilled for a track to be playable/selectable.
  335. * The restrictions system behaves somewhat differently at the ABR level and the
  336. * player level, so please refer to the documentation for those specific
  337. * settings.
  338. *
  339. * @see shaka.extern.PlayerConfiguration
  340. * @see shaka.extern.AbrConfiguration
  341. *
  342. * @property {number} minWidth
  343. * The minimum width of a video track, in pixels.
  344. * @property {number} maxWidth
  345. * The maximum width of a video track, in pixels.
  346. * @property {number} minHeight
  347. * The minimum height of a video track, in pixels.
  348. * @property {number} maxHeight
  349. * The maximum height of a video track, in pixels.
  350. * @property {number} minPixels
  351. * The minimum number of total pixels in a video track (i.e.
  352. * <code>width * height</code>).
  353. * @property {number} maxPixels
  354. * The maximum number of total pixels in a video track (i.e.
  355. * <code>width * height</code>).
  356. *
  357. * @property {number} minFrameRate
  358. * The minimum framerate of a variant track.
  359. * @property {number} maxFrameRate
  360. * The maximum framerate of a variant track.
  361. *
  362. * @property {number} minBandwidth
  363. * The minimum bandwidth of a variant track, in bit/sec.
  364. * @property {number} maxBandwidth
  365. * The maximum bandwidth of a variant track, in bit/sec.
  366. * @exportDoc
  367. */
  368. shaka.extern.Restrictions;
  369. /**
  370. * @typedef {{
  371. * persistentState: boolean
  372. * }}
  373. *
  374. * @property {boolean} persistentState
  375. * Whether this key system supports persistent state.
  376. * @exportDoc
  377. */
  378. shaka.extern.DrmSupportType;
  379. /**
  380. * @typedef {{
  381. * manifest: !Object.<string, boolean>,
  382. * media: !Object.<string, boolean>,
  383. * drm: !Object.<string, ?shaka.extern.DrmSupportType>
  384. * }}
  385. *
  386. * @description
  387. * An object detailing browser support for various features.
  388. *
  389. * @property {!Object.<string, boolean>} manifest
  390. * A map of supported manifest types.
  391. * The keys are manifest MIME types and file extensions.
  392. * @property {!Object.<string, boolean>} media
  393. * A map of supported media types.
  394. * The keys are media MIME types.
  395. * @property {!Object.<string, ?shaka.extern.DrmSupportType>} drm
  396. * A map of supported key systems.
  397. * The keys are the key system names. The value is <code>null</code> if it is
  398. * not supported. Key systems not probed will not be in this dictionary.
  399. *
  400. * @exportDoc
  401. */
  402. shaka.extern.SupportType;
  403. /**
  404. * @typedef {!Object.<string, ?>}
  405. *
  406. * @description
  407. * ID3 metadata in format defined by
  408. * https://id3.org/id3v2.3.0#Declared_ID3v2_frames
  409. * The content of the field.
  410. *
  411. * @exportDoc
  412. */
  413. shaka.extern.ID3Metadata;
  414. /**
  415. * @typedef {{
  416. * schemeIdUri: string,
  417. * value: string,
  418. * startTime: number,
  419. * endTime: number,
  420. * id: string,
  421. * eventElement: Element
  422. * }}
  423. *
  424. * @description
  425. * Contains information about a region of the timeline that will cause an event
  426. * to be raised when the playhead enters or exits it. In DASH this is the
  427. * EventStream element.
  428. *
  429. * @property {string} schemeIdUri
  430. * Identifies the message scheme.
  431. * @property {string} value
  432. * Specifies the value for the region.
  433. * @property {number} startTime
  434. * The presentation time (in seconds) that the region should start.
  435. * @property {number} endTime
  436. * The presentation time (in seconds) that the region should end.
  437. * @property {string} id
  438. * Specifies an identifier for this instance of the region.
  439. * @property {Element} eventElement
  440. * The XML element that defines the Event.
  441. * @exportDoc
  442. */
  443. shaka.extern.TimelineRegionInfo;
  444. /**
  445. * @typedef {{
  446. * schemeIdUri: string,
  447. * value: string,
  448. * startTime: number,
  449. * endTime: number,
  450. * timescale: number,
  451. * presentationTimeDelta: number,
  452. * eventDuration: number,
  453. * id: number,
  454. * messageData: Uint8Array
  455. * }}
  456. *
  457. * @description
  458. * Contains information about an EMSG MP4 box.
  459. *
  460. * @property {string} schemeIdUri
  461. * Identifies the message scheme.
  462. * @property {string} value
  463. * Specifies the value for the event.
  464. * @property {number} startTime
  465. * The time that the event starts (in presentation time).
  466. * @property {number} endTime
  467. * The time that the event ends (in presentation time).
  468. * @property {number} timescale
  469. * Provides the timescale, in ticks per second.
  470. * @property {number} presentationTimeDelta
  471. * The offset that the event starts, relative to the start of the segment
  472. * this is contained in (in units of timescale).
  473. * @property {number} eventDuration
  474. * The duration of the event (in units of timescale).
  475. * @property {number} id
  476. * A field identifying this instance of the message.
  477. * @property {Uint8Array} messageData
  478. * Body of the message.
  479. * @exportDoc
  480. */
  481. shaka.extern.EmsgInfo;
  482. /**
  483. * @typedef {{
  484. * distinctiveIdentifierRequired: boolean,
  485. * persistentStateRequired: boolean,
  486. * videoRobustness: string,
  487. * audioRobustness: string,
  488. * serverCertificate: Uint8Array,
  489. * serverCertificateUri: string,
  490. * individualizationServer: string,
  491. * sessionType: string
  492. * }}
  493. *
  494. * @property {boolean} distinctiveIdentifierRequired
  495. * <i>Defaults to false.</i> <br>
  496. * True if the application requires the key system to support distinctive
  497. * identifiers.
  498. * @property {boolean} persistentStateRequired
  499. * <i>Defaults to false.</i> <br>
  500. * True if the application requires the key system to support persistent
  501. * state, e.g., for persistent license storage.
  502. * @property {string} videoRobustness
  503. * A key-system-specific string that specifies a required security level for
  504. * video.
  505. * <i>Defaults to <code>''</code>, i.e., no specific robustness required.</i>
  506. * @property {string} audioRobustness
  507. * A key-system-specific string that specifies a required security level for
  508. * audio.
  509. * <i>Defaults to <code>''</code>, i.e., no specific robustness required.</i>
  510. * @property {Uint8Array} serverCertificate
  511. * <i>Defaults to null.</i> <br>
  512. * <i>An empty certificate (<code>byteLength==0</code>) will be treated as
  513. * <code>null</code>.</i> <br>
  514. * <i>A certificate will be requested from the license server if
  515. * required.</i> <br>
  516. * A key-system-specific server certificate used to encrypt license requests.
  517. * Its use is optional and is meant as an optimization to avoid a round-trip
  518. * to request a certificate.
  519. * @property {string} serverCertificateUri
  520. * <i>Defaults to <code>''</code>.</i><br>
  521. * If given, will make a request to the given URI to get the server
  522. * certificate. This is ignored if <code>serverCertificate</code> is set.
  523. * @property {string} individualizationServer
  524. * The server that handles an <code>'individualiation-request'</code>. If the
  525. * server isn't given, it will default to the license server.
  526. * @property {string} sessionType
  527. * <i>Defaults to <code>'temporary'</code> for streaming.</i> <br>
  528. * The MediaKey session type to create streaming licenses with. This doesn't
  529. * affect offline storage.
  530. *
  531. * @exportDoc
  532. */
  533. shaka.extern.AdvancedDrmConfiguration;
  534. /**
  535. * @typedef {{
  536. * retryParameters: shaka.extern.RetryParameters,
  537. * servers: !Object.<string, string>,
  538. * clearKeys: !Object.<string, string>,
  539. * delayLicenseRequestUntilPlayed: boolean,
  540. * advanced: Object.<string, shaka.extern.AdvancedDrmConfiguration>,
  541. * initDataTransform:
  542. * ((function(!Uint8Array, string, ?shaka.extern.DrmInfo):!Uint8Array)|
  543. * undefined),
  544. * logLicenseExchange: boolean,
  545. * updateExpirationTime: number,
  546. * preferredKeySystems: !Array.<string>
  547. * }}
  548. *
  549. * @property {shaka.extern.RetryParameters} retryParameters
  550. * Retry parameters for license requests.
  551. * @property {!Object.<string, string>} servers
  552. * <i>Required for all but the clear key CDM.</i> <br>
  553. * A dictionary which maps key system IDs to their license servers.
  554. * For example,
  555. * <code>{'com.widevine.alpha': 'https://example.com/drm'}</code>.
  556. * @property {!Object.<string, string>} clearKeys
  557. * <i>Forces the use of the Clear Key CDM.</i>
  558. * A map of key IDs (hex) to keys (hex).
  559. * @property {boolean} delayLicenseRequestUntilPlayed
  560. * <i>Defaults to false.</i> <br>
  561. * True to configure drm to delay sending a license request until a user
  562. * actually starts playing content.
  563. * @property {Object.<string, shaka.extern.AdvancedDrmConfiguration>} advanced
  564. * <i>Optional.</i> <br>
  565. * A dictionary which maps key system IDs to advanced DRM configuration for
  566. * those key systems.
  567. * @property
  568. * {((function(!Uint8Array, string, ?shaka.extern.DrmInfo):!Uint8Array)|
  569. * undefined)}
  570. * initDataTransform
  571. * <i>Optional.</i><br>
  572. * If given, this function is called with the init data from the
  573. * manifest/media and should return the (possibly transformed) init data to
  574. * pass to the browser.
  575. * @property {boolean} logLicenseExchange
  576. * <i>Optional.</i><br>
  577. * If set to <code>true</code>, prints logs containing the license exchange.
  578. * This includes the init data, request, and response data, printed as base64
  579. * strings. Don't use in production, for debugging only; has no affect in
  580. * release builds as logging is removed.
  581. * @property {number} updateExpirationTime
  582. * <i>Defaults to 1.</i> <br>
  583. * The frequency in seconds with which to check the expiration of a session.
  584. * @property {!Array.<string>} preferredKeySystems
  585. * <i>Defaults to an empty array. </i> <br>
  586. * Specifies the priorties of available DRM key systems.
  587. *
  588. * @exportDoc
  589. */
  590. shaka.extern.DrmConfiguration;
  591. /**
  592. * @typedef {{
  593. * clockSyncUri: string,
  594. * ignoreDrmInfo: boolean,
  595. * disableXlinkProcessing: boolean,
  596. * xlinkFailGracefully: boolean,
  597. * ignoreMinBufferTime: boolean,
  598. * autoCorrectDrift: boolean,
  599. * initialSegmentLimit: number,
  600. * ignoreSuggestedPresentationDelay: boolean,
  601. * ignoreEmptyAdaptationSet: boolean,
  602. * ignoreMaxSegmentDuration: boolean,
  603. * keySystemsByURI: !Object.<string, string>,
  604. * manifestPreprocessor: function(!Element)
  605. * }}
  606. *
  607. * @property {string} clockSyncUri
  608. * A default clock sync URI to be used with live streams which do not
  609. * contain any clock sync information. The <code>Date</code> header from this
  610. * URI will be used to determine the current time.
  611. * @property {boolean} ignoreDrmInfo
  612. * If true will cause DASH parser to ignore DRM information specified
  613. * by the manifest and treat it as if it signaled no particular key
  614. * system and contained no init data. Defaults to false if not provided.
  615. * @property {boolean} disableXlinkProcessing
  616. * If true, xlink-related processing will be disabled. Defaults to
  617. * <code>false</code> if not provided.
  618. * @property {boolean} xlinkFailGracefully
  619. * If true, xlink-related errors will result in a fallback to the tag's
  620. * existing contents. If false, xlink-related errors will be propagated
  621. * to the application and will result in a playback failure. Defaults to
  622. * false if not provided.
  623. * @property {boolean} ignoreMinBufferTime
  624. * If true will cause DASH parser to ignore <code>minBufferTime</code> from
  625. * manifest. It allows player config to take precedence over manifest for
  626. * <code>rebufferingGoal</code>. Defaults to <code>false</code> if not
  627. * provided.
  628. * @property {boolean} autoCorrectDrift
  629. * If <code>true</code>, ignore the <code>availabilityStartTime</code> in the
  630. * manifest and instead use the segments to determine the live edge. This
  631. * allows us to play streams that have a lot of drift. If <code>false</code>,
  632. * we can't play content where the manifest specifies segments in the future.
  633. * Defaults to <code>true</code>.
  634. * @property {number} initialSegmentLimit
  635. * The maximum number of initial segments to generate for
  636. * <code>SegmentTemplate</code> with fixed-duration segments. This is limited
  637. * to avoid excessive memory consumption with very large
  638. * <code>timeShiftBufferDepth</code> values.
  639. * @property {boolean} ignoreSuggestedPresentationDelay
  640. * If true will cause DASH parser to ignore
  641. * <code>suggestedPresentationDelay</code> from manifest. Defaults to
  642. * <code>false</code> if not provided.
  643. * @property {boolean} ignoreEmptyAdaptationSet
  644. * If true will cause DASH parser to ignore
  645. * empty <code>AdaptationSet</code> from manifest. Defaults to
  646. * <code>false</code> if not provided.
  647. * @property {boolean} ignoreMaxSegmentDuration
  648. * If true will cause DASH parser to ignore
  649. * <code>maxSegmentDuration</code> from manifest. Defaults to
  650. * <code>false</code> if not provided.
  651. * @property {Object.<string, string>} keySystemsByURI
  652. * A map of scheme URI to key system name. Defaults to default key systems
  653. * mapping handled by Shaka.
  654. * @property {function(!Element)} manifestPreprocessor
  655. * Called immediately after the DASH manifest has been parsed into an
  656. * XMLDocument. Provides a way for applications to perform efficient
  657. * preprocessing of the manifest.
  658. * @exportDoc
  659. */
  660. shaka.extern.DashManifestConfiguration;
  661. /**
  662. * @typedef {{
  663. * ignoreTextStreamFailures: boolean,
  664. * ignoreImageStreamFailures: boolean,
  665. * useFullSegmentsForStartTime: boolean
  666. * }}
  667. *
  668. * @property {boolean} ignoreTextStreamFailures
  669. * If <code>true</code>, ignore any errors in a text stream and filter out
  670. * those streams.
  671. * @property {boolean} ignoreImageStreamFailures
  672. * If <code>true</code>, ignore any errors in a image stream and filter out
  673. * those streams.
  674. * @property {boolean} useFullSegmentsForStartTime
  675. * If <code>true</code>, force HlsParser to use a full segment request for
  676. * determining start time in case the server does not support partial requests
  677. * @exportDoc
  678. */
  679. shaka.extern.HlsManifestConfiguration;
  680. /**
  681. * @typedef {{
  682. * retryParameters: shaka.extern.RetryParameters,
  683. * availabilityWindowOverride: number,
  684. * disableAudio: boolean,
  685. * disableVideo: boolean,
  686. * disableText: boolean,
  687. * disableThumbnails: boolean,
  688. * defaultPresentationDelay: number,
  689. * dash: shaka.extern.DashManifestConfiguration,
  690. * hls: shaka.extern.HlsManifestConfiguration
  691. * }}
  692. *
  693. * @property {shaka.extern.RetryParameters} retryParameters
  694. * Retry parameters for manifest requests.
  695. * @property {number} availabilityWindowOverride
  696. * A number, in seconds, that overrides the availability window in the
  697. * manifest, or <code>NaN</code> if the default value should be used. This is
  698. * enforced by the manifest parser, so custom manifest parsers should take
  699. * care to honor this parameter.
  700. * @property {boolean} disableAudio
  701. * If <code>true</code>, the audio tracks are ignored.
  702. * Defaults to <code>false</code>.
  703. * @property {boolean} disableVideo
  704. * If <code>true</code>, the video tracks are ignored.
  705. * Defaults to <code>false</code>.
  706. * @property {boolean} disableText
  707. * If <code>true</code>, the text tracks are ignored.
  708. * Defaults to <code>false</code>.
  709. * @property {boolean} disableThumbnails
  710. * If <code>true</code>, the image tracks are ignored.
  711. * Defaults to <code>false</code>.
  712. * @property {number} defaultPresentationDelay
  713. * A default <code>presentationDelay</code> value.
  714. * For DASH, it's a default <code>presentationDelay</code> value if
  715. * <code>suggestedPresentationDelay</code> is missing in the MPEG DASH
  716. * manifest. The default value is <code>1.5 * minBufferTime</code> if not
  717. * configured or set as 0.
  718. * For HLS, the default value is 3 segments duration if not configured or
  719. * set as 0.
  720. * @property {shaka.extern.DashManifestConfiguration} dash
  721. * Advanced parameters used by the DASH manifest parser.
  722. * @property {shaka.extern.HlsManifestConfiguration} hls
  723. * Advanced parameters used by the HLS manifest parser.
  724. *
  725. * @exportDoc
  726. */
  727. shaka.extern.ManifestConfiguration;
  728. /**
  729. * @typedef {{
  730. * retryParameters: shaka.extern.RetryParameters,
  731. * failureCallback: function(!shaka.util.Error),
  732. * rebufferingGoal: number,
  733. * bufferingGoal: number,
  734. * bufferBehind: number,
  735. * ignoreTextStreamFailures: boolean,
  736. * alwaysStreamText: boolean,
  737. * startAtSegmentBoundary: boolean,
  738. * gapDetectionThreshold: number,
  739. * smallGapLimit: number,
  740. * jumpLargeGaps: boolean,
  741. * durationBackoff: number,
  742. * forceTransmuxTS: boolean,
  743. * safeSeekOffset: number,
  744. * stallEnabled: boolean,
  745. * stallThreshold: number,
  746. * stallSkip: number,
  747. * useNativeHlsOnSafari: boolean,
  748. * inaccurateManifestTolerance: number,
  749. * lowLatencyMode: boolean,
  750. * autoLowLatencyMode: boolean,
  751. * forceHTTPS: boolean,
  752. * preferNativeHls: boolean,
  753. * updateIntervalSeconds: number
  754. * }}
  755. *
  756. * @description
  757. * The StreamingEngine's configuration options.
  758. *
  759. * @property {shaka.extern.RetryParameters} retryParameters
  760. * Retry parameters for segment requests.
  761. * @property {function(!shaka.util.Error)} failureCallback
  762. * A callback to decide what to do on a streaming failure. Default behavior
  763. * is to retry on live streams and not on VOD.
  764. * @property {number} rebufferingGoal
  765. * The minimum number of seconds of content that the StreamingEngine must
  766. * buffer before it can begin playback or can continue playback after it has
  767. * entered into a buffering state (i.e., after it has depleted one more
  768. * more of its buffers).
  769. * @property {number} bufferingGoal
  770. * The number of seconds of content that the StreamingEngine will attempt to
  771. * buffer ahead of the playhead. This value must be greater than or equal to
  772. * the rebuffering goal.
  773. * @property {number} bufferBehind
  774. * The maximum number of seconds of content that the StreamingEngine will keep
  775. * in buffer behind the playhead when it appends a new media segment.
  776. * The StreamingEngine will evict content to meet this limit.
  777. * @property {boolean} ignoreTextStreamFailures
  778. * If <code>true</code>, the player will ignore text stream failures and
  779. * continue playing other streams.
  780. * @property {boolean} alwaysStreamText
  781. * If <code>true</code>, always stream text tracks, regardless of whether or
  782. * not they are shown. This is necessary when using the browser's built-in
  783. * controls, which are not capable of signaling display state changes back to
  784. * Shaka Player.
  785. * Defaults to <code>false</code>.
  786. * @property {boolean} startAtSegmentBoundary
  787. * If <code>true</code>, adjust the start time backwards so it is at the start
  788. * of a segment. This affects both explicit start times and calculated start
  789. * time for live streams. This can put us further from the live edge. Defaults
  790. * to <code>false</code>.
  791. * @property {number} gapDetectionThreshold
  792. * TThe maximum distance (in seconds) before a gap when we'll automatically
  793. * jump. This value defaults to <code>0.1</code>, except in Edge Legacy, IE,
  794. * Tizen, Chromecast that value defaults value is <code>0.5</code>
  795. * @property {number} smallGapLimit
  796. * The limit (in seconds) for a gap in the media to be considered "small".
  797. * Small gaps are jumped automatically without events. Large gaps result
  798. * in a Player event and can be jumped.
  799. * @property {boolean} jumpLargeGaps
  800. * If <code>true</code>, jump large gaps in addition to small gaps. A
  801. * <code>largegap</code> event will be raised first. Then, if the app doesn't
  802. * call <code>preventDefault()</code> on the event, the Player will jump the
  803. * gap. If <code>false</code>, then the event will be raised, but the gap
  804. * will not be jumped.
  805. * @property {number} durationBackoff
  806. * By default, we will not allow seeking to exactly the duration of a
  807. * presentation. This field is the number of seconds before duration we will
  808. * seek to when the user tries to seek to or start playback at the duration.
  809. * To disable this behavior, the config can be set to 0. We recommend using
  810. * the default value unless you have a good reason not to.
  811. * @property {boolean} forceTransmuxTS
  812. * If this is <code>true</code>, we will transmux TS content even if not
  813. * strictly necessary for the assets to be played. Shaka Player currently
  814. * only supports CEA 708 captions by transmuxing, so this value is necessary
  815. * for enabling them on platforms with native TS support like Edge or
  816. * Chromecast. This value defaults to <code>false</code>.
  817. * @property {number} safeSeekOffset
  818. * The amount of seconds that should be added when repositioning the playhead
  819. * after falling out of the availability window or seek. This gives the player
  820. * more time to buffer before falling outside again, but increases the forward
  821. * jump in the stream skipping more content. This is helpful for lower
  822. * bandwidth scenarios. Defaults to 5 if not provided.
  823. * @property {boolean} stallEnabled
  824. * When set to <code>true</code>, the stall detector logic will run. If the
  825. * playhead stops moving for <code>stallThreshold</code> seconds, the player
  826. * will either seek or pause/play to resolve the stall, depending on the value
  827. * of <code>stallSkip</code>.
  828. * @property {number} stallThreshold
  829. * The maximum number of seconds that may elapse without the playhead moving
  830. * (when playback is expected) before it will be labeled as a stall.
  831. * @property {number} stallSkip
  832. * The number of seconds that the player will skip forward when a stall has
  833. * been detected. If 0, the player will pause and immediately play instead of
  834. * seeking. A value of 0 is recommended and provided as default on TV
  835. * platforms (WebOS, Tizen, Chromecast, etc).
  836. * @property {boolean} useNativeHlsOnSafari
  837. * Desktop Safari has both MediaSource and their native HLS implementation.
  838. * Depending on the application's needs, it may prefer one over the other.
  839. * Examples: FairPlay is only supported via Safari's native HLS, but it
  840. * doesn't have an API for selecting specific tracks.
  841. * @property {number} inaccurateManifestTolerance
  842. * The maximum difference, in seconds, between the times in the manifest and
  843. * the times in the segments. Larger values allow us to compensate for more
  844. * drift (up to one segment duration). Smaller values reduce the incidence of
  845. * extra segment requests necessary to compensate for drift.
  846. * @property {boolean} lowLatencyMode
  847. * If <code>true</code>, low latency streaming mode is enabled. If
  848. * lowLatencyMode is set to true, inaccurateManifestTolerance is set to 0
  849. * unless specified, and rebufferingGoal to 0.01 unless specified at the same
  850. * time.
  851. * @property {boolean} autoLowLatencyMode
  852. * If the stream is low latency and the user has not configured the
  853. * lowLatencyMode, but if it has been configured to activate the
  854. * lowLatencyMode if a stream of this type is detected, we automatically
  855. * activate the lowLatencyMode. Defaults to false.
  856. * @property {boolean} forceHTTPS
  857. * If true, if the protocol is HTTP change it to HTTPs.
  858. * @property {boolean} preferNativeHls
  859. * If true, prefer native HLS playback when possible, regardless of platform.
  860. * @property {number} updateIntervalSeconds
  861. * The minimum number of seconds to see if the manifest has changes.
  862. *
  863. * @exportDoc
  864. */
  865. shaka.extern.StreamingConfiguration;
  866. /**
  867. * @typedef {{
  868. * enabled: boolean,
  869. * useNetworkInformation: boolean,
  870. * defaultBandwidthEstimate: number,
  871. * restrictions: shaka.extern.Restrictions,
  872. * switchInterval: number,
  873. * bandwidthUpgradeTarget: number,
  874. * bandwidthDowngradeTarget: number
  875. * }}
  876. *
  877. * @property {boolean} enabled
  878. * If true, enable adaptation by the current AbrManager. Defaults to true.
  879. * @property {boolean} useNetworkInformation
  880. * If true, use Network Information API in the current AbrManager.
  881. * Defaults to true.
  882. * @property {number} defaultBandwidthEstimate
  883. * The default bandwidth estimate to use if there is not enough data, in
  884. * bit/sec.
  885. * @property {shaka.extern.Restrictions} restrictions
  886. * The restrictions to apply to ABR decisions. These are "soft" restrictions.
  887. * Any track that fails to meet these restrictions will not be selected
  888. * automatically, but will still appear in the track list and can still be
  889. * selected via <code>selectVariantTrack()</code>. If no tracks meet these
  890. * restrictions, AbrManager should not fail, but choose a low-res or
  891. * low-bandwidth variant instead. It is the responsibiliy of AbrManager
  892. * implementations to follow these rules and implement this behavior.
  893. * @property {number} switchInterval
  894. * The minimum amount of time that must pass between switches, in
  895. * seconds. This keeps us from changing too often and annoying the user.
  896. * @property {number} bandwidthUpgradeTarget
  897. * The fraction of the estimated bandwidth which we should try to use when
  898. * upgrading.
  899. * @property {number} bandwidthDowngradeTarget
  900. * The largest fraction of the estimated bandwidth we should use. We should
  901. * downgrade to avoid this.
  902. * @exportDoc
  903. */
  904. shaka.extern.AbrConfiguration;
  905. /**
  906. * @typedef {{
  907. * trackSelectionCallback:
  908. * function(shaka.extern.TrackList):!Promise<shaka.extern.TrackList>,
  909. * downloadSizeCallback: function(number):!Promise<boolean>,
  910. * progressCallback: function(shaka.extern.StoredContent,number),
  911. * usePersistentLicense: boolean
  912. * }}
  913. *
  914. * @property {function(shaka.extern.TrackList):!Promise<shaka.extern.TrackList>}
  915. * trackSelectionCallback
  916. * Called inside <code>store()</code> to determine which tracks to save from a
  917. * manifest. It is passed an array of Tracks from the manifest and it should
  918. * return an array of the tracks to store.
  919. * @property {function(number):!Promise<boolean>} downloadSizeCallback
  920. * Called inside <code>store()</code> to determine if the content can be
  921. * downloaded due to its estimated size. The estimated size of the download is
  922. * passed and it must return if the download is allowed or not.
  923. * @property {function(shaka.extern.StoredContent,number)} progressCallback
  924. * Called inside <code>store()</code> to give progress info back to the app.
  925. * It is given the current manifest being stored and the progress of it being
  926. * stored.
  927. * @property {boolean} usePersistentLicense
  928. * If <code>true</code>, store protected content with a persistent license so
  929. * that no network is required to view.
  930. * If <code>false</code>, store protected content without a persistent
  931. * license. A network will be required to retrieve a temporary license to
  932. * view.
  933. * Defaults to <code>true</code>.
  934. * @exportDoc
  935. */
  936. shaka.extern.OfflineConfiguration;
  937. /**
  938. * @typedef {{
  939. * drm: shaka.extern.DrmConfiguration,
  940. * manifest: shaka.extern.ManifestConfiguration,
  941. * streaming: shaka.extern.StreamingConfiguration,
  942. * abrFactory: shaka.extern.AbrManager.Factory,
  943. * abr: shaka.extern.AbrConfiguration,
  944. * offline: shaka.extern.OfflineConfiguration,
  945. * preferredAudioLanguage: string,
  946. * preferredTextLanguage: string,
  947. * preferredVariantRole: string,
  948. * preferredTextRole: string,
  949. * preferredVideoCodecs: !Array.<string>,
  950. * preferredAudioCodecs: !Array.<string>,
  951. * preferredAudioChannelCount: number,
  952. * preferredDecodingAttributes: !Array.<string>,
  953. * preferForcedSubs: boolean,
  954. * restrictions: shaka.extern.Restrictions,
  955. * playRangeStart: number,
  956. * playRangeEnd: number,
  957. * textDisplayFactory: shaka.extern.TextDisplayer.Factory
  958. * }}
  959. *
  960. * @property {shaka.extern.DrmConfiguration} drm
  961. * DRM configuration and settings.
  962. * @property {shaka.extern.ManifestConfiguration} manifest
  963. * Manifest configuration and settings.
  964. * @property {shaka.extern.StreamingConfiguration} streaming
  965. * Streaming configuration and settings.
  966. * @property {shaka.extern.AbrManager.Factory} abrFactory
  967. * A factory to construct an abr manager.
  968. * @property {shaka.extern.AbrConfiguration} abr
  969. * ABR configuration and settings.
  970. * @property {shaka.extern.OfflineConfiguration} offline
  971. * Offline configuration and settings.
  972. * @property {string} preferredAudioLanguage
  973. * The preferred language to use for audio tracks. If not given it will use
  974. * the <code>'main'</code> track.
  975. * Changing this during playback will not affect the current playback.
  976. * @property {string} preferredTextLanguage
  977. * The preferred language to use for text tracks. If a matching text track
  978. * is found, and the selected audio and text tracks have different languages,
  979. * the text track will be shown.
  980. * Changing this during playback will not affect the current playback.
  981. * @property {string} preferredVariantRole
  982. * The preferred role to use for variants.
  983. * @property {string} preferredTextRole
  984. * The preferred role to use for text tracks.
  985. * @property {!Array.<string>} preferredVideoCodecs
  986. * The list of preferred video codecs, in order of highest to lowest priority.
  987. * @property {!Array.<string>} preferredAudioCodecs
  988. * The list of preferred audio codecs, in order of highest to lowest priority.
  989. * @property {number} preferredAudioChannelCount
  990. * The preferred number of audio channels.
  991. * @property {!Array.<string>} preferredDecodingAttributes
  992. * The list of preferred attributes of decodingInfo, in the order of their
  993. * priorities.
  994. * @property {boolean} preferForcedSubs
  995. * If true, a forced text track is preferred. Defaults to false.
  996. * If the content has no forced captions and the value is true,
  997. * no text track is chosen.
  998. * Changing this during playback will not affect the current playback.
  999. * @property {shaka.extern.Restrictions} restrictions
  1000. * The application restrictions to apply to the tracks. These are "hard"
  1001. * restrictions. Any track that fails to meet these restrictions will not
  1002. * appear in the track list. If no tracks meet these restrictions, playback
  1003. * will fail.
  1004. * @property {number} playRangeStart
  1005. * Optional playback and seek start time in seconds. Defaults to 0 if
  1006. * not provided.
  1007. * @property {number} playRangeEnd
  1008. * Optional playback and seek end time in seconds. Defaults to the end of
  1009. * the presentation if not provided.
  1010. * @property {shaka.extern.TextDisplayer.Factory} textDisplayFactory
  1011. * A factory to construct a text displayer. Note that, if this is changed
  1012. * during playback, it will cause the text tracks to be reloaded.
  1013. * @exportDoc
  1014. */
  1015. shaka.extern.PlayerConfiguration;
  1016. /**
  1017. * @typedef {{
  1018. * language: string,
  1019. * role: string,
  1020. * label: ?string
  1021. * }}
  1022. *
  1023. * @property {string} language
  1024. * The language code for the stream.
  1025. * @property {string} role
  1026. * The role name for the stream. If the stream has no role, <code>role</code>
  1027. * will be <code>''</code>.
  1028. * @property {?string} label
  1029. * The label of the audio stream, if it has one.
  1030. * @exportDoc
  1031. */
  1032. shaka.extern.LanguageRole;
  1033. /**
  1034. * @typedef {{
  1035. * height: number,
  1036. * positionX: number,
  1037. * positionY: number,
  1038. * startTime: number,
  1039. * duration: number,
  1040. * uris: !Array.<string>,
  1041. * width: number
  1042. * }}
  1043. *
  1044. * @property {number} height
  1045. * The thumbnail height in px.
  1046. * @property {number} positionX
  1047. * The thumbnail left position in px.
  1048. * @property {number} positionY
  1049. * The thumbnail top position in px.
  1050. * @property {number} startTime
  1051. * The start time of the thumbnail in the presentation timeline, in seconds.
  1052. * @property {number} duration
  1053. * The duration of the thumbnail, in seconds.
  1054. * @property {!Array.<string>} uris
  1055. * An array of URIs to attempt. They will be tried in the order they are
  1056. * given.
  1057. * @property {number} width
  1058. * The thumbnail width in px.
  1059. * @exportDoc
  1060. */
  1061. shaka.extern.Thumbnail;
  1062. /**
  1063. * @typedef {{
  1064. * title: string,
  1065. * startTime: number,
  1066. * endTime: number
  1067. * }}
  1068. *
  1069. * @property {string} title
  1070. * The title of the chapter.
  1071. * @property {number} startTime
  1072. * The time that describes the beginning of the range of the chapter.
  1073. * @property {number} endTime
  1074. * The time that describes the end of the range of chapter.
  1075. * @exportDoc
  1076. */
  1077. shaka.extern.Chapter;