Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the waited time didn't include the dispatch delay #209

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/MediaFrameListenerBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,17 @@ void MediaFrameListenerBridge::onMediaFrame(DWORD ignored, const MediaFrame& fra
return;

}

// Calculate the scheduled time
auto scheduled = now + dispatchingDelayMs;
if (!packets.empty())
{
// Ensure scheduled time increasing
scheduled = std::max(scheduled, packets.back().scheduled + std::chrono::milliseconds(1));
}

//Get now in ms
uint64_t ms = now.count();
//Get scheduled time in ms
uint64_t ms = scheduled.count();
//Get frame reception time
uint64_t time = frame->GetTime();

Expand Down Expand Up @@ -293,14 +301,6 @@ void MediaFrameListenerBridge::onMediaFrame(DWORD ignored, const MediaFrame& fra

//Calculate each packet duration
uint32_t pendingDuration = frame->GetDuration() * 1000 / rate;

// Calculate the scheduled time
auto scheduled = now + dispatchingDelayMs;
if (!packets.empty())
{
// Ensure scheduled time increasing
scheduled = std::max(scheduled, packets.back().scheduled + std::chrono::milliseconds(1));
}

//For each one
for (size_t i=0;i<info.size();i++)
Expand Down