videomeasure: Fix indention, line endings and use LRN's real name

This commit is contained in:
Sebastian Dröge 2009-09-10 11:58:02 +02:00
parent e9297ba3eb
commit bdbd944c52
6 changed files with 2173 additions and 2233 deletions

View File

@ -1,70 +1,69 @@
/* GStreamer /* GStreamer
* Copyright (C) <2009> LRN <lrn1986 _at_ gmail _dot_ com> * Copyright (C) <2009> Руслан Ижбулатов <lrn1986 _at_ gmail _dot_ com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include "gstvideomeasure.h" #include "gstvideomeasure.h"
#include "gstvideomeasure_ssim.h" #include "gstvideomeasure_ssim.h"
#include "gstvideomeasure_collector.h" #include "gstvideomeasure_collector.h"
GstEvent *gst_event_new_measured (guint64 framenumber, GstClockTime timestamp, GstEvent *
const gchar *metric, const GValue *mean, const GValue *lowest, gst_event_new_measured (guint64 framenumber, GstClockTime timestamp,
const GValue *highest) const gchar * metric, const GValue * mean, const GValue * lowest,
{ const GValue * highest)
GstStructure *str = gst_structure_new( {
GST_EVENT_VIDEO_MEASURE, GstStructure *str = gst_structure_new (GST_EVENT_VIDEO_MEASURE,
"event", G_TYPE_STRING, "frame-measured", "event", G_TYPE_STRING, "frame-measured",
"offset", G_TYPE_UINT64, framenumber, "offset", G_TYPE_UINT64, framenumber,
"timestamp", GST_TYPE_CLOCK_TIME, timestamp, "timestamp", GST_TYPE_CLOCK_TIME, timestamp,
"metric", G_TYPE_STRING, metric, "metric", G_TYPE_STRING, metric,
NULL); NULL);
gst_structure_set_value (str, "mean", mean); gst_structure_set_value (str, "mean", mean);
gst_structure_set_value (str, "lowest", lowest); gst_structure_set_value (str, "lowest", lowest);
gst_structure_set_value (str, "highest", highest); gst_structure_set_value (str, "highest", highest);
return gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, str); return gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, str);
} }
static gboolean static gboolean
plugin_init (GstPlugin * plugin) plugin_init (GstPlugin * plugin)
{ {
gboolean res; gboolean res;
#if ENABLE_NLS #if ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE, GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
LOCALEDIR); LOCALEDIR);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif #endif
res = gst_element_register (plugin, "ssim", GST_RANK_NONE, res = gst_element_register (plugin, "ssim", GST_RANK_NONE, GST_TYPE_SSIM);
GST_TYPE_SSIM);
res &= gst_element_register (plugin, "measurecollector", GST_RANK_NONE,
res &= gst_element_register (plugin, "measurecollector", GST_RANK_NONE, GST_TYPE_MEASURE_COLLECTOR);
GST_TYPE_MEASURE_COLLECTOR);
return res;
return res; }
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR,
GST_VERSION_MINOR, "videomeasure",
"videomeasure", "Various video measurers",
"Various video measurers", plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);

View File

@ -1,5 +1,5 @@
/* GStreamer /* GStreamer
* Copyright (C) <2009> LRN <lrn1986 _at_ gmail _dot_ com> * Copyright (C) <2009> Руслан Ижбулатов <lrn1986 _at_ gmail _dot_ com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View File

@ -1,417 +1,407 @@
/* GStreamer /* GStreamer
* Copyright (C) <2009> LRN <lrn1986 _at_ gmail _dot_ com> * Copyright (C) <2009> Руслан Ижбулатов <lrn1986 _at_ gmail _dot_ com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
/** /**
* SECTION:element-measurecollector * SECTION:element-measurecollector
* *
* This plugin collects measurements from measuring elemtns and calculates * This plugin collects measurements from measuring elemtns and calculates
* total measure for the whole sequence and also outputs measurements to a file * total measure for the whole sequence and also outputs measurements to a file
* <classname>&quot;GstMeasureCollector&quot;</classname>. * <classname>&quot;GstMeasureCollector&quot;</classname>.
* *
* *
* Last reviewed on 2009-03-15 (0.10.?) * Last reviewed on 2009-03-15 (0.10.?)
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
#include "../../gst-libs/gst/gst-i18n-plugin.h" #include "../../gst-libs/gst/gst-i18n-plugin.h"
#include "gstvideomeasure_collector.h" #include "gstvideomeasure_collector.h"
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include <gst/video/video.h> #include <gst/video/video.h>
/* GstMeasureCollector signals and args */ /* GstMeasureCollector signals and args */
enum enum
{ {
PROP_0, PROP_0,
PROP_FLAGS, PROP_FLAGS,
PROP_FILENAME PROP_FILENAME
}; };
GST_DEBUG_CATEGORY_STATIC (measure_collector_debug); GST_DEBUG_CATEGORY_STATIC (measure_collector_debug);
#define GST_CAT_DEFAULT measure_collector_debug #define GST_CAT_DEFAULT measure_collector_debug
static const GstElementDetails measure_collector_details = static const GstElementDetails measure_collector_details =
GST_ELEMENT_DETAILS ("Video measure collector", GST_ELEMENT_DETAILS ("Video measure collector",
"Filter/Effect/Video", "Filter/Effect/Video",
"Collect measurements from a measuring element", "Collect measurements from a measuring element",
"LRN <lrn _at_ gmail _dot_ com>"); "Руслан Ижбулатов <lrn _at_ gmail _dot_ com>");
static GstStaticPadTemplate gst_measure_collector_src_template = static GstStaticPadTemplate gst_measure_collector_src_template =
GST_STATIC_PAD_TEMPLATE ("src", GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY GST_STATIC_CAPS_ANY);
);
static GstStaticPadTemplate gst_measure_collector_sink_template =
static GstStaticPadTemplate gst_measure_collector_sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK,
GST_PAD_SINK, GST_PAD_ALWAYS,
GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY);
GST_STATIC_CAPS_ANY
); //static GstBaseTransformClass *parent_class = NULL;
//static GstBaseTransformClass *parent_class = NULL; static void gst_measure_collector_finalize (GObject * object);
static gboolean gst_measure_collector_event (GstBaseTransform * base,
static void gst_measure_collector_finalize (GObject * object); GstEvent * event);
static gboolean gst_measure_collector_event (GstBaseTransform * base, static void gst_measure_collector_save_csv (GstMeasureCollector * mc);
GstEvent * event);
static void gst_measure_collector_save_csv(GstMeasureCollector *mc); static void gst_measure_collector_post_message (GstMeasureCollector * mc);
static void gst_measure_collector_post_message (GstMeasureCollector *mc); GST_BOILERPLATE (GstMeasureCollector, gst_measure_collector, GstBaseTransform,
GST_TYPE_BASE_TRANSFORM);
GST_BOILERPLATE (GstMeasureCollector, gst_measure_collector, GstBaseTransform,
GST_TYPE_BASE_TRANSFORM); static void
gst_measure_collector_collect (GstMeasureCollector * mc, GstEvent * gstevent)
static void {
gst_measure_collector_collect (GstMeasureCollector *mc, GstEvent *gstevent) const GstStructure *str;
{ const gchar *event, *metric;
const GstStructure *str; guint64 framenumber = G_MAXUINT64;
const gchar *event, *metric; const GValue *framenumber_v;
guint64 framenumber = G_MAXUINT64;
const GValue *framenumber_v; str = gst_event_get_structure (gstevent);
str = gst_event_get_structure (gstevent); event = gst_structure_get_string (str, "event");
metric = gst_structure_get_string (str, "metric");
event = gst_structure_get_string (str, "event");
metric = gst_structure_get_string (str, "metric"); if (strcmp (event, "frame-measured") == 0 && metric != NULL) {
GstStructure *cpy;
if (strcmp (event, "frame-measured") == 0 && metric != NULL) cpy = gst_structure_copy (str);
{
GstStructure *cpy; framenumber_v = gst_structure_get_value (str, "offset");
cpy = gst_structure_copy (str); if (framenumber_v) {
if (G_VALUE_TYPE (framenumber_v) == G_TYPE_UINT64)
framenumber_v = gst_structure_get_value (str, "offset"); framenumber = g_value_get_uint64 (framenumber_v);
if (framenumber_v) else if (G_VALUE_TYPE (framenumber_v) == G_TYPE_INT64)
{ framenumber = g_value_get_int64 (framenumber_v);
if (G_VALUE_TYPE (framenumber_v) == G_TYPE_UINT64) }
framenumber = g_value_get_uint64 (framenumber_v);
else if (G_VALUE_TYPE (framenumber_v) == G_TYPE_INT64) if (framenumber == G_MAXUINT64)
framenumber = g_value_get_int64 (framenumber_v); framenumber = mc->nextoffset++;
}
if (mc->measurements->len <= framenumber)
if (framenumber == G_MAXUINT64) g_ptr_array_set_size (mc->measurements, framenumber + 1);
framenumber = mc->nextoffset++; g_ptr_array_index (mc->measurements, framenumber) = cpy;
if (mc->measurements->len <= framenumber) mc->nextoffset = framenumber + 1;
g_ptr_array_set_size (mc->measurements, framenumber + 1);
g_ptr_array_index (mc->measurements, framenumber) = cpy; if (!mc->metric)
mc->metric = g_strdup (metric);
mc->nextoffset = framenumber + 1; }
}
if (!mc->metric)
mc->metric = g_strdup (metric); static void
} gst_measure_collector_post_message (GstMeasureCollector * mc)
} {
GstBaseTransform *trans;
static void GstMessage *m;
gst_measure_collector_post_message (GstMeasureCollector *mc) guint64 i;
{
GstBaseTransform *trans; trans = GST_BASE_TRANSFORM_CAST (mc);
GstMessage *m;
guint64 i; g_return_if_fail (mc->metric);
trans = GST_BASE_TRANSFORM_CAST (mc); if (strcmp (mc->metric, "SSIM") == 0) {
gfloat dresult = 0;
g_return_if_fail (mc->metric); g_free (mc->result);
mc->result = g_new0 (GValue, 1);
if (strcmp (mc->metric, "SSIM") == 0) g_value_init (mc->result, G_TYPE_FLOAT);
{ for (i = 0; i < mc->measurements->len; i++) {
gfloat dresult = 0; const GValue *v;
g_free (mc->result); GstStructure *str =
mc->result = g_new0 (GValue, 1); (GstStructure *) g_ptr_array_index (mc->measurements, i);
g_value_init (mc->result, G_TYPE_FLOAT); v = gst_structure_get_value (str, "mean");
for (i = 0; i < mc->measurements->len; i++) dresult += g_value_get_float (v);
{ }
const GValue *v; g_value_set_float (mc->result, dresult / mc->measurements->len);
GstStructure *str = (GstStructure *) g_ptr_array_index (mc->measurements, i); }
v = gst_structure_get_value (str, "mean");
dresult += g_value_get_float (v); m = gst_message_new_element (GST_OBJECT_CAST (mc),
} gst_structure_new ("GstMeasureCollector",
g_value_set_float (mc->result, dresult / mc->measurements->len); "measure-result", G_TYPE_VALUE, mc->result, NULL));
}
gst_element_post_message (GST_ELEMENT_CAST (mc), m);
m = gst_message_new_element (GST_OBJECT_CAST (mc), }
gst_structure_new ("GstMeasureCollector",
"measure-result", G_TYPE_VALUE, mc->result, static void
NULL)); gst_measure_collector_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
gst_element_post_message (GST_ELEMENT_CAST (mc), m); {
} GstMeasureCollector *measurecollector;
static void measurecollector = GST_MEASURE_COLLECTOR (object);
gst_measure_collector_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) switch (prop_id) {
{ case PROP_FLAGS:
GstMeasureCollector *measurecollector; measurecollector->flags = g_value_get_uint64 (value);
break;
measurecollector = GST_MEASURE_COLLECTOR (object); case PROP_FILENAME:
measurecollector->filename = g_value_dup_string (value);
switch (prop_id) { break;
case PROP_FLAGS: default:
measurecollector->flags = g_value_get_uint64 (value); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
case PROP_FILENAME: }
measurecollector->filename = g_value_dup_string (value); }
break;
default: static void
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); gst_measure_collector_get_property (GObject * object, guint prop_id,
break; GValue * value, GParamSpec * pspec)
} {
} GstMeasureCollector *measurecollector;
static void measurecollector = GST_MEASURE_COLLECTOR (object);
gst_measure_collector_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec) switch (prop_id) {
{ case PROP_FLAGS:
GstMeasureCollector *measurecollector; g_value_set_uint64 (value, measurecollector->flags);
break;
measurecollector = GST_MEASURE_COLLECTOR (object); case PROP_FILENAME:
g_value_set_string (value, measurecollector->filename);
switch (prop_id) { break;
case PROP_FLAGS: default:
g_value_set_uint64 (value, measurecollector->flags); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
case PROP_FILENAME: }
g_value_set_string (value, measurecollector->filename); }
break;
default: static gboolean
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); gst_measure_collector_event (GstBaseTransform * base, GstEvent * event)
break; {
} GstMeasureCollector *mc = GST_MEASURE_COLLECTOR (base);
}
switch (GST_EVENT_TYPE (event)) {
static gboolean case GST_EVENT_CUSTOM_DOWNSTREAM:
gst_measure_collector_event (GstBaseTransform * base, GstEvent * event) if (gst_event_has_name (event, GST_EVENT_VIDEO_MEASURE))
{ gst_measure_collector_collect (mc, event);
GstMeasureCollector *mc = GST_MEASURE_COLLECTOR (base); break;
case GST_EVENT_EOS:
switch (GST_EVENT_TYPE (event)) { gst_measure_collector_post_message (mc);
case GST_EVENT_CUSTOM_DOWNSTREAM: gst_measure_collector_save_csv (mc);
if (gst_event_has_name (event, GST_EVENT_VIDEO_MEASURE)) break;
gst_measure_collector_collect (mc, event); default:
break; break;
case GST_EVENT_EOS: }
gst_measure_collector_post_message (mc);
gst_measure_collector_save_csv (mc); return parent_class->event (base, event);
break; }
default:
break; static void
} gst_measure_collector_save_csv (GstMeasureCollector * mc)
{
return parent_class->event (base, event); gchar *name_local;
} FILE *file;
guint64 i, j;
static void gst_measure_collector_save_csv(GstMeasureCollector *mc) GstStructure *str;
{ GValue tmp = { 0 };
gchar *name_local; g_value_init (&tmp, G_TYPE_STRING);
FILE *file;
guint64 i, j; if (!(mc->flags & GST_MEASURE_COLLECTOR_WRITE_CSV))
GstStructure *str; return;
GValue tmp = { 0 };
g_value_init (&tmp, G_TYPE_STRING); if (mc->measurements->len <= 0)
goto empty;
if (!(mc->flags & GST_MEASURE_COLLECTOR_WRITE_CSV))
return; /* open the file */
if (mc->filename == NULL || mc->filename[0] == '\0')
if (mc->measurements->len <= 0) goto no_filename;
goto empty;
name_local = g_filename_from_utf8 ((const gchar *) mc->filename,
/* open the file */ -1, NULL, NULL, NULL);
if (mc->filename == NULL || mc->filename[0] == '\0')
goto no_filename; /* open the file */
if (name_local == NULL || name_local[0] == '\0')
name_local = g_filename_from_utf8 ((const gchar*) mc->filename, goto not_good_filename;
-1, NULL, NULL, NULL);
/* open the file */ /* FIXME, can we use g_fopen here? some people say that the FILE object is
if (name_local == NULL || name_local[0] == '\0') * local to the .so that performed the fopen call, which would not be us when
goto not_good_filename; * we use g_fopen. */
file = fopen (name_local, "wb");
/* FIXME, can we use g_fopen here? some people say that the FILE object is g_free (name_local);
* local to the .so that performed the fopen call, which would not be us when
* we use g_fopen. */ if (file == NULL)
file = fopen (name_local, "wb"); goto open_failed;
g_free(name_local); str = (GstStructure *) g_ptr_array_index (mc->measurements, 0);
if (file == NULL) for (j = 0; j < gst_structure_n_fields (str); j++) {
goto open_failed; const gchar *fieldname;
fieldname = gst_structure_nth_field_name (str, j);
str = (GstStructure *) g_ptr_array_index (mc->measurements, 0); if (G_LIKELY (j > 0))
fprintf (file, ";", fieldname);
for (j = 0; j < gst_structure_n_fields (str); j++) fprintf (file, "%s", fieldname);
{ }
const gchar *fieldname;
fieldname = gst_structure_nth_field_name (str, j); for (i = 0; i < mc->measurements->len; i++) {
if (G_LIKELY (j > 0)) fprintf (file, "\n");
fprintf(file, ";", fieldname); str = (GstStructure *) g_ptr_array_index (mc->measurements, i);
fprintf(file, "%s", fieldname); for (j = 0; j < gst_structure_n_fields (str); j++) {
} const gchar *fieldname;
fieldname = gst_structure_nth_field_name (str, j);
for (i = 0; i < mc->measurements->len; i++) if (G_LIKELY (j > 0))
{ fprintf (file, ";", fieldname);
fprintf(file, "\n"); if (G_LIKELY (g_value_transform (gst_structure_get_value (str, fieldname),
str = (GstStructure *) g_ptr_array_index (mc->measurements, i); &tmp)))
for (j = 0; j < gst_structure_n_fields (str); j++) fprintf (file, "%s", g_value_get_string (&tmp));
{ else
const gchar *fieldname; fprintf (file, "<untranslatable>");
fieldname = gst_structure_nth_field_name (str, j); }
if (G_LIKELY (j > 0)) }
fprintf(file, ";", fieldname);
if (G_LIKELY (g_value_transform (gst_structure_get_value (str, fieldname), &tmp))) fclose (file);
fprintf(file, "%s", g_value_get_string (&tmp));
else /* ERRORS */
fprintf(file, "<untranslatable>"); empty:
} {
} return;
}
fclose(file); no_filename:
{
/* ERRORS */ GST_ELEMENT_ERROR (mc, RESOURCE, NOT_FOUND,
empty: (_("No file name specified for writing.")), (NULL));
{ return;
return; }
} not_good_filename:
no_filename: {
{ GST_ELEMENT_ERROR (mc, RESOURCE, NOT_FOUND,
GST_ELEMENT_ERROR (mc, RESOURCE, NOT_FOUND, (_("Given file name \"%s\" can't be converted to local file name \
(_("No file name specified for writing.")), (NULL)); encoding."), mc->filename), (NULL));
return; return;
} }
not_good_filename: open_failed:
{ {
GST_ELEMENT_ERROR (mc, RESOURCE, NOT_FOUND, GST_ELEMENT_ERROR (mc, RESOURCE, OPEN_WRITE,
(_("Given file name \"%s\" can't be converted to local file name \ (_("Could not open file \"%s\" for writing."), mc->filename),
encoding."), GST_ERROR_SYSTEM);
mc->filename), (NULL)); return;
return; }
} }
open_failed:
{ static void
GST_ELEMENT_ERROR (mc, RESOURCE, OPEN_WRITE, gst_measure_collector_base_init (gpointer g_class)
(_("Could not open file \"%s\" for writing."), mc->filename), {
GST_ERROR_SYSTEM); GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
return;
} gst_element_class_set_details (element_class, &measure_collector_details);
}
gst_element_class_add_pad_template (element_class,
static void gst_static_pad_template_get (&gst_measure_collector_sink_template));
gst_measure_collector_base_init (gpointer g_class) gst_element_class_add_pad_template (element_class,
{ gst_static_pad_template_get (&gst_measure_collector_src_template));
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); }
gst_element_class_set_details (element_class, &measure_collector_details); static void
gst_measure_collector_class_init (GstMeasureCollectorClass * klass)
gst_element_class_add_pad_template (element_class, {
gst_static_pad_template_get (&gst_measure_collector_sink_template)); GObjectClass *gobject_class;
gst_element_class_add_pad_template (element_class, GstBaseTransformClass *trans_class;
gst_static_pad_template_get (&gst_measure_collector_src_template));
} gobject_class = G_OBJECT_CLASS (klass);
trans_class = GST_BASE_TRANSFORM_CLASS (klass);
static void
gst_measure_collector_class_init (GstMeasureCollectorClass *klass) parent_class = g_type_class_peek_parent (klass);
{
GObjectClass *gobject_class; GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "measurecollect", 0,
GstBaseTransformClass *trans_class; "measurement collector");
gobject_class = G_OBJECT_CLASS (klass); gobject_class->set_property = gst_measure_collector_set_property;
trans_class = GST_BASE_TRANSFORM_CLASS (klass); gobject_class->get_property = gst_measure_collector_get_property;
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_measure_collector_finalize);
parent_class = g_type_class_peek_parent (klass);
g_object_class_install_property (gobject_class, PROP_FLAGS,
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "measurecollect", 0, g_param_spec_uint64 ("flags", "Flags",
"measurement collector"); "Flags that control the operation of the element",
0, G_MAXUINT64, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
gobject_class->set_property = gst_measure_collector_set_property;
gobject_class->get_property = gst_measure_collector_get_property; g_object_class_install_property (gobject_class, PROP_FILENAME,
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_measure_collector_finalize); g_param_spec_string ("filename", "Output file name",
"A name of a file into which element will write the measurement \
g_object_class_install_property (gobject_class, PROP_FLAGS, information", "", G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_param_spec_uint64 ("flags", "Flags",
"Flags that control the operation of the element", trans_class->event = GST_DEBUG_FUNCPTR (gst_measure_collector_event);
0, G_MAXUINT64, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
trans_class->passthrough_on_same_caps = TRUE;
g_object_class_install_property (gobject_class, PROP_FILENAME,
g_param_spec_string ("filename", "Output file name", }
"A name of a file into which element will write the measurement \
information", static void
"", G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); gst_measure_collector_init (GstMeasureCollector * instance,
GstMeasureCollectorClass * g_class)
trans_class->event = {
GST_DEBUG_FUNCPTR (gst_measure_collector_event); GstMeasureCollector *measurecollector;
trans_class->passthrough_on_same_caps = TRUE; measurecollector = GST_MEASURE_COLLECTOR (instance);
} GST_DEBUG_OBJECT (measurecollector, "gst_measure_collector_init");
static void gst_base_transform_set_qos_enabled (GST_BASE_TRANSFORM (measurecollector),
gst_measure_collector_init (GstMeasureCollector *instance, FALSE);
GstMeasureCollectorClass *g_class)
{ measurecollector->measurements = g_ptr_array_new ();
GstMeasureCollector *measurecollector; measurecollector->metric = NULL;
measurecollector->inited = TRUE;
measurecollector = GST_MEASURE_COLLECTOR (instance); measurecollector->filename = NULL;
measurecollector->flags = 0;
GST_DEBUG_OBJECT (measurecollector, "gst_measure_collector_init"); measurecollector->nextoffset = 0;
measurecollector->result = NULL;
gst_base_transform_set_qos_enabled (GST_BASE_TRANSFORM (measurecollector), }
FALSE);
static void
measurecollector->measurements = g_ptr_array_new (); gst_measure_collector_finalize (GObject * object)
measurecollector->metric = NULL; {
measurecollector->inited = TRUE; gint i;
measurecollector->filename = NULL; GstMeasureCollector *mc = GST_MEASURE_COLLECTOR (object);
measurecollector->flags = 0;
measurecollector->nextoffset = 0; for (i = 0; i < mc->measurements->len; i++) {
measurecollector->result = NULL; gst_structure_free ((GstStructure *) g_ptr_array_index (mc->measurements,
} i));
}
static void
gst_measure_collector_finalize (GObject * object) g_ptr_array_free (mc->measurements, TRUE);
{ mc->measurements = NULL;
gint i;
GstMeasureCollector *mc = GST_MEASURE_COLLECTOR (object); g_free (mc->result);
mc->result = NULL;
for (i = 0; i < mc->measurements->len; i++)
{ g_free (mc->metric);
gst_structure_free ((GstStructure *) g_ptr_array_index (mc->measurements, i)); mc->metric = NULL;
}
g_free (mc->filename);
g_ptr_array_free (mc->measurements, TRUE); mc->filename = NULL;
mc->measurements = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
g_free (mc->result); }
mc->result = NULL;
g_free (mc->metric);
mc->metric = NULL;
g_free (mc->filename);
mc->filename = NULL;
G_OBJECT_CLASS (parent_class)->finalize (object);
}

View File

@ -1,5 +1,5 @@
/* GStreamer /* GStreamer
* Copyright (C) <2009> LRN <lrn1986 _at_ gmail _dot_ com> * Copyright (C) <2009> Руслан Ижбулатов <lrn1986 _at_ gmail _dot_ com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* GStreamer /* GStreamer
* Copyright (C) <2009> LRN <lrn1986 _at_ gmail _dot_ com> * Copyright (C) <2009> Руслан Ижбулатов <lrn1986 _at_ gmail _dot_ com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public