summaryrefslogtreecommitdiff
path: root/gst/encoding/gstsmartencoder.h
blob: 71e79011f9e6f10bcb2e84114ce519c674291c74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* 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__ */