2020-07-09 16:37:55 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) 2006 Stefan Kost <ensonic@users.sf.net>
|
2020-07-09 17:05:20 +00:00
|
|
|
* Copyright (c) 2020 Anthony Violo <anthony.violo@ubicast.eu>
|
2020-07-12 04:03:04 +00:00
|
|
|
* Copyright (c) 2020 Thibault Saunier <tsaunier@igalia.com>
|
2020-07-09 16:37:55 +00:00
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2020-07-12 04:03:04 +00:00
|
|
|
* SECTION:element-qroverlay
|
2020-07-09 16:37:55 +00:00
|
|
|
*
|
2020-07-12 04:03:04 +00:00
|
|
|
* Element to set random data on a qroverlay.
|
2020-07-09 16:49:51 +00:00
|
|
|
*
|
|
|
|
* ## Example launch line
|
|
|
|
*
|
|
|
|
* ``` bash
|
2020-07-09 16:37:55 +00:00
|
|
|
* gst-launch -v -m videotestsrc ! qroverlay ! fakesink silent=TRUE
|
2020-07-09 16:49:51 +00:00
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* Since: 1.20
|
2020-07-09 16:37:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/base/gstbasetransform.h>
|
2020-07-09 18:14:45 +00:00
|
|
|
#include <json-glib/json-glib.h>
|
2020-07-09 16:37:55 +00:00
|
|
|
|
|
|
|
#include <qrencode.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2021-02-18 15:23:42 +00:00
|
|
|
#include "gstqroverlayelements.h"
|
2020-07-09 16:37:55 +00:00
|
|
|
#include "gstqroverlay.h"
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2020-07-12 04:03:04 +00:00
|
|
|
PROP_DATA,
|
2020-07-09 16:37:55 +00:00
|
|
|
};
|
|
|
|
|
2020-07-12 04:03:04 +00:00
|
|
|
struct _GstQROverlay
|
2020-07-12 03:06:16 +00:00
|
|
|
{
|
2020-07-12 03:43:01 +00:00
|
|
|
GstBaseQROverlay parent;
|
2020-07-12 04:03:04 +00:00
|
|
|
gchar *data;
|
2020-11-21 22:00:02 +00:00
|
|
|
|
|
|
|
gboolean data_changed;
|
2020-07-12 03:06:16 +00:00
|
|
|
};
|
|
|
|
|
2020-07-12 04:03:04 +00:00
|
|
|
#define gst_qr_overlay_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE (GstQROverlay, gst_qr_overlay, GST_TYPE_BASE_QR_OVERLAY);
|
2021-02-18 15:23:42 +00:00
|
|
|
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (qroverlay, "qroverlay", GST_RANK_NONE,
|
|
|
|
GST_TYPE_QR_OVERLAY, qroverlay_element_init (plugin));
|
2020-07-09 16:37:55 +00:00
|
|
|
|
2020-07-12 04:03:04 +00:00
|
|
|
static gchar *
|
2020-11-21 22:00:02 +00:00
|
|
|
get_qrcode_content (GstBaseQROverlay * base, GstBuffer * buf,
|
|
|
|
GstVideoInfo * info, gboolean * reuse_prev)
|
2020-07-09 16:37:55 +00:00
|
|
|
{
|
2020-11-21 22:00:02 +00:00
|
|
|
gchar *content;
|
|
|
|
GstQROverlay *self = GST_QR_OVERLAY (base);
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (self);
|
|
|
|
content = g_strdup (self->data);
|
|
|
|
*reuse_prev = self->data_changed;
|
|
|
|
GST_OBJECT_UNLOCK (self);
|
|
|
|
|
|
|
|
return content;
|
2020-07-09 16:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-07-12 04:03:04 +00:00
|
|
|
gst_qr_overlay_set_property (GObject * object, guint prop_id,
|
2020-07-09 16:37:55 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2020-07-12 04:03:04 +00:00
|
|
|
GstQROverlay *self = GST_QR_OVERLAY (object);
|
2020-07-09 16:37:55 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2020-07-12 04:03:04 +00:00
|
|
|
case PROP_DATA:
|
2020-11-21 22:00:02 +00:00
|
|
|
GST_OBJECT_LOCK (self);
|
2020-07-12 04:03:04 +00:00
|
|
|
self->data = g_value_dup_string (value);
|
2020-11-21 22:00:02 +00:00
|
|
|
self->data_changed = TRUE;
|
|
|
|
GST_OBJECT_UNLOCK (self);
|
2020-07-09 16:37:55 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-07-12 04:03:04 +00:00
|
|
|
gst_qr_overlay_get_property (GObject * object, guint prop_id,
|
2020-07-09 16:37:55 +00:00
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2020-07-12 04:03:04 +00:00
|
|
|
GstQROverlay *self = GST_QR_OVERLAY (object);
|
2020-07-09 16:37:55 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2020-07-12 04:03:04 +00:00
|
|
|
case PROP_DATA:
|
|
|
|
g_value_set_string (value, self->data);
|
2020-07-09 16:37:55 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-12 04:03:04 +00:00
|
|
|
static void
|
|
|
|
gst_qr_overlay_class_init (GstQROverlayClass * klass)
|
2020-07-09 16:37:55 +00:00
|
|
|
{
|
2020-07-12 04:03:04 +00:00
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
2020-07-09 16:37:55 +00:00
|
|
|
|
2020-07-12 04:03:04 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2020-07-09 18:14:45 +00:00
|
|
|
|
2020-07-12 04:03:04 +00:00
|
|
|
gobject_class->set_property = gst_qr_overlay_set_property;
|
|
|
|
gobject_class->get_property = gst_qr_overlay_get_property;
|
2020-07-09 18:14:45 +00:00
|
|
|
|
2020-07-12 04:03:04 +00:00
|
|
|
gst_element_class_set_details_simple (gstelement_class,
|
|
|
|
"qroverlay",
|
|
|
|
"Qrcode overlay containing random data",
|
|
|
|
"Overlay Qrcodes over each buffer with data passed in",
|
|
|
|
"Thibault Saunier <tsaunier@igalia.com>");
|
2020-07-12 03:43:01 +00:00
|
|
|
|
2020-07-12 04:03:04 +00:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_DATA, g_param_spec_string ("data",
|
|
|
|
"Data",
|
|
|
|
"Data to write in the QRCode to be overlaid",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE | GST_PARAM_MUTABLE_PLAYING |
|
|
|
|
GST_PARAM_CONTROLLABLE));
|
2020-07-09 18:14:45 +00:00
|
|
|
|
2020-07-12 04:03:04 +00:00
|
|
|
GST_BASE_QR_OVERLAY_CLASS (klass)->get_content =
|
|
|
|
GST_DEBUG_FUNCPTR (get_qrcode_content);
|
|
|
|
}
|
2020-07-09 18:14:45 +00:00
|
|
|
|
2020-07-12 04:03:04 +00:00
|
|
|
/* initialize the new element
|
|
|
|
* initialize instance structure
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
gst_qr_overlay_init (GstQROverlay * filter)
|
|
|
|
{
|
2020-07-09 16:37:55 +00:00
|
|
|
}
|