pub struct CarrierVideoStreamDecoder<C: FfmpegCarrier> { /* private fields */ }Expand description
mediadecode::VideoStreamDecoder impl over FFmpeg’s hardware and
software decoders, on the DecodePath it was opened on — under
DecodePath::Auto, hardware with a lossless fallback to software
before the first picture.
Implementations§
Source§impl CarrierVideoStreamDecoder<View>
impl CarrierVideoStreamDecoder<View>
Sourcepub fn open(
parameters: Parameters,
time_base: Timebase,
limits: DecoderLimits,
) -> Result<Self, Error>
pub fn open( parameters: Parameters, time_base: Timebase, limits: DecoderLimits, ) -> Result<Self, Error>
Opens a video decoder for parameters, probing hardware
backends in order and falling back to software.
open_as(.., DecodePath::Auto).
Sourcepub fn open_as(
parameters: Parameters,
time_base: Timebase,
limits: DecoderLimits,
path: DecodePath,
) -> Result<Self, Error>
pub fn open_as( parameters: Parameters, time_base: Timebase, limits: DecoderLimits, path: DecodePath, ) -> Result<Self, Error>
Opens a video decoder on a named decode path.
DecodePath::Auto is open exactly;
DecodePath::AnyHardware keeps the session to the platform’s
hardware backends and the other two arms pin it to one backend or
to software, each for its whole life. See DecodePath for what
each permits and what it costs.
Everything else about the session is unchanged — the same
VideoStreamDecoder face, the same frames, the same
is_hardware / is_software
readings. The choice is which decoder is behind them, which
is what a determinism comparison and a deployment policy each
need and neither could reach.
§Errors
DecodePath::AnyHardware fails here with
Error::AllBackendsFailed when no hardware backend opens for
the stream — at once on a platform with none — carrying every
backend’s attempt and no packet, since none was sent.
DecodePath::Hardware fails here when the named backend
cannot be opened for the stream. DecodePath::Auto would have
gone on to software in both cases. DecodePath::Software fails
only where libavcodec has no decoder for the stream, or the
context cannot be built.
§Examples
use mediadecode_ffmpeg::{DecodePath, DecoderLimits, FfmpegVideoStreamDecoder};
// The same stream, decoded without a GPU anywhere in the story.
let decoder = FfmpegVideoStreamDecoder::open_as(
parameters,
time_base,
DecoderLimits::default(),
DecodePath::Software,
)?;
assert!(decoder.is_software());Sourcepub const fn is_software(&self) -> bool
pub const fn is_software(&self) -> bool
Whether this decoder is currently running on software.
Sourcepub const fn is_hardware(&self) -> bool
pub const fn is_hardware(&self) -> bool
Whether this decoder is currently running on hardware.
Sourcepub fn scaled_output_capability(&self) -> ScaledOutputCapability
pub fn scaled_output_capability(&self) -> ScaledOutputCapability
Whether this session can currently emit pictures at a
caller-requested output size. See
ScaledOutputCapability and
Self::request_scaled_output.
Supported on a live VideoToolbox session on an Apple
target, Unsupported everywhere else — including on a
session that fell back to software during its probe, which is
why this reads the session’s live state rather than a fact
recorded once at open.
Sourcepub fn request_scaled_output(
&mut self,
size: (u32, u32),
) -> ScaledOutputCapability
pub fn request_scaled_output( &mut self, size: (u32, u32), ) -> ScaledOutputCapability
Requests that this session emit pictures at size (width,
height) from the next frame on, and reports whether the
request was recorded. See
VideoStreamDecoder::request_scaled_output for the full
contract (never an error) and
Self::scaled_output_capability’s documentation for which
road can honor one, what a mid-stream request means, and the
zero / upscale refusals this seat mints itself.
Sourcepub fn hardware_inner(&self) -> Option<&VideoDecoder>
pub fn hardware_inner(&self) -> Option<&VideoDecoder>
The hardware wrapper, when one is in use.
Source§impl CarrierVideoStreamDecoder<Owned>
impl CarrierVideoStreamDecoder<Owned>
Sourcepub fn open(
parameters: Parameters,
time_base: Timebase,
limits: DecoderLimits,
) -> Result<Self, Error>
pub fn open( parameters: Parameters, time_base: Timebase, limits: DecoderLimits, ) -> Result<Self, Error>
Opens a video decoder for parameters, probing hardware
backends in order and falling back to software.
open_as(.., DecodePath::Auto).
Sourcepub fn open_as(
parameters: Parameters,
time_base: Timebase,
limits: DecoderLimits,
path: DecodePath,
) -> Result<Self, Error>
pub fn open_as( parameters: Parameters, time_base: Timebase, limits: DecoderLimits, path: DecodePath, ) -> Result<Self, Error>
Opens a video decoder on a named decode path.
DecodePath::Auto is open exactly;
DecodePath::AnyHardware keeps the session to the platform’s
hardware backends and the other two arms pin it to one backend or
to software, each for its whole life. See DecodePath for what
each permits and what it costs.
Everything else about the session is unchanged — the same
VideoStreamDecoder face, the same frames, the same
is_hardware / is_software
readings. The choice is which decoder is behind them, which
is what a determinism comparison and a deployment policy each
need and neither could reach.
§Errors
DecodePath::AnyHardware fails here with
Error::AllBackendsFailed when no hardware backend opens for
the stream — at once on a platform with none — carrying every
backend’s attempt and no packet, since none was sent.
DecodePath::Hardware fails here when the named backend
cannot be opened for the stream. DecodePath::Auto would have
gone on to software in both cases. DecodePath::Software fails
only where libavcodec has no decoder for the stream, or the
context cannot be built.
§Examples
use mediadecode_ffmpeg::{DecodePath, DecoderLimits, FfmpegVideoStreamDecoder};
// The same stream, decoded without a GPU anywhere in the story.
let decoder = FfmpegVideoStreamDecoder::open_as(
parameters,
time_base,
DecoderLimits::default(),
DecodePath::Software,
)?;
assert!(decoder.is_software());Sourcepub const fn is_software(&self) -> bool
pub const fn is_software(&self) -> bool
Whether this decoder is currently running on software.
Sourcepub const fn is_hardware(&self) -> bool
pub const fn is_hardware(&self) -> bool
Whether this decoder is currently running on hardware.
Sourcepub fn scaled_output_capability(&self) -> ScaledOutputCapability
pub fn scaled_output_capability(&self) -> ScaledOutputCapability
Whether this session can currently emit pictures at a
caller-requested output size. See
ScaledOutputCapability and
Self::request_scaled_output.
Supported on a live VideoToolbox session on an Apple
target, Unsupported everywhere else — including on a
session that fell back to software during its probe, which is
why this reads the session’s live state rather than a fact
recorded once at open.
Sourcepub fn request_scaled_output(
&mut self,
size: (u32, u32),
) -> ScaledOutputCapability
pub fn request_scaled_output( &mut self, size: (u32, u32), ) -> ScaledOutputCapability
Requests that this session emit pictures at size (width,
height) from the next frame on, and reports whether the
request was recorded. See
VideoStreamDecoder::request_scaled_output for the full
contract (never an error) and
Self::scaled_output_capability’s documentation for which
road can honor one, what a mid-stream request means, and the
zero / upscale refusals this seat mints itself.
Sourcepub fn hardware_inner(&self) -> Option<&VideoDecoder>
pub fn hardware_inner(&self) -> Option<&VideoDecoder>
The hardware wrapper, when one is in use.
Trait Implementations§
Source§impl VideoStreamDecoder for CarrierVideoStreamDecoder<View>
impl VideoStreamDecoder for CarrierVideoStreamDecoder<View>
Source§type Buffer = <View as FfmpegCarrier>::Buffer
type Buffer = <View as FfmpegCarrier>::Buffer
Source§type Error = VideoDecodeError
type Error = VideoDecodeError
Source§fn send_packet(
&mut self,
packet: &VideoPacket<VideoPacketExtra, Self::Buffer>,
) -> Result<Sent, Self::Error>
fn send_packet( &mut self, packet: &VideoPacket<VideoPacketExtra, Self::Buffer>, ) -> Result<Sent, Self::Error>
Source§fn receive_frame(
&mut self,
dst: &mut VideoFrame<PixelFormat, VideoFrameExtra, Self::Buffer>,
) -> Result<Received, Self::Error>
fn receive_frame( &mut self, dst: &mut VideoFrame<PixelFormat, VideoFrameExtra, Self::Buffer>, ) -> Result<Received, Self::Error>
dst. Read moreSource§fn flush(&mut self) -> Result<(), Self::Error>
fn flush(&mut self) -> Result<(), Self::Error>
Source§fn scaled_output_capability(&self) -> ScaledOutputCapability
fn scaled_output_capability(&self) -> ScaledOutputCapability
ScaledOutputCapability for what a Self::Supported answer
costs a caller who acts on it. Read moreSource§fn request_scaled_output(&mut self, size: (u32, u32)) -> ScaledOutputCapability
fn request_scaled_output(&mut self, size: (u32, u32)) -> ScaledOutputCapability
size
(width, height) from here on, and reports whether the request was
honored. Read moreSource§impl VideoStreamDecoder for CarrierVideoStreamDecoder<Owned>
impl VideoStreamDecoder for CarrierVideoStreamDecoder<Owned>
Source§type Buffer = <Owned as FfmpegCarrier>::Buffer
type Buffer = <Owned as FfmpegCarrier>::Buffer
Source§type Error = VideoDecodeError
type Error = VideoDecodeError
Source§fn send_packet(
&mut self,
packet: &VideoPacket<VideoPacketExtra, Self::Buffer>,
) -> Result<Sent, Self::Error>
fn send_packet( &mut self, packet: &VideoPacket<VideoPacketExtra, Self::Buffer>, ) -> Result<Sent, Self::Error>
Source§fn receive_frame(
&mut self,
dst: &mut VideoFrame<PixelFormat, VideoFrameExtra, Self::Buffer>,
) -> Result<Received, Self::Error>
fn receive_frame( &mut self, dst: &mut VideoFrame<PixelFormat, VideoFrameExtra, Self::Buffer>, ) -> Result<Received, Self::Error>
dst. Read moreSource§fn flush(&mut self) -> Result<(), Self::Error>
fn flush(&mut self) -> Result<(), Self::Error>
Source§fn scaled_output_capability(&self) -> ScaledOutputCapability
fn scaled_output_capability(&self) -> ScaledOutputCapability
ScaledOutputCapability for what a Self::Supported answer
costs a caller who acts on it. Read moreSource§fn request_scaled_output(&mut self, size: (u32, u32)) -> ScaledOutputCapability
fn request_scaled_output(&mut self, size: (u32, u32)) -> ScaledOutputCapability
size
(width, height) from here on, and reports whether the request was
honored. Read more