• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012, Collabora Ltd.
3  *   Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
4  *
5  * Copyright (C) 2013, Lemote Ltd.
6  *   Author: Chen Jie <chenj@lemote.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation
11  * version 2.1 of the License.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
21  *
22  */
23 
24 #ifndef __GST_AMC_VIDEO_ENC_H__
25 #define __GST_AMC_VIDEO_ENC_H__
26 
27 #include <gst/gst.h>
28 
29 #include <gst/video/gstvideoencoder.h>
30 
31 #include "gstamc.h"
32 
33 G_BEGIN_DECLS
34 
35 #define GST_TYPE_AMC_VIDEO_ENC \
36   (gst_amc_video_enc_get_type())
37 #define GST_AMC_VIDEO_ENC(obj) \
38   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AMC_VIDEO_ENC,GstAmcVideoEnc))
39 #define GST_AMC_VIDEO_ENC_CLASS(klass) \
40   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AMC_VIDEO_ENC,GstAmcVideoEncClass))
41 #define GST_AMC_VIDEO_ENC_GET_CLASS(obj) \
42   (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_AMC_VIDEO_ENC,GstAmcVideoEncClass))
43 #define GST_IS_AMC_VIDEO_ENC(obj) \
44   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AMC_VIDEO_ENC))
45 #define GST_IS_AMC_VIDEO_ENC_CLASS(obj) \
46   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AMC_VIDEO_ENC))
47 typedef struct _GstAmcVideoEnc GstAmcVideoEnc;
48 typedef struct _GstAmcVideoEncClass GstAmcVideoEncClass;
49 
50 struct _GstAmcVideoEnc
51 {
52   GstVideoEncoder parent;
53 
54   /* < private > */
55   GMutex codec_lock; // Protect creation / destruction of the codec
56   GstAmcCodec *codec;
57   GstAmcFormat *amc_format;
58 
59   /* Set to TRUE if codec headers should be placed
60    * in the stream, or FALSE if they go in the headers */
61   gboolean codec_data_in_bytestream;
62 
63   GstVideoCodecState *input_state;
64 
65   /* Input format of the codec */
66   GstVideoFormat format;
67   GstAmcColorFormatInfo color_format_info;
68 
69   guint bitrate;
70   gfloat i_frame_int;
71 
72   /* TRUE if the component is configured and saw
73    * the first buffer */
74   gboolean started;
75   gboolean flushing;
76 
77   GstClockTime last_upstream_ts;
78 
79   /* Draining state */
80   GMutex drain_lock;
81   GCond drain_cond;
82   /* TRUE if EOS buffers shouldn't be forwarded */
83   gboolean draining;
84   /* TRUE if the component is drained */
85   gboolean drained;
86 
87   GstFlowReturn downstream_flow_ret;
88 };
89 
90 struct _GstAmcVideoEncClass
91 {
92   GstVideoEncoderClass parent_class;
93 
94   const GstAmcCodecInfo *codec_info;
95 };
96 
97 GType gst_amc_video_enc_get_type (void);
98 
99 G_END_DECLS
100 
101 #endif /* __GST_AMC_VIDEO_ENC_H__ */
102