Skip to content

Commit

Permalink
add initial support for NDI routing functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
rse committed Jan 15, 2022
1 parent c41e723 commit 7459f92
Show file tree
Hide file tree
Showing 9 changed files with 531 additions and 2 deletions.
1 change: 1 addition & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"src/grandiose_find.cc",
"src/grandiose_send.cc",
"src/grandiose_receive.cc",
"src/grandiose_routing.cc",
"src/grandiose.cc"
],
"include_dirs": [ "ndi/include" ],
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ module.exports = {
find: find,
receive: addon.receive,
send: addon.send,
routing: addon.routing,
COLOR_FORMAT_BGRX_BGRA, COLOR_FORMAT_UYVY_BGRA,
COLOR_FORMAT_RGBX_RGBA, COLOR_FORMAT_UYVY_RGBA,
COLOR_FORMAT_BGRX_BGRA_FLIPPED, COLOR_FORMAT_FASTEST,
Expand Down
22 changes: 22 additions & 0 deletions scratch/api_sketch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,25 @@ await sender.send({

sender.destroy();

# routing

let routing = await grandiose.routing(<args>);

<args> is {
name: <string>,
[groups: <string>]
}

<routing> is {
name: <string>,
[groups: <string>],
embedded: <native<NDIlib_routing_instance_t>>
}

<int> = routing.change(<source>);
<bool> = routing.clear();
<int> = routing.connections();
<string> = routing.sourcename();

await routing.destroy();

31 changes: 31 additions & 0 deletions scratch/scratchRouting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* 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 sources = await g.find()
console.log(sources[0])

const r = await g.routing({ name: "ROUTER-1" })
console.log(r.connections())
console.log(r.sourcename())
console.log(r.change(sources[0]))
setInterval(() => {
console.log(r.connections())
}, 1000)
// r.destroy()
})()

4 changes: 3 additions & 1 deletion src/grandiose.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "grandiose_find.h"
#include "grandiose_send.h"
#include "grandiose_receive.h"
#include "grandiose_routing.h"
#include "node_api.h"

napi_value version(napi_env env, napi_callback_info info) {
Expand Down Expand Up @@ -83,7 +84,8 @@ napi_value Init(napi_env env, napi_value exports) {
DECLARE_NAPI_METHOD("destroy", destroy),
DECLARE_NAPI_METHOD("find", find),
DECLARE_NAPI_METHOD("send", send),
DECLARE_NAPI_METHOD("receive", receive)
DECLARE_NAPI_METHOD("receive", receive),
DECLARE_NAPI_METHOD("routing", routing)
};
status = napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
CHECK_STATUS;
Expand Down
1 change: 0 additions & 1 deletion src/grandiose_receive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ napi_value receive(napi_env env, napi_callback_info info) {
REJECT_RETURN;
c->status = napi_typeof(env, checkType, &type);
REJECT_RETURN;

if (type != napi_undefined && type != napi_string) REJECT_ERROR_RETURN(
"Source 'urlAddress' sub-property must be of type string.",
GRANDIOSE_INVALID_ARGS);
Expand Down
Loading

0 comments on commit 7459f92

Please sign in to comment.