Added exception handling for null buffer
[platform/upstream/gstreamer.git] / omx / gstomxvideoenc.h
1 /*
2  * Copyright (C) 2011, Hewlett-Packard Development Company, L.P.
3  *   Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>, Collabora Ltd.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation
8  * version 2.1 of the License.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
18  *
19  */
20
21 #ifndef __GST_OMX_VIDEO_ENC_H__
22 #define __GST_OMX_VIDEO_ENC_H__
23
24 #include <gst/gst.h>
25 #include <gst/video/video.h>
26 #include <gst/video/gstvideoencoder.h>
27 #include <tbm_bufmgr.h>
28
29 #include "gstomx.h"
30
31 G_BEGIN_DECLS
32
33 #define GST_TYPE_OMX_VIDEO_ENC \
34   (gst_omx_video_enc_get_type())
35 #define GST_OMX_VIDEO_ENC(obj) \
36   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OMX_VIDEO_ENC,GstOMXVideoEnc))
37 #define GST_OMX_VIDEO_ENC_CLASS(klass) \
38   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OMX_VIDEO_ENC,GstOMXVideoEncClass))
39 #define GST_OMX_VIDEO_ENC_GET_CLASS(obj) \
40   (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_OMX_VIDEO_ENC,GstOMXVideoEncClass))
41 #define GST_IS_OMX_VIDEO_ENC(obj) \
42   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OMX_VIDEO_ENC))
43 #define GST_IS_OMX_VIDEO_ENC_CLASS(obj) \
44   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OMX_VIDEO_ENC))
45
46 typedef struct _GstOMXVideoEnc GstOMXVideoEnc;
47 typedef struct _GstOMXVideoEncClass GstOMXVideoEncClass;
48
49 struct _GstOMXVideoEnc
50 {
51   GstVideoEncoder parent;
52
53   /* < protected > */
54   GstOMXComponent *enc;
55   GstOMXPort *enc_in_port, *enc_out_port;
56
57   /* < private > */
58   GstVideoCodecState *input_state;
59   /* TRUE if the component is configured and saw
60    * the first buffer */
61   gboolean started;
62
63   GstClockTime last_upstream_ts;
64
65   /* Draining state */
66   GMutex drain_lock;
67   GCond drain_cond;
68   /* TRUE if EOS buffers shouldn't be forwarded */
69   gboolean draining;
70
71   /* properties */
72   guint32 control_rate;
73   guint32 target_bitrate;
74   guint32 quant_i_frames;
75   guint32 quant_p_frames;
76   guint32 quant_b_frames;
77
78   GstFlowReturn downstream_flow_ret;
79 #ifdef TIZEN_FEATURE_OMX
80   gint drm_fd;
81   tbm_bufmgr bufmgr;
82 #endif
83 };
84
85 struct _GstOMXVideoEncClass
86 {
87   GstVideoEncoderClass parent_class;
88
89   GstOMXClassData cdata;
90
91   gboolean            (*set_format)          (GstOMXVideoEnc * self, GstOMXPort * port, GstVideoCodecState * state);
92   GstCaps            *(*get_caps)           (GstOMXVideoEnc * self, GstOMXPort * port, GstVideoCodecState * state);
93   GstFlowReturn       (*handle_output_frame) (GstOMXVideoEnc * self, GstOMXPort * port, GstOMXBuffer * buffer, GstVideoCodecFrame * frame);
94 };
95
96 GType gst_omx_video_enc_get_type (void);
97
98 G_END_DECLS
99
100 #endif /* __GST_OMX_VIDEO_ENC_H__ */