Jonas Larsson | 78e38c6 | 2020-11-06 16:25:06 -0800 | [diff] [blame] | 1 | /* |
| 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 Larsson | 2d9a07b | 2020-11-16 17:28:20 -0800 | [diff] [blame] | 22 | #include <gst/gl/egl/gstegl.h> |
| 23 | #include "gst/gl/egl/gstgldisplay_egl.h" |
Jonas Larsson | 78e38c6 | 2020-11-06 16:25:06 -0800 | [diff] [blame] | 24 | #include <gst/gl/gstglfilter.h> |
| 25 | |
| 26 | G_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 | |
| 35 | typedef struct _GstGLSvgOverlay GstGLSvgOverlay; |
| 36 | typedef struct _GstGLSvgOverlayClass GstGLSvgOverlayClass; |
| 37 | typedef struct _TaskData TaskData; |
Jonas Larsson | 2d9a07b | 2020-11-16 17:28:20 -0800 | [diff] [blame] | 38 | typedef struct _EglImageTexture EglImageTexture; |
Jonas Larsson | 78e38c6 | 2020-11-06 16:25:06 -0800 | [diff] [blame] | 39 | |
| 40 | struct _GstGLSvgOverlay |
| 41 | { |
| 42 | GstGLFilter filter; |
| 43 | |
| 44 | GstGLContext *context; |
| 45 | GMutex mutex; |
| 46 | GCond cond; |
| 47 | GstGLShader *shader; |
| 48 | GThreadPool *thread_pool; |
Jonas Larsson | 2d9a07b | 2020-11-16 17:28:20 -0800 | [diff] [blame] | 49 | GstBufferPool *buffer_pool; |
| 50 | GstAllocator *ion_allocator; |
| 51 | gboolean use_ion; |
Jonas Larsson | 78e38c6 | 2020-11-06 16:25:06 -0800 | [diff] [blame] | 52 | 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 Larsson | 2d9a07b | 2020-11-16 17:28:20 -0800 | [diff] [blame] | 59 | gint internal_format; |
| 60 | GstVideoInfo info; |
Jonas Larsson | 78e38c6 | 2020-11-06 16:25:06 -0800 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | struct _GstGLSvgOverlayClass |
| 64 | { |
| 65 | GstGLFilterClass filter_class; |
| 66 | gboolean (*set_svg) (GstGLSvgOverlay *overlay, const gchar *svg, GstClockTime pts); |
| 67 | }; |
| 68 | |
| 69 | enum TaskOp |
| 70 | { |
| 71 | OP_ALLOC, |
| 72 | OP_DRAW, |
| 73 | OP_UPLOAD, |
| 74 | OP_READY, |
| 75 | }; |
| 76 | |
Jonas Larsson | 2d9a07b | 2020-11-16 17:28:20 -0800 | [diff] [blame] | 77 | struct _EglImageTexture { |
| 78 | GstGLSvgOverlay *overlay; |
| 79 | EGLImageKHR *image; |
| 80 | guint tex; |
| 81 | }; |
| 82 | |
Jonas Larsson | 78e38c6 | 2020-11-06 16:25:06 -0800 | [diff] [blame] | 83 | struct _TaskData { |
| 84 | GstGLSvgOverlay *overlay; |
| 85 | enum TaskOp op; |
| 86 | gchar *svg; |
| 87 | GstClockTime pts; |
| 88 | GstBuffer *buf; |
| 89 | GstMapInfo map; |
Jonas Larsson | 2d9a07b | 2020-11-16 17:28:20 -0800 | [diff] [blame] | 90 | EglImageTexture *egl_tex; |
Jonas Larsson | 78e38c6 | 2020-11-06 16:25:06 -0800 | [diff] [blame] | 91 | guint tex; |
| 92 | }; |
| 93 | |
| 94 | GType gst_gl_svg_overlay_get_type (void); |
| 95 | |
| 96 | G_END_DECLS |
| 97 | |
| 98 | #endif /* _GST_GLSVGOVERLAY_H */ |