Skip to main content

CarrierVideoStreamDecoder

Struct CarrierVideoStreamDecoder 

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

Source

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).

Source

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());
Source

pub const fn is_software(&self) -> bool

Whether this decoder is currently running on software.

Source

pub const fn is_hardware(&self) -> bool

Whether this decoder is currently running on hardware.

Source

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.

Source

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.

Source

pub fn hardware_inner(&self) -> Option<&VideoDecoder>

The hardware wrapper, when one is in use.

Source

pub const fn time_base(&self) -> Timebase

The stream timebase every produced timestamp is stamped with.

Source§

impl CarrierVideoStreamDecoder<Owned>

Source

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).

Source

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());
Source

pub const fn is_software(&self) -> bool

Whether this decoder is currently running on software.

Source

pub const fn is_hardware(&self) -> bool

Whether this decoder is currently running on hardware.

Source

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.

Source

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.

Source

pub fn hardware_inner(&self) -> Option<&VideoDecoder>

The hardware wrapper, when one is in use.

Source

pub const fn time_base(&self) -> Timebase

The stream timebase every produced timestamp is stamped with.

Trait Implementations§

Source§

impl VideoStreamDecoder for CarrierVideoStreamDecoder<View>

Source§

type Adapter = Ffmpeg

Backend-specific vocabulary.
Source§

type Buffer = <View as FfmpegCarrier>::Buffer

Buffer type held by the packets and frames this decoder produces or accepts.
Source§

type Error = VideoDecodeError

Decoder-specific error type.
Source§

fn send_packet( &mut self, packet: &VideoPacket<VideoPacketExtra, Self::Buffer>, ) -> Result<Sent, Self::Error>

Submits one compressed packet. Read more
Source§

fn receive_frame( &mut self, dst: &mut VideoFrame<PixelFormat, VideoFrameExtra, Self::Buffer>, ) -> Result<Received, Self::Error>

Drains one decoded frame into dst. Read more
Source§

fn send_eof(&mut self) -> Result<Sent, Self::Error>

Signals end-of-stream. Read more
Source§

fn flush(&mut self) -> Result<(), Self::Error>

Flushes internal state. Not a submission — nothing is offered, so there is nothing to be back-pressured.
Source§

fn scaled_output_capability(&self) -> ScaledOutputCapability

Whether this session can currently emit pictures at a caller- requested output size instead of full coded size. See ScaledOutputCapability for what a Self::Supported answer costs a caller who acts on it. Read more
Source§

fn request_scaled_output(&mut self, size: (u32, u32)) -> ScaledOutputCapability

Requests that this session emit decoded pictures at size (width, height) from here on, and reports whether the request was honored. Read more
Source§

impl VideoStreamDecoder for CarrierVideoStreamDecoder<Owned>

Source§

type Adapter = Ffmpeg

Backend-specific vocabulary.
Source§

type Buffer = <Owned as FfmpegCarrier>::Buffer

Buffer type held by the packets and frames this decoder produces or accepts.
Source§

type Error = VideoDecodeError

Decoder-specific error type.
Source§

fn send_packet( &mut self, packet: &VideoPacket<VideoPacketExtra, Self::Buffer>, ) -> Result<Sent, Self::Error>

Submits one compressed packet. Read more
Source§

fn receive_frame( &mut self, dst: &mut VideoFrame<PixelFormat, VideoFrameExtra, Self::Buffer>, ) -> Result<Received, Self::Error>

Drains one decoded frame into dst. Read more
Source§

fn send_eof(&mut self) -> Result<Sent, Self::Error>

Signals end-of-stream. Read more
Source§

fn flush(&mut self) -> Result<(), Self::Error>

Flushes internal state. Not a submission — nothing is offered, so there is nothing to be back-pressured.
Source§

fn scaled_output_capability(&self) -> ScaledOutputCapability

Whether this session can currently emit pictures at a caller- requested output size instead of full coded size. See ScaledOutputCapability for what a Self::Supported answer costs a caller who acts on it. Read more
Source§

fn request_scaled_output(&mut self, size: (u32, u32)) -> ScaledOutputCapability

Requests that this session emit decoded pictures at size (width, height) from here on, and reports whether the request was honored. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more