leadedge / ofxNDI

An Openframeworks addon to allow sending and receiving images over a network using the NewTek Network Device Protocol.
GNU General Public License v3.0
134 stars 48 forks source link

Failing to compile latest commit on macOS #46

Closed eduardfrigola closed 8 months ago

eduardfrigola commented 9 months ago

Hi, I'm working on making a proposal for #42 but, pulling latest changes eec7ef99f4fc7cad8d710ac41d4f0761bc616a79 made the addon not able to compile on macos.

Machine: Macbook Pro M2 Max OS: macOS 13.2.1 (arm) Openframeworks version: commit cb8c7af NDI installed version: 5.6.0

Issue:

io.h file not found referenced in ofxNDIdynloader.h#L31. As far as I know, this is a function only available in MSVC compiler.

Prior to this last commit it compiled and worked fine in macOS.

leadedge commented 9 months ago

io.h is for "_access" which is simply to find whether a file exists or not. The change was due to a problem using path functions in shlwapi.dll which fail with Openframeworks 12.0. We can't use an Openframeworks function because the core of the addon must work without it. Can you suggest another function that tests for file existence?

eduardfrigola commented 9 months ago

There seems to be access without the underscore. Documentation here

I think is as simple as adding io.h inside the conditional compile of TARGET_WIN32 Similar to this line as _acces method is just called here and is inside a compile conditional that appears here.

eduardfrigola commented 9 months ago

Now I see that ofxNDIsender::SetFormat(NDIlib_FourCC_video_type_e format) uses _acces and other windows related functions. I will try to reimplement that for macOS compatibility.

leadedge commented 9 months ago

Yes I see.

"_access" is only used for a Windows target and so #include can be conditional. I tested it and it works.

The purpose of the file existence check is to allow the NDI dll to be located in the executable folder without depending on runtime installation. The OSX/Linux part just uses the NDI runtime and so there is no need to use "access" or spend any time on it.

I am looking now at a video timecode function. It's a simple change and avoids the need for any overloads. I will find out the result shortly. Can you give me some idea on how you use the timecode value.

leadedge commented 9 months ago

I fixed the #include <io.h> problem as mentioned. It should still work for OSX because "_access" is not used. At the same time I included two functions in ofxNDIreceive with very little change to the original SendImage functions -

uint64_t GetVideoTimecode() , double GetVideoFrameTime()

I updated the example source and binaries. The receiver shows the received frame interval.

eduardfrigola commented 8 months ago

Still not able to compile with latest commit. Missing a closing curly braces for those lines: https://github.com/leadedge/ofxNDI/blob/ea14bfbd8e4359db3451e9fbe7f7ab0631b2d5d1/src/ofxNDIdynloader.cpp#L70-L73

Also you are redeclaring m_hNDILib (already declared in .h file) in https://github.com/leadedge/ofxNDI/blob/ea14bfbd8e4359db3451e9fbe7f7ab0631b2d5d1/src/ofxNDIdynloader.cpp#L192

leadedge commented 8 months ago

Thanks for the heads up. Meanwhile you can fix these things to get going. This code is kindly contributed and I cant test with OSX. Have a happy new year.

eduardfrigola commented 8 months ago

Sure! Working well on my branch, posting here so anyone that encounters issues with macos have some more information. Happy new year for you too!

eduardfrigola commented 8 months ago

After commit https://github.com/leadedge/ofxNDI/commit/73354d2fcba924f8efe94e19d287056096c14360 compiles correctly on macos.

Thanks!