diff --git a/video/external/src/backend.rs b/video/external/src/backend.rs index c11683cd7..3ffc8befa 100644 --- a/video/external/src/backend.rs +++ b/video/external/src/backend.rs @@ -63,6 +63,24 @@ impl VideoBackend for ExternalVideoBackend { Ok(self.streams.insert(proxy_or_stream)) } + fn configure_video_stream_decoder( + &mut self, + stream: VideoStreamHandle, + configuration_data: &[u8], + ) -> Result<(), Error> { + let stream = self + .streams + .get_mut(stream) + .ok_or(Error::VideoStreamIsNotRegistered)?; + + match stream { + ProxyOrStream::Proxied(handle) => self + .software + .configure_video_stream_decoder(*handle, configuration_data), + ProxyOrStream::Owned(stream) => stream.decoder.configure_decoder(configuration_data), + } + } + fn preload_video_stream_frame( &mut self, stream: VideoStreamHandle, diff --git a/video/software/src/backend.rs b/video/software/src/backend.rs index 14923b088..5bdc4aea0 100644 --- a/video/software/src/backend.rs +++ b/video/software/src/backend.rs @@ -66,6 +66,15 @@ impl VideoBackend for SoftwareVideoBackend { stream.decoder.preload_frame(encoded_frame) } + fn configure_video_stream_decoder( + &mut self, + _stream: VideoStreamHandle, + _configuration_data: &[u8], + ) -> Result<(), Error> { + // None of the software decoders require configuration. + Ok(()) + } + fn decode_video_stream_frame( &mut self, stream: VideoStreamHandle, diff --git a/video/software/src/decoder.rs b/video/software/src/decoder.rs index 096ef8fb6..3696b7ec4 100644 --- a/video/software/src/decoder.rs +++ b/video/software/src/decoder.rs @@ -13,6 +13,11 @@ pub mod screen; /// Trait for video decoders. /// This should be implemented for each video codec. pub trait VideoDecoder { + /// Configure the decoder. + fn configure_decoder(&mut self, _configuration_data: &[u8]) -> Result<(), Error> { + Ok(()) + } + /// Preload a frame. /// /// No decoding is intended to happen at this point in time. Instead, the diff --git a/video/src/backend.rs b/video/src/backend.rs index 12a1a3a79..0af1b2eb4 100644 --- a/video/src/backend.rs +++ b/video/src/backend.rs @@ -26,6 +26,15 @@ pub trait VideoBackend { filter: VideoDeblocking, ) -> Result; + /// Configure the decoder of a given video stream. + /// + /// The `configuration_data` contains codec-specific parameters. + fn configure_video_stream_decoder( + &mut self, + stream: VideoStreamHandle, + configuration_data: &[u8], + ) -> Result<(), Error>; + /// Preload a frame of a given video stream. /// /// No decoding is intended to happen at this point in time. Instead, the diff --git a/video/src/null.rs b/video/src/null.rs index 0588c9ced..f1011e330 100644 --- a/video/src/null.rs +++ b/video/src/null.rs @@ -44,6 +44,14 @@ impl VideoBackend for NullVideoBackend { Ok(self.streams.insert(())) } + fn configure_video_stream_decoder( + &mut self, + _stream: VideoStreamHandle, + _configuration_data: &[u8], + ) -> Result<(), Error> { + Ok(()) + } + fn preload_video_stream_frame( &mut self, _stream: VideoStreamHandle,