summaryrefslogtreecommitdiff
path: root/sys/v4l2codecs/gstv4l2decoder.h
blob: 0d32e31c5ed078c2ac2099de24360a0dcb6413db (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* GStreamer
 * Copyright (C) 2020 Nicolas Dufresne <nicolas.dufresne@collabora.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 __GST_V4L2_DECODER_H__
#define __GST_V4L2_DECODER_H__

#include <gst/gst.h>
#include <gst/video/video.h>

#include "gstv4l2codecdevice.h"
#include "linux/videodev2.h"

G_BEGIN_DECLS

#define GST_TYPE_V4L2_DECODER gst_v4l2_decoder_get_type ()
G_DECLARE_FINAL_TYPE (GstV4l2Decoder, gst_v4l2_decoder, GST, V4L2_DECODER, GstObject);

typedef struct _GstV4l2Request GstV4l2Request;

GstV4l2Decoder *  gst_v4l2_decoder_new (GstV4l2CodecDevice * device);

gboolean          gst_v4l2_decoder_open (GstV4l2Decoder * decoder);

gboolean          gst_v4l2_decoder_close (GstV4l2Decoder * decoder);

gboolean          gst_v4l2_decoder_streamon (GstV4l2Decoder * self,
                                             GstPadDirection direction);

gboolean          gst_v4l2_decoder_streamoff (GstV4l2Decoder * self,
                                              GstPadDirection direction);

gboolean          gst_v4l2_decoder_flush (GstV4l2Decoder * self);

gboolean          gst_v4l2_decoder_enum_sink_fmt (GstV4l2Decoder * self,
                                                  gint i, guint32 * out_fmt);

gboolean          gst_v4l2_decoder_set_sink_fmt (GstV4l2Decoder * self, guint32 fmt,
                                                 gint width, gint height,
                                                 gint pixel_bitdepth);

GstCaps *         gst_v4l2_decoder_enum_src_formats (GstV4l2Decoder * self);

gboolean          gst_v4l2_decoder_select_src_format (GstV4l2Decoder * self,
                                                      GstCaps * caps,
                                                      GstVideoInfo * info);

gint              gst_v4l2_decoder_request_buffers (GstV4l2Decoder * self,
                                                    GstPadDirection direction,
                                                    guint num_buffers);

gboolean          gst_v4l2_decoder_export_buffer (GstV4l2Decoder * self,
                                                  GstPadDirection directon,
                                                  gint index,
                                                  gint * fds,
                                                  gsize * sizes,
                                                  gsize * offsets,
                                                  guint *num_fds);

gboolean          gst_v4l2_decoder_queue_sink_mem (GstV4l2Decoder * self,
                                                   GstV4l2Request * request,
                                                   GstMemory * mem,
                                                   guint32 frame_num,
                                                   gsize bytesused,
                                                   guint flags);

gboolean          gst_v4l2_decoder_dequeue_sink (GstV4l2Decoder * self);

gboolean          gst_v4l2_decoder_queue_src_buffer (GstV4l2Decoder * self,
                                                     GstBuffer * buffer,
                                                     guint32 frame_num);

gboolean          gst_v4l2_decoder_dequeue_src (GstV4l2Decoder * self,
                                                guint32 *out_frame_num);

gboolean          gst_v4l2_decoder_set_controls (GstV4l2Decoder * self,
                                                 GstV4l2Request * request,
                                                 struct v4l2_ext_control *control,
                                                 guint count);

gboolean          gst_v4l2_decoder_get_controls (GstV4l2Decoder * self,
                                                 struct v4l2_ext_control * control,
                                                 guint count);

void              gst_v4l2_decoder_install_properties (GObjectClass * gobject_class,
                                                       gint prop_offset,
                                                       GstV4l2CodecDevice * device);

void              gst_v4l2_decoder_set_property (GObject * object, guint prop_id,
                                                 const GValue * value, GParamSpec * pspec);

void              gst_v4l2_decoder_get_property (GObject * object, guint prop_id,
                                                 GValue * value, GParamSpec * pspec);

void              gst_v4l2_decoder_register (GstPlugin * plugin,
                                             GType dec_type,
                                             GClassInitFunc class_init,
                                             GInstanceInitFunc instance_init,
                                             const gchar *element_name_tmpl,
                                             GstV4l2CodecDevice * device,
                                             guint rank);

GstV4l2Request   *gst_v4l2_decoder_alloc_request (GstV4l2Decoder * self);

void              gst_v4l2_request_free (GstV4l2Request * request);

gboolean          gst_v4l2_request_queue (GstV4l2Request * request);

gint              gst_v4l2_request_poll (GstV4l2Request * request, GstClockTime timeout);

void              gst_v4l2_request_set_done (GstV4l2Request * request);

gboolean          gst_v4l2_request_is_done (GstV4l2Request * request);

G_END_DECLS

#endif /* __GST_V4L2_DECODER_H__ */