1 /*
2  * Copyright (C) 2013, Fluendo S.A.
3  *   Author: Andoni Morales <amorales@fluendo.com>
4  *
5  * Copyright (C) 2014, Collabora Ltd.
6  *   Author: Matthieu Bouron <matthieu.bouron@collabora.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation
11  * version 2.1 of the License.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
21  *
22  */
23 
24 #ifndef __GST_AMC_SURFACE_TEXTURE_H__
25 #define __GST_AMC_SURFACE_TEXTURE_H__
26 
27 #include <glib.h>
28 #include <glib-object.h>
29 #include <jni.h>
30 
31 G_BEGIN_DECLS
32 
33 #define GST_TYPE_AMC_SURFACE_TEXTURE                  (gst_amc_surface_texture_get_type ())
34 #define GST_AMC_SURFACE_TEXTURE(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_AMC_SURFACE_TEXTURE, GstAmcSurfaceTexture))
35 #define GST_IS_AMC_SURFACE_TEXTURE(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_AMC_SURFACE_TEXTURE))
36 #define GST_AMC_SURFACE_TEXTURE_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_AMC_SURFACE_TEXTURE, GstAmcSurfaceTextureClass))
37 #define GST_IS_AMC_SURFACE_TEXTURE_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_AMC_SURFACE_TEXTURE))
38 #define GST_AMC_SURFACE_TEXTURE_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AMC_SURFACE_TEXTURE, GstAmcSurfaceTextureClass))
39 
40 typedef struct _GstAmcSurfaceTexture        GstAmcSurfaceTexture;
41 typedef struct _GstAmcSurfaceTextureClass   GstAmcSurfaceTextureClass;
42 
43 struct _GstAmcSurfaceTexture
44 {
45   GObject parent_instance;
46 
47   /* instance members */
48   gint texture_id;
49   jobject jobject;
50 };
51 
52 struct _GstAmcSurfaceTextureClass
53 {
54   GObjectClass parent_class;
55 
56   /* class members */
57   gint texture_id;
58 
59   jclass jklass;
60   jmethodID constructor;
61   jmethodID set_on_frame_available_listener;
62   jmethodID set_default_buffer_size;
63   jmethodID update_tex_image;
64   jmethodID detach_from_gl_context;
65   jmethodID attach_to_gl_context;
66   jmethodID get_transform_matrix;
67   jmethodID get_timestamp;
68   jmethodID release;
69 };
70 
71 GType gst_amc_surface_texture_get_type                   (void);
72 
73 GstAmcSurfaceTexture * gst_amc_surface_texture_new       (GError ** err);
74 
75 gboolean gst_amc_surface_texture_set_default_buffer_size (GstAmcSurfaceTexture *texture,
76                                                          gint width,
77                                                          gint height,
78                                                          GError ** err);
79 
80 gboolean gst_amc_surface_texture_update_tex_image        (GstAmcSurfaceTexture *texture,
81                                                          GError ** err);
82 
83 gboolean gst_amc_surface_texture_detach_from_gl_context  (GstAmcSurfaceTexture *texture,
84                                                          GError ** err);
85 
86 gboolean gst_amc_surface_texture_attach_to_gl_context    (GstAmcSurfaceTexture *texture,
87                                                          gint index,
88                                                          GError ** err);
89 
90 gboolean gst_amc_surface_texture_get_transform_matrix    (GstAmcSurfaceTexture *texture,
91                                                          const gfloat *matrix,
92                                                          GError ** err);
93 
94 gboolean gst_amc_surface_texture_get_timestamp           (GstAmcSurfaceTexture *texture,
95                                                          gint64 * result,
96                                                          GError ** err);
97 
98 gboolean gst_amc_surface_texture_release                 (GstAmcSurfaceTexture *texture,
99                                                          GError ** err);
100 
101 gboolean gst_amc_surface_texture_set_on_frame_available_listener (GstAmcSurfaceTexture * self,
102                                                                  jobject listener,
103                                                                  GError ** err);
104 
105 G_END_DECLS
106 #endif
107