Skip to content
Snippets Groups Projects
Commit c53ec3dc authored by Patrick Godwin's avatar Patrick Godwin
Browse files

added latency element to ugly

parent 50602b04
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ libgstlalugly_la_SOURCES = \
gstlal_interpolator.h gstlal_interpolator.c \
gstlal_tdwhiten.h gstlal_tdwhiten.c \
gstlal_trigger.h gstlal_trigger.c \
gstlal_latency.h gstlal_latency.c \
#gstlal_specgram.h gstlal_specgram.c \
#gstlal_mean.h gstlal_mean.c \
#gstlal_pad.h gstlal_pad.c \
......
/*
* Copyright (C) 2017 Patrick Godwin <patrick.godwin@ligo.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* ============================================================================
*
* Preamble
*
* ============================================================================
*/
/*
* stuff from C
*/
#include <string.h>
#include <math.h>
/*
* stuff from gobject/gstreamer
*/
#include <glib.h>
#include <gst/gst.h>
#include <gst/audio/audio.h>
#include <gst/base/gstbasetransform.h>
/*
* stuff from LAL/gstlal
*/
#include <lal/Date.h>
#include <lal/LALAtomicDatatypes.h>
#include <gstlal/gstlal_audio_info.h>
#include <gstlal_latency.h>
/*
* ============================================================================
*
* GStreamer Boiler Plate
*
* ============================================================================
*/
#define GST_CAT_DEFAULT gstlal_latency_debug
GST_DEBUG_CATEGORY_STATIC(GST_CAT_DEFAULT);
G_DEFINE_TYPE_WITH_CODE(
GSTLALLatency,
gstlal_latency,
GST_TYPE_BASE_TRANSFORM,
GST_DEBUG_CATEGORY_INIT(GST_CAT_DEFAULT, "lal_latency", 0, "lal_latency element")
);
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE(
GST_BASE_TRANSFORM_SINK_NAME,
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY
);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE(
GST_BASE_TRANSFORM_SRC_NAME,
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY
);
/*
* ============================================================================
*
* GstBaseTransform Method Overrides
*
* ============================================================================
*/
/*
* transform_ip()
*/
static GstFlowReturn transform_ip(GstBaseTransform *trans, GstBuffer *buf)
{
GSTLALLatency *element = GSTLAL_LATENCY(trans);
gboolean silent = element->silent;
GST_BUFFER_FLAG_UNSET(buf, GST_BUFFER_FLAG_GAP);
LIGOTimeGPS current_gpstime = LIGOTIMEGPSZERO;
XLALGPSTimeNow(&current_gpstime);
gint current_time = current_gpstime.gpsSeconds;
gint buffer_time = (int) GST_TIME_AS_SECONDS(GST_BUFFER_PTS(buf));
gint latency = current_time - buffer_time;
if (!silent) {
g_print("%s: current time = %9d, buffer time = %9d, latency = %9d\n",
GST_OBJECT_NAME(element), current_time, buffer_time, latency);
}
return GST_FLOW_OK;
}
/*
* ============================================================================
*
* GObject Method Overrides
*
* ============================================================================
*/
enum property {
ARG_SILENT = 1
};
#define DEFAULT_SILENT FALSE
/*
* set_property()
*/
static void set_property(GObject *object, enum property prop_id, const GValue *value, GParamSpec *pspec)
{
GSTLALLatency *element = GSTLAL_LATENCY(object);
GST_OBJECT_LOCK(element);
switch (prop_id) {
case ARG_SILENT:
element->silent = g_value_get_boolean(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
GST_OBJECT_UNLOCK(element);
}
/*
* get_property()
*/
static void get_property(GObject *object, enum property prop_id, GValue *value, GParamSpec *pspec)
{
GSTLALLatency *element = GSTLAL_LATENCY(object);
GST_OBJECT_LOCK(element);
switch (prop_id) {
case ARG_SILENT:
g_value_set_boolean(value, element->silent);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
GST_OBJECT_UNLOCK(element);
}
/*
* class_init()
*/
static void gstlal_latency_class_init(GSTLALLatencyClass *klass)
{
GstBaseTransformClass *transform_class = GST_BASE_TRANSFORM_CLASS(klass);
GstElementClass *element_class = GST_ELEMENT_CLASS(klass);
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
gst_element_class_set_details_simple(
element_class,
"Latency",
"Testing",
"Outputs the current GPS time at time of data flow",
"Patrick Godwin <patrick.godwin@ligo.org>"
);
gobject_class->set_property = GST_DEBUG_FUNCPTR(set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR(get_property);
g_object_class_install_property(
gobject_class,
ARG_SILENT,
g_param_spec_boolean(
"silent",
"Silent",
"Do not print output to stdout.",
DEFAULT_SILENT,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT
)
);
gst_element_class_add_pad_template(element_class, gst_static_pad_template_get(&src_factory));
gst_element_class_add_pad_template(element_class, gst_static_pad_template_get(&sink_factory));
transform_class->transform_ip = GST_DEBUG_FUNCPTR(transform_ip);
}
/*
* init()
*/
static void gstlal_latency_init(GSTLALLatency *element)
{
// gst_base_transform_set_passthrough(GST_BASE_TRANSFORM(element), TRUE);
element->silent = DEFAULT_SILENT;
}
/*
* Copyright (C) 2017 Patrick Godwin <patrick.godwin@ligo.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Alternatively, the contents of this file may be used under the GNU
* Lesser General Public License Version 2.1 (the "LGPL"), in which case
* the following provisions apply instead of the ones mentioned above:
*
* 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.
*/
#ifndef __GST_LAL_LATENCY_H__
#define __GST_LAL_LATENCY_H__
#include <glib.h>
#include <gst/gst.h>
#include <gst/base/gstbasetransform.h>
G_BEGIN_DECLS
#define GSTLAL_LATENCY_TYPE \
(gstlal_latency_get_type())
#define GSTLAL_LATENCY(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), GSTLAL_LATENCY_TYPE, GSTLALLatency))
#define GSTLAL_LATENCY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), GSTLAL_LATENCY_TYPE, GSTLALLatencyClass))
#define GST_IS_GSTLAL_LATENCY(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GSTLAL_LATENCY_TYPE))
#define GST_IS_GSTLAL_LATENCY_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GSTLAL_LATENCY_TYPE))
typedef struct _GSTLALLatency GSTLALLatency;
typedef struct _GSTLALLatencyClass GSTLALLatencyClass;
/**
* GSTLALLatency:
*/
struct _GSTLALLatency {
GstBaseTransform element;
/* properties */
gboolean silent;
};
/**
* GSTLALLatencyClass:
* @parent_class: the parent class
*/
struct _GSTLALLatencyClass {
GstBaseTransformClass parent_class;
};
GType gstlal_latency_get_type(void);
G_END_DECLS
#endif /* __GST_LAL_LATENCY_H__ */
......@@ -59,6 +59,7 @@
#include <gstlal_bitvectorgen.h>
#include <audioratefaker.h>
#include <gstlal_trigger.h>
#include <gstlal_latency.h>
/*
......@@ -85,6 +86,7 @@ static gboolean plugin_init(GstPlugin *plugin)
{"lal_bitvectorgen", GSTLAL_BITVECTORGEN_TYPE},
{"audioratefaker", GST_TYPE_AUDIO_RATE_FAKER},
{"lal_trigger", GSTLAL_TRIGGER_TYPE},
{"lal_latency", GSTLAL_LATENCY_TYPE},
{NULL, 0},
};
......
......@@ -933,6 +933,9 @@ def mktrigger(pipeline, src, n, autocorrelation_matrix = None, mask_matrix = Non
properties["sigmasq"] = sigmasq
return mkgeneric(pipeline, src, "lal_trigger", **properties)
def mklatency(pipeline, src, silent = False):
return mkgeneric(pipeline, src, "lal_latency", silent = silent)
def mklhocoherentnull(pipeline, H1src, H2src, H1_impulse, H1_latency, H2_impulse, H2_latency, srate):
elem = mkgeneric(pipeline, None, "lal_lho_coherent_null", block_stride = srate, H1_impulse = H1_impulse, H2_impulse = H2_impulse, H1_latency = H1_latency, H2_latency = H2_latency)
for peer, padname in ((H1src, "H1sink"), (H2src, "H2sink")):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment