From 1dae136ae3b0d935f4cf336f111d8aad2feab723 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Mon, 27 Dec 2021 11:47:54 -0300 Subject: [PATCH] navigation: Add a method to get the GstStructure from NavigationEvent The `GstNavigationInterface` requires to pass a GstStructure to it `send_event()` method, so it makes sense to allow getting that structure without building the navigation event itself --- gstreamer-video/src/video_event.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gstreamer-video/src/video_event.rs b/gstreamer-video/src/video_event.rs index a96981040..46162413f 100644 --- a/gstreamer-video/src/video_event.rs +++ b/gstreamer-video/src/video_event.rs @@ -519,10 +519,9 @@ impl NavigationEvent { }) } - pub fn build(&self) -> gst::Event { + pub fn structure(&self) -> gst::Structure { skip_assert_initialized!(); - - gst::event::Navigation::new(match self { + match self { Self::MouseMove { x, y } => gst::Structure::builder(NAVIGATION_EVENT_NAME) .field("event", "mouse-move") .field("pointer_x", x) @@ -570,7 +569,13 @@ impl NavigationEvent { .field("event", "command") .field("command-code", command) .build(), - }) + } + } + + pub fn build(&self) -> gst::Event { + skip_assert_initialized!(); + + gst::event::Navigation::new(self.structure()) } }