Streampunk / grandiose

Node.JS native bindings to Newtek NDI(tm).
Apache License 2.0
189 stars 48 forks source link

Mac OS support #4

Closed jensstigaard closed 1 year ago

jensstigaard commented 4 years ago

Added mac OS support.

Included NDI library for Mac, updated bindings and tested. It worked.

Also updated readme.

2xAA commented 4 years ago

@sparkpunkd would we be able to get this merged soon?

kyelewis commented 4 years ago

Thanks for this great work @jensstigaard on the darwin support - I grabbed your branch to test on an electron app on MacOS and the find and video receive works some of the time.

Unfortunately sometimes the process crashes after an invalid 0x0 video resolution- I see there is a check in the receive code for this condition, but things crash before it bubbles up to a promise rejection.

Hope to have some time to help investigate why next week... but wanted to say thanks for the great work and starting point!

jensstigaard commented 3 years ago

Thanks for this great work @jensstigaard on the darwin support - I grabbed your branch to test on an electron app on MacOS and the find and video receive works some of the time.

Unfortunately sometimes the process crashes after an invalid 0x0 video resolution- I see there is a check in the receive code for this condition, but things crash before it bubbles up to a promise rejection.

Hope to have some time to help investigate why next week... but wanted to say thanks for the great work and starting point!

Hi Kyle, any news on the issue you are experiencing?

danjenkins commented 3 years ago

@jensstigaard I cant make an issue or anything on your fork.... just wanted to say thanks for all the work on this! much appreciated! I was just about to start looking at forking this and updating it when I thought I'd better check the network graph!

jensstigaard commented 3 years ago

@jensstigaard I cant make an issue or anything on your fork.... just wanted to say thanks for all the work on this! much appreciated! I was just about to start looking at forking this and updating it when I thought I'd better check the network graph!

You are welcome. Hopefully at some point we can have all the updated code merged into the main repo...

danjenkins commented 3 years ago

@jensstigaard things work perfectly on macosx but I try and just install the module on debian and I get failures...

  CXX(target) Release/obj.target/grandiose/src/grandiose_util.o
../src/grandiose_util.cc: In function ‘napi_status checkArgs(napi_env, napi_callback_info, char*, napi_value__**, size_t, napi_valuetype*)’:
../src/grandiose_util.cc:139:21: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
  139 |   for (int x = 0; x < argc; x++)
      |                   ~~^~~~~~
  CXX(target) Release/obj.target/grandiose/src/grandiose_find.o
../src/grandiose_find.cc: In function ‘void findComplete(napi_env, napi_status, void*)’:
../src/grandiose_util.h:100:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  100 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:66:3: note: in expansion of macro ‘REJECT_STATUS’
   66 |   REJECT_STATUS;
      |   ^~~~~~~~~~~~~
../src/grandiose_util.h:100:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  100 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:72:3: note: in expansion of macro ‘REJECT_STATUS’
   72 |   REJECT_STATUS;
      |   ^~~~~~~~~~~~~
../src/grandiose_util.h:100:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  100 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:79:5: note: in expansion of macro ‘REJECT_STATUS’
   79 |     REJECT_STATUS;
      |     ^~~~~~~~~~~~~
../src/grandiose_util.h:100:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  100 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:81:5: note: in expansion of macro ‘REJECT_STATUS’
   81 |     REJECT_STATUS;
      |     ^~~~~~~~~~~~~
../src/grandiose_util.h:100:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  100 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:83:5: note: in expansion of macro ‘REJECT_STATUS’
   83 |     REJECT_STATUS;
      |     ^~~~~~~~~~~~~
../src/grandiose_util.h:100:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  100 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:85:5: note: in expansion of macro ‘REJECT_STATUS’
   85 |     REJECT_STATUS;
      |     ^~~~~~~~~~~~~
../src/grandiose_util.h:100:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  100 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:87:5: note: in expansion of macro ‘REJECT_STATUS’
   87 |     REJECT_STATUS;
      |     ^~~~~~~~~~~~~
../src/grandiose_util.h:100:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  100 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:90:5: note: in expansion of macro ‘REJECT_STATUS’
   90 |     REJECT_STATUS;
      |     ^~~~~~~~~~~~~
../src/grandiose_find.cc: In function ‘napi_value__* find(napi_env, napi_callback_info)’:
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:110:3: note: in expansion of macro ‘REJECT_RETURN’
  110 |   REJECT_RETURN;
      |   ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:123:3: note: in expansion of macro ‘REJECT_RETURN’
  123 |   REJECT_RETURN;
      |   ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:132:5: note: in expansion of macro ‘REJECT_RETURN’
  132 |     REJECT_RETURN;
      |     ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:144:9: note: in expansion of macro ‘REJECT_RETURN’
  144 |         REJECT_RETURN;
      |         ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:148:11: note: in expansion of macro ‘REJECT_RETURN’
  148 |           REJECT_RETURN;
      |           ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:158:9: note: in expansion of macro ‘REJECT_RETURN’
  158 |         REJECT_RETURN;
      |         ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:165:11: note: in expansion of macro ‘REJECT_RETURN’
  165 |           REJECT_RETURN;
      |           ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:175:11: note: in expansion of macro ‘REJECT_RETURN’
  175 |           REJECT_RETURN;
      |           ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:188:9: note: in expansion of macro ‘REJECT_RETURN’
  188 |         REJECT_RETURN;
      |         ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:195:11: note: in expansion of macro ‘REJECT_RETURN’
  195 |           REJECT_RETURN;
      |           ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:201:11: note: in expansion of macro ‘REJECT_RETURN’
  201 |           REJECT_RETURN;
      |           ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:218:5: note: in expansion of macro ‘REJECT_RETURN’
  218 |     REJECT_RETURN;
      |     ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:224:7: note: in expansion of macro ‘REJECT_RETURN’
  224 |       REJECT_RETURN;
      |       ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_util.h:131:5: note: in expansion of macro ‘REJECT_RETURN’
  131 |     REJECT_RETURN;                     \
      |     ^~~~~~~~~~~~~
../src/grandiose_find.cc:234:5: note: in expansion of macro ‘REJECT_ERROR_RETURN’
  234 |     REJECT_ERROR_RETURN("Failed to create NDI find instance.", GRANDIOSE_INVALID_ARGS);
      |     ^~~~~~~~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:239:3: note: in expansion of macro ‘REJECT_RETURN’
  239 |   REJECT_RETURN;
      |   ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:249:3: note: in expansion of macro ‘REJECT_RETURN’
  249 |   REJECT_RETURN;
      |   ^~~~~~~~~~~~~
../src/grandiose_util.h:103:28: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  103 |   if (rejectStatus(env, c, __FILE__, __LINE__) != GRANDIOSE_SUCCESS) \
      |                            ^~~~~~~~
../src/grandiose_find.cc:253:3: note: in expansion of macro ‘REJECT_RETURN’
  253 |   REJECT_RETURN;
      |   ^~~~~~~~~~~~~
  CXX(target) Release/obj.target/grandiose/src/grandiose_send.o
  CXX(target) Release/obj.target/grandiose/src/grandiose_send_video.o
../src/grandiose_send_video.cc: In function ‘napi_value__* sendVideo(napi_env, napi_callback_info)’:
../src/grandiose_send_video.cc:92:7: error: ‘memset’ was not declared in this scope
   92 |       memset((void *)NDI_video_frame.p_data, (frame_index & 1) ? 255 : 0, number_of_pixels * 4);
      |       ^~~~~~
../src/grandiose_send_video.cc:30:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
   29 | #include "grandiose_util.h"
  +++ |+#include <cstring>
   30 |
make: *** [grandiose.target.mk:116: Release/obj.target/grandiose/src/grandiose_send_video.o] Error 1
jensstigaard commented 3 years ago

@jensstigaard things work perfectly on macosx but I try and just install the module on debian and I get failures...

Hi Dan Just to let you know, this pull request is regarding support for MacOS, not Linux. There is another pull request specifically regarding Linux support. Please visit https://github.com/Streampunk/grandiose/pull/2 I think it is more appropriate to post your concerns in that thread.

danjenkins commented 3 years ago

hey @jensstigaard - that fork works fine for linux - looks like something changed in your fork of that fork

jensstigaard commented 3 years ago

hey @jensstigaard - that fork works fine for linux - looks like something changed in your fork of that fork

That sounds strange. Can you provide any error messages? There's a lot of things updated in my repo - cpp header files, change of nullptr to NULL in napi module, extended commenting, and more. So it is hard to say what you be the root cause. I have not tested on Linux myself, and I have no plan to do so ATM.

danjenkins commented 3 years ago

Looks like the ultimate error is

  CXX(target) Release/obj.target/grandiose/src/grandiose_send.o
  CXX(target) Release/obj.target/grandiose/src/grandiose_send_video.o
../src/grandiose_send_video.cc: In function ‘napi_value__* sendVideo(napi_env, napi_callback_info)’:
../src/grandiose_send_video.cc:92:7: error: ‘memset’ was not declared in this scope
   92 |       memset((void *)NDI_video_frame.p_data, (frame_index & 1) ? 255 : 0, number_of_pixels * 4);
      |       ^~~~~~
../src/grandiose_send_video.cc:30:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
   29 | #include "grandiose_util.h"
  +++ |+#include <cstring>
   30 |
make: *** [grandiose.target.mk:116: Release/obj.target/grandiose/src/grandiose_send_video.o] Error 1
make: Leaving directory '/home/dan/broadcaster-watcher/node_modules/grandiose/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2

or more specifically

../src/grandiose_send_video.cc:92:7: error: ‘memset’ was not declared in this scope

and

../src/grandiose_send_video.cc:30:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?

Works fine on OSX though!

Julusian commented 1 year ago

Support for macos has been merged in #18