Return to lobby when the video is stalled
This commit is contained in:
@@ -526,7 +526,7 @@ void scenes::lobby::render(XrTime predicted_display_time, bool should_render)
|
|||||||
{
|
{
|
||||||
if (!next_scene->alive())
|
if (!next_scene->alive())
|
||||||
next_scene.reset();
|
next_scene.reset();
|
||||||
else if (next_scene->ready())
|
else if (next_scene->current_state() == scenes::stream::state::streaming)
|
||||||
application::push_scene(next_scene);
|
application::push_scene(next_scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "imgui_internal.h"
|
#include "imgui_internal.h"
|
||||||
#include "lobby.h"
|
#include "lobby.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "stream.h"
|
||||||
#include <spdlog/fmt/fmt.h>
|
#include <spdlog/fmt/fmt.h>
|
||||||
#include <utils/strings.h>
|
#include <utils/strings.h>
|
||||||
|
|
||||||
@@ -71,7 +72,12 @@ void scenes::lobby::gui_connecting()
|
|||||||
|
|
||||||
std::string status;
|
std::string status;
|
||||||
if (next_scene)
|
if (next_scene)
|
||||||
status = "Waiting for video stream";
|
{
|
||||||
|
if (next_scene->current_state() == scenes::stream::state::stalled)
|
||||||
|
status = "Video stream interrupted";
|
||||||
|
else
|
||||||
|
status = "Waiting for video stream";
|
||||||
|
}
|
||||||
else if (async_session.valid())
|
else if (async_session.valid())
|
||||||
status = async_session.get_progress();
|
status = async_session.get_progress();
|
||||||
else if (async_error)
|
else if (async_error)
|
||||||
|
|||||||
@@ -230,11 +230,11 @@ void scenes::stream::push_blit_handle(shard_accumulator * decoder, std::shared_p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ready_ && std::all_of(decoders.begin(), decoders.end(), [](accumulator_images & i) {
|
if (state_ != state::streaming && std::all_of(decoders.begin(), decoders.end(), [](accumulator_images & i) {
|
||||||
return i.latest_frames.back();
|
return i.latest_frames.back();
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
ready_ = true;
|
state_ = state::streaming;
|
||||||
first_frame_time = application::now();
|
first_frame_time = application::now();
|
||||||
spdlog::info("Stream scene ready at t={}", first_frame_time);
|
spdlog::info("Stream scene ready at t={}", first_frame_time);
|
||||||
}
|
}
|
||||||
@@ -465,6 +465,9 @@ void scenes::stream::render(XrTime predicted_display_time, bool should_render)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state_ == state::stalled)
|
||||||
|
application::pop_scene();
|
||||||
|
|
||||||
session.begin_frame();
|
session.begin_frame();
|
||||||
|
|
||||||
auto [flags, views] = session.locate_views(viewconfig, predicted_display_time, world_space);
|
auto [flags, views] = session.locate_views(viewconfig, predicted_display_time, world_space);
|
||||||
|
|||||||
+12
-4
@@ -35,6 +35,15 @@ namespace scenes
|
|||||||
{
|
{
|
||||||
class stream : public scene_impl<stream>, public std::enable_shared_from_this<stream>
|
class stream : public scene_impl<stream>, public std::enable_shared_from_this<stream>
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
enum class state
|
||||||
|
{
|
||||||
|
initializing,
|
||||||
|
streaming,
|
||||||
|
stalled
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
static const size_t view_count = 2;
|
static const size_t view_count = 2;
|
||||||
|
|
||||||
using stream_description = xrt::drivers::wivrn::to_headset::video_stream_description::item;
|
using stream_description = xrt::drivers::wivrn::to_headset::video_stream_description::item;
|
||||||
@@ -79,8 +88,7 @@ class stream : public scene_impl<stream>, public std::enable_shared_from_this<st
|
|||||||
std::array<std::pair<XrAction, XrPath>, 2> haptics_actions;
|
std::array<std::pair<XrAction, XrPath>, 2> haptics_actions;
|
||||||
std::vector<std::tuple<device_id, XrAction, XrActionType>> input_actions;
|
std::vector<std::tuple<device_id, XrAction, XrActionType>> input_actions;
|
||||||
|
|
||||||
bool ready_ = false;
|
state state_ = state::initializing;
|
||||||
bool video_started_ = false;
|
|
||||||
XrTime first_frame_time{};
|
XrTime first_frame_time{};
|
||||||
const float dbrightness = 2;
|
const float dbrightness = 2;
|
||||||
bool show_performance_metrics = false;
|
bool show_performance_metrics = false;
|
||||||
@@ -116,9 +124,9 @@ public:
|
|||||||
|
|
||||||
void send_feedback(const xrt::drivers::wivrn::from_headset::feedback & feedback);
|
void send_feedback(const xrt::drivers::wivrn::from_headset::feedback & feedback);
|
||||||
|
|
||||||
bool ready() const
|
state current_state() const
|
||||||
{
|
{
|
||||||
return ready_;
|
return state_ ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool alive() const
|
bool alive() const
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ void scenes::stream::process_packets()
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int n = network_session->poll(*this, std::chrono::milliseconds(5000));
|
int n = network_session->poll(*this, std::chrono::milliseconds(500));
|
||||||
if (n == 0 && video_started_)
|
if (n == 0 && state_ == state::streaming)
|
||||||
throw std::runtime_error("Timeout waiting for network packets");
|
state_ = state::stalled;
|
||||||
}
|
}
|
||||||
catch (std::exception & e)
|
catch (std::exception & e)
|
||||||
{
|
{
|
||||||
@@ -41,7 +41,6 @@ void scenes::stream::process_packets()
|
|||||||
|
|
||||||
void scenes::stream::operator()(to_headset::video_stream_data_shard && shard)
|
void scenes::stream::operator()(to_headset::video_stream_data_shard && shard)
|
||||||
{
|
{
|
||||||
video_started_ = true;
|
|
||||||
shard_queue.push(std::move(shard));
|
shard_queue.push(std::move(shard));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user