v4l2slh264dec: Add output format negotiation
[platform/upstream/gstreamer.git] / sys / v4l2codecs / gstv4l2decoder.h
1 /* GStreamer
2  * Copyright (C) 2020 Nicolas Dufresne <nicolas.dufresne@collabora.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
20 #ifndef __GST_V4L2_DECODER_H__
21 #define __GST_V4L2_DECODER_H__
22
23 #include <gst/gst.h>
24 #include <gst/video/video.h>
25
26 #include "gstv4l2codecdevice.h"
27 #include "linux/videodev2.h"
28
29 G_BEGIN_DECLS
30
31 #define GST_TYPE_V4L2_DECODER gst_v4l2_decoder_get_type ()
32 G_DECLARE_FINAL_TYPE (GstV4l2Decoder, gst_v4l2_decoder, GST, V4L2_DECODER, GstObject);
33
34 typedef struct _GstV4l2Request GstV4l2Request;
35
36 GstV4l2Decoder *  gst_v4l2_decoder_new (GstV4l2CodecDevice * device);
37
38 gboolean          gst_v4l2_decoder_open (GstV4l2Decoder * decoder);
39
40 gboolean          gst_v4l2_decoder_close (GstV4l2Decoder * decoder);
41
42 gboolean          gst_v4l2_decoder_streamon (GstV4l2Decoder * self,
43                                              GstPadDirection direction);
44
45 gboolean          gst_v4l2_decoder_streamoff (GstV4l2Decoder * self,
46                                               GstPadDirection direction);
47
48 gboolean          gst_v4l2_decoder_enum_sink_fmt (GstV4l2Decoder * self,
49                                                   gint i, guint32 * out_fmt);
50
51 gboolean          gst_v4l2_decoder_set_sink_fmt (GstV4l2Decoder * self, guint32 fmt,
52                                                  gint width, gint height);
53
54 GstCaps *         gst_v4l2_decoder_enum_src_formats (GstV4l2Decoder * self);
55
56 gboolean          gst_v4l2_decoder_select_src_format (GstV4l2Decoder * self,
57                                                       GstCaps * caps,
58                                                       GstVideoInfo * info);
59
60 gint              gst_v4l2_decoder_request_buffers (GstV4l2Decoder * self,
61                                                     GstPadDirection direction,
62                                                     guint num_buffers);
63
64 gboolean          gst_v4l2_decoder_export_buffer (GstV4l2Decoder * self,
65                                                   GstPadDirection directon,
66                                                   gint index,
67                                                   gint * fds,
68                                                   gsize * sizes,
69                                                   gsize * offsets,
70                                                   guint *num_fds);
71
72 gboolean          gst_v4l2_decoder_queue_sink_mem (GstV4l2Decoder * self,
73                                                    GstV4l2Request * request,
74                                                    GstMemory * mem,
75                                                    guint32 frame_num,
76                                                    gsize bytesused);
77
78 gboolean          gst_v4l2_decoder_dequeue_sink (GstV4l2Decoder * self);
79
80 gboolean          gst_v4l2_decoder_queue_src_buffer (GstV4l2Decoder * self,
81                                                      GstBuffer * buffer,
82                                                      guint32 frame_num);
83
84 gboolean          gst_v4l2_decoder_dequeue_src (GstV4l2Decoder * self,
85                                                 guint32 *out_frame_num);
86
87 gboolean          gst_v4l2_decoder_set_controls (GstV4l2Decoder * self,
88                                                  GstV4l2Request * request,
89                                                  struct v4l2_ext_control *control,
90                                                  guint count);
91
92 void              gst_v4l2_decoder_install_properties (GObjectClass * gobject_class,
93                                                        gint prop_offset,
94                                                        GstV4l2CodecDevice * device);
95
96 void              gst_v4l2_decoder_set_property (GObject * object, guint prop_id,
97                                                  const GValue * value, GParamSpec * pspec);
98
99 void              gst_v4l2_decoder_get_property (GObject * object, guint prop_id,
100                                                  GValue * value, GParamSpec * pspec);
101
102 GstV4l2Request   *gst_v4l2_decoder_alloc_request (GstV4l2Decoder * self);
103
104 void              gst_v4l2_request_free (GstV4l2Request * request);
105
106 gboolean          gst_v4l2_request_queue (GstV4l2Request * request);
107
108 gint              gst_v4l2_request_poll (GstV4l2Request * request, GstClockTime timeout);
109
110 void              gst_v4l2_request_set_done (GstV4l2Request * request);
111
112 gboolean          gst_v4l2_request_is_done (GstV4l2Request * request);
113
114 G_END_DECLS
115
116 #endif /* __GST_V4L2_DECODER_H__ */