gstreamer/gst/encoding/gstsmartencoder.h
Mathieu Duponchelle 4aa72cea4f smartencoder: clean up and extend accepted formats
* Add support for H265

* Don't overwrite original codec_data / streamheader in the output
  caps, but instead allow them to change and send them to the
  combiner at the right moment: encoder caps, reencoded GOP,
  original caps, original GOP(s), and potentially encoder caps
  and rencoded last GOP.

* For H264 / H265, force usage of a format with inband SPS / PPS
  (avc3 / hev1), this is cleaner than misadvertising avc1, hvc1 and
  some muxers like mp4mux will actually advertise both differently.

  Unfortunately, while mp4 supports updating the codec_data and using
  avc1 with no in-band SPS / PPS updates, it turns out some decoders
  (eg chrome / firefox) don't handle this particularly well and stop
  decoding after the reencoded GOP. We could expose a switch to
  force usage of avc1 / hvc1 nevertheless, but for now stick to
  requiring that the parser output SPS / PPS in-band with
  config-interval=-1 (that has not changed)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1249>
2021-08-20 14:20: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 *original_caps;
gboolean push_original_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__ */