@eluvio/elv-client-js 4.0.56 → 4.0.58

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.
@@ -2215,7 +2215,7 @@ exports.UpdateContentObjectGraph = /*#__PURE__*/function () {
2215
2215
  return _context30.delegateYield(_loop(), "t0", 8);
2216
2216
  case 8:
2217
2217
  _ret = _context30.t0;
2218
- if (!(_typeof(_ret) === "object")) {
2218
+ if (!_ret) {
2219
2219
  _context30.next = 11;
2220
2220
  break;
2221
2221
  }
@@ -1,3 +1,4 @@
1
+ var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
1
2
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
2
3
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
3
4
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
@@ -772,7 +773,7 @@ exports.UploadStatus = /*#__PURE__*/function () {
772
773
  }();
773
774
  exports.UploadJobStatus = /*#__PURE__*/function () {
774
775
  var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref14) {
775
- var libraryId, objectId, writeToken, uploadId, jobId, path;
776
+ var libraryId, objectId, writeToken, uploadId, jobId, path, response, newResponse;
776
777
  return _regeneratorRuntime.wrap(function _callee9$(_context10) {
777
778
  while (1) switch (_context10.prev = _context10.next) {
778
779
  case 0:
@@ -795,17 +796,59 @@ exports.UploadJobStatus = /*#__PURE__*/function () {
795
796
  _context10.t2 = _context10.sent;
796
797
  _context10.t3 = path;
797
798
  _context10.t4 = {
799
+ start: 0,
800
+ limit: 10000
801
+ };
802
+ _context10.t5 = {
798
803
  headers: _context10.t2,
799
804
  method: "GET",
800
805
  path: _context10.t3,
801
- allowFailover: false
806
+ allowFailover: false,
807
+ queryParams: _context10.t4
802
808
  };
803
- _context10.t5 = _context10.t1.Request.call(_context10.t1, _context10.t4);
804
- _context10.next = 14;
805
- return _context10.t0.ResponseToJson.call(_context10.t0, _context10.t5);
806
- case 14:
807
- return _context10.abrupt("return", _context10.sent);
809
+ _context10.t6 = _context10.t1.Request.call(_context10.t1, _context10.t5);
810
+ _context10.next = 15;
811
+ return _context10.t0.ResponseToJson.call(_context10.t0, _context10.t6);
808
812
  case 15:
813
+ response = _context10.sent;
814
+ case 16:
815
+ if (!(response.next !== response.total && response.next >= 0)) {
816
+ _context10.next = 33;
817
+ break;
818
+ }
819
+ _context10.t7 = this.utils;
820
+ _context10.t8 = this.HttpClient;
821
+ _context10.next = 21;
822
+ return this.authClient.AuthorizationHeader({
823
+ libraryId: libraryId,
824
+ objectId: objectId,
825
+ update: true
826
+ });
827
+ case 21:
828
+ _context10.t9 = _context10.sent;
829
+ _context10.t10 = path;
830
+ _context10.t11 = {
831
+ start: response.next
832
+ };
833
+ _context10.t12 = {
834
+ headers: _context10.t9,
835
+ method: "GET",
836
+ path: _context10.t10,
837
+ allowFailover: false,
838
+ queryParams: _context10.t11
839
+ };
840
+ _context10.t13 = _context10.t8.Request.call(_context10.t8, _context10.t12);
841
+ _context10.next = 28;
842
+ return _context10.t7.ResponseToJson.call(_context10.t7, _context10.t13);
843
+ case 28:
844
+ newResponse = _context10.sent;
845
+ response.files = [].concat(_toConsumableArray(response.files), _toConsumableArray(newResponse.files));
846
+ response.next = newResponse.next;
847
+ _context10.next = 16;
848
+ break;
849
+ case 33:
850
+ return _context10.abrupt("return", response);
851
+ case 34:
809
852
  case "end":
810
853
  return _context10.stop();
811
854
  }
@@ -0,0 +1,343 @@
1
+ var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
2
+ var _createClass = require("@babel/runtime/helpers/createClass");
3
+ var LadderTemplate = {
4
+ "2160": {
5
+ bit_rate: 14000000,
6
+ codecs: "avc1.640028,mp4a.40.2",
7
+ height: 2160,
8
+ media_type: 1,
9
+ representation: "videovideo_3840x2160_h264@14000000",
10
+ stream_name: "video",
11
+ width: 3840
12
+ },
13
+ "1080": {
14
+ bit_rate: 9500000,
15
+ codecs: "avc1.640028,mp4a.40.2",
16
+ height: 1080,
17
+ media_type: 1,
18
+ representation: "videovideo_1920x1080_h264@9500000",
19
+ stream_name: "video",
20
+ width: 1920
21
+ },
22
+ "720": {
23
+ bit_rate: 4500000,
24
+ codecs: "avc1.640028,mp4a.40.2",
25
+ height: 720,
26
+ media_type: 1,
27
+ representation: "videovideo_1280x720_h264@4500000",
28
+ stream_name: "video",
29
+ width: 1280
30
+ },
31
+ "540": {
32
+ bit_rate: 2000000,
33
+ codecs: "avc1.640028,mp4a.40.2",
34
+ height: 540,
35
+ media_type: 1,
36
+ representation: "videovideo_960x540_h264@2000000",
37
+ stream_name: "video",
38
+ width: 960
39
+ },
40
+ "540_low": {
41
+ bit_rate: 900000,
42
+ codecs: "avc1.640028,mp4a.40.2",
43
+ height: 540,
44
+ media_type: 1,
45
+ representation: "videovideo_960x540_h264@900000",
46
+ stream_name: "video",
47
+ width: 960
48
+ }
49
+ };
50
+ var LiveconfTemplate = {
51
+ live_recording: {
52
+ fabric_config: {
53
+ ingress_node_api: "",
54
+ ingress_node_id: ""
55
+ },
56
+ playout_config: {
57
+ rebroadcast_start_time_sec_epoch: 0,
58
+ vod_enabled: false
59
+ },
60
+ recording_config: {
61
+ recording_params: {
62
+ description: "",
63
+ ladder_specs: [{
64
+ bit_rate: 384000,
65
+ channels: 2,
66
+ codecs: "mp4a.40.2",
67
+ media_type: 2,
68
+ representation: "audioaudio_aac@384000",
69
+ stream_name: "audio"
70
+ }],
71
+ listen: true,
72
+ live_delay_nano: 2000000000,
73
+ max_duration_sec: -1,
74
+ name: "",
75
+ origin_url: "",
76
+ part_ttl: 3600,
77
+ playout_type: "live",
78
+ source_timescale: null,
79
+ xc_params: {
80
+ audio_bitrate: 384000,
81
+ audio_index: [0, 0, 0, 0, 0, 0, 0, 0],
82
+ audio_seg_duration_ts: null,
83
+ ecodec2: "aac",
84
+ enc_height: null,
85
+ enc_width: null,
86
+ filter_descriptor: "",
87
+ force_keyint: null,
88
+ format: "fmp4-segment",
89
+ listen: true,
90
+ n_audio: 1,
91
+ preset: "faster",
92
+ sample_rate: 48000,
93
+ seg_duration: null,
94
+ skip_decoding: false,
95
+ start_segment_str: "1",
96
+ stream_id: -1,
97
+ sync_audio_to_stream_id: -1,
98
+ video_bitrate: null,
99
+ video_seg_duration_ts: null,
100
+ xc_type: 3
101
+ }
102
+ }
103
+ }
104
+ }
105
+ };
106
+ var LiveConf = /*#__PURE__*/function () {
107
+ "use strict";
108
+
109
+ function LiveConf(probeData, nodeId, nodeUrl, includeAVSegDurations, overwriteOriginUrl, syncAudioToVideo) {
110
+ _classCallCheck(this, LiveConf);
111
+ this.probeData = probeData;
112
+ this.nodeId = nodeId;
113
+ this.nodeUrl = nodeUrl;
114
+ this.includeAVSegDurations = includeAVSegDurations;
115
+ this.overwriteOriginUrl = overwriteOriginUrl;
116
+ this.syncAudioToVideo = syncAudioToVideo;
117
+ }
118
+ _createClass(LiveConf, [{
119
+ key: "probeKind",
120
+ value: function probeKind() {
121
+ var fileNameSplit = this.probeData.format.filename.split(":");
122
+ return fileNameSplit[0];
123
+ }
124
+ }, {
125
+ key: "getStreamDataForCodecType",
126
+ value: function getStreamDataForCodecType(codecType) {
127
+ var stream = null;
128
+ for (var index = 0; index < this.probeData.streams.length; index++) {
129
+ if (this.probeData.streams[index].codec_type == codecType) {
130
+ stream = this.probeData.streams[index];
131
+ }
132
+ }
133
+ return stream;
134
+ }
135
+ }, {
136
+ key: "getFrameRate",
137
+ value: function getFrameRate() {
138
+ var videoStream = this.getStreamDataForCodecType("video");
139
+ var frameRate = videoStream.r_frame_rate || videoStream.frame_rate;
140
+ return frameRate.split("/");
141
+ }
142
+ }, {
143
+ key: "isFrameRateWhole",
144
+ value: function isFrameRateWhole() {
145
+ var frameRate = this.getFrameRate();
146
+ return frameRate[1] == "1";
147
+ }
148
+ }, {
149
+ key: "getForceKeyint",
150
+ value: function getForceKeyint() {
151
+ var frameRate = this.getFrameRate();
152
+ var roundedFrameRate = Math.round(frameRate[0] / frameRate[1]);
153
+ if (roundedFrameRate > 30) {
154
+ return roundedFrameRate;
155
+ } else {
156
+ return roundedFrameRate * 2;
157
+ }
158
+ }
159
+ }, {
160
+ key: "calcSegDuration",
161
+ value: function calcSegDuration(_ref) {
162
+ var sourceTimescale = _ref.sourceTimescale;
163
+ var videoStream = this.getStreamDataForCodecType("video");
164
+ var frameRate = videoStream.frame_rate;
165
+ var seg = {};
166
+ switch (frameRate) {
167
+ case "24":
168
+ seg.video = 30 * sourceTimescale;
169
+ seg.audio = 30 * 48000;
170
+ seg.keyint = 48;
171
+ seg.duration = "30";
172
+ break;
173
+ case "25":
174
+ seg.video = 30 * sourceTimescale;
175
+ seg.audio = 30 * 48000;
176
+ seg.keyint = 50;
177
+ seg.duration = "30";
178
+ break;
179
+ case "30":
180
+ seg.video = 30 * sourceTimescale;
181
+ seg.audio = 30 * 48000;
182
+ seg.keyint = 60;
183
+ seg.duration = "30";
184
+ break;
185
+ case "30000/1001":
186
+ seg.video = 30.03 * sourceTimescale;
187
+ seg.audio = 29.76 * 48000;
188
+ seg.keyint = 60;
189
+ seg.duration = "30.03";
190
+ break;
191
+ case "48":
192
+ seg.video = 30 * sourceTimescale;
193
+ seg.audio = 30 * 48000;
194
+ seg.keyint = 96;
195
+ seg.duration = "30";
196
+ break;
197
+ case "50":
198
+ seg.video = 30 * sourceTimescale;
199
+ seg.audio = 30 * 48000;
200
+ seg.keyint = 100;
201
+ seg.duration = "30";
202
+ break;
203
+ case "60":
204
+ seg.video = 30 * sourceTimescale;
205
+ seg.audio = 30 * 48000;
206
+ seg.keyint = 120;
207
+ seg.duration = "30";
208
+ break;
209
+ case "60000/1001":
210
+ seg.video = 30.03 * sourceTimescale;
211
+ seg.audio = 29.76 * 48000;
212
+ seg.keyint = 120;
213
+ seg.duration = "30.03";
214
+ break;
215
+ default:
216
+ console.log("Unsupported frame rate", frameRate);
217
+ break;
218
+ }
219
+ return seg;
220
+ }
221
+ }, {
222
+ key: "syncAudioToStreamIdValue",
223
+ value: function syncAudioToStreamIdValue() {
224
+ var sync_id = -1;
225
+ var videoStream = this.getStreamDataForCodecType("video");
226
+ switch (this.probeKind()) {
227
+ case "udp":
228
+ sync_id = videoStream.stream_id;
229
+ break;
230
+ case "rtmp":
231
+ sync_id = -1; // Pending fabric API: videoStream.stream_index
232
+ break;
233
+ }
234
+ return sync_id;
235
+ }
236
+ }, {
237
+ key: "generateLiveConf",
238
+ value: function generateLiveConf(_ref2) {
239
+ var audioBitrate = _ref2.audioBitrate,
240
+ audioIndex = _ref2.audioIndex,
241
+ partTtl = _ref2.partTtl,
242
+ channelLayout = _ref2.channelLayout;
243
+ // gather required data
244
+ var conf = JSON.parse(JSON.stringify(LiveconfTemplate));
245
+ var fileName = this.overwriteOriginUrl || this.probeData.format.filename;
246
+ var audioStream = this.getStreamDataForCodecType("audio");
247
+ var sampleRate = parseInt(audioStream.sample_rate);
248
+ var videoStream = this.getStreamDataForCodecType("video");
249
+ var sourceTimescale;
250
+ console.log("AUDIO", audioStream);
251
+ console.log("VIDEO", videoStream);
252
+
253
+ // Fill in liveconf all formats have in common
254
+ conf.live_recording.fabric_config.ingress_node_api = this.nodeUrl || null;
255
+ conf.live_recording.fabric_config.ingress_node_id = this.nodeId || null;
256
+ conf.live_recording.recording_config.recording_params.description;
257
+ conf.live_recording.recording_config.recording_params.origin_url = fileName;
258
+ conf.live_recording.recording_config.recording_params.description = "Ingest stream ".concat(fileName);
259
+ conf.live_recording.recording_config.recording_params.name = "Ingest stream ".concat(fileName);
260
+ conf.live_recording.recording_config.recording_params.xc_params.audio_index[0] = audioIndex === undefined ? audioStream.stream_index : audioIndex;
261
+ conf.live_recording.recording_config.recording_params.xc_params.sample_rate = sampleRate;
262
+ conf.live_recording.recording_config.recording_params.xc_params.enc_height = videoStream.height;
263
+ conf.live_recording.recording_config.recording_params.xc_params.enc_width = videoStream.width;
264
+ if (this.syncAudioToVideo) {
265
+ conf.live_recording.recording_config.recording_params.xc_params.sync_audio_to_stream_id = this.syncAudioToStreamIdValue();
266
+ }
267
+ if (partTtl) {
268
+ conf.live_recording.recording_config.recording_params.part_ttl = partTtl;
269
+ }
270
+
271
+ // Fill in specifics for protocol
272
+ switch (this.probeKind()) {
273
+ case "udp":
274
+ sourceTimescale = 90000;
275
+ conf.live_recording.recording_config.recording_params.source_timescale = sourceTimescale;
276
+ break;
277
+ case "rtmp":
278
+ sourceTimescale = 16000;
279
+ conf.live_recording.recording_config.recording_params.source_timescale = sourceTimescale;
280
+ break;
281
+ case "hls":
282
+ console.log("HLS detected. Not yet implemented");
283
+ break;
284
+ default:
285
+ console.log("Unsuppoted media", this.probeKind());
286
+ break;
287
+ }
288
+ var segDurations = this.calcSegDuration({
289
+ sourceTimescale: sourceTimescale
290
+ });
291
+
292
+ // Segment conditioning parameters
293
+ conf.live_recording.recording_config.recording_params.xc_params.seg_duration = segDurations.duration;
294
+ conf.live_recording.recording_config.recording_params.xc_params.audio_seg_duration_ts = segDurations.audio;
295
+ conf.live_recording.recording_config.recording_params.xc_params.video_seg_duration_ts = segDurations.video;
296
+ conf.live_recording.recording_config.recording_params.xc_params.force_keyint = segDurations.keyint;
297
+ switch (videoStream.height) {
298
+ case 2160:
299
+ conf.live_recording.recording_config.recording_params.ladder_specs.unshift(LadderTemplate[2160], LadderTemplate[1080], LadderTemplate[720], LadderTemplate[540], LadderTemplate["540_low"]);
300
+ conf.live_recording.recording_config.recording_params.xc_params.video_bitrate = LadderTemplate[2160].bit_rate;
301
+ conf.live_recording.recording_config.recording_params.xc_params.enc_height = 2160;
302
+ conf.live_recording.recording_config.recording_params.xc_params.enc_width = 3840;
303
+ break;
304
+ case 1080:
305
+ conf.live_recording.recording_config.recording_params.ladder_specs.unshift(LadderTemplate[1080], LadderTemplate[720], LadderTemplate[540], LadderTemplate["540_low"]);
306
+ conf.live_recording.recording_config.recording_params.xc_params.video_bitrate = LadderTemplate[1080].bit_rate;
307
+ conf.live_recording.recording_config.recording_params.xc_params.enc_height = 1080;
308
+ conf.live_recording.recording_config.recording_params.xc_params.enc_width = 1920;
309
+ break;
310
+ case 720:
311
+ conf.live_recording.recording_config.recording_params.ladder_specs.unshift(LadderTemplate[720], LadderTemplate[540], LadderTemplate["540_low"]);
312
+ conf.live_recording.recording_config.recording_params.xc_params.video_bitrate = LadderTemplate[720].bit_rate;
313
+ conf.live_recording.recording_config.recording_params.xc_params.enc_height = 720;
314
+ conf.live_recording.recording_config.recording_params.xc_params.enc_width = 1280;
315
+ break;
316
+ case 540:
317
+ conf.live_recording.recording_config.recording_params.ladder_specs.unshift(LadderTemplate[540], LadderTemplate["540_low"]);
318
+ conf.live_recording.recording_config.recording_params.xc_params.video_bitrate = LadderTemplate[540].bit_rate;
319
+ conf.live_recording.recording_config.recording_params.xc_params.enc_height = 540;
320
+ conf.live_recording.recording_config.recording_params.xc_params.enc_width = 960;
321
+ break;
322
+ default:
323
+ throw new Error("ERROR: Probed stream does not conform to one of the following built in resolution ladders [4096, 2160], [1920, 1080] [1280, 720], [960, 540]");
324
+ }
325
+ if (audioBitrate || channelLayout) {
326
+ var audioLadderSpec = conf.live_recording.recording_config.recording_params.ladder_specs.find(function (spec) {
327
+ return spec.stream_name === "audio";
328
+ });
329
+ if (audioBitrate) {
330
+ conf.live_recording.recording_config.recording_params.xc_params.audio_bitrate = audioBitrate;
331
+ audioLadderSpec.bit_rate = audioBitrate;
332
+ audioLadderSpec.representation = "audioaudio_aac@".concat(audioBitrate);
333
+ }
334
+ if (channelLayout) {
335
+ audioLadderSpec.channels = channelLayout;
336
+ }
337
+ }
338
+ return JSON.stringify(conf, null, 2);
339
+ }
340
+ }]);
341
+ return LiveConf;
342
+ }();
343
+ exports.LiveConf = LiveConf;