blob: 5e71d49c584b96486690ba0566158934e9e93688 [file] [log] [blame]
Jonas Larsson78e38c62020-11-06 16:25:06 -08001/*
2 * # Copyright 2020 Google LLC
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _GST_GLSVGOVERLAY_H
18#define _GST_GLSVGOVERLAY_H
19
20#include <gst/gst.h>
21
Jonas Larsson2d9a07b2020-11-16 17:28:20 -080022#include <gst/gl/egl/gstegl.h>
23#include "gst/gl/egl/gstgldisplay_egl.h"
Jonas Larsson78e38c62020-11-06 16:25:06 -080024#include <gst/gl/gstglfilter.h>
25
26G_BEGIN_DECLS
27
28#define GST_TYPE_GL_SVG_OVERLAY (gst_gl_svg_overlay_get_type())
29#define GST_GL_SVG_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_SVG_OVERLAY,GstGLSvgOverlay))
30#define GST_IS_GL_SVG_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_SVG_OVERLAY))
31#define GST_GL_SVG_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_GL_SVG_OVERLAY,GstGLSvgOverlayClass))
32#define GST_IS_GL_SVG_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_GL_SVG_OVERLAY))
33#define GST_GL_SVG_OVERLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_GL_SVG_OVERLAY,GstGLSvgOverlayClass))
34
35typedef struct _GstGLSvgOverlay GstGLSvgOverlay;
36typedef struct _GstGLSvgOverlayClass GstGLSvgOverlayClass;
37typedef struct _TaskData TaskData;
Jonas Larsson2d9a07b2020-11-16 17:28:20 -080038typedef struct _EglImageTexture EglImageTexture;
Jonas Larsson78e38c62020-11-06 16:25:06 -080039
40struct _GstGLSvgOverlay
41{
42 GstGLFilter filter;
43
44 GstGLContext *context;
45 GMutex mutex;
46 GCond cond;
47 GstGLShader *shader;
48 GThreadPool *thread_pool;
Jonas Larsson2d9a07b2020-11-16 17:28:20 -080049 GstBufferPool *buffer_pool;
50 GstAllocator *ion_allocator;
51 gboolean use_ion;
Jonas Larsson78e38c62020-11-06 16:25:06 -080052 GQueue *svg_queue;
53 GQueue *gl_queue;
54 GstClockTime next_pts;
55 guint num_tasks;
56 TaskData *current;
57 gboolean sync;
58 gboolean started;
Jonas Larsson2d9a07b2020-11-16 17:28:20 -080059 gint internal_format;
60 GstVideoInfo info;
Jonas Larsson78e38c62020-11-06 16:25:06 -080061};
62
63struct _GstGLSvgOverlayClass
64{
65 GstGLFilterClass filter_class;
66 gboolean (*set_svg) (GstGLSvgOverlay *overlay, const gchar *svg, GstClockTime pts);
67};
68
69enum TaskOp
70{
71 OP_ALLOC,
72 OP_DRAW,
73 OP_UPLOAD,
74 OP_READY,
75};
76
Jonas Larsson2d9a07b2020-11-16 17:28:20 -080077struct _EglImageTexture {
78 GstGLSvgOverlay *overlay;
79 EGLImageKHR *image;
80 guint tex;
81};
82
Jonas Larsson78e38c62020-11-06 16:25:06 -080083struct _TaskData {
84 GstGLSvgOverlay *overlay;
85 enum TaskOp op;
86 gchar *svg;
87 GstClockTime pts;
88 GstBuffer *buf;
89 GstMapInfo map;
Jonas Larsson2d9a07b2020-11-16 17:28:20 -080090 EglImageTexture *egl_tex;
Jonas Larsson78e38c62020-11-06 16:25:06 -080091 guint tex;
92};
93
94GType gst_gl_svg_overlay_get_type (void);
95
96G_END_DECLS
97
98#endif /* _GST_GLSVGOVERLAY_H */