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

Viewer playback - enable step backwards #4706

Merged
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
46 changes: 16 additions & 30 deletions common/model-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3422,25 +3422,19 @@ namespace rs2

//////////////////// Step Backwards Button ////////////////////
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + space_width);

std::string label = to_string() << textual_icons::step_backward << "##Step Backwards " << id;

if (pause_required)
std::string label = to_string() << textual_icons::step_backward << "##Step Backward " << id;
if (ImGui::ButtonEx(label.c_str(), button_dim, supports_playback_step ? 0 : ImGuiButtonFlags_Disabled))
{
p.pause();
for (auto&& s : subdevices)
int fps = 0;
for (auto&& s : viewer.streams)
{
if (s->streaming)
s->pause();
s->on_frame = []{};
if (s.second.profile.fps() > fps)
fps = s.second.profile.fps();
}
syncer->on_frame = []{};
pause_required = false;
auto curr_frame = p.get_position();
uint64_t step = 1000.0 / (float)fps * 1e6;
p.seek(std::chrono::nanoseconds(curr_frame - step));
}

// TODO: Figure out how to properly step-back
ImGui::ButtonEx(label.c_str(), button_dim, ImGuiButtonFlags_Disabled);

if (ImGui::IsItemHovered())
{
std::string tooltip = to_string() << "Step Backwards" << (supports_playback_step ? "" : "(Not available)");
Expand Down Expand Up @@ -3531,23 +3525,15 @@ namespace rs2
label = to_string() << textual_icons::step_forward << "##Step Forward " << id;
if (ImGui::ButtonEx(label.c_str(), button_dim, supports_playback_step ? 0 : ImGuiButtonFlags_Disabled))
{
pause_required = false;
auto action = [this]() {
pause_required = true;
};
for (auto& s : subdevices)
{
s->on_frame = action;
}
syncer->on_frame = action;

p.resume();
for (auto&& s : subdevices)
int fps = 0;
for (auto&& s : viewer.streams)
{
if (s->streaming)
s->resume();
if (s.second.profile.fps() > fps)
fps = s.second.profile.fps();
}
viewer.paused = false;
auto curr_frame = p.get_position();
uint64_t step = 1000.0 / (float)fps * 1e6;
p.seek(std::chrono::nanoseconds(curr_frame + step));
}
if (ImGui::IsItemHovered())
{
Expand Down