Commit 69b57181 authored by Tammo 'kb' Hinrichs's avatar Tammo 'kb' Hinrichs Committed by Gargaj
Browse files

NDI: Update to NDISDK 3 (#52)

* NDI: Update to NDISDK 3
- use BGRX instead of BGRA (less bitrate)
- warning fixes

* NDI:  Env variable check, fixed lib dependendy, fixed whitespace
parent 362c1de2
......@@ -140,11 +140,18 @@ set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} bzc_jsonxx)
##############################################################################
# NDI
if (MSVC AND BONZOMATIC_NDI)
set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES} "c:/Program Files/NewTek/NewTek NDI SDK/Include/")
if(DEFINED ENV{NDI_SDK_DIR})
set(NDI_SDK_DIR "$ENV{NDI_SDK_DIR}")
else()
message(FATAL_ERROR "Could not find NDI SDK. The NDI_SDK_DIR environment variable must be set to the SDK path.")
endif()
set(BZC_PROJECT_INCLUDES ${BZC_PROJECT_INCLUDES} "${NDI_SDK_DIR}/Include/")
if (BONZOMATIC_64BIT)
set(BZC_LINK_DIRS ${BZC_LINK_DIRS} "c:/Program Files/NewTek/NewTek NDI SDK/Lib/x64/")
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} "${NDI_SDK_DIR}/Lib/x64/Processing.NDI.Lib.x64.lib")
else ()
set(BZC_LINK_DIRS ${BZC_LINK_DIRS} "c:/Program Files/NewTek/NewTek NDI SDK/Lib/x86/")
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} "${NDI_SDK_DIR}/Lib/x86/Processing.NDI.Lib.x86.lib")
endif ()
endif ()
......@@ -472,9 +479,9 @@ if (MSVC)
endif ()
if (BONZOMATIC_NDI)
if (BONZOMATIC_64BIT)
add_custom_command(TARGET ${BZC_EXE_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "c:/Program Files/NewTek/NewTek NDI SDK/Bin/x64/Processing.NDI.Lib.x64.dll" $<TARGET_FILE_DIR:${BZC_EXE_NAME}>)
add_custom_command(TARGET ${BZC_EXE_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${NDI_SDK_DIR}/Bin/x64/Processing.NDI.Lib.x64.dll" $<TARGET_FILE_DIR:${BZC_EXE_NAME}>)
else ()
add_custom_command(TARGET ${BZC_EXE_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "c:/Program Files/NewTek/NewTek NDI SDK/Bin/x86/Processing.NDI.Lib.x86.dll" $<TARGET_FILE_DIR:${BZC_EXE_NAME}>)
add_custom_command(TARGET ${BZC_EXE_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${NDI_SDK_DIR}/Bin/x86/Processing.NDI.Lib.x86.dll" $<TARGET_FILE_DIR:${BZC_EXE_NAME}>)
endif ()
endif ()
endif ()
......
......@@ -12,7 +12,7 @@ namespace Capture
bool bNDIEnabled = true;
unsigned int * pBuffer[2] = { NULL, NULL };
unsigned int nBufferIndex = 0;
NDIlib_video_frame_t pNDIFrame;
NDIlib_video_frame_v2_t pNDIFrame;
NDIlib_send_instance_t pNDI_send;
void LoadSettings(jsonxx::Object & o)
......@@ -26,7 +26,7 @@ namespace Capture
if (o.get<jsonxx::Object>("ndi").has<jsonxx::String>("identifier"))
sNDIIdentifier = o.get<jsonxx::Object>("ndi").get<jsonxx::String>("identifier");
if (o.get<jsonxx::Object>("ndi").has<jsonxx::Number>("frameRate"))
fNDIFrameRate = o.get<jsonxx::Object>("ndi").get<jsonxx::Number>("frameRate");
fNDIFrameRate = (float)o.get<jsonxx::Object>("ndi").get<jsonxx::Number>("frameRate");
if (o.get<jsonxx::Object>("ndi").has<jsonxx::Boolean>("progressive"))
bNDIProgressive = o.get<jsonxx::Object>("ndi").get<jsonxx::Boolean>("progressive");
}
......@@ -56,7 +56,7 @@ namespace Capture
}
NDIlib_metadata_frame_t pNDIConnType;
pNDIConnType.length = sNDIConnectionString.length();
pNDIConnType.length = (int)sNDIConnectionString.length();
pNDIConnType.timecode = NDIlib_send_timecode_synthesize;
pNDIConnType.p_data = (char*)sNDIConnectionString.c_str();
......@@ -64,8 +64,8 @@ namespace Capture
pNDIFrame.xres = settings.nWidth;
pNDIFrame.yres = settings.nHeight;
pNDIFrame.FourCC = NDIlib_FourCC_type_BGRA;
pNDIFrame.frame_rate_N = fNDIFrameRate * 100;
pNDIFrame.FourCC = NDIlib_FourCC_type_BGRX;
pNDIFrame.frame_rate_N = (int)(fNDIFrameRate * 100);
pNDIFrame.frame_rate_D = 100;
pNDIFrame.picture_aspect_ratio = settings.nWidth / (float)settings.nHeight;
pNDIFrame.frame_format_type = bNDIProgressive ? NDIlib_frame_format_type_progressive : NDIlib_frame_format_type_interleaved;
......@@ -88,7 +88,7 @@ namespace Capture
unsigned int * p = (unsigned int *)pNDIFrame.p_data;
for(int i=0; i < pNDIFrame.xres * pNDIFrame.yres; i++)
p[i] = (p[i] & 0x00FF00) | ((p[i] >> 16) & 0xFF) | ((p[i] & 0xFF) << 16) | 0xFF000000;
NDIlib_send_send_video_async(pNDI_send, &pNDIFrame);
NDIlib_send_send_video_async_v2(pNDI_send, &pNDIFrame);
}
}
}
......@@ -96,7 +96,7 @@ namespace Capture
{
if (pBuffer[0] && pBuffer[1])
{
NDIlib_send_send_video_async(pNDI_send, NULL); // stop async thread
NDIlib_send_send_video_async_v2(pNDI_send, NULL); // stop async thread
delete[] pBuffer[0];
delete[] pBuffer[1];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment