pub trait VideoEncoderExtManual: Sealed + IsA<VideoEncoder> + 'static {
Show 16 methods
// Provided methods
fn allocate_output_frame(
&self,
frame: &mut VideoCodecFrame<'_>,
size: usize,
) -> Result<FlowSuccess, FlowError> { ... }
fn frame(&self, frame_number: i32) -> Option<VideoCodecFrame<'_>> { ... }
fn frames(&self) -> Vec<VideoCodecFrame<'_>> { ... }
fn oldest_frame(&self) -> Option<VideoCodecFrame<'_>> { ... }
fn allocator(&self) -> (Option<Allocator>, AllocationParams) { ... }
fn finish_subframe(
&self,
frame: &VideoCodecFrame<'_>,
) -> Result<FlowSuccess, FlowError> { ... }
fn latency(&self) -> (ClockTime, Option<ClockTime>) { ... }
fn set_latency(
&self,
min_latency: ClockTime,
max_latency: impl Into<Option<ClockTime>>,
) { ... }
fn output_state(&self) -> Option<VideoCodecState<'static, Readable>> { ... }
fn set_output_state(
&self,
caps: Caps,
reference: Option<&VideoCodecState<'_, Readable>>,
) -> Result<VideoCodecState<'_, InNegotiation<'_>>, FlowError> { ... }
fn negotiate<'a>(
&'a self,
output_state: VideoCodecState<'a, InNegotiation<'a>>,
) -> Result<(), FlowError> { ... }
fn set_headers(&self, headers: impl IntoIterator<Item = Buffer>) { ... }
fn sink_pad(&self) -> &Pad { ... }
fn src_pad(&self) -> &Pad { ... }
fn input_segment(&self) -> Segment { ... }
fn output_segment(&self) -> Segment { ... }
}
Provided Methods§
sourcefn allocate_output_frame(
&self,
frame: &mut VideoCodecFrame<'_>,
size: usize,
) -> Result<FlowSuccess, FlowError>
fn allocate_output_frame( &self, frame: &mut VideoCodecFrame<'_>, size: usize, ) -> Result<FlowSuccess, FlowError>
Helper function that allocates a buffer to hold an encoded video frame for self
’s
current VideoCodecState
. Subclass should already have configured video
state and set src pad caps.
The buffer allocated here is owned by the frame and you should only keep references to the frame, not the buffer.
§frame
§size
size of the buffer
§Returns
gst::FlowReturn::Ok
if an output buffer could be allocated
sourcefn frame(&self, frame_number: i32) -> Option<VideoCodecFrame<'_>>
fn frame(&self, frame_number: i32) -> Option<VideoCodecFrame<'_>>
Get a pending unfinished VideoCodecFrame
§frame_number
system_frame_number of a frame
§Returns
pending unfinished VideoCodecFrame
identified by frame_number
.
sourcefn frames(&self) -> Vec<VideoCodecFrame<'_>>
fn frames(&self) -> Vec<VideoCodecFrame<'_>>
sourcefn oldest_frame(&self) -> Option<VideoCodecFrame<'_>>
fn oldest_frame(&self) -> Option<VideoCodecFrame<'_>>
Get the oldest unfinished pending VideoCodecFrame
§Returns
oldest unfinished pending VideoCodecFrame
sourcefn allocator(&self) -> (Option<Allocator>, AllocationParams)
fn allocator(&self) -> (Option<Allocator>, AllocationParams)
Lets VideoEncoder
sub-classes to know the memory allocator
used by the base class and its params
.
Unref the allocator
after use it.
§Returns
§allocator
the gst::Allocator
used
§params
the
gst::AllocationParams
of allocator
sourcefn finish_subframe(
&self,
frame: &VideoCodecFrame<'_>,
) -> Result<FlowSuccess, FlowError>
fn finish_subframe( &self, frame: &VideoCodecFrame<'_>, ) -> Result<FlowSuccess, FlowError>
If multiple subframes are produced for one input frame then use this method for each subframe, except for the last one. Before calling this function, you need to fill frame->output_buffer with the encoded buffer to push.
You must call VideoEncoderExt::finish_frame()
for the last sub-frame
to tell the encoder that the frame has been fully encoded.
This function will change the metadata of frame
and frame->output_buffer
will be pushed downstream.
§frame
a VideoCodecFrame
being encoded
§Returns
a gst::FlowReturn
resulting from pushing the buffer downstream.
sourcefn output_state(&self) -> Option<VideoCodecState<'static, Readable>>
fn output_state(&self) -> Option<VideoCodecState<'static, Readable>>
sourcefn set_output_state(
&self,
caps: Caps,
reference: Option<&VideoCodecState<'_, Readable>>,
) -> Result<VideoCodecState<'_, InNegotiation<'_>>, FlowError>
fn set_output_state( &self, caps: Caps, reference: Option<&VideoCodecState<'_, Readable>>, ) -> Result<VideoCodecState<'_, InNegotiation<'_>>, FlowError>
Creates a new VideoCodecState
with the specified caps as the output state
for the encoder.
Any previously set output state on self
will be replaced by the newly
created one.
The specified caps
should not contain any resolution, pixel-aspect-ratio,
framerate, codec-data, …. Those should be specified instead in the returned
VideoCodecState
.
If the subclass wishes to copy over existing fields (like pixel aspect ratio,
or framerate) from an existing VideoCodecState
, it can be provided as a
reference
.
If the subclass wishes to override some fields from the output state (like
pixel-aspect-ratio or framerate) it can do so on the returned VideoCodecState
.
The new output state will only take effect (set on pads and buffers) starting
from the next call to VideoEncoderExt::finish_frame()
.
§caps
the gst::Caps
to use for the output
§reference
An optional reference VideoCodecState
§Returns
the newly configured output state.
sourcefn negotiate<'a>(
&'a self,
output_state: VideoCodecState<'a, InNegotiation<'a>>,
) -> Result<(), FlowError>
fn negotiate<'a>( &'a self, output_state: VideoCodecState<'a, InNegotiation<'a>>, ) -> Result<(), FlowError>
Negotiate with downstream elements to currently configured VideoCodecState
.
Unmark GST_PAD_FLAG_NEED_RECONFIGURE in any case. But mark it again if
negotiate fails.
§Returns
sourcefn set_headers(&self, headers: impl IntoIterator<Item = Buffer>)
fn set_headers(&self, headers: impl IntoIterator<Item = Buffer>)
Set the codec headers to be sent downstream whenever requested.
§headers
a list of gst::Buffer
containing the codec header