![]() |
![]() |
![]() |
GStreamer Bad Plugins 0.10 Library Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
#define GST_BASE_VIDEO_ENCODER_SINK_NAME #define GST_BASE_VIDEO_ENCODER_SRC_NAME #define GST_BASE_VIDEO_ENCODER_FLOW_DROPPED struct GstBaseVideoEncoder; struct GstBaseVideoEncoderClass; const GstVideoState * gst_base_video_encoder_get_state (GstBaseVideoEncoder *coder
); GstVideoFrame * gst_base_video_encoder_get_oldest_frame (GstBaseVideoEncoder *coder
); GstFlowReturn gst_base_video_encoder_finish_frame (GstBaseVideoEncoder *base_video_encoder
,GstVideoFrame *frame
); void gst_base_video_encoder_set_latency (GstBaseVideoEncoder *base_video_encoder
,GstClockTime min_latency
,GstClockTime max_latency
); void gst_base_video_encoder_set_latency_fields (GstBaseVideoEncoder *base_video_encoder
,int n_fields
);
This base class is for video encoders turning raw video into encoded video data.
GstBaseVideoEncoder and subclass should cooperate as follows.
Configuration
Initially, GstBaseVideoEncoder calls start
when the encoder element
is activated, which allows subclass to perform any global setup.
GstBaseVideoEncoder 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.
GstBaseVideoEncoder 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_base_video_encoder_finish_frame
to have encoded data pushed
downstream.
If implemented, baseclass calls subclass shape_output
which then sends
data downstream in desired form. Otherwise, it is sent as-is.
GstBaseVideoEncoderClass will handle both srcpad and sinkpad events.
Sink events will be passed to subclass if event
callback has been
provided.
Shutdown phase
GstBaseVideoEncoder 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_base_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_base_video_encoder_finish_frame
.
#define GST_BASE_VIDEO_ENCODER_SINK_NAME "sink"
The name of the templates for the sink pad.
#define GST_BASE_VIDEO_ENCODER_SRC_NAME "src"
The name of the templates for the source pad.
#define GST_BASE_VIDEO_ENCODER_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS_1
Returned when the event/buffer should be dropped.
struct GstBaseVideoEncoder { GstBaseVideoCodec base_video_codec; };
The opaque GstBaseVideoEncoder data structure.
GstBaseVideoCodec |
struct GstBaseVideoEncoderClass { GstBaseVideoCodecClass base_video_codec_class; /* virtual methods for subclasses */ gboolean (*start) (GstBaseVideoEncoder *coder); gboolean (*stop) (GstBaseVideoEncoder *coder); gboolean (*set_format) (GstBaseVideoEncoder *coder, GstVideoState *state); GstFlowReturn (*handle_frame) (GstBaseVideoEncoder *coder, GstVideoFrame *frame); gboolean (*reset) (GstBaseVideoEncoder *coder); GstFlowReturn (*finish) (GstBaseVideoEncoder *coder); GstFlowReturn (*shape_output) (GstBaseVideoEncoder *coder, GstVideoFrame *frame); gboolean (*event) (GstBaseVideoEncoder *coder, GstEvent *event); };
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.
GstBaseVideoCodecClass |
|
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. GstVideoState fields have already been set according to provided caps. | |
Provides input frame to subclass. | |
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. 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). |
const GstVideoState * gst_base_video_encoder_get_state (GstBaseVideoEncoder *coder
);
|
a GstBaseVideoEncoder |
Returns : |
GstVideoState describing format of video data. |
GstVideoFrame * gst_base_video_encoder_get_oldest_frame
(GstBaseVideoEncoder *coder
);
|
a GstBaseVideoEncoder |
Returns : |
oldest unfinished pending GstVideoFrame |
GstFlowReturn gst_base_video_encoder_finish_frame (GstBaseVideoEncoder *base_video_encoder
,GstVideoFrame *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 shape_output
.
In any case, the frame is considered finished and released.
|
a GstBaseVideoEncoder |
|
an encoded GstVideoFrame |
Returns : |
a GstFlowReturn resulting from sending data downstream |
void gst_base_video_encoder_set_latency (GstBaseVideoEncoder *base_video_encoder
,GstClockTime min_latency
,GstClockTime max_latency
);
Informs baseclass of encoding latency.
|
a GstBaseVideoEncoder |
|
minimum latency |
|
maximum latency |
void gst_base_video_encoder_set_latency_fields (GstBaseVideoEncoder *base_video_encoder
,int n_fields
);
Informs baseclass of encoding latency in terms of fields (both min and max latency).
|
a GstBaseVideoEncoder |
|
latency in fields |