forked from honkasuo/gst-sh-mobile
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgstshvideodec.h
204 lines (158 loc) · 5.47 KB
/
gstshvideodec.h
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/**
* gst-sh-mobile-dec-sink
*
* 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 Street, Fifth Floor, Boston MA 02110-1301 USA
*
* @author Pablo Virolainen <[email protected]>
* @author Johannes Lahti <[email protected]>
* @author Aki Honkasuo <[email protected]>
*
*/
#ifndef GSTSHVIDEODEC_H
#define GSTSHVIDEODEC_H
#include <gst/gst.h>
#include <gst/video/gstvideosink.h>
#include <gst/gstelement.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
G_BEGIN_DECLS
#define GST_TYPE_SHVIDEODEC \
(gst_shvideodec_get_type())
#define GST_SHVIDEODEC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SHVIDEODEC,Gstshvideodec))
#define GST_SHVIDEODEC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SHVIDEODEC,Gstshvideodec))
#define GST_IS_SHVIDEODEC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SHVIDEODEC))
#define GST_IS_SHVIDEODEC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SHVIDEODEC))
typedef struct _Gstshvideodec Gstshvideodec;
typedef struct _GstshvideodecClass GstshvideodecClass;
#include <shcodecs/shcodecs_decoder.h>
/**
* Define Gstreamer SH Video Decoder structure
*/
struct _Gstshvideodec
{
GstElement element;
GstPad *sinkpad;
/* Input stream */
SHCodecs_Format format;
gint width;
gint height;
gint fps_numerator;
gint fps_denominator;
SHCodecs_Decoder * decoder;
/* Needed? */
gboolean caps_set;
gboolean first_frame;
/* Output */
int output_fd; /* Debug */
gint dst_width;
gint dst_height;
gint dst_x;
gint dst_y;
/* Buffer for data that hasn't been consumed yet */
GstBuffer* pcache;
GstClockTime playback_timestamp;
gint playback_played;
GstClock* clock;
GstClockTime first_timestamp;
GstClockTime current_timestamp;
GstClockTime start_time;
};
/**
* Define Gstreamer SH Video Decoder Class structure
*/
struct _GstshvideodecClass
{
GstElementClass parent;
};
/** Initialize shvideodec class plugin event handler
@param g_class Gclass
@param data user data pointer, unused in the function
*/
static void gst_shvideodec_init_class (gpointer g_class, gpointer data);
/** Get gst-sh-mobile-dec-sink object type
@return object type
*/
GType gst_shvideodec_get_type (void);
/** Initialize SH hardware video decoder & sink
@param klass Gstreamer element class
*/
static void gst_shvideodec_base_init (gpointer klass);
/** Dispose decoder
@param object Gstreamer element class
*/
static void gst_shvideodec_dispose (GObject * object);
/** Initialize the class for decoder and player
@param klass Gstreamer SH video decodes class
*/
static void gst_shvideodec_class_init (GstshvideodecClass * klass);
/** Initialize the decoder
@param dec Gstreamer SH video element
@param gklass Gstreamer SH video decode class
*/
static void gst_shvideodec_init (Gstshvideodec * dec, GstshvideodecClass * gklass);
/** Sets the clock for the element
@param element GStreamer element
@param clock the used clock. If NULL we use system clock
@return Returns true if clock was accepted
*/
static gboolean
gst_shvideodec_set_clock (GstElement *element, GstClock *clock);
/** Event handler for decoder sink events
@param pad Gstreamer sink pad
@param event The Gstreamer event
@return returns true if the event can be handled, else false
*/
static gboolean gst_shvideodec_sink_event (GstPad * pad, GstEvent * event);
/** Initialize the decoder sink pad
@param pad Gstreamer sink pad
@param caps The capabilities of the video to decode
@return returns true if the video capatilies are supported and the video can be decoded, else false
*/
static gboolean gst_shvideodec_setcaps (GstPad * pad, GstCaps * caps);
/** GStreamer buffer handling function
@param pad Gstreamer sink pad
@param inbuffer The input buffer
@return returns GST_FLOW_OK if buffer handling was successful. Otherwise GST_FLOW_UNEXPECTED
*/
static GstFlowReturn gst_shvideodec_chain (GstPad * pad, GstBuffer * inbuffer);
/** The video input buffer decode function
@param data decoder object
*/
void* gst_shvideodec_decode (void *data);
/** Initialize the decoder sink
@param plugin Gstreamer plugin
@return returns true if plugin initialized, else false
*/
gboolean gst_shvideo_dec_plugin_init (GstPlugin * plugin);
/** Event handler for the video frame is decoded and can be shown on screen
@param decoder SHCodecs Decoder, unused in the function
@param y_buf Userland address to the Y buffer
@param y_size Size of the Y buffer
@param c_buf Userland address to teh C buffer
@param c_size Size of the C buffer
@param user_data Contains Gstshvideodec
@return The result of passing data to a pad
*/
static int gst_shcodecs_decoded_callback (SHCodecs_Decoder * decoder,
unsigned char * y_buf, int y_size,
unsigned char * c_buf, int c_size,
void * user_data);
G_END_DECLS
#endif