-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(video/surfaces): add surface mapping node (#358) [WIP]
Most of what the node requires to function is already implemented. * Renaming functionality of the surface and section is not implemented * The transform doesn't update in realtime * Currently there is an issue with the transform, as you can see the seem between the triangles rendering the video when the transform is non rectangular * The input fields in the settings pane don't actually change the transform * The surface is not deleted when deleting the node * The Open surface button doesn't navigate to the surfaces view
- Loading branch information
Showing
63 changed files
with
2,430 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
syntax = "proto3"; | ||
|
||
package mizer.surfaces; | ||
|
||
message Surface { | ||
string id = 1; | ||
string name = 2; | ||
repeated SurfaceSection sections = 3; | ||
} | ||
|
||
message Surfaces { | ||
repeated Surface surfaces = 1; | ||
} | ||
|
||
message SurfaceSection { | ||
uint32 id = 1; | ||
string name = 2; | ||
SurfaceTransform input = 3; | ||
SurfaceTransform output = 4; | ||
} | ||
|
||
message SurfaceTransform { | ||
SurfaceTransformPoint top_left = 1; | ||
SurfaceTransformPoint top_right = 2; | ||
SurfaceTransformPoint bottom_left = 3; | ||
SurfaceTransformPoint bottom_right = 4; | ||
} | ||
|
||
message SurfaceTransformPoint { | ||
double x = 1; | ||
double y = 2; | ||
} | ||
|
||
message UpdateSectionTransform { | ||
string surface_id = 1; | ||
uint32 section_id = 2; | ||
SurfaceTransform transform = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
use futures::{Stream, StreamExt}; | ||
|
||
use mizer_command_executor::UpdateSurfaceSectionCommand; | ||
use mizer_surfaces::{SurfaceRegistryApi, SurfaceSectionId}; | ||
|
||
use crate::proto::surfaces::*; | ||
use crate::RuntimeApi; | ||
|
||
#[derive(Clone)] | ||
pub struct SurfacesHandler<R: RuntimeApi> { | ||
api: SurfaceRegistryApi, | ||
runtime: R, | ||
} | ||
|
||
impl<R: RuntimeApi> SurfacesHandler<R> { | ||
pub fn new(runtime: R, api: SurfaceRegistryApi) -> Self { | ||
Self { runtime, api } | ||
} | ||
|
||
#[tracing::instrument(skip(self))] | ||
#[profiling::function] | ||
pub fn update_input_mapping( | ||
&self, | ||
surface_id: String, | ||
section_id: usize, | ||
mapping: SurfaceTransform, | ||
) -> anyhow::Result<()> { | ||
let id = SurfaceSectionId { | ||
surface_id: surface_id.parse()?, | ||
index: section_id, | ||
}; | ||
self.runtime.run_command(UpdateSurfaceSectionCommand { | ||
id, | ||
input: Some(mapping.into()), | ||
output: None, | ||
})?; | ||
Ok(()) | ||
} | ||
|
||
#[tracing::instrument(skip(self))] | ||
#[profiling::function] | ||
pub fn update_output_mapping( | ||
&self, | ||
surface_id: String, | ||
section_id: usize, | ||
mapping: SurfaceTransform, | ||
) -> anyhow::Result<()> { | ||
let id = SurfaceSectionId { | ||
surface_id: surface_id.parse()?, | ||
index: section_id, | ||
}; | ||
self.runtime.run_command(UpdateSurfaceSectionCommand { | ||
id, | ||
input: None, | ||
output: Some(mapping.into()), | ||
})?; | ||
Ok(()) | ||
} | ||
|
||
#[tracing::instrument(skip(self))] | ||
#[profiling::function] | ||
pub fn observe_surfaces(&self) -> impl Stream<Item = Surfaces> { | ||
log::debug!("Observing surfaces"); | ||
self.api | ||
.bus | ||
.subscribe() | ||
.into_stream() | ||
.map(|surfaces| surfaces.into_iter().map(|surface| surface.into()).collect()) | ||
.map(|surfaces| { | ||
log::debug!("Emitting new surfaces"); | ||
Surfaces { surfaces } | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ mod plans; | |
mod programmer; | ||
mod sequencer; | ||
mod settings; | ||
mod surfaces; | ||
mod timecode; | ||
mod transport; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use crate::proto::surfaces::*; | ||
|
||
impl From<mizer_surfaces::Surface> for Surface { | ||
fn from(surface: mizer_surfaces::Surface) -> Self { | ||
Self { | ||
id: surface.id.to_string(), | ||
name: surface.name, | ||
sections: surface.sections.into_iter().map(Into::into).collect(), | ||
} | ||
} | ||
} | ||
|
||
impl From<mizer_surfaces::SurfaceSection> for SurfaceSection { | ||
fn from(value: mizer_surfaces::SurfaceSection) -> Self { | ||
Self { | ||
id: value.id.index as u32, | ||
name: value.name, | ||
input: Some(value.input.into()), | ||
output: Some(value.output.into()), | ||
} | ||
} | ||
} | ||
|
||
impl From<mizer_surfaces::SurfaceTransform> for SurfaceTransform { | ||
fn from(value: mizer_surfaces::SurfaceTransform) -> Self { | ||
Self { | ||
top_left: Some(value.top_left.into()), | ||
top_right: Some(value.top_right.into()), | ||
bottom_left: Some(value.bottom_left.into()), | ||
bottom_right: Some(value.bottom_right.into()), | ||
} | ||
} | ||
} | ||
|
||
impl From<mizer_surfaces::SurfaceTransformPoint> for SurfaceTransformPoint { | ||
fn from(value: mizer_surfaces::SurfaceTransformPoint) -> Self { | ||
Self { | ||
x: value.x, | ||
y: value.y, | ||
} | ||
} | ||
} | ||
|
||
impl From<SurfaceTransform> for mizer_surfaces::SurfaceTransform { | ||
fn from(value: SurfaceTransform) -> Self { | ||
Self { | ||
top_left: value.top_left.unwrap().into(), | ||
top_right: value.top_right.unwrap().into(), | ||
bottom_left: value.bottom_left.unwrap().into(), | ||
bottom_right: value.bottom_right.unwrap().into(), | ||
} | ||
} | ||
} | ||
|
||
impl From<SurfaceTransformPoint> for mizer_surfaces::SurfaceTransformPoint { | ||
fn from(value: SurfaceTransformPoint) -> Self { | ||
Self { | ||
x: value.x, | ||
y: value.y, | ||
} | ||
} | ||
} |
Oops, something went wrong.