@eluvio/elv-client-js 4.0.48 → 4.0.49
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 +1 -1
- package/src/ElvClient.js +49 -49
- package/src/client/LiveConf.js +3 -3
- package/src/client/LiveStream.js +9 -9
package/package.json
CHANGED
package/src/ElvClient.js
CHANGED
|
@@ -571,78 +571,78 @@ class ElvClient {
|
|
|
571
571
|
*
|
|
572
572
|
* @methodGroup Nodes
|
|
573
573
|
* @namedParams
|
|
574
|
-
* @param {string} -
|
|
575
|
-
* @param {string} -
|
|
574
|
+
* @param {string=} matchEndpoint - Return node(s) matching the specified endpoint
|
|
575
|
+
* @param {string=} matchNodeId - Return node(s) matching the specified node ID
|
|
576
576
|
*
|
|
577
|
-
* @return {Array<Object>} - A list of nodes in the space
|
|
577
|
+
* @return {Array<Object>} - A list of nodes in the space matching the parameters
|
|
578
578
|
*/
|
|
579
|
-
async SpaceNodes({matchEndpoint, matchNodeId}) {
|
|
579
|
+
async SpaceNodes({matchEndpoint, matchNodeId}={}) {
|
|
580
580
|
let bign = await this.CallContractMethod({
|
|
581
581
|
contractAddress: this.contentSpaceAddress,
|
|
582
582
|
methodName: "numActiveNodes",
|
|
583
583
|
});
|
|
584
584
|
let n = bign.toNumber();
|
|
585
|
-
let nodes = [];
|
|
586
585
|
|
|
587
|
-
|
|
586
|
+
return (await Utils.LimitedMap(
|
|
587
|
+
5,
|
|
588
|
+
[...new Array(n)],
|
|
589
|
+
async (_, index) => {
|
|
590
|
+
let bigi = Ethers.BigNumber.from(index);
|
|
591
|
+
let addr = await this.CallContractMethod({
|
|
592
|
+
contractAddress: this.contentSpaceAddress,
|
|
593
|
+
methodName: "activeNodeAddresses",
|
|
594
|
+
methodArgs: [bigi],
|
|
595
|
+
formatArguments: true
|
|
596
|
+
});
|
|
588
597
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
formatArguments: true
|
|
595
|
-
});
|
|
598
|
+
let locatorsHex = await this.CallContractMethod({
|
|
599
|
+
contractAddress: this.contentSpaceAddress,
|
|
600
|
+
methodName: "activeNodeLocators",
|
|
601
|
+
methodArgs: [bigi]
|
|
602
|
+
});
|
|
596
603
|
|
|
597
|
-
|
|
598
|
-
contractAddress: this.contentSpaceAddress,
|
|
599
|
-
methodName: "activeNodeLocators",
|
|
600
|
-
methodArgs: [bigi]
|
|
601
|
-
});
|
|
604
|
+
let nodeId = this.utils.AddressToNodeId(addr);
|
|
602
605
|
|
|
603
|
-
|
|
606
|
+
if(matchNodeId &&nodeId !== matchNodeId) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
604
609
|
|
|
605
|
-
|
|
606
|
-
continue; // Not a match
|
|
607
|
-
}
|
|
610
|
+
let node = {id: nodeId, endpoints: []};
|
|
608
611
|
|
|
609
|
-
|
|
612
|
+
// Parse locators CBOR
|
|
613
|
+
let buffer = locatorsHex.slice(2, locatorsHex.length); // Skip "0x"
|
|
614
|
+
let hex = buffer.toString("hex");
|
|
615
|
+
let locators = CBOR.decodeAllSync(hex);
|
|
610
616
|
|
|
611
|
-
|
|
612
|
-
let buffer = locatorsHex.slice(2, locatorsHex.length); // Skip "0x"
|
|
613
|
-
let hex = buffer.toString("hex");
|
|
614
|
-
let locators = CBOR.decodeAllSync(hex);
|
|
617
|
+
let match = false;
|
|
615
618
|
|
|
616
|
-
|
|
619
|
+
if(locators.length >= 5) {
|
|
620
|
+
let fabArray = locators[4].fab;
|
|
621
|
+
if(fabArray) {
|
|
622
|
+
for(let i = 0; i < fabArray.length; i ++) {
|
|
623
|
+
let host = fabArray[i].host;
|
|
617
624
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
for(let i = 0; i < fabArray.length; i ++) {
|
|
622
|
-
let host = fabArray[i].host;
|
|
625
|
+
if(matchEndpoint && !matchEndpoint.includes(host)) {
|
|
626
|
+
continue; // Not a match
|
|
627
|
+
}
|
|
623
628
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
}
|
|
629
|
+
match = true;
|
|
630
|
+
let endpoint = fabArray[i].scheme + "://" + host;
|
|
627
631
|
|
|
628
|
-
|
|
629
|
-
|
|
632
|
+
if(fabArray[i].port) {
|
|
633
|
+
endpoint = endpoint + ":" + fabArray[i].port;
|
|
634
|
+
}
|
|
630
635
|
|
|
631
|
-
|
|
632
|
-
endpoint
|
|
636
|
+
endpoint = endpoint + "/" + fabArray[i].path;
|
|
637
|
+
node.endpoints.push(endpoint);
|
|
633
638
|
}
|
|
634
|
-
|
|
635
|
-
endpoint = endpoint + "/" + fabArray[i].path;
|
|
636
|
-
node.endpoints.push(endpoint);
|
|
637
639
|
}
|
|
638
640
|
}
|
|
639
|
-
}
|
|
640
|
-
if(match) {
|
|
641
|
-
nodes.push(node);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
641
|
|
|
645
|
-
|
|
642
|
+
return match ? node : undefined;
|
|
643
|
+
}
|
|
644
|
+
))
|
|
645
|
+
.filter(n => n);
|
|
646
646
|
}
|
|
647
647
|
|
|
648
648
|
/**
|
package/src/client/LiveConf.js
CHANGED
|
@@ -131,7 +131,7 @@ class LiveConf {
|
|
|
131
131
|
|
|
132
132
|
getStreamDataForCodecType(codecType) {
|
|
133
133
|
let stream = null;
|
|
134
|
-
for
|
|
134
|
+
for(let index = 0; index < this.probeData.streams.length; index++) {
|
|
135
135
|
if(this.probeData.streams[index].codec_type == codecType) {
|
|
136
136
|
stream = this.probeData.streams[index];
|
|
137
137
|
}
|
|
@@ -166,7 +166,7 @@ class LiveConf {
|
|
|
166
166
|
let frameRate = videoStream.frame_rate;
|
|
167
167
|
|
|
168
168
|
let seg ={};
|
|
169
|
-
switch
|
|
169
|
+
switch(frameRate) {
|
|
170
170
|
case "24":
|
|
171
171
|
seg.video = 30 * sourceTimescale;
|
|
172
172
|
seg.audio = 30 * 48000;
|
|
@@ -225,7 +225,7 @@ class LiveConf {
|
|
|
225
225
|
syncAudioToStreamIdValue() {
|
|
226
226
|
let sync_id = -1;
|
|
227
227
|
let videoStream = this.getStreamDataForCodecType("video");
|
|
228
|
-
switch
|
|
228
|
+
switch(this.probeKind()) {
|
|
229
229
|
case "udp":
|
|
230
230
|
sync_id = videoStream.stream_id;
|
|
231
231
|
break;
|
package/src/client/LiveStream.js
CHANGED
|
@@ -68,12 +68,12 @@ exports.StreamStatus = async function({name, stopLro=false, showParams=false}) {
|
|
|
68
68
|
]
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
if
|
|
71
|
+
if(mainMeta.live_recording_config == undefined || mainMeta.live_recording_config.url == undefined) {
|
|
72
72
|
status.state = "unconfigured";
|
|
73
73
|
return status;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
if
|
|
76
|
+
if(mainMeta.live_recording == undefined || mainMeta.live_recording.fabric_config == undefined ||
|
|
77
77
|
mainMeta.live_recording.playout_config == undefined || mainMeta.live_recording.recording_config == undefined) {
|
|
78
78
|
status.state = "uninitialized";
|
|
79
79
|
return status;
|
|
@@ -96,7 +96,7 @@ exports.StreamStatus = async function({name, stopLro=false, showParams=false}) {
|
|
|
96
96
|
status.url = mainMeta.live_recording.recording_config.recording_params.origin_url;
|
|
97
97
|
|
|
98
98
|
let edgeWriteToken = mainMeta.live_recording.fabric_config.edge_write_token;
|
|
99
|
-
if
|
|
99
|
+
if(edgeWriteToken == undefined) {
|
|
100
100
|
status.state = "inactive";
|
|
101
101
|
return status;
|
|
102
102
|
}
|
|
@@ -157,7 +157,7 @@ exports.StreamStatus = async function({name, stopLro=false, showParams=false}) {
|
|
|
157
157
|
if((edgeMeta.live_recording.playout_config.interleaves != undefined) &&
|
|
158
158
|
(edgeMeta.live_recording.playout_config.interleaves[sequence] != undefined)) {
|
|
159
159
|
let insertions = edgeMeta.live_recording.playout_config.interleaves[sequence];
|
|
160
|
-
for
|
|
160
|
+
for(let i = 0; i < insertions.length; i ++) {
|
|
161
161
|
let insertionTimeSinceEpoch = recording_period.start_time_epoch_sec + insertions[i].insertion_time;
|
|
162
162
|
status.insertions[i] = {
|
|
163
163
|
insertion_time_since_start: insertions[i].insertion_time,
|
|
@@ -190,7 +190,7 @@ exports.StreamStatus = async function({name, stopLro=false, showParams=false}) {
|
|
|
190
190
|
state = "starting";
|
|
191
191
|
} else if(state === "running" && sinceLastFinalize > 32.9) {
|
|
192
192
|
state = "stalled";
|
|
193
|
-
} else if
|
|
193
|
+
} else if(state == "terminated") {
|
|
194
194
|
state = "stopped";
|
|
195
195
|
}
|
|
196
196
|
status.state = state;
|
|
@@ -493,7 +493,7 @@ exports.StreamStartOrStopOrReset = async function({name, op}) {
|
|
|
493
493
|
|
|
494
494
|
// Wait until LRO is 'starting'
|
|
495
495
|
let tries = 10;
|
|
496
|
-
while
|
|
496
|
+
while(status.state != "starting" && tries-- > 0) {
|
|
497
497
|
console.log("Wait to start - ", status.state);
|
|
498
498
|
await sleep(1000);
|
|
499
499
|
status = await this.StreamStatus({name});
|
|
@@ -505,7 +505,7 @@ exports.StreamStartOrStopOrReset = async function({name, op}) {
|
|
|
505
505
|
} catch(error) {
|
|
506
506
|
console.error(error);
|
|
507
507
|
}
|
|
508
|
-
}
|
|
508
|
+
};
|
|
509
509
|
|
|
510
510
|
/*
|
|
511
511
|
* Stop the live stream session and close the edge write token.
|
|
@@ -943,7 +943,7 @@ exports.LoadConf = async function({name}) {
|
|
|
943
943
|
}
|
|
944
944
|
|
|
945
945
|
return conf;
|
|
946
|
-
}
|
|
946
|
+
};
|
|
947
947
|
|
|
948
948
|
/*
|
|
949
949
|
* Read a playable contnet object and get information about a particular offering
|
|
@@ -1136,7 +1136,7 @@ exports.StreamConfig = async function({name}) {
|
|
|
1136
1136
|
status.user_config = userConfig;
|
|
1137
1137
|
|
|
1138
1138
|
// Get node URI from user config
|
|
1139
|
-
const hostName = userConfig.url.replace("udp://", "").split(":")[0];
|
|
1139
|
+
const hostName = userConfig.url.replace("udp://", "").replace("rtmp://", "").split(":")[0];
|
|
1140
1140
|
const streamUrl = new URL(userConfig.url);
|
|
1141
1141
|
|
|
1142
1142
|
console.log("Retrieving nodes...");
|