• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 guint             gst_v4l2_decoder_get_version (GstV4l2Decoder * self);
39 
40 gboolean          gst_v4l2_decoder_open (GstV4l2Decoder * decoder);
41 
42 gboolean          gst_v4l2_decoder_close (GstV4l2Decoder * decoder);
43 
44 gboolean          gst_v4l2_decoder_streamon (GstV4l2Decoder * self,
45                                              GstPadDirection direction);
46 
47 gboolean          gst_v4l2_decoder_streamoff (GstV4l2Decoder * self,
48                                               GstPadDirection direction);
49 
50 gboolean          gst_v4l2_decoder_flush (GstV4l2Decoder * self);
51 
52 gboolean          gst_v4l2_decoder_enum_sink_fmt (GstV4l2Decoder * self,
53                                                   gint i, guint32 * out_fmt);
54 
55 gboolean          gst_v4l2_decoder_set_sink_fmt (GstV4l2Decoder * self, guint32 fmt,
56                                                  gint width, gint height,
57                                                  gint pixel_bitdepth);
58 
59 GstCaps *         gst_v4l2_decoder_enum_src_formats (GstV4l2Decoder * self);
60 
61 gboolean          gst_v4l2_decoder_select_src_format (GstV4l2Decoder * self,
62                                                       GstCaps * caps,
63                                                       GstVideoInfo * info);
64 
65 gint              gst_v4l2_decoder_request_buffers (GstV4l2Decoder * self,
66                                                     GstPadDirection direction,
67                                                     guint num_buffers);
68 
69 gboolean          gst_v4l2_decoder_export_buffer (GstV4l2Decoder * self,
70                                                   GstPadDirection directon,
71                                                   gint index,
72                                                   gint * fds,
73                                                   gsize * sizes,
74                                                   gsize * offsets,
75                                                   guint *num_fds);
76 
77 gboolean          gst_v4l2_decoder_set_controls (GstV4l2Decoder * self,
78                                                  GstV4l2Request * request,
79                                                  struct v4l2_ext_control *control,
80                                                  guint count);
81 
82 gboolean          gst_v4l2_decoder_get_controls (GstV4l2Decoder * self,
83                                                  struct v4l2_ext_control * control,
84                                                  guint count);
85 
86 gboolean          gst_v4l2_decoder_query_control_size (GstV4l2Decoder * self,
87                                                  unsigned int control_id,
88 						 unsigned int *control_size);
89 
90 void              gst_v4l2_decoder_install_properties (GObjectClass * gobject_class,
91                                                        gint prop_offset,
92                                                        GstV4l2CodecDevice * device);
93 
94 void              gst_v4l2_decoder_set_property (GObject * object, guint prop_id,
95                                                  const GValue * value, GParamSpec * pspec);
96 
97 void              gst_v4l2_decoder_get_property (GObject * object, guint prop_id,
98                                                  GValue * value, GParamSpec * pspec);
99 
100 void              gst_v4l2_decoder_register (GstPlugin * plugin,
101                                              GType dec_type,
102                                              GClassInitFunc class_init,
103                                              gconstpointer class_data,
104                                              GInstanceInitFunc instance_init,
105                                              const gchar *element_name_tmpl,
106                                              GstV4l2CodecDevice * device,
107                                              guint rank,
108                                              gchar ** element_name);
109 
110 GstV4l2Request   *gst_v4l2_decoder_alloc_request (GstV4l2Decoder * self,
111                                                   guint32 frame_num,
112                                                   GstMemory *bitstream,
113                                                   GstBuffer * pic_buf);
114 
115 GstV4l2Request   *gst_v4l2_decoder_alloc_sub_request (GstV4l2Decoder * self,
116                                                       GstV4l2Request * prev_request,
117                                                       GstMemory *bitstream);
118 
119 void              gst_v4l2_decoder_set_render_delay (GstV4l2Decoder * self,
120                                                      guint delay);
121 
122 guint             gst_v4l2_decoder_get_render_delay (GstV4l2Decoder * self);
123 
124 
125 GstV4l2Request *  gst_v4l2_request_ref (GstV4l2Request * request);
126 
127 void              gst_v4l2_request_unref (GstV4l2Request * request);
128 
129 gboolean          gst_v4l2_request_queue (GstV4l2Request * request,
130                                           guint flags);
131 
132 gint              gst_v4l2_request_poll (GstV4l2Request * request,
133                                          GstClockTime timeout);
134 
135 gint              gst_v4l2_request_set_done (GstV4l2Request * request);
136 
137 gboolean          gst_v4l2_request_failed (GstV4l2Request * request);
138 
139 GstBuffer *       gst_v4l2_request_dup_pic_buf (GstV4l2Request * request);
140 
141 G_END_DECLS
142 
143 #endif /* __GST_V4L2_DECODER_H__ */
144