/* * WiVRn VR streaming * Copyright (C) 2022 Guillaume Meunier * Copyright (C) 2022 Patrick Nicolas * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #pragma once #include "decoder/shard_accumulator.h" #include "scene.h" #include "stream_reprojection.h" #include "utils/sync_queue.h" #include "wivrn_client.h" #include "wivrn_packets.h" #include #include #include #include "audio/audio.h" namespace scenes { class stream : public scene_impl, public std::enable_shared_from_this { static const size_t view_count = 2; using stream_description = xrt::drivers::wivrn::to_headset::video_stream_description::item; struct accumulator_images { std::unique_ptr decoder; // latest frames from oldest to most recent std::array, 2> latest_frames; static std::optional common_frame(const std::vector &); std::shared_ptr frame(std::optional id); std::vector frames() const; }; struct renderpass_output { vk::Extent2D size; vk::Format format; image_allocation image; vk::raii::ImageView image_view = nullptr; }; std::unique_ptr network_session; std::atomic exiting = false; std::thread network_thread; std::optional tracking_thread; std::thread video_thread; utils::sync_queue shard_queue; std::mutex decoder_mutex; std::vector decoders; // Locked by decoder_mutex std::array decoder_output{}; std::optional reprojector; vk::raii::Fence fence = nullptr; vk::raii::CommandBuffer command_buffer = nullptr; std::array, 2> haptics_actions; std::vector> input_actions; bool ready_ = false; bool video_started_ = false; XrTime first_frame_time{}; const float dbrightness = 2; std::vector swapchains; vk::Format swapchain_format; std::optional