use crate::frame::Platform;
use serde::Serialize;
use super::identity::StableSourceId;
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub enum InputDeviceSelector {
#[default]
Default,
StableId(String),
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub enum CaptureMode {
#[default]
SystemMix,
Application(String),
Process(u32),
ExactApplication {
process_id: u32,
stable_id: StableSourceId,
},
ExactApplicationStable {
stable_id: StableSourceId,
},
InputDevice(InputDeviceSelector),
}
impl CaptureMode {
pub fn selector_persistence_scope(&self) -> SelectorPersistenceScope {
match self {
Self::SystemMix => SelectorPersistenceScope::PlatformIdentity,
Self::Application(_) | Self::ExactApplicationStable { .. } => {
SelectorPersistenceScope::ApplicationIdentity
}
Self::Process(_) | Self::ExactApplication { .. } => {
SelectorPersistenceScope::ProcessLifetime
}
Self::InputDevice(InputDeviceSelector::Default) => {
SelectorPersistenceScope::SessionDefaultDevice
}
Self::InputDevice(InputDeviceSelector::StableId(_)) => {
SelectorPersistenceScope::DeviceIdentity
}
}
}
pub fn process_tree_scope(&self, platform: Platform) -> ProcessTreeScope {
match self {
Self::Process(_) | Self::ExactApplication { .. } if platform == Platform::Windows => {
ProcessTreeScope::SelectedProcessAndDescendants
}
Self::Process(_) | Self::ExactApplication { .. } => {
ProcessTreeScope::SelectedProcessOnly
}
Self::Application(_) | Self::ExactApplicationStable { .. } => {
ProcessTreeScope::ApplicationIdentity
}
Self::SystemMix | Self::InputDevice(_) => ProcessTreeScope::NotApplicable,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum SelectorPersistenceScope {
ProcessLifetime,
ApplicationIdentity,
DeviceIdentity,
SessionDefaultDevice,
PlatformIdentity,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum ProcessTreeScope {
SelectedProcessOnly,
SelectedProcessAndDescendants,
ApplicationIdentity,
NotApplicable,
}