@eluvio/elv-client-js 4.0.76 → 4.0.78

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.
Files changed (37) hide show
  1. package/dist/ElvClient-min.js +18 -10
  2. package/dist/ElvClient-node-min.js +18 -10
  3. package/dist/ElvFrameClient-min.js +9 -9
  4. package/dist/ElvPermissionsClient-min.js +10 -10
  5. package/dist/ElvWalletClient-min.js +18 -10
  6. package/dist/ElvWalletClient-node-min.js +18 -10
  7. package/dist/src/AuthorizationClient.js +18 -12
  8. package/dist/src/Crypto.js +2 -2
  9. package/dist/src/ElvClient.js +111 -76
  10. package/dist/src/EthClient.js +2 -2
  11. package/dist/src/FrameClient.js +4 -4
  12. package/dist/src/PermissionsClient.js +2 -2
  13. package/dist/src/Utils.js +6 -5
  14. package/dist/src/abr_profiles/abr_profile_live_drm.js +1621 -0
  15. package/dist/src/abr_profiles/abr_profile_live_to_vod.js +1599 -0
  16. package/dist/src/client/ABRPublishing.js +2 -2
  17. package/dist/src/client/AccessGroups.js +19 -20
  18. package/dist/src/client/ContentAccess.js +48 -28
  19. package/dist/src/client/ContentManagement.js +3 -3
  20. package/dist/src/client/Contracts.js +235 -203
  21. package/dist/src/client/Files.js +2 -2
  22. package/dist/src/client/LiveConf.js +152 -21
  23. package/dist/src/client/LiveStream.js +1376 -1248
  24. package/dist/src/client/NFT.js +2 -2
  25. package/dist/src/contracts/v3b/BaseAccessControlGroup.js +1704 -0
  26. package/dist/src/walletClient/ClientMethods.js +423 -280
  27. package/dist/src/walletClient/Profile.js +2 -2
  28. package/dist/src/walletClient/Utils.js +7 -3
  29. package/dist/src/walletClient/index.js +124 -44
  30. package/package.json +2 -1
  31. package/src/FrameClient.js +4 -0
  32. package/src/abr_profiles/abr_profile_live_drm.js +1907 -0
  33. package/src/abr_profiles/abr_profile_live_to_vod.js +1885 -0
  34. package/src/client/ContentAccess.js +21 -0
  35. package/src/client/LiveConf.js +133 -17
  36. package/src/client/LiveStream.js +907 -947
  37. package/testScripts/Test.js +7 -0
@@ -2176,6 +2176,11 @@ const EmbedMediaTypes = {
2176
2176
  - `showTitle` - Shows the video title, which is set from the title option (if set) or the metadata
2177
2177
  - `title` - Sets the page title
2178
2178
  - `viewRecordKey` - Contains record key
2179
+ - `useTicketCodes` - Use tickets authorization
2180
+ - `tenantId` - Tenant ID, required for tickets authorization
2181
+ - `ntpId` - NTP ID, required for tickets authorization
2182
+ - `ticketCode` - Ticket code, optional with tickets authorization
2183
+ - `ticketSubject` - Ticket subject, optional with tickets authorization
2179
2184
  *
2180
2185
  * @returns {Promise<string>} - Will return an embed URL
2181
2186
  */
@@ -2279,6 +2284,22 @@ exports.EmbedUrl = async function({
2279
2284
  case "viewRecordKey":
2280
2285
  embedUrl.searchParams.set("vrk", options.viewRecordKey);
2281
2286
  break;
2287
+ case "useTicketCodes":
2288
+ embedUrl.searchParams.set("ptk", "");
2289
+ if (options.tenantId) {
2290
+ embedUrl.searchParams.set("ten", options.tenantId);
2291
+ }
2292
+ if (options.ntpId) {
2293
+ embedUrl.searchParams.set("ntp", options.ntpId);
2294
+ }
2295
+ if (options.ticketCode) {
2296
+ embedUrl.searchParams.set("tk", Buffer.from(options.ticketCode).toString("base64"));
2297
+
2298
+ }
2299
+ if (options.ticketSubject) {
2300
+ embedUrl.searchParams.set("sbj", Buffer.from(options.ticketSubject).toString("base64"));
2301
+ }
2302
+ break;
2282
2303
  }
2283
2304
  }
2284
2305
 
@@ -107,6 +107,7 @@ const LiveconfTemplate = {
107
107
  sync_audio_to_stream_id: -1,
108
108
  video_bitrate: null,
109
109
  video_seg_duration_ts: null,
110
+ video_time_base: null,
110
111
  xc_type: 3
111
112
  }
112
113
  }
@@ -160,56 +161,156 @@ class LiveConf {
160
161
  }
161
162
  }
162
163
 
163
- calcSegDuration({sourceTimescale}) {
164
+ /*
165
+ * Calculates mez segment durations based on input stream parameters
166
+ *
167
+ * Live input formats have fixed timebase:
168
+ * - MPEG-TS/SRT input stream timebase is 90000
169
+ * - RTMP input stream timebase is 1000 and gets translated to 16000 if not otherwise specified
170
+ *
171
+ * This causes frame duration irregularities for certain frame rates.
172
+ * For example RTMP 60fps has frames of durations 16 and 17. MPEG-TS 59.94fps has frames of
173
+ * durations 1001 and 1002.
174
+ *
175
+ * Live mez segmentation requires that the segment be cut at the specific number of frames, and when
176
+ * the frame durations are irregular we adjust both the video timebase and the video frame duration
177
+ * to make the math possible. This adjustment is also required for live-to-vod conversion.
178
+ *
179
+ * For example for MPEG-TS 59.94fps, the mez segment timebase needs to be 60000
180
+ * (and resulting frame duration is 1001) and for RTMP 60fps the timebase needs to be 15360 (resulting frame
181
+ * duration is 256).
182
+ *
183
+ * @sourceTimescale - adjusted source video stream timescale (eg. MPEGTS 90000, RTMP 16000 )
184
+ * @sampleRate - audio sample rate (commonly 48000 but can be different)
185
+ * @audioCodec - audio codec as a string (eg. "aac")
186
+ * @return - segment encoding parameters
187
+ */
188
+ calcSegDuration({sourceTimescale, sampleRate, audioCodec}) {
189
+ let seg = {};
190
+
191
+ switch(this.probeKind()) {
192
+ case "rtmp":
193
+ seg = this.calcSegDurationRtmp({sourceTimescale, sampleRate, audioCodec});
194
+ break;
195
+ case "udp":
196
+ case "srt":
197
+ seg = this.calcSegDurationMpegts({sourceTimescale, sampleRate, audioCodec});
198
+ break;
199
+ default:
200
+ throw "protocol not supported - " + this.probeKind();
201
+ }
202
+
203
+ if(audioCodec == "aac") {
204
+ seg.audio = 29.76 * sampleRate;
205
+ } else {
206
+ seg.audio = 29.76 * 48000; // Other codecs are resampled @48000
207
+ }
208
+
209
+ return seg;
210
+ }
211
+
212
+ calcSegDurationMpegts({sourceTimescale}) {
164
213
  let videoStream = this.getStreamDataForCodecType("video");
165
214
  let frameRate = videoStream.frame_rate;
215
+ let seg = {};
216
+
217
+ switch(frameRate) {
218
+ case "24":
219
+ seg.video = sourceTimescale * 30;
220
+ seg.keyint = 48;
221
+ seg.duration = "30";
222
+ break;
223
+ case "25":
224
+ seg.video = sourceTimescale * 30;
225
+ seg.keyint = 50;
226
+ seg.duration = "30";
227
+ break;
228
+ case "30":
229
+ seg.video = sourceTimescale * 30;
230
+ seg.keyint = 60;
231
+ seg.duration = "30";
232
+ break;
233
+ case "30000/1001":
234
+ seg.video = sourceTimescale * 30;
235
+ seg.keyint = 60;
236
+ seg.duration = "30.03";
237
+ break;
238
+ case "48":
239
+ seg.video = sourceTimescale * 30;
240
+ seg.keyint = 96;
241
+ seg.duration = "30";
242
+ break;
243
+ case "50":
244
+ seg.video = sourceTimescale * 30;
245
+ seg.keyint = 100;
246
+ seg.duration = "30";
247
+ break;
248
+ case "60":
249
+ seg.video = sourceTimescale * 30;
250
+ seg.keyint = 120;
251
+ seg.duration = "30";
252
+ break;
253
+ case "60000/1001":
254
+ seg.videoTimeBase = 60000;
255
+ seg.video = seg.videoTimeBase * 30.03;
256
+ seg.keyint = 120;
257
+ seg.duration = "30.03";
258
+ break;
259
+ default:
260
+ throw "unsupported frame rate for MPEGTS - " + frameRate;
261
+ break;
262
+ }
263
+ return seg;
264
+ }
166
265
 
266
+ calcSegDurationRtmp({sourceTimescale}) {
267
+ let videoStream = this.getStreamDataForCodecType("video");
268
+ let frameRate = videoStream.frame_rate;
167
269
  let seg = {};
168
- seg.audio = 29.76 * 48000;
169
270
 
170
271
  switch(frameRate) {
171
272
  case "24":
172
- seg.video = 30 * sourceTimescale;
273
+ seg.video = sourceTimescale * 30;
173
274
  seg.keyint = 48;
174
275
  seg.duration = "30";
175
276
  break;
176
277
  case "25":
177
- seg.video = 30 * sourceTimescale;
278
+ seg.video = sourceTimescale * 30;
178
279
  seg.keyint = 50;
179
280
  seg.duration = "30";
180
281
  break;
181
282
  case "30":
182
- seg.video = 30 * sourceTimescale;
283
+ seg.video = sourceTimescale * 30;
183
284
  seg.keyint = 60;
184
285
  seg.duration = "30";
185
286
  break;
186
287
  case "30000/1001":
187
- seg.video = 30.03 * sourceTimescale;
288
+ seg.video = sourceTimescale * 30.03;
188
289
  seg.keyint = 60;
189
290
  seg.duration = "30.03";
190
291
  break;
191
292
  case "48":
192
- seg.video = 30 * sourceTimescale;
293
+ seg.video = sourceTimescale * 30;
193
294
  seg.keyint = 96;
194
295
  seg.duration = "30";
195
296
  break;
196
297
  case "50":
197
- seg.video = 30 * sourceTimescale;
298
+ seg.video = sourceTimescale * 30;
198
299
  seg.keyint = 100;
199
300
  seg.duration = "30";
200
301
  break;
201
302
  case "60":
202
- seg.video = 30 * sourceTimescale;
303
+ seg.video = sourceTimescale * 30;
203
304
  seg.keyint = 120;
204
305
  seg.duration = "30";
205
306
  break;
206
307
  case "60000/1001":
207
- seg.video = 30.03 * sourceTimescale;
308
+ seg.video = sourceTimescale * 30.03;
208
309
  seg.keyint = 120;
209
310
  seg.duration = "30.03";
210
311
  break;
211
312
  default:
212
- console.log("Unsupported frame rate", frameRate);
313
+ throw "unsupported frame rate for RTMP - " + frameRate;
213
314
  break;
214
315
  }
215
316
  return seg;
@@ -220,10 +321,11 @@ class LiveConf {
220
321
  let videoStream = this.getStreamDataForCodecType("video");
221
322
  switch(this.probeKind()) {
222
323
  case "udp":
324
+ case "srt":
223
325
  sync_id = videoStream.stream_id;
224
326
  break;
225
327
  case "rtmp":
226
- sync_id = -1; // Pending fabric API: videoStream.stream_index
328
+ sync_id = videoStream.stream_index;
227
329
  break;
228
330
  }
229
331
  return sync_id;
@@ -234,14 +336,14 @@ class LiveConf {
234
336
  const conf = JSON.parse(JSON.stringify(LiveconfTemplate));
235
337
  const fileName = this.overwriteOriginUrl || this.probeData.format.filename;
236
338
  const audioStream = this.getStreamDataForCodecType("audio");
339
+
237
340
  const sampleRate = parseInt(audioStream.sample_rate);
341
+ const audioCodec = audioStream.codec_name;
238
342
  const videoStream = this.getStreamDataForCodecType("video");
239
343
  let sourceTimescale;
240
344
 
241
- console.log("AUDIO", audioStream);
242
- console.log("VIDEO", videoStream);
243
-
244
345
  // Fill in liveconf all formats have in common
346
+ conf.live_recording.probe_info = this.probeData;
245
347
  conf.live_recording.fabric_config.ingress_node_api = this.nodeUrl || null;
246
348
  conf.live_recording.fabric_config.ingress_node_id = this.nodeId || null;
247
349
  conf.live_recording.recording_config.recording_params.description;
@@ -267,6 +369,11 @@ class LiveConf {
267
369
  sourceTimescale = 90000;
268
370
  conf.live_recording.recording_config.recording_params.source_timescale = sourceTimescale;
269
371
  break;
372
+ case "srt":
373
+ sourceTimescale = 90000;
374
+ conf.live_recording.recording_config.recording_params.source_timescale = sourceTimescale;
375
+ conf.live_recording.recording_config.recording_params.live_delay_nano = 4000000000;
376
+ break;
270
377
  case "rtmp":
271
378
  sourceTimescale = 16000;
272
379
  conf.live_recording.recording_config.recording_params.source_timescale = sourceTimescale;
@@ -275,11 +382,11 @@ class LiveConf {
275
382
  console.log("HLS detected. Not yet implemented");
276
383
  break;
277
384
  default:
278
- console.log("Unsuppoted media", this.probeKind());
385
+ console.log("Unsupported media", this.probeKind());
279
386
  break;
280
387
  }
281
388
 
282
- const segDurations = this.calcSegDuration({sourceTimescale});
389
+ const segDurations = this.calcSegDuration({sourceTimescale, sampleRate, audioCodec});
283
390
 
284
391
  // Segment conditioning parameters
285
392
  conf.live_recording.recording_config.recording_params.xc_params.seg_duration = segDurations.duration;
@@ -287,6 +394,15 @@ class LiveConf {
287
394
  conf.live_recording.recording_config.recording_params.xc_params.video_seg_duration_ts = segDurations.video;
288
395
  conf.live_recording.recording_config.recording_params.xc_params.force_keyint = segDurations.keyint;
289
396
 
397
+ // Optional override output timebase and frame duration (ts)
398
+ if(segDurations.videoTimeBase) {
399
+ conf.live_recording.recording_config.recording_params.xc_params.video_time_base = segDurations.videoTimeBase;
400
+ conf.live_recording.recording_config.recording_params.source_timescale = segDurations.videoTimeBase;
401
+ }
402
+ if(segDurations.videoFrameDurationTs) {
403
+ conf.live_recording.recording_config.recording_params.xc_params.video_frame_duration_ts = segDurations.videoFrameDurationTs;
404
+ }
405
+
290
406
  switch(videoStream.height) {
291
407
  case 2160:
292
408
  conf.live_recording.recording_config.recording_params.ladder_specs.unshift(