NDIReceiver probe fix
This commit is contained in:
+10
-15
@@ -138,26 +138,21 @@ public:
|
|||||||
throw std::runtime_error("NDI source lost");
|
throw std::runtime_error("NDI source lost");
|
||||||
|
|
||||||
if (type == NDIlib_frame_type_status_change) {
|
if (type == NDIlib_frame_type_status_change) {
|
||||||
const SourceInfo old = info_;
|
// Don't call probe() here — it would consume a video frame from the queue.
|
||||||
info_ = probe();
|
// Format changes are detected on the next actual video frame below.
|
||||||
if (info_.width != old.width || info_.height != old.height ||
|
|
||||||
info_.fps_num != old.fps_num || info_.fps_den != old.fps_den) {
|
|
||||||
throw std::runtime_error(
|
|
||||||
"source format changed: " +
|
|
||||||
std::to_string(old.width) + "x" + std::to_string(old.height) +
|
|
||||||
" @" + std::to_string(old.fps_num) + "/" + std::to_string(old.fps_den) +
|
|
||||||
" -> " +
|
|
||||||
std::to_string(info_.width) + "x" + std::to_string(info_.height) +
|
|
||||||
" @" + std::to_string(info_.fps_num) + "/" + std::to_string(info_.fps_den));
|
|
||||||
}
|
|
||||||
return FrameKind::None;
|
return FrameKind::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == NDIlib_frame_type_video) {
|
if (type == NDIlib_frame_type_video) {
|
||||||
switch (info_.fourcc) {
|
// Use the actual frame's FourCC and stride, not the stale values from probe().
|
||||||
|
const auto fourcc = static_cast<NDIlib_FourCC_type_e>(video_frame.FourCC);
|
||||||
|
const int stride = video_frame.line_stride_in_bytes > 0
|
||||||
|
? video_frame.line_stride_in_bytes
|
||||||
|
: video_frame.xres * bytes_per_pixel(fourcc);
|
||||||
|
switch (fourcc) {
|
||||||
case NDIlib_FourCC_type_UYVY:
|
case NDIlib_FourCC_type_UYVY:
|
||||||
v210::UYVYtoV210(video_frame.p_data, frame_buffer,
|
v210::UYVYtoV210(video_frame.p_data, frame_buffer,
|
||||||
info_.width, info_.height, info_.stride, frame_stride);
|
video_frame.xres, video_frame.yres, stride, frame_stride);
|
||||||
break;
|
break;
|
||||||
case NDIlib_FourCC_type_P216: {
|
case NDIlib_FourCC_type_P216: {
|
||||||
NDIlib_video_frame_v2_t dst{};
|
NDIlib_video_frame_v2_t dst{};
|
||||||
@@ -168,7 +163,7 @@ public:
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
NDIlib_recv_free_video_v2(recv_, &video_frame);
|
NDIlib_recv_free_video_v2(recv_, &video_frame);
|
||||||
throw std::runtime_error("Unsupported NDI color format: " + fourcc_str(info_.fourcc));
|
throw std::runtime_error("Unsupported NDI color format: " + fourcc_str(fourcc));
|
||||||
}
|
}
|
||||||
NDIlib_recv_free_video_v2(recv_, &video_frame);
|
NDIlib_recv_free_video_v2(recv_, &video_frame);
|
||||||
return FrameKind::Video;
|
return FrameKind::Video;
|
||||||
|
|||||||
Reference in New Issue
Block a user