Skip to content

Commit

Permalink
reimplement find() functionality from scatch to keep a finder object …
Browse files Browse the repository at this point in the history
…in memory and query it for its sources instead of a one-shot find (which usually cannot catch all sources)
  • Loading branch information
rse committed Mar 3, 2022
1 parent 15df439 commit cf09bb8
Show file tree
Hide file tree
Showing 9 changed files with 378 additions and 206 deletions.
18 changes: 14 additions & 4 deletions scratch/api_sketch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@ const grandiose = require('grandiose');

# Find

let sources = await grandiose.find(<args>, <max_wait>);
let finder = await grandiose.find(<args>);

<args> is {
showLocalSources: <boolean>,
groups: <string> or <array<string>>,
extraIPs: <string> or <array<string>>
groups: <string>,
extraIPs: <string>
}

<finder> is {
embedded: <native<NDIlib_routing_instance_t>>
}

<sources> = finder.sources(<max_wait>);
<int> = finder.wait();

await finder.destroy();

<max_wait> is number of milliseconds to wait before failing

sources is an <array<source>> where source is {
<sources> is an <array<source>> where <source> is {
name: <string>,
urlAddress: <string>,
embedded: <native<NDIlib_source_t>>
Expand Down
26 changes: 26 additions & 0 deletions scratch/scratchFind.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* Copyright 2018 Streampunk Media Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

const g = require('../index.js');

;(async () => {
const finder = await g.find({ showLocalSources: true })
setInterval(() => {
const sources = finder.sources()
console.log(sources)
finder.wait()
}, 1000)
})()

3 changes: 2 additions & 1 deletion scratch/scratchReceiveAudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
const g = require('../index.js');

async function run() {
let l = await g.find();
let f = await g.find({});
let l = f.sources();
console.log('>>> FOUND >>>', l);
let r = await g.receive({ source: l[0] });
console.log('>>> RECEIVER >>>', r);
Expand Down
3 changes: 2 additions & 1 deletion scratch/scratchReceiveData.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
const g = require('../index.js');

async function run() {
let l = await g.find();
let f = await g.find({});
let l = f.sources();
console.log('>>> FOUND >>>', l);
let r = await g.receive({ source: l[0] });
console.log('>>> RECEIVER >>>', r);
Expand Down
3 changes: 2 additions & 1 deletion scratch/scratchReceiveMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
const g = require('../index.js');

async function run() {
let l = await g.find();
let f = await g.find({});
let l = f.sources();
console.log('>>> FOUND >>>', l);
let r = await g.receive({ source: l[0] });
console.log('>>> RECEIVER >>>', r);
Expand Down
3 changes: 2 additions & 1 deletion scratch/scratchReceiveVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
const g = require('../index.js');

async function run() {
let l = await g.find();
let f = await g.find({});
let l = f.sources();
console.log('>>> FOUND >>>', l);
let r = await g.receive({ source: l[0] });
console.log('>>> RECEIVER >>>', r);
Expand Down
3 changes: 2 additions & 1 deletion scratch/scratchRouting.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
const g = require('../index.js');

;(async () => {
const sources = await g.find()
const f = await g.find({})
const sources = f.sources()
console.log(sources[0])

const r = await g.routing({ name: "ROUTER-1" })
Expand Down
Loading

0 comments on commit cf09bb8

Please sign in to comment.