mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 14:08:56 +00:00
dwrite: Add GstDWriteSubtitleMeta
dwrite plugin internal use and will be removed once it's added to -base Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4934>
This commit is contained in:
parent
7445b73e76
commit
fce6edd0f1
2 changed files with 121 additions and 1 deletions
|
@ -24,6 +24,102 @@
|
||||||
#include <gst/d3d11/gstd3d11.h>
|
#include <gst/d3d11/gstd3d11.h>
|
||||||
#include "gstdwrite-utils.h"
|
#include "gstdwrite-utils.h"
|
||||||
|
|
||||||
|
GType
|
||||||
|
gst_dwrite_subtitle_meta_api_get_type (void)
|
||||||
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
static const gchar *tags[] = { NULL, };
|
||||||
|
|
||||||
|
GST_DWRITE_CALL_ONCE_BEGIN {
|
||||||
|
type = gst_meta_api_type_register ("GstDWriteSubtitleMetaAPI", tags);
|
||||||
|
} GST_DWRITE_CALL_ONCE_END;
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_dwrite_subtitle_meta_init (GstMeta * meta, gpointer params,
|
||||||
|
GstBuffer * buffer)
|
||||||
|
{
|
||||||
|
GstDWriteSubtitleMeta *m = (GstDWriteSubtitleMeta *) meta;
|
||||||
|
|
||||||
|
m->stream = NULL;
|
||||||
|
m->subtitle = NULL;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_dwrite_subtitle_meta_free (GstMeta * meta, GstBuffer * buffer)
|
||||||
|
{
|
||||||
|
GstDWriteSubtitleMeta *m = (GstDWriteSubtitleMeta *) meta;
|
||||||
|
|
||||||
|
if (m->stream)
|
||||||
|
gst_object_unref (m->stream);
|
||||||
|
|
||||||
|
if (m->subtitle)
|
||||||
|
gst_buffer_unref (m->subtitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_dwrite_subtitle_meta_transform (GstBuffer * dest, GstMeta * meta,
|
||||||
|
GstBuffer * buffer, GQuark type, gpointer data)
|
||||||
|
{
|
||||||
|
GstDWriteSubtitleMeta *dmeta, *smeta;
|
||||||
|
|
||||||
|
if (GST_META_TRANSFORM_IS_COPY (type)) {
|
||||||
|
smeta = (GstDWriteSubtitleMeta *) meta;
|
||||||
|
|
||||||
|
dmeta = gst_buffer_add_dwrite_subtitle_meta (dest,
|
||||||
|
smeta->stream, smeta->subtitle);
|
||||||
|
if (!dmeta)
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
const GstMetaInfo *
|
||||||
|
gst_dwrite_subtitle_meta_get_info (void)
|
||||||
|
{
|
||||||
|
static const GstMetaInfo *info = NULL;
|
||||||
|
|
||||||
|
GST_DWRITE_CALL_ONCE_BEGIN {
|
||||||
|
info = gst_meta_register (GST_DWRITE_SUBTITLE_META_API_TYPE,
|
||||||
|
"GstDWriteSubtitleMeta",
|
||||||
|
sizeof (GstDWriteSubtitleMeta),
|
||||||
|
gst_dwrite_subtitle_meta_init,
|
||||||
|
gst_dwrite_subtitle_meta_free, gst_dwrite_subtitle_meta_transform);
|
||||||
|
}
|
||||||
|
GST_DWRITE_CALL_ONCE_END;
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
GstDWriteSubtitleMeta *
|
||||||
|
gst_buffer_add_dwrite_subtitle_meta (GstBuffer * buffer, GstStream * stream,
|
||||||
|
GstBuffer * subtitle)
|
||||||
|
{
|
||||||
|
GstDWriteSubtitleMeta *meta;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
|
||||||
|
g_return_val_if_fail (GST_IS_STREAM (stream), NULL);
|
||||||
|
g_return_val_if_fail (GST_IS_BUFFER (subtitle), NULL);
|
||||||
|
|
||||||
|
meta = (GstDWriteSubtitleMeta *) gst_buffer_add_meta (buffer,
|
||||||
|
GST_DWRITE_SUBTITLE_META_INFO, NULL);
|
||||||
|
|
||||||
|
if (!meta)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
meta->stream = (GstStream *) gst_object_ref (stream);
|
||||||
|
meta->subtitle = gst_buffer_ref (subtitle);
|
||||||
|
|
||||||
|
return meta;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_dwrite_is_windows_10_or_greater (void)
|
gst_dwrite_is_windows_10_or_greater (void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_DWRITE_CAPS \
|
#define GST_DWRITE_CAPS \
|
||||||
GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY "," \
|
GST_VIDEO_CAPS_MAKE_WITH_FEATURES (GST_CAPS_FEATURE_MEMORY_D3D11_MEMORY "," \
|
||||||
GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION, \
|
GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION, \
|
||||||
|
@ -31,7 +33,29 @@
|
||||||
GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION, GST_VIDEO_FORMATS_ALL) ";" \
|
GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION, GST_VIDEO_FORMATS_ALL) ";" \
|
||||||
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL)
|
GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL)
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
typedef struct
|
||||||
|
{
|
||||||
|
GstMeta meta;
|
||||||
|
|
||||||
|
GstStream *stream;
|
||||||
|
GstBuffer *subtitle;
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
|
} GstDWriteSubtitleMeta;
|
||||||
|
|
||||||
|
GType gst_dwrite_subtitle_meta_api_get_type (void);
|
||||||
|
#define GST_DWRITE_SUBTITLE_META_API_TYPE (gst_dwrite_subtitle_meta_api_get_type())
|
||||||
|
|
||||||
|
const GstMetaInfo * gst_dwrite_subtitle_meta_get_info (void);
|
||||||
|
#define GST_DWRITE_SUBTITLE_META_INFO (gst_dwrite_subtitle_meta_get_info())
|
||||||
|
|
||||||
|
#define gst_buffer_get_dwrite_subtitle_meta(b) \
|
||||||
|
((GstDWriteSubtitleMeta *) gst_buffer_get_meta((b), GST_DWRITE_SUBTITLE_META_API_TYPE))
|
||||||
|
|
||||||
|
GstDWriteSubtitleMeta * gst_buffer_add_dwrite_subtitle_meta (GstBuffer * buffer,
|
||||||
|
GstStream * stream,
|
||||||
|
GstBuffer * subtitle);
|
||||||
|
|
||||||
gboolean gst_dwrite_is_windows_10_or_greater (void);
|
gboolean gst_dwrite_is_windows_10_or_greater (void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue