NDI related tests

This commit is contained in:
2026-05-22 16:34:20 +10:00
parent cec8b76f61
commit 4e6b37304f
5 changed files with 118 additions and 29 deletions

View File

@@ -136,6 +136,13 @@ add_video_shader_test(VideoIOFormatTests
"${TEST_DIR}/VideoIOFormatTests.cpp"
)
add_video_shader_test(NdiInputFormatTests
"${SRC_DIR}/video/ndi/NdiInputFormat.cpp"
${VIDEO_FORMAT_SOURCES}
"${TEST_DIR}/NdiInputFormatTests.cpp"
)
target_include_directories(NdiInputFormatTests PRIVATE "${NDI_INCLUDE_DIR}")
add_video_shader_test(VideoPlayoutSchedulerTests
"${SRC_DIR}/video/playout/VideoPlayoutScheduler.cpp"
"${TEST_DIR}/VideoPlayoutSchedulerTests.cpp"

View File

@@ -0,0 +1,62 @@
#include "video/ndi/NdiInputFormat.h"
#include <iostream>
#include <string>
namespace
{
int gFailures = 0;
void Expect(bool condition, const std::string& message)
{
if (condition)
return;
++gFailures;
std::cerr << "FAILED: " << message << "\n";
}
void TestNdiFourCcMapping()
{
using namespace RenderCadenceCompositor;
VideoIOPixelFormat format = VideoIOPixelFormat::Uyvy8;
Expect(MapNdiFourCcToVideoIOPixelFormat(NDIlib_FourCC_video_type_BGRA, format), "BGRA maps successfully");
Expect(format == VideoIOPixelFormat::Bgra8, "BGRA maps to Bgra8");
format = VideoIOPixelFormat::Uyvy8;
Expect(MapNdiFourCcToVideoIOPixelFormat(NDIlib_FourCC_video_type_BGRX, format), "BGRX maps successfully");
Expect(format == VideoIOPixelFormat::Bgra8, "BGRX maps to Bgra8");
format = VideoIOPixelFormat::Bgra8;
Expect(MapNdiFourCcToVideoIOPixelFormat(NDIlib_FourCC_video_type_UYVY, format), "UYVY maps successfully");
Expect(format == VideoIOPixelFormat::Uyvy8, "UYVY maps to Uyvy8");
format = VideoIOPixelFormat::Bgra8;
Expect(!MapNdiFourCcToVideoIOPixelFormat(NDIlib_FourCC_video_type_RGBA, format), "RGBA is unsupported until conversion is implemented");
Expect(format == VideoIOPixelFormat::Bgra8, "unsupported mapping leaves output untouched");
}
void TestNdiFourCcNames()
{
using namespace RenderCadenceCompositor;
Expect(std::string(NdiFourCcName(NDIlib_FourCC_video_type_BGRA)) == "BGRA", "BGRA name is readable");
Expect(std::string(NdiFourCcName(NDIlib_FourCC_video_type_UYVY)) == "UYVY", "UYVY name is readable");
}
}
int main()
{
TestNdiFourCcMapping();
TestNdiFourCcNames();
if (gFailures != 0)
{
std::cerr << gFailures << " NdiInputFormat test failure(s).\n";
return 1;
}
std::cout << "NdiInputFormat tests passed.\n";
return 0;
}