video: Add `configure_video_stream_decoder` to the `VideoBackend` trait

This commit is contained in:
TÖRÖK Attila 2024-01-24 02:38:40 +01:00 committed by Nathan Adams
parent fe2a264a93
commit a66bec40dd
5 changed files with 49 additions and 0 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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

View File

@ -26,6 +26,15 @@ pub trait VideoBackend {
filter: VideoDeblocking,
) -> Result<VideoStreamHandle, Error>;
/// 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

View File

@ -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,