wip: set bitrate at runtime
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "driver/wivrn_session.h"
|
||||
#include "encoder/video_encoder.h"
|
||||
#include "util/u_logging.h"
|
||||
#include "utils/scoped_lock.h"
|
||||
#include "wivrn_foveation.h"
|
||||
|
||||
@@ -784,6 +785,17 @@ void wivrn_comp_target::reset_encoders()
|
||||
cnx.send_control(to_headset::video_stream_description{desc});
|
||||
}
|
||||
|
||||
void wivrn_comp_target::set_bitrate(int bitrate_bps)
|
||||
{
|
||||
for (auto & encoder: encoders)
|
||||
{
|
||||
// Alpha will have multiplier of 0 and will be left unchanged.
|
||||
auto encoder_bps = (int)(bitrate_bps * encoder->bitrate_multiplier);
|
||||
U_LOG_D("Encoder %d bitrate: %d", encoder->stream_idx, encoder_bps);
|
||||
encoder->set_bitrate(encoder_bps);
|
||||
}
|
||||
}
|
||||
|
||||
void wivrn_comp_target::render_dynamic_foveation(std::array<to_headset::foveation_parameter, 2> foveation)
|
||||
{
|
||||
assert(foveation_renderer);
|
||||
|
||||
@@ -105,6 +105,7 @@ struct wivrn_comp_target : public comp_target
|
||||
|
||||
void on_feedback(const from_headset::feedback &, const clock_offset &);
|
||||
void reset_encoders();
|
||||
void set_bitrate(int bitrate_bps);
|
||||
|
||||
void render_dynamic_foveation(std::array<to_headset::foveation_parameter, 2> foveation);
|
||||
|
||||
|
||||
@@ -38,6 +38,11 @@ static void handle_event_from_main_loop(to_monado::disconnect)
|
||||
// Ignore disconnect request when no headset is connected
|
||||
}
|
||||
|
||||
static void handle_event_from_main_loop(to_monado::set_bitrate)
|
||||
{
|
||||
// Ignore bitrate request when no headset is connected
|
||||
}
|
||||
|
||||
static std::string clean_key(std::string key)
|
||||
{
|
||||
static const std::regex header{"^-+BEGIN .*-+$", std::regex_constants::multiline};
|
||||
|
||||
@@ -449,6 +449,11 @@ void wivrn_session::operator()(to_monado::disconnect &&)
|
||||
throw std::runtime_error("Disconnecting as requested by main loop");
|
||||
}
|
||||
|
||||
void wivrn_session::operator()(to_monado::set_bitrate && data)
|
||||
{
|
||||
comp_target->set_bitrate(data.bitrate_bps);
|
||||
}
|
||||
|
||||
void wivrn_session::run(std::stop_token stop)
|
||||
{
|
||||
while (not stop.stop_requested())
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "wivrn_connection.h"
|
||||
#include "wivrn_controller.h"
|
||||
#include "wivrn_hmd.h"
|
||||
#include "wivrn_ipc.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include "xrt/xrt_results.h"
|
||||
#include "xrt/xrt_system.h"
|
||||
@@ -164,6 +165,7 @@ public:
|
||||
void operator()(audio_data &&);
|
||||
|
||||
void operator()(to_monado::disconnect &&);
|
||||
void operator()(to_monado::set_bitrate &&);
|
||||
|
||||
template <typename T>
|
||||
void send_stream(T && packet)
|
||||
|
||||
Reference in New Issue
Block a user