diff --git a/shared/NDIReceiver.hpp b/shared/NDIReceiver.hpp index 9f7b8ba..7ef8935 100644 --- a/shared/NDIReceiver.hpp +++ b/shared/NDIReceiver.hpp @@ -138,26 +138,21 @@ public: throw std::runtime_error("NDI source lost"); if (type == NDIlib_frame_type_status_change) { - const SourceInfo old = info_; - info_ = probe(); - 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)); - } + // Don't call probe() here — it would consume a video frame from the queue. + // Format changes are detected on the next actual video frame below. return FrameKind::None; } 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(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: 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; case NDIlib_FourCC_type_P216: { NDIlib_video_frame_v2_t dst{}; @@ -168,7 +163,7 @@ public: } default: 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); return FrameKind::Video;