1 /* GStreamer video re-encoder element 2 * Copyright (C) <2010> Edward Hervey <bilboed@bilboed.com> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public 15 * License along with this library; if not, write to the 16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 #ifndef __SMART_ENCODER_H__ 20 #define __SMART_ENCODER_H__ 21 22 #include <gst/gst.h> 23 24 G_BEGIN_DECLS 25 26 #define GST_TYPE_SMART_ENCODER (gst_smart_encoder_get_type()) 27 G_DECLARE_FINAL_TYPE (GstSmartEncoder, gst_smart_encoder, GST, SMART_ENCODER, GstBin) 28 29 struct _GstSmartEncoder { 30 GstBin parent; 31 32 GstPad *sinkpad, *srcpad; 33 34 gboolean pushed_segment; 35 36 /* Segment received upstream */ 37 GstSegment input_segment; 38 39 /* The segment we pushed downstream */ 40 GstSegment output_segment; 41 42 /* Internal segments to compute buffers running time before pushing 43 * them downstream. It is the encoder segment when reecoding gops, 44 * and the input segment when pushing them unmodified. */ 45 GstSegment internal_segment; 46 GstClockTime last_dts; 47 48 GstCaps *original_caps; 49 gboolean push_original_caps; 50 GstEvent *segment_event; 51 GstEvent *stream_start_event; 52 53 /* Pending GOP to be checked */ 54 GList* pending_gop; 55 guint64 gop_start; /* GOP start PTS in the `input_segment` scale. */ 56 guint64 gop_stop; /* GOP end PTS in the `input_segment` scale. */ 57 58 /* Internal recoding elements */ 59 GstPad *internal_sinkpad; 60 GstPad *internal_srcpad; 61 GstElement *decoder; 62 GstElement *encoder; 63 64 GstFlowReturn internal_flow; 65 GMutex internal_flow_lock; 66 GCond internal_flow_cond; 67 }; 68 69 gboolean gst_smart_encoder_set_encoder (GstSmartEncoder *self, 70 GstCaps *format, 71 GstElement *encoder); 72 73 G_END_DECLS 74 75 #endif /* __SMART_ENCODER_H__ */ 76