Color links and ports according to their formats

Format params for links and ports are now being watched for in the pipewire connection code.

The parsed media type is then set on the port widget / link object
and they are colored accordingly.

For ports, which were already colored before, this new method of determining the media type
should be more reliable and accurate as this uses the real Format/EnumFormat
params instead of parsing optional properties.
This commit is contained in:
Tom A. Wagner
2023-07-30 12:09:08 +02:00
parent ba73d8cdcc
commit 7f754b207c
8 changed files with 362 additions and 148 deletions

View File

@@ -20,7 +20,7 @@ mod pipewire_connection;
mod ui;
use gtk::prelude::*;
use pipewire::spa::Direction;
use pipewire::spa::{format::MediaType, Direction};
/// Messages sent by the GTK thread to notify the pipewire thread.
#[derive(Debug, Clone)]
@@ -44,18 +44,26 @@ pub enum PipewireMessage {
node_id: u32,
name: String,
direction: Direction,
media_type: Option<MediaType>,
},
PortFormatChanged {
id: u32,
media_type: MediaType,
},
LinkAdded {
id: u32,
port_from: u32,
port_to: u32,
active: bool,
media_type: MediaType,
},
LinkStateChanged {
id: u32,
active: bool,
},
LinkFormatChanged {
id: u32,
media_type: MediaType,
},
NodeRemoved {
id: u32,
},
@@ -74,13 +82,6 @@ pub enum NodeType {
Output,
}
#[derive(Debug, Copy, Clone)]
pub enum MediaType {
Audio,
Video,
Midi,
}
#[derive(Debug, Clone)]
pub struct PipewireLink {
pub node_from: u32,