gboolean valid;
GstPad *sinkpad, *srcpad;
+ GstVideoOverlayComposition *prev_overlay;
};
#define PRIV(s) gst_base_qr_overlay_get_instance_private (GST_BASE_QR_OVERLAY (s))
GstBaseQROverlayPrivate *priv = PRIV (self);
QRcode *qrcode;
gchar *content;
+ gboolean reuse_previous = FALSE;
GstVideoOverlayComposition *overlay = NULL;
GstBuffer *buffer = gst_sample_get_buffer (sample);
GstSegment *segment = gst_sample_get_segment (sample);
content =
GST_BASE_QR_OVERLAY_GET_CLASS (self)->get_content (GST_BASE_QR_OVERLAY
- (self), buffer, &priv->info);
- GST_INFO_OBJECT (self, "String will be encoded : %s", content);
- qrcode = QRcode_encodeString (content, 0, priv->qrcode_quality, QR_MODE_8, 0);
-
- if (qrcode) {
- GST_DEBUG_OBJECT (self, "String encoded");
- overlay = draw_overlay (GST_BASE_QR_OVERLAY (self), qrcode);
- } else {
- GST_WARNING_OBJECT (self, "Could not encode content: %s", content);
+ (self), buffer, &priv->info, &reuse_previous);
+ if (reuse_previous && priv->prev_overlay) {
+ overlay = gst_video_overlay_composition_ref (priv->prev_overlay);
+ } else if (content) {
+ GST_INFO_OBJECT (self, "String will be encoded : %s", content);
+ qrcode =
+ QRcode_encodeString (content, 0, priv->qrcode_quality, QR_MODE_8, 0);
+
+ if (qrcode) {
+ GST_DEBUG_OBJECT (self, "String encoded");
+ overlay = draw_overlay (GST_BASE_QR_OVERLAY (self), qrcode);
+ gst_mini_object_replace (((GstMiniObject **) & priv->prev_overlay),
+ (GstMiniObject *) overlay);
+ } else {
+ GST_WARNING_OBJECT (self, "Could not encode content: %s", content);
+ }
}
g_free (content);
/* GObject vmethod implementations */
+static void
+gst_base_qr_overlay_dispose (GObject * object)
+{
+ GstBaseQROverlayPrivate *priv = PRIV (object);
+
+ gst_mini_object_replace (((GstMiniObject **) & priv->prev_overlay), NULL);
+}
+
/* initialize the qroverlay's class */
static void
gst_base_qr_overlay_class_init (GstBaseQROverlayClass * klass)
gobject_class->set_property = gst_base_qr_overlay_set_property;
gobject_class->get_property = gst_base_qr_overlay_get_property;
+ gobject_class->dispose = gst_base_qr_overlay_dispose;
GST_DEBUG_CATEGORY_INIT (gst_base_qr_overlay_debug, "qroverlay", 0,
"Qrcode overlay base class");
#define GST_CAT_DEFAULT gst_debug_qr_overlay_debug
static gchar *get_qrcode_content (GstBaseQROverlay * base, GstBuffer * buf,
- GstVideoInfo * info);
+ GstVideoInfo * info, gboolean * reuse_prev);
enum
{
static gchar *
get_qrcode_content (GstBaseQROverlay * base, GstBuffer * buf,
- GstVideoInfo * info)
+ GstVideoInfo * info, gboolean * reuse_prev)
{
GstDebugQROverlay *filter = GST_DEBUG_QR_OVERLAY (base);
GString *res = g_string_new (NULL);
JsonObject *jobj = json_object_new ();
JsonNode *root = json_node_new (JSON_NODE_OBJECT);
+ *reuse_prev = FALSE;
json_object_set_int_member (jobj, "TIMESTAMP",
(gint64) GST_BUFFER_TIMESTAMP (buf));
json_object_set_int_member (jobj, "BUFFERCOUNT",
{
GstBaseQROverlay parent;
gchar *data;
+
+ gboolean data_changed;
};
#define gst_qr_overlay_parent_class parent_class
G_DEFINE_TYPE (GstQROverlay, gst_qr_overlay, GST_TYPE_BASE_QR_OVERLAY);
static gchar *
-get_qrcode_content (GstBaseQROverlay * self, GstBuffer * buf,
- GstVideoInfo * info)
+get_qrcode_content (GstBaseQROverlay * base, GstBuffer * buf,
+ GstVideoInfo * info, gboolean * reuse_prev)
{
- return g_strdup (GST_QR_OVERLAY (self)->data);
+ 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;
}
static void
switch (prop_id) {
case PROP_DATA:
+ GST_OBJECT_LOCK (self);
self->data = g_value_dup_string (value);
+ self->data_changed = TRUE;
+ GST_OBJECT_UNLOCK (self);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);