2015-01-08 13:16:17 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Ole André Vadla Ravnås <oleavr@soundrop.com>
|
|
|
|
*
|
|
|
|
* 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 St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !HAVE_IOS
|
|
|
|
#import <AppKit/AppKit.h>
|
|
|
|
#endif
|
2015-12-10 05:22:08 +00:00
|
|
|
#include "videotexturecache.h"
|
2015-01-08 13:16:17 +00:00
|
|
|
#include "coremediabuffer.h"
|
2015-01-15 03:09:43 +00:00
|
|
|
#include "corevideobuffer.h"
|
2015-02-09 10:18:24 +00:00
|
|
|
#include "vtutil.h"
|
|
|
|
|
2019-08-28 08:59:35 +00:00
|
|
|
G_DEFINE_ABSTRACT_TYPE (GstVideoTextureCache, gst_video_texture_cache, G_TYPE_OBJECT);
|
2019-08-26 06:51:03 +00:00
|
|
|
|
2019-08-28 08:59:35 +00:00
|
|
|
static void gst_video_texture_cache_default_set_format (GstVideoTextureCache * cache,
|
|
|
|
GstVideoFormat in_format, GstCaps * out_caps);
|
2015-01-08 13:16:17 +00:00
|
|
|
|
2019-08-26 06:51:03 +00:00
|
|
|
static void
|
|
|
|
gst_video_texture_cache_finalize (GObject * object)
|
2015-01-08 13:16:17 +00:00
|
|
|
{
|
2019-08-26 06:51:03 +00:00
|
|
|
GstVideoTextureCache *cache = GST_VIDEO_TEXTURE_CACHE (object);
|
2015-01-08 13:16:17 +00:00
|
|
|
|
2015-10-29 02:04:31 +00:00
|
|
|
if (cache->in_caps)
|
|
|
|
gst_caps_unref (cache->in_caps);
|
|
|
|
if (cache->out_caps)
|
|
|
|
gst_caps_unref (cache->out_caps);
|
2019-08-26 06:51:03 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gst_video_texture_cache_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_video_texture_cache_init (GstVideoTextureCache * cache)
|
|
|
|
{
|
|
|
|
gst_video_info_init (&cache->input_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_video_texture_cache_class_init (GstVideoTextureCacheClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->finalize = gst_video_texture_cache_finalize;
|
|
|
|
|
2019-08-28 08:59:35 +00:00
|
|
|
klass->set_format = gst_video_texture_cache_default_set_format;
|
2015-01-08 13:16:17 +00:00
|
|
|
}
|
|
|
|
|
2019-08-28 08:59:35 +00:00
|
|
|
static void
|
|
|
|
gst_video_texture_cache_default_set_format (GstVideoTextureCache * cache,
|
2015-04-20 07:08:23 +00:00
|
|
|
GstVideoFormat in_format, GstCaps * out_caps)
|
2015-01-08 13:16:17 +00:00
|
|
|
{
|
2015-01-29 13:28:18 +00:00
|
|
|
GstCaps *in_caps;
|
|
|
|
|
|
|
|
g_return_if_fail (gst_caps_is_fixed (out_caps));
|
|
|
|
|
|
|
|
out_caps = gst_caps_copy (out_caps);
|
2015-12-11 02:20:05 +00:00
|
|
|
gst_video_info_from_caps (&cache->output_info, out_caps);
|
|
|
|
|
2015-01-29 13:28:18 +00:00
|
|
|
in_caps = gst_caps_copy (out_caps);
|
2015-04-20 07:08:23 +00:00
|
|
|
gst_caps_set_simple (in_caps, "format",
|
|
|
|
G_TYPE_STRING, gst_video_format_to_string (in_format), NULL);
|
2015-01-29 13:28:18 +00:00
|
|
|
gst_video_info_from_caps (&cache->input_info, in_caps);
|
|
|
|
|
2019-08-28 08:59:35 +00:00
|
|
|
gst_caps_take (&cache->in_caps, in_caps);
|
|
|
|
gst_caps_take (&cache->out_caps, out_caps);
|
2015-01-29 13:28:18 +00:00
|
|
|
}
|
|
|
|
|
2019-08-28 08:59:35 +00:00
|
|
|
void
|
|
|
|
gst_video_texture_cache_set_format (GstVideoTextureCache * cache,
|
|
|
|
GstVideoFormat in_format, GstCaps * out_caps)
|
2015-02-09 10:18:24 +00:00
|
|
|
{
|
2019-08-28 08:59:35 +00:00
|
|
|
GstVideoTextureCacheClass *cache_class = GST_VIDEO_TEXTURE_CACHE_GET_CLASS (cache);
|
2015-10-29 02:04:31 +00:00
|
|
|
|
2019-08-28 08:59:35 +00:00
|
|
|
g_return_if_fail (cache_class->set_format);
|
|
|
|
cache_class->set_format (cache, in_format, out_caps);
|
2017-02-26 09:24:46 +00:00
|
|
|
}
|
2015-12-17 04:07:33 +00:00
|
|
|
|
2016-08-26 07:37:54 +00:00
|
|
|
GstMemory *
|
|
|
|
gst_video_texture_cache_create_memory (GstVideoTextureCache * cache,
|
2019-08-28 08:59:35 +00:00
|
|
|
GstAppleCoreVideoPixelBuffer *gpixbuf, guint plane, gsize size)
|
2015-01-29 13:28:18 +00:00
|
|
|
{
|
2019-08-28 08:59:35 +00:00
|
|
|
GstVideoTextureCacheClass *cache_class = GST_VIDEO_TEXTURE_CACHE_GET_CLASS (cache);
|
2016-01-19 04:50:22 +00:00
|
|
|
|
2019-08-28 08:59:35 +00:00
|
|
|
g_return_val_if_fail (cache_class->create_memory, NULL);
|
|
|
|
return cache_class->create_memory (cache, gpixbuf, plane, size);
|
2015-01-08 13:16:17 +00:00
|
|
|
}
|