![]() |
![]() |
![]() |
GStreamer Base Plugins 1.0 Library Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
#define GST_VIDEO_ENCODER_CAST (enc) #define GST_VIDEO_ENCODER_FLOW_DROPPED #define GST_VIDEO_ENCODER_FLOW_NEED_DATA #define GST_VIDEO_ENCODER_SINK_NAME #define GST_VIDEO_ENCODER_SINK_PAD (obj) #define GST_VIDEO_ENCODER_SRC_NAME #define GST_VIDEO_ENCODER_SRC_PAD (obj) #define GST_VIDEO_ENCODER_INPUT_SEGMENT (obj) #define GST_VIDEO_ENCODER_OUTPUT_SEGMENT (obj) #define GST_VIDEO_ENCODER_STREAM_LOCK (encoder) #define GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder) struct GstVideoEncoder; struct GstVideoEncoderClass; GstFlowReturn gst_video_encoder_finish_frame (GstVideoEncoder *encoder
,GstVideoCodecFrame *frame
); GstVideoCodecFrame * gst_video_encoder_get_frame (GstVideoEncoder *encoder
,int frame_number
); GstVideoCodecFrame * gst_video_encoder_get_oldest_frame (GstVideoEncoder *encoder
); void gst_video_encoder_set_headers (GstVideoEncoder *encoder
,GList *headers
); void gst_video_encoder_get_latency (GstVideoEncoder *encoder
,GstClockTime *min_latency
,GstClockTime *max_latency
); void gst_video_encoder_set_latency (GstVideoEncoder *encoder
,GstClockTime min_latency
,GstClockTime max_latency
); gboolean gst_video_encoder_get_discont (GstVideoEncoder *encoder
); void gst_video_encoder_set_discont (GstVideoEncoder *encoder
); GstVideoCodecState * gst_video_encoder_set_output_state (GstVideoEncoder *encoder
,GstCaps *caps
,GstVideoCodecState *reference
); GstVideoCodecState * gst_video_encoder_get_output_state (GstVideoEncoder *encoder
); GstCaps * gst_video_encoder_proxy_getcaps (GstVideoEncoder *enc
,GstCaps *caps
,GstCaps *filter
);
This base class is for video encoders turning raw video into encoded video data.
GstVideoEncoder and subclass should cooperate as follows.
Configuration
Initially, GstVideoEncoder calls start
when the encoder element
is activated, which allows subclass to perform any global setup.
GstVideoEncoder calls set_format
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.
GstVideoEncoder calls stop
at end of all processing.
Data processing
Base class collects input data and metadata into a frame and hands
this to subclass' handle_frame
.
If codec processing results in encoded data, subclass should call
gst_video_encoder_finish_frame
to have encoded data pushed
downstream.
If implemented, baseclass calls subclass pre_push
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.
GstVideoEncoderClass will handle both srcpad and sinkpad events.
Sink events will be passed to subclass if event
callback has been
provided.
Shutdown phase
GstVideoEncoder class calls stop
to inform the subclass that data
parsing will be stopped.
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
gst_video_encoder_finish_frame
.
Things that subclass need to take care of:
Provide pad templates
Provide source pad caps before pushing the first buffer
Accept data in handle_frame
and provide encoded results to
gst_video_encoder_finish_frame
.
#define GST_VIDEO_ENCODER_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS_1
Returned when the event/buffer should be dropped.
Since 0.10.36
#define GST_VIDEO_ENCODER_FLOW_NEED_DATA GST_FLOW_CUSTOM_SUCCESS
Returned while parsing to indicate more data is needed.
Since 0.10.36
#define GST_VIDEO_ENCODER_SINK_NAME "sink"
The name of the templates for the sink pad.
Since 0.10.36
#define GST_VIDEO_ENCODER_SINK_PAD(obj) (((GstVideoEncoder *) (obj))->sinkpad)
Gives the pointer to the sink GstPad object of the element.
|
a GstVideoEncoder |
Since 0.10.36
#define GST_VIDEO_ENCODER_SRC_NAME "src"
The name of the templates for the source pad.
Since 0.10.36
#define GST_VIDEO_ENCODER_SRC_PAD(obj) (((GstVideoEncoder *) (obj))->srcpad)
Gives the pointer to the source GstPad object of the element.
|
a GstVideoEncoder |
Since 0.10.36
#define GST_VIDEO_ENCODER_INPUT_SEGMENT(obj) (GST_VIDEO_ENCODER_CAST (obj)->input_segment)
Gives the segment of the element.
|
base parse instance |
Since 0.10.36
#define GST_VIDEO_ENCODER_OUTPUT_SEGMENT(obj) (GST_VIDEO_ENCODER_CAST (obj)->output_segment)
Gives the segment of the element.
|
base parse instance |
Since 0.10.36
#define GST_VIDEO_ENCODER_STREAM_LOCK(encoder) g_rec_mutex_lock (&GST_VIDEO_ENCODER (encoder)->stream_lock)
Obtain a lock to protect the encoder function from concurrent access.
|
video encoder instance |
Since 0.10.36
#define GST_VIDEO_ENCODER_STREAM_UNLOCK(encoder) g_rec_mutex_unlock (&GST_VIDEO_ENCODER (encoder)->stream_lock)
Release the lock that protects the encoder function from concurrent access.
|
video encoder instance |
Since 0.10.36
struct GstVideoEncoder { };
The opaque GstVideoEncoder data structure.
Since 0.10.36
struct GstVideoEncoderClass { /* virtual methods for subclasses */ gboolean (*open) (GstVideoEncoder *encoder); gboolean (*close) (GstVideoEncoder *encoder); gboolean (*start) (GstVideoEncoder *encoder); gboolean (*stop) (GstVideoEncoder *encoder); gboolean (*set_format) (GstVideoEncoder *encoder, GstVideoCodecState *state); GstFlowReturn (*handle_frame) (GstVideoEncoder *encoder, GstVideoCodecFrame *frame); gboolean (*reset) (GstVideoEncoder *encoder, gboolean hard); GstFlowReturn (*finish) (GstVideoEncoder *encoder); GstFlowReturn (*pre_push) (GstVideoEncoder *encoder, GstVideoCodecFrame *frame); GstCaps * (*getcaps) (GstVideoEncoder *enc, GstCaps *filter); gboolean (*sink_event) (GstVideoEncoder *encoder, GstEvent *event); gboolean (*src_event) (GstVideoEncoder *encoder, GstEvent *event); gboolean (*propose_allocation) (GstVideoEncoder * encoder, GstQuery * query); };
Subclasses can override any of the available virtual methods or not, as
needed. At minimum handle_frame
needs to be overridden, and set_format
and get_caps
are likely needed as well.
Optional. Called when the element changes to GST_STATE_READY. Allows opening external resources. Since: 0.10.37. | |
Optional. Called when the element changes to GST_STATE_NULL. Allows closing external resources. Since: 0.10.37. | |
Optional. Called when the element starts processing. Allows opening external resources. | |
Optional. Called when the element stops processing. Allows closing external resources. | |
Optional. Notifies subclass of incoming data format. GstVideoCodecState fields have already been set according to provided caps. | |
Provides input frame to subclass. | |
Optional. Allows subclass (encoder) to perform post-seek semantics reset. | |
Optional. Called to request subclass to dispatch any pending remaining data (e.g. at EOS). | |
Optional. Allows subclass to push frame downstream in whatever shape or form it deems appropriate. If not provided, provided encoded frame data is simply pushed downstream. | |
Optional. Allows for a custom sink getcaps implementation (e.g. for multichannel input specification). If not implemented, default returns gst_video_encoder_proxy_getcaps applied to sink template caps. | |
Optional. Event handler on the sink pad. This function should return TRUE if the event was handled and should be discarded (i.e. not unref'ed). | |
Optional. Event handler on the source pad. This function should return TRUE if the event was handled and should be discarded (i.e. not unref'ed). | |
Optional. Propose buffer allocation parameters for upstream elements. |
Since 0.10.36
GstFlowReturn gst_video_encoder_finish_frame (GstVideoEncoder *encoder
,GstVideoCodecFrame *frame
);
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 pre_push
.
In any case, the frame is considered finished and released.
|
a GstVideoEncoder |
|
an encoded GstVideoCodecFrame. [transfer full] |
Returns : |
a GstFlowReturn resulting from sending data downstream |
Since 0.10.36
GstVideoCodecFrame * gst_video_encoder_get_frame (GstVideoEncoder *encoder
,int frame_number
);
Get a pending unfinished GstVideoCodecFrame
|
a GstVideoEnccoder |
|
system_frame_number of a frame |
Returns : |
pending unfinished GstVideoCodecFrame identified by frame_number . [transfer none]
|
Since 0.10.36
GstVideoCodecFrame * gst_video_encoder_get_oldest_frame (GstVideoEncoder *encoder
);
Get the oldest unfinished pending GstVideoCodecFrame
|
a GstVideoEncoder |
Returns : |
oldest unfinished pending GstVideoCodecFrame. [transfer full] |
Since 0.10.36
void gst_video_encoder_set_headers (GstVideoEncoder *encoder
,GList *headers
);
Set the codec headers to be sent downstream whenever requested.
|
a GstVideoEncoder |
|
a list of GstBuffer containing the codec header. [transfer full][element-type GstBuffer] |
Since 0.10.36
void gst_video_encoder_get_latency (GstVideoEncoder *encoder
,GstClockTime *min_latency
,GstClockTime *max_latency
);
|
a GstVideoEncoder |
|
the configured minimum latency. [out][allow-none] |
|
the configured maximum latency. [out][allow-none] |
Returns : |
the configured encoding latency. |
Since 0.10.36
void gst_video_encoder_set_latency (GstVideoEncoder *encoder
,GstClockTime min_latency
,GstClockTime max_latency
);
Informs baseclass of encoding latency.
|
a GstVideoEncoder |
|
minimum latency |
|
maximum latency |
Since 0.10.36
GstVideoCodecState * gst_video_encoder_set_output_state (GstVideoEncoder *encoder
,GstCaps *caps
,GstVideoCodecState *reference
);
Creates a new GstVideoCodecState with the specified caps as the output state
for the encoder.
Any previously set output state on decoder
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
GstVideoCodecState.
If the subclass wishes to copy over existing fields (like pixel aspect ratio,
or framerate) from an existing GstVideoCodecState, 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 GstVideoCodecState.
The new output state will only take effect (set on pads and buffers) starting
from the next call to #gst_video_encoder_finish_frame()
.
|
a GstVideoEncoder |
|
the GstCaps to use for the output. [transfer full] |
|
An optional reference GstVideoCodecState . [allow-none][transfer none]
|
Returns : |
the newly configured output state. [transfer full] |
Since 0.10.36
GstVideoCodecState * gst_video_encoder_get_output_state (GstVideoEncoder *encoder
);
Get the current GstVideoCodecState
|
a GstVideoEncoder |
Returns : |
GstVideoCodecState describing format of video data. [transfer full] |
Since 0.10.36
GstCaps * gst_video_encoder_proxy_getcaps (GstVideoEncoder *enc
,GstCaps *caps
,GstCaps *filter
);
Returns caps that express caps
(or sink template caps if caps
== NULL)
restricted to resolution/format/... combinations supported by downstream
elements (e.g. muxers).
|
a GstVideoEncoder |
|
initial caps |
Returns : |
a GstCaps owned by caller |
Since 0.10.36