Skip to content

Commit

Permalink
Do not allow enabling passtrhough in real time
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerp committed Jan 31, 2025
1 parent 8cbf0a1 commit 6517229
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
4 changes: 3 additions & 1 deletion alvr/client_openxr/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ impl StreamContext {
}

pub fn update_real_time_config(&mut self, config: &RealTimeConfig) {
self.config.passthrough = config.passthrough.clone();
if let Some(passthrough) = &mut self.config.passthrough {
*passthrough = config.passthrough.clone();
}
}

pub fn render(
Expand Down
2 changes: 1 addition & 1 deletion alvr/packets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ pub enum ServerRequest {
// compatibility between different versions, even if within the same major version.
#[derive(Serialize, Deserialize)]
pub struct RealTimeConfig {
pub passthrough: Option<PassthroughMode>,
pub passthrough: PassthroughMode,
}

pub fn encode_real_time_config(config: &RealTimeConfig) -> Result<ServerControlPacket> {
Expand Down
13 changes: 9 additions & 4 deletions alvr/server_core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use alvr_packets::{
};
use alvr_session::{
BodyTrackingSinkConfig, CodecType, ControllersEmulationMode, FrameSize, H264Profile,
OpenvrConfig, SessionConfig, SocketProtocol,
OpenvrConfig, PassthroughMode, SessionConfig, SocketProtocol,
};
use alvr_sockets::{
PeerType, ProtoControlSocket, StreamSocketBuilder, CONTROL_PORT, KEEPALIVE_INTERVAL,
Expand Down Expand Up @@ -1079,9 +1079,14 @@ fn connection_pipeline(
let session_manager_lock = SESSION_MANAGER.read();
let settings = session_manager_lock.settings();

RealTimeConfig {
passthrough: settings.video.passthrough.clone().into_option(),
}
let passthrough =
if let Switch::Enabled(mode) = settings.video.passthrough.clone() {
mode
} else {
PassthroughMode::default()
};

RealTimeConfig { passthrough }
};

if let Ok(config) = alvr_packets::encode_real_time_config(&config) {
Expand Down
10 changes: 8 additions & 2 deletions alvr/session/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,17 @@ pub enum PassthroughMode {
ChromaKey(#[schema(flag = "real-time")] ChromaKeyConfig),
}

impl Default for PassthroughMode {
fn default() -> Self {
Self::AugmentedReality { brightness: 0.0 }
}
}

#[derive(SettingsSchema, Serialize, Deserialize, Clone)]
pub struct VideoConfig {
#[schema(strings(help = r"Augmented reality: corresponds to premultiplied alpha
Blend: corresponds to un-premultiplied alpha"))]
#[schema(flag = "real-time")]
Blend: corresponds to un-premultiplied alpha
Note: if connection is initiated while the switch is disabled, the nested settings will be ignored"))]
pub passthrough: Switch<PassthroughMode>,

pub bitrate: BitrateConfig,
Expand Down

0 comments on commit 6517229

Please sign in to comment.