From 3caa30ce3b4d257234b7607d1603c1abd2ce084a Mon Sep 17 00:00:00 2001 From: palana Date: Tue, 16 Sep 2014 17:08:53 +0200 Subject: [PATCH] Add HandleStreamStopInfo helper --- Source/OBS.h | 10 ++++++++++ Source/OBSVideoCapture.cpp | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Source/OBS.h b/Source/OBS.h index 2dd2db9a0..f8ee7f435 100644 --- a/Source/OBS.h +++ b/Source/OBS.h @@ -637,6 +637,16 @@ class OBS //--------------------------------------------------- + struct StopInfo + { + DWORD time = (DWORD)-1; + bool timeSeen = false; + std::function func; + }; + bool HandleStreamStopInfo(StopInfo &, PacketType, const VideoSegment&); + + //--------------------------------------------------- + std::unique_ptr network; //--------------------------------------------------- diff --git a/Source/OBSVideoCapture.cpp b/Source/OBSVideoCapture.cpp index 40f22dff6..e132e7042 100644 --- a/Source/OBSVideoCapture.cpp +++ b/Source/OBSVideoCapture.cpp @@ -222,6 +222,25 @@ void OBS::SendFrame(VideoSegment &curSegment, QWORD firstFrameTime) } } +bool OBS::HandleStreamStopInfo(OBS::StopInfo &info, PacketType type, const VideoSegment& segment) +{ + if (type == PacketType_Audio || !info.func) + return false; + + if (segment.pts < info.time) + return false; + + if (!info.timeSeen) + { + info.timeSeen = true; + return false; + } + + info.func(); + info = {}; + return true; +} + bool OBS::ProcessFrame(FrameProcessInfo &frameInfo) { List videoPackets;