gstreamer/gst/encoding/gstsmartencoder.h
Thibault Saunier 1cead20777 encodebin: Fix and refactor smart encoding
It was not working properly and the implementation of the smartencoder
element was weird. This introduce a number of changes (which are all
in one single commit because they basically all work together and lead
to basically reimplementing the element):

* Make smartencoder a bin so that the reencoding chain of elements are
  inside of it instead of not having any parent. Those elements were not
  be visible when dumping the pipeline which was very confusing.
* Make encodebin create the right encoder with a capsfilter (and parser)
  to properly enforce the format specified by the user, and so that the
  encoder properties specified in the encoding profile are respected.
* Use `decodebin` to do the decoding instead of selecting a decoder
  ourself and not plug any parser etc...
* Ensure that negotiated format in the sinkpad of smart encoder is fixed
  through time when the user requested a non dynamic output
* Add a parser at the beginning of the smart encoder
* Handle errors when reencoding

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/751>
2020-07-22 16:01:25 +00:00

75 lines
2.3 KiB
C

/* GStreamer video re-encoder element
* Copyright (C) <2010> Edward Hervey <bilboed@bilboed.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __SMART_ENCODER_H__
#define __SMART_ENCODER_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_SMART_ENCODER (gst_smart_encoder_get_type())
G_DECLARE_FINAL_TYPE (GstSmartEncoder, gst_smart_encoder, GST, SMART_ENCODER, GstBin)
struct _GstSmartEncoder {
GstBin parent;
GstPad *sinkpad, *srcpad;
gboolean pushed_segment;
/* Segment received upstream */
GstSegment input_segment;
/* The segment we pushed downstream */
GstSegment output_segment;
/* Internal segments to compute buffers running time before pushing
* them downstream. It is the encoder segment when reecoding gops,
* and the input segment when pushing them unmodified. */
GstSegment internal_segment;
GstClockTime last_dts;
GstCaps *last_caps;
GstEvent *segment_event;
GstEvent *stream_start_event;
/* Pending GOP to be checked */
GList* pending_gop;
guint64 gop_start; /* GOP start PTS in the `input_segment` scale. */
guint64 gop_stop; /* GOP end PTS in the `input_segment` scale. */
/* Internal recoding elements */
GstPad *internal_sinkpad;
GstPad *internal_srcpad;
GstElement *decoder;
GstElement *encoder;
GstFlowReturn internal_flow;
GMutex internal_flow_lock;
GCond internal_flow_cond;
};
gboolean gst_smart_encoder_set_encoder (GstSmartEncoder *self,
GstCaps *format,
GstElement *encoder);
G_END_DECLS
#endif /* __SMART_ENCODER_H__ */