hls.js 1.5.14-0.canary.10601 → 1.5.14-0.canary.10603

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -130,5 +130,5 @@
130
130
  "url-toolkit": "2.2.5",
131
131
  "wrangler": "3.75.0"
132
132
  },
133
- "version": "1.5.14-0.canary.10601"
133
+ "version": "1.5.14-0.canary.10603"
134
134
  }
package/src/config.ts CHANGED
@@ -241,6 +241,7 @@ export type LatencyControllerConfig = {
241
241
  export type MetadataControllerConfig = {
242
242
  enableDateRangeMetadataCues: boolean;
243
243
  enableEmsgMetadataCues: boolean;
244
+ enableEmsgKLVMetadata: boolean;
244
245
  enableID3MetadataCues: boolean;
245
246
  };
246
247
 
@@ -412,6 +413,7 @@ export const hlsDefaultConfig: HlsConfig = {
412
413
  cmcd: undefined,
413
414
  enableDateRangeMetadataCues: true,
414
415
  enableEmsgMetadataCues: true,
416
+ enableEmsgKLVMetadata: false,
415
417
  enableID3MetadataCues: true,
416
418
  useMediaCapabilities: __USE_MEDIA_CAPABILITIES__,
417
419
 
@@ -20,6 +20,7 @@ import {
20
20
  parseInitSegment,
21
21
  RemuxerTrackIdConfig,
22
22
  hasMoofData,
23
+ IEmsgParsingData,
23
24
  } from '../utils/mp4-tools';
24
25
  import { dummyTrack } from './dummy-demuxed-track';
25
26
  import type { HlsEventEmitter } from '../events';
@@ -115,7 +116,6 @@ class MP4Demuxer implements Demuxer {
115
116
  } else {
116
117
  videoTrack.samples = videoSamples;
117
118
  }
118
-
119
119
  const id3Track = this.extractID3Track(videoTrack, timeOffset);
120
120
  textTrack.samples = parseSamples(timeOffset, videoTrack);
121
121
 
@@ -156,10 +156,7 @@ class MP4Demuxer implements Demuxer {
156
156
  emsgs.forEach((data: Uint8Array) => {
157
157
  const emsgInfo = parseEmsg(data);
158
158
  if (emsgSchemePattern.test(emsgInfo.schemeIdUri)) {
159
- const pts = Number.isFinite(emsgInfo.presentationTime)
160
- ? emsgInfo.presentationTime! / emsgInfo.timeScale
161
- : timeOffset +
162
- emsgInfo.presentationTimeDelta! / emsgInfo.timeScale;
159
+ const pts = getEmsgStartTime(emsgInfo, timeOffset);
163
160
  let duration =
164
161
  emsgInfo.eventDuration === 0xffffffff
165
162
  ? Number.POSITIVE_INFINITY
@@ -177,6 +174,19 @@ class MP4Demuxer implements Demuxer {
177
174
  type: MetadataSchema.emsg,
178
175
  duration: duration,
179
176
  });
177
+ } else if (
178
+ this.config.enableEmsgKLVMetadata &&
179
+ emsgInfo.schemeIdUri.startsWith('urn:misb:KLV:bin:1910.1')
180
+ ) {
181
+ const pts = getEmsgStartTime(emsgInfo, timeOffset);
182
+ id3Track.samples.push({
183
+ data: emsgInfo.payload,
184
+ len: emsgInfo.payload.byteLength,
185
+ dts: pts,
186
+ pts: pts,
187
+ type: MetadataSchema.misbklv,
188
+ duration: Number.POSITIVE_INFINITY,
189
+ });
180
190
  }
181
191
  });
182
192
  }
@@ -206,4 +216,14 @@ class MP4Demuxer implements Demuxer {
206
216
  }
207
217
  }
208
218
 
219
+ function getEmsgStartTime(
220
+ emsgInfo: IEmsgParsingData,
221
+ timeOffset: number,
222
+ ): number {
223
+ return Number.isFinite(emsgInfo.presentationTime)
224
+ ? (emsgInfo.presentationTime as number) / emsgInfo.timeScale
225
+ : timeOffset +
226
+ (emsgInfo.presentationTimeDelta as number) / emsgInfo.timeScale;
227
+ }
228
+
209
229
  export default MP4Demuxer;
package/src/hls.ts CHANGED
@@ -12,6 +12,7 @@ import { enableLogs, type ILogger } from './utils/logger';
12
12
  import { enableStreamingMode, hlsDefaultConfig, mergeConfig } from './config';
13
13
  import { EventEmitter } from 'eventemitter3';
14
14
  import { Events } from './events';
15
+ import { MetadataSchema } from './types/demuxer';
15
16
  import { ErrorTypes, ErrorDetails } from './errors';
16
17
  import { version } from './version';
17
18
  import { isHdcpLevel, type HdcpLevel, type Level } from './types/level';
@@ -116,6 +117,10 @@ export default class Hls implements HlsEventEmitter {
116
117
  return Events;
117
118
  }
118
119
 
120
+ static get MetadataSchema(): typeof MetadataSchema {
121
+ return MetadataSchema;
122
+ }
123
+
119
124
  static get ErrorTypes(): typeof ErrorTypes {
120
125
  return ErrorTypes;
121
126
  }
@@ -1026,6 +1031,7 @@ export type {
1026
1031
  ErrorDetails,
1027
1032
  ErrorTypes,
1028
1033
  Events,
1034
+ MetadataSchema,
1029
1035
  Level,
1030
1036
  HlsListeners,
1031
1037
  HlsEventEmitter,
@@ -1097,11 +1103,7 @@ export type { LoadStats } from './loader/load-stats';
1097
1103
  export type { LevelKey } from './loader/level-key';
1098
1104
  export type { LevelDetails } from './loader/level-details';
1099
1105
  export type { SourceBufferName } from './types/buffer';
1100
- export type {
1101
- MetadataSample,
1102
- MetadataSchema,
1103
- UserdataSample,
1104
- } from './types/demuxer';
1106
+ export type { MetadataSample, UserdataSample } from './types/demuxer';
1105
1107
  export type {
1106
1108
  HlsSkip,
1107
1109
  HlsUrlParameters,
@@ -95,10 +95,11 @@ export interface DemuxedUserdataTrack extends DemuxedTrack {
95
95
  samples: UserdataSample[];
96
96
  }
97
97
 
98
- export const enum MetadataSchema {
98
+ export enum MetadataSchema {
99
99
  audioId3 = 'org.id3',
100
100
  dateRange = 'com.apple.quicktime.HLS',
101
101
  emsg = 'https://aomedia.org/emsg/ID3',
102
+ misbklv = 'urn:misb:KLV:bin:1910.1',
102
103
  }
103
104
  export interface MetadataSample {
104
105
  pts: number;