@eluvio/elv-client-js 4.0.49 → 4.0.50

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.49",
3
+ "version": "4.0.50",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
@@ -1122,108 +1122,105 @@ exports.StreamConfig = async function({name}) {
1122
1122
  let conf = await this.LoadConf({name});
1123
1123
  let status = {name};
1124
1124
 
1125
- try {
1126
- let libraryId = await this.ContentObjectLibraryId({objectId: conf.objectId});
1127
- status.library_id = libraryId;
1128
- status.object_id = conf.objectId;
1125
+ let libraryId = await this.ContentObjectLibraryId({objectId: conf.objectId});
1126
+ status.library_id = libraryId;
1127
+ status.object_id = conf.objectId;
1129
1128
 
1130
- let mainMeta = await this.ContentObjectMetadata({
1131
- libraryId: libraryId,
1132
- objectId: conf.objectId
1133
- });
1129
+ let mainMeta = await this.ContentObjectMetadata({
1130
+ libraryId: libraryId,
1131
+ objectId: conf.objectId
1132
+ });
1134
1133
 
1135
- let userConfig = mainMeta.live_recording_config;
1136
- status.user_config = userConfig;
1134
+ let userConfig = mainMeta.live_recording_config;
1135
+ status.user_config = userConfig;
1137
1136
 
1138
- // Get node URI from user config
1139
- const hostName = userConfig.url.replace("udp://", "").replace("rtmp://", "").split(":")[0];
1140
- const streamUrl = new URL(userConfig.url);
1137
+ // Get node URI from user config
1138
+ const hostName = userConfig.url.replace("udp://", "").replace("rtmp://", "").split(":")[0];
1139
+ const streamUrl = new URL(userConfig.url);
1141
1140
 
1142
- console.log("Retrieving nodes...");
1143
- let nodes = await this.SpaceNodes({matchEndpoint: hostName});
1144
- if(nodes.length < 1) {
1145
- status.error = "No node matching stream URL " + streamUrl.href;
1146
- return status;
1147
- }
1148
- const node = nodes[0];
1149
- status.node = node;
1150
-
1151
- let endpoint = node.endpoints[0];
1152
- this.SetNodes({fabricURIs: [endpoint]});
1153
-
1154
- // Probe the stream
1155
- let probe = {};
1156
- const controller = new AbortController();
1157
- const timeoutId = setTimeout(() => {
1158
- controller.abort();
1159
- }, 60 * 1000); // milliseconds
1160
- try {
1161
-
1162
- let probeUrl = await this.Rep({
1163
- libraryId,
1164
- objectId: conf.objectId,
1165
- rep: "probe"
1166
- });
1167
-
1168
- probe = await this.utils.ResponseToJson(
1169
- await HttpClient.Fetch(probeUrl, {
1170
- body: JSON.stringify({
1171
- "filename": streamUrl.href,
1172
- "listen": true
1173
- }),
1174
- method: "POST",
1175
- signal: controller.signal
1176
- })
1177
- );
1141
+ console.log("Retrieving nodes...");
1142
+ let nodes = await this.SpaceNodes({matchEndpoint: hostName});
1143
+ if(nodes.length < 1) {
1144
+ status.error = "No node matching stream URL " + streamUrl.href;
1145
+ return status;
1146
+ }
1147
+ const node = nodes[0];
1148
+ status.node = node;
1149
+
1150
+ let endpoint = node.endpoints[0];
1151
+ this.SetNodes({fabricURIs: [endpoint]});
1152
+
1153
+ // Probe the stream
1154
+ let probe = {};
1155
+ const controller = new AbortController();
1156
+ const timeoutId = setTimeout(() => {
1157
+ controller.abort();
1158
+ }, 60 * 1000); // milliseconds
1159
+ try {
1178
1160
 
1179
- if(probe) { clearTimeout(timeoutId); }
1180
- } catch(error) {
1181
- if(error.code === "ETIMEDOUT") {
1182
- status.error = "Stream probe time out - make sure the stream source is available";
1183
- } else {
1184
- console.log("Stream probe failed", error);
1185
- }
1186
- }
1161
+ let probeUrl = await this.Rep({
1162
+ libraryId,
1163
+ objectId: conf.objectId,
1164
+ rep: "probe"
1165
+ });
1187
1166
 
1188
- probe.format.filename = streamUrl.href;
1189
- console.log("PROBE", probe);
1167
+ probe = await this.utils.ResponseToJson(
1168
+ await HttpClient.Fetch(probeUrl, {
1169
+ body: JSON.stringify({
1170
+ "filename": streamUrl.href,
1171
+ "listen": true
1172
+ }),
1173
+ method: "POST",
1174
+ signal: controller.signal
1175
+ })
1176
+ );
1190
1177
 
1191
- // Create live reocording config
1192
- let lc = new LiveConf(probe, node.id, endpoint, false, false, true);
1178
+ if(probe) { clearTimeout(timeoutId); }
1193
1179
 
1194
- const liveRecordingConfigStr = lc.generateLiveConf();
1195
- let liveRecordingConfig = JSON.parse(liveRecordingConfigStr);
1196
- console.log("CONFIG", JSON.stringify(liveRecordingConfig.live_recording));
1180
+ if(probe.errors) {
1181
+ throw probe.errors[0];
1182
+ }
1183
+ } catch(error) {
1184
+ if(error.code === "ETIMEDOUT") {
1185
+ throw "Stream probe time out - make sure the stream source is available";
1186
+ } else {
1187
+ throw error;
1188
+ }
1189
+ }
1197
1190
 
1198
- // Store live recording config into the stream object
1199
- let e = await this.EditContentObject({
1200
- libraryId,
1201
- objectId: conf.objectId
1202
- });
1203
- let writeToken = e.write_token;
1191
+ console.log("PROBE", probe);
1192
+ probe.format.filename = streamUrl.href;
1204
1193
 
1205
- await this.ReplaceMetadata({
1206
- libraryId,
1207
- objectId: conf.objectId,
1208
- writeToken,
1209
- metadataSubtree: "live_recording",
1210
- metadata: liveRecordingConfig.live_recording
1211
- });
1194
+ // Create live reocording config
1195
+ let lc = new LiveConf(probe, node.id, endpoint, false, false, true);
1212
1196
 
1213
- let fin = await this.FinalizeContentObject({
1214
- libraryId,
1215
- objectId: conf.objectId,
1216
- writeToken,
1217
- commitMessage: "Apply live stream configuration"
1218
- });
1197
+ const liveRecordingConfigStr = lc.generateLiveConf();
1198
+ let liveRecordingConfig = JSON.parse(liveRecordingConfigStr);
1199
+ console.log("CONFIG", JSON.stringify(liveRecordingConfig.live_recording));
1219
1200
 
1220
- status.fin = fin;
1201
+ // Store live recording config into the stream object
1202
+ let e = await this.EditContentObject({
1203
+ libraryId,
1204
+ objectId: conf.objectId
1205
+ });
1206
+ let writeToken = e.write_token;
1207
+
1208
+ await this.ReplaceMetadata({
1209
+ libraryId,
1210
+ objectId: conf.objectId,
1211
+ writeToken,
1212
+ metadataSubtree: "live_recording",
1213
+ metadata: liveRecordingConfig.live_recording
1214
+ });
1221
1215
 
1222
- return status;
1216
+ status.fin = await this.FinalizeContentObject({
1217
+ libraryId,
1218
+ objectId: conf.objectId,
1219
+ writeToken,
1220
+ commitMessage: "Apply live stream configuration"
1221
+ });
1223
1222
 
1224
- } catch(e) {
1225
- console.log("ERROR", e);
1226
- }
1223
+ return status;
1227
1224
  };
1228
1225
 
1229
1226
  // const ChannelStatus = async ({client, name}) => {