Use a property for bitrate

This commit is contained in:
Patrick Nicolas
2025-02-07 19:00:34 +01:00
committed by xytovl
parent e9f4b52b50
commit a79bb781ae
5 changed files with 40 additions and 30 deletions
+4
View File
@@ -132,8 +132,11 @@ static void create_encoders(wivrn_comp_target * cn)
std::map<int, std::vector<std::shared_ptr<video_encoder>>> thread_params;
uint32_t bitrate = 0;
for (auto & settings: cn->settings)
{
bitrate += settings.bitrate;
uint8_t stream_index = cn->encoders.size();
auto & encoder = cn->encoders.emplace_back(
video_encoder::create(*cn->wivrn_bundle, settings, stream_index, desc.width, desc.height, desc.fps));
@@ -141,6 +144,7 @@ static void create_encoders(wivrn_comp_target * cn)
thread_params[settings.group].emplace_back(encoder);
}
wivrn_ipc_socket_monado->send(from_monado::bitrate_changed{bitrate});
for (auto & [group, params]: thread_params)
{
+11 -21
View File
@@ -558,6 +558,9 @@ gboolean control_received(gint fd, GIOCondition condition, gpointer user_data)
inhibitor.reset();
wivrn_server_set_headset_connected(dbus_server, false);
},
[&](const from_monado::bitrate_changed & value) {
wivrn_server_set_bitrate(dbus_server, value.bitrate_bps);
},
},
*packet);
}
@@ -675,22 +678,6 @@ gboolean on_handle_rename_key(WivrnServer * skeleton, GDBusMethodInvocation * in
return G_SOURCE_CONTINUE;
}
gboolean on_handle_set_bitrate(WivrnServer * skeleton, GDBusMethodInvocation * invocation, gpointer user_data)
{
GVariant * args = g_dbus_method_invocation_get_parameters(invocation);
int32_t bitrate_bps;
g_variant_get_child(args, 0, "i", &bitrate_bps);
if (bitrate_bps > 0)
{
wivrn_ipc_socket_main_loop->send(to_monado::set_bitrate{bitrate_bps});
}
g_dbus_method_invocation_return_value(invocation, nullptr);
return G_SOURCE_CONTINUE;
}
gboolean on_handle_enable_pairing(WivrnServer * skeleton, GDBusMethodInvocation * invocation, gpointer user_data)
{
set_encryption_state(wivrn_connection::encryption_state::pairing);
@@ -721,6 +708,13 @@ gboolean on_handle_disable_pairing(WivrnServer * skeleton, GDBusMethodInvocation
return G_SOURCE_CONTINUE;
}
void on_bitrate(WivrnServer * server, const GParamSpec * pspec, gpointer data)
{
auto bitrate = wivrn_server_get_bitrate(server);
if (bitrate > 0)
wivrn_ipc_socket_main_loop->send(to_monado::set_bitrate{bitrate});
}
void on_json_configuration(WivrnServer * server, const GParamSpec * pspec, gpointer data)
{
const char * json = wivrn_server_get_json_configuration(server);
@@ -829,11 +823,6 @@ void on_name_acquired(GDBusConnection * connection, const gchar * name, gpointer
G_CALLBACK(on_handle_rename_key),
NULL);
g_signal_connect(dbus_server,
"handle-set-bitrate",
G_CALLBACK(on_handle_set_bitrate),
NULL);
if (enc_state != wivrn_connection::encryption_state::disabled)
{
g_signal_connect(dbus_server,
@@ -859,6 +848,7 @@ void on_name_acquired(GDBusConnection * connection, const gchar * name, gpointer
expose_known_keys_on_dbus();
g_signal_connect(dbus_server, "notify::json-configuration", G_CALLBACK(on_json_configuration), NULL);
g_signal_connect(dbus_server, "notify::bitrate", G_CALLBACK(on_bitrate), NULL);
g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(dbus_server),
connection,
+7 -2
View File
@@ -42,7 +42,12 @@ struct headset_connected
struct headset_disconnected
{};
using packets = std::variant<wivrn::from_headset::headset_info_packet, headset_connected, headset_disconnected>;
struct bitrate_changed
{
uint32_t bitrate_bps;
};
using packets = std::variant<wivrn::from_headset::headset_info_packet, headset_connected, headset_disconnected, bitrate_changed>;
} // namespace from_monado
namespace to_monado
@@ -52,7 +57,7 @@ struct disconnect
struct set_bitrate
{
int32_t bitrate_bps;
uint32_t bitrate_bps;
};
using packets = std::variant<disconnect, set_bitrate>;