Source: externs/shaka/cea.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. * Interface for parsing inband closed caption data from MP4 streams.
  11. * @interface
  12. * @exportDoc
  13. */
  14. shaka.extern.ICeaParser = class {
  15. /**
  16. * Initializes the parser with init segment data.
  17. * @param {!BufferSource} initSegment init segment to parse.
  18. * @exportDoc
  19. */
  20. init(initSegment) {}
  21. /**
  22. * Parses the stream and extracts closed captions packets.
  23. * @param {!BufferSource} mediaSegment media segment to parse.
  24. * @return {!Array<!shaka.extern.ICeaParser.CaptionPacket>}
  25. * @exportDoc
  26. */
  27. parse(mediaSegment) {}
  28. };
  29. /**
  30. * @typedef {{
  31. * packet: !Uint8Array,
  32. * pts: number
  33. * }}
  34. *
  35. * @description Parsed Caption Packet.
  36. * @property {!Uint8Array} packet
  37. * Caption packet. More specifically, it contains a "User data
  38. * registered by Recommendation ITU-T T.35 SEI message", from section D.1.6
  39. * and section D.2.6 of Rec. ITU-T H.264 (06/2019).
  40. * @property {number} pts
  41. * The presentation timestamp (pts) at which the ITU-T T.35 data shows up.
  42. * in seconds.
  43. * @exportDoc
  44. */
  45. shaka.extern.ICeaParser.CaptionPacket;
  46. /**
  47. * Interface for decoding inband closed captions from packets.
  48. * @interface
  49. * @exportDoc
  50. */
  51. shaka.extern.ICaptionDecoder = class {
  52. /**
  53. * Extracts packets and prepares them for decoding. In a given media fragment,
  54. * all the caption packets found in its SEI messages should be extracted by
  55. * successive calls to extract(), followed by a single call to decode().
  56. *
  57. * @param {!Uint8Array} userDataSeiMessage
  58. * This is a User Data registered by Rec.ITU-T T.35 SEI message.
  59. * It is described in sections D.1.6 and D.2.6 of Rec. ITU-T H.264 (06/2019).
  60. * @param {number} pts PTS when this packet was received, in seconds.
  61. * @exportDoc
  62. */
  63. extract(userDataSeiMessage, pts) {}
  64. /**
  65. * Decodes all currently extracted packets and then clears them.
  66. * This should be called once for a set of extracts (see comment on extract).
  67. * @return {!Array.<!shaka.extern.ICaptionDecoder.ClosedCaption>}
  68. * @exportDoc
  69. */
  70. decode() {}
  71. /**
  72. * Clears the decoder state completely.
  73. * Should be used when an action renders the decoder state invalid,
  74. * e.g. unbuffered seeks.
  75. * @exportDoc
  76. */
  77. clear() {}
  78. /**
  79. * Returns the streams that the CEA decoder found.
  80. * @return {!Array.<string>}
  81. * @exportDoc
  82. */
  83. getStreams() {}
  84. };
  85. /**
  86. * Parsed Cue.
  87. * @typedef {{
  88. * cue: !shaka.text.Cue,
  89. * stream: string
  90. * }}
  91. *
  92. * @exportDoc
  93. */
  94. shaka.extern.ICaptionDecoder.ClosedCaption;
  95. /**
  96. * @typedef {function():!shaka.extern.ICeaParser}
  97. * @exportDoc
  98. */
  99. shaka.extern.CeaParserPlugin;
  100. /**
  101. * @typedef {function():!shaka.extern.ICaptionDecoder}
  102. * @exportDoc
  103. */
  104. shaka.extern.CaptionDecoderPlugin;