| Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
| Safe Haskell | None |
| Language | Haskell2010 |
GI.GstVideo.Objects.VideoEncoder
Contents
Description
This base class is for video encoders turning raw video into encoded video data.
GstVideoEncoder and subclass should cooperate as follows.
<orderedlist>
<listitem>
<itemizedlist><title>Configuration</title>
<listitem><para>
Initially, GstVideoEncoder calls start when the encoder element
is activated, which allows subclass to perform any global setup.
</para></listitem>
<listitem><para>
GstVideoEncoder calls setFormat to inform subclass of the format
of input video data that it is about to receive. Subclass should
setup for encoding and configure base class as appropriate
(e.g. latency). While unlikely, it might be called more than once,
if changing input parameters require reconfiguration. Baseclass
will ensure that processing of current configuration is finished.
</para></listitem>
<listitem><para>
GstVideoEncoder calls stop at end of all processing.
</para></listitem>
</itemizedlist>
</listitem>
<listitem>
<itemizedlist>
<title>Data processing</title>
<listitem><para>
Base class collects input data and metadata into a frame and hands
this to subclass' handleFrame.
</para></listitem>
<listitem><para>
If codec processing results in encoded data, subclass should call
gstVideoEncoderFinishFrame to have encoded data pushed
downstream.
</para></listitem>
<listitem><para>
If implemented, baseclass calls subclass prePush just prior to
pushing to allow subclasses to modify some metadata on the buffer.
If it returns GST_FLOW_OK, the buffer is pushed downstream.
</para></listitem>
<listitem><para>
GstVideoEncoderClass will handle both srcpad and sinkpad events.
Sink events will be passed to subclass if event callback has been
provided.
</para></listitem>
</itemizedlist>
</listitem>
<listitem>
<itemizedlist><title>Shutdown phase</title>
<listitem><para>
GstVideoEncoder class calls stop to inform the subclass that data
parsing will be stopped.
</para></listitem>
</itemizedlist>
</listitem>
</orderedlist>
Subclass is responsible for providing pad template caps for
source and sink pads. The pads need to be named "sink" and "src". It should
also be able to provide fixed src pad caps in getcaps by the time it calls
gstVideoEncoderFinishFrame.
Things that subclass need to take care of:
<itemizedlist>
<listitem><para>Provide pad templates</para></listitem>
<listitem><para>
Provide source pad caps before pushing the first buffer
</para></listitem>
<listitem><para>
Accept data in handleFrame and provide encoded results to
gstVideoEncoderFinishFrame.
</para></listitem>
</itemizedlist>
- newtype VideoEncoder = VideoEncoder (ManagedPtr VideoEncoder)
- class GObject o => IsVideoEncoder o
- toVideoEncoder :: IsVideoEncoder o => o -> IO VideoEncoder
- noVideoEncoder :: Maybe VideoEncoder
- data VideoEncoderAllocateOutputBufferMethodInfo
- videoEncoderAllocateOutputBuffer :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> Word64 -> m Buffer
- data VideoEncoderAllocateOutputFrameMethodInfo
- videoEncoderAllocateOutputFrame :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> VideoCodecFrame -> Word64 -> m FlowReturn
- data VideoEncoderFinishFrameMethodInfo
- videoEncoderFinishFrame :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> VideoCodecFrame -> m FlowReturn
- data VideoEncoderGetAllocatorMethodInfo
- videoEncoderGetAllocator :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> m (Allocator, AllocationParams)
- data VideoEncoderGetFrameMethodInfo
- videoEncoderGetFrame :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> Int32 -> m VideoCodecFrame
- data VideoEncoderGetFramesMethodInfo
- videoEncoderGetFrames :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> m [VideoCodecFrame]
- data VideoEncoderGetLatencyMethodInfo
- videoEncoderGetLatency :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> m (Word64, Word64)
- data VideoEncoderGetOldestFrameMethodInfo
- videoEncoderGetOldestFrame :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> m VideoCodecFrame
- data VideoEncoderGetOutputStateMethodInfo
- videoEncoderGetOutputState :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> m VideoCodecState
- data VideoEncoderMergeTagsMethodInfo
- videoEncoderMergeTags :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> Maybe TagList -> TagMergeMode -> m ()
- data VideoEncoderNegotiateMethodInfo
- videoEncoderNegotiate :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> m Bool
- data VideoEncoderProxyGetcapsMethodInfo
- videoEncoderProxyGetcaps :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> Maybe Caps -> Maybe Caps -> m Caps
- data VideoEncoderSetHeadersMethodInfo
- videoEncoderSetHeaders :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> [Buffer] -> m ()
- data VideoEncoderSetLatencyMethodInfo
- videoEncoderSetLatency :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> Word64 -> Word64 -> m ()
- data VideoEncoderSetMinPtsMethodInfo
- videoEncoderSetMinPts :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> Word64 -> m ()
- data VideoEncoderSetOutputStateMethodInfo
- videoEncoderSetOutputState :: (HasCallStack, MonadIO m, IsVideoEncoder a) => a -> Caps -> Maybe VideoCodecState -> m VideoCodecState
Exported types
newtype VideoEncoder Source #
Constructors
| VideoEncoder (ManagedPtr VideoEncoder) |
Instances
| GObject VideoEncoder Source # | |
| IsObject VideoEncoder Source # | |
| IsPreset VideoEncoder Source # | |
| IsElement VideoEncoder Source # | |
| IsObject VideoEncoder Source # | |
| IsVideoEncoder VideoEncoder Source # | |
| ((~) * info (ResolveVideoEncoderMethod t VideoEncoder), MethodInfo * info VideoEncoder p) => IsLabel t (VideoEncoder -> p) Source # | |
| ((~) * info (ResolveVideoEncoderMethod t VideoEncoder), MethodInfo * info VideoEncoder p) => IsLabelProxy t (VideoEncoder -> p) Source # | |
| HasAttributeList * VideoEncoder Source # | |
| type AttributeList VideoEncoder Source # | |
| type SignalList VideoEncoder Source # | |
class GObject o => IsVideoEncoder o Source #
Instances
toVideoEncoder :: IsVideoEncoder o => o -> IO VideoEncoder Source #
Methods
allocateOutputBuffer
data VideoEncoderAllocateOutputBufferMethodInfo Source #
Instances
| ((~) * signature (Word64 -> m Buffer), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderAllocateOutputBufferMethodInfo a signature Source # | |
videoEncoderAllocateOutputBuffer Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> Word64 |
|
| -> m Buffer | Returns: allocated buffer |
Helper function that allocates a buffer to hold an encoded video frame
for encoder's current VideoCodecState.
allocateOutputFrame
data VideoEncoderAllocateOutputFrameMethodInfo Source #
Instances
| ((~) * signature (VideoCodecFrame -> Word64 -> m FlowReturn), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderAllocateOutputFrameMethodInfo a signature Source # | |
videoEncoderAllocateOutputFrame Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> VideoCodecFrame |
|
| -> Word64 |
|
| -> m FlowReturn | Returns: |
Helper function that allocates a buffer to hold an encoded video frame for encoder'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.
finishFrame
data VideoEncoderFinishFrameMethodInfo Source #
Instances
| ((~) * signature (VideoCodecFrame -> m FlowReturn), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderFinishFrameMethodInfo a signature Source # | |
videoEncoderFinishFrame Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> VideoCodecFrame |
|
| -> m FlowReturn | Returns: a |
frame must have a valid encoded data buffer, whose metadata fields
are then appropriately set according to frame data or no buffer at
all if the frame should be dropped.
It is subsequently pushed downstream or provided to prePush.
In any case, the frame is considered finished and released.
After calling this function the output buffer of the frame is to be considered read-only. This function will also change the metadata of the buffer.
getAllocator
data VideoEncoderGetAllocatorMethodInfo Source #
Instances
| ((~) * signature (m (Allocator, AllocationParams)), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderGetAllocatorMethodInfo a signature Source # | |
videoEncoderGetAllocator Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> m (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.
getFrame
data VideoEncoderGetFrameMethodInfo Source #
Instances
| ((~) * signature (Int32 -> m VideoCodecFrame), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderGetFrameMethodInfo a signature Source # | |
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> Int32 |
|
| -> m VideoCodecFrame | Returns: pending unfinished |
Get a pending unfinished VideoCodecFrame
getFrames
data VideoEncoderGetFramesMethodInfo Source #
Instances
| ((~) * signature (m [VideoCodecFrame]), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderGetFramesMethodInfo a signature Source # | |
videoEncoderGetFrames Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> m [VideoCodecFrame] | Returns: pending unfinished |
Get all pending unfinished VideoCodecFrame
getLatency
data VideoEncoderGetLatencyMethodInfo Source #
Instances
| ((~) * signature (m (Word64, Word64)), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderGetLatencyMethodInfo a signature Source # | |
videoEncoderGetLatency Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> m (Word64, Word64) |
Query the configured encoding latency. Results will be returned via
minLatency and maxLatency.
getOldestFrame
data VideoEncoderGetOldestFrameMethodInfo Source #
Instances
| ((~) * signature (m VideoCodecFrame), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderGetOldestFrameMethodInfo a signature Source # | |
videoEncoderGetOldestFrame Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> m VideoCodecFrame | Returns: oldest unfinished pending |
Get the oldest unfinished pending VideoCodecFrame
getOutputState
data VideoEncoderGetOutputStateMethodInfo Source #
Instances
| ((~) * signature (m VideoCodecState), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderGetOutputStateMethodInfo a signature Source # | |
videoEncoderGetOutputState Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> m VideoCodecState | Returns: |
Get the current VideoCodecState
mergeTags
data VideoEncoderMergeTagsMethodInfo Source #
Instances
| ((~) * signature (Maybe TagList -> TagMergeMode -> m ()), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderMergeTagsMethodInfo a signature Source # | |
videoEncoderMergeTags Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> Maybe TagList |
|
| -> TagMergeMode |
|
| -> m () |
Sets the video encoder tags and how they should be merged with any
upstream stream tags. This will override any tags previously-set
with videoEncoderMergeTags.
Note that this is provided for convenience, and the subclass is not required to use this and can still do tag handling on its own.
MT safe.
negotiate
data VideoEncoderNegotiateMethodInfo Source #
Instances
| ((~) * signature (m Bool), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderNegotiateMethodInfo a signature Source # | |
videoEncoderNegotiate Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> m Bool | Returns: |
Negotiate with downstream elements to currently configured VideoCodecState.
Unmark GST_PAD_FLAG_NEED_RECONFIGURE in any case. But mark it again if
negotiate fails.
proxyGetcaps
data VideoEncoderProxyGetcapsMethodInfo Source #
Instances
| ((~) * signature (Maybe Caps -> Maybe Caps -> m Caps), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderProxyGetcapsMethodInfo a signature Source # | |
videoEncoderProxyGetcaps Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> Maybe Caps |
|
| -> Maybe Caps |
|
| -> m Caps | Returns: a |
Returns caps that express caps (or sink template caps if caps == NULL)
restricted to resolution/format/... combinations supported by downstream
elements (e.g. muxers).
setHeaders
data VideoEncoderSetHeadersMethodInfo Source #
Instances
| ((~) * signature ([Buffer] -> m ()), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderSetHeadersMethodInfo a signature Source # | |
videoEncoderSetHeaders Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> [Buffer] |
|
| -> m () |
Set the codec headers to be sent downstream whenever requested.
setLatency
data VideoEncoderSetLatencyMethodInfo Source #
Instances
| ((~) * signature (Word64 -> Word64 -> m ()), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderSetLatencyMethodInfo a signature Source # | |
videoEncoderSetLatency Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> Word64 |
|
| -> Word64 |
|
| -> m () |
Informs baseclass of encoding latency.
setMinPts
data VideoEncoderSetMinPtsMethodInfo Source #
Instances
| ((~) * signature (Word64 -> m ()), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderSetMinPtsMethodInfo a signature Source # | |
videoEncoderSetMinPts Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> Word64 |
|
| -> m () |
Request minimal value for PTS passed to handle_frame.
For streams with reordered frames this can be used to ensure that there is enough time to accomodate first DTS, which may be less than first PTS
Since 1.6
setOutputState
data VideoEncoderSetOutputStateMethodInfo Source #
Instances
| ((~) * signature (Caps -> Maybe VideoCodecState -> m VideoCodecState), MonadIO m, IsVideoEncoder a) => MethodInfo * VideoEncoderSetOutputStateMethodInfo a signature Source # | |
videoEncoderSetOutputState Source #
Arguments
| :: (HasCallStack, MonadIO m, IsVideoEncoder a) | |
| => a |
|
| -> Caps |
|
| -> Maybe VideoCodecState |
|
| -> m VideoCodecState | Returns: the newly configured output state. |
Creates a new VideoCodecState with the specified caps as the output state
for the encoder.
Any previously set output state on encoder 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 gst_video_encoder_finish_frame().