niimaq: cleanup, remove unused property, organize code
This commit is contained in:
parent
1b6b14d225
commit
4fa97a4290
@ -57,12 +57,10 @@ enum
|
|||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_INTERFACE,
|
PROP_INTERFACE,
|
||||||
PROP_TIMESTAMP_OFFSET,
|
|
||||||
PROP_BUFSIZE
|
PROP_BUFSIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_PROP_INTERFACE "img0"
|
#define DEFAULT_PROP_INTERFACE "img0"
|
||||||
#define DEFAULT_PROP_TIMESTAMP_OFFSET 0
|
|
||||||
#define DEFAULT_PROP_BUFSIZE 10
|
#define DEFAULT_PROP_BUFSIZE 10
|
||||||
|
|
||||||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
@ -452,11 +450,6 @@ gst_niimaqsrc_class_init (GstNiImaqSrcClass * klass)
|
|||||||
"Interface",
|
"Interface",
|
||||||
"NI-IMAQ interface to open", DEFAULT_PROP_INTERFACE,
|
"NI-IMAQ interface to open", DEFAULT_PROP_INTERFACE,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
|
||||||
PROP_TIMESTAMP_OFFSET, g_param_spec_int64 ("timestamp-offset",
|
|
||||||
"Timestamp offset",
|
|
||||||
"An offset added to timestamps set on buffers (in ns)", G_MININT64,
|
|
||||||
G_MAXINT64, DEFAULT_PROP_TIMESTAMP_OFFSET, G_PARAM_READWRITE));
|
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BUFSIZE,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BUFSIZE,
|
||||||
g_param_spec_int ("buffer-size",
|
g_param_spec_int ("buffer-size",
|
||||||
"Number of frames in the IMAQ ringbuffer",
|
"Number of frames in the IMAQ ringbuffer",
|
||||||
@ -492,28 +485,11 @@ gst_niimaqsrc_init (GstNiImaqSrc * niimaqsrc, GstNiImaqSrcClass * g_class)
|
|||||||
/* override default of BYTES to operate in time mode */
|
/* override default of BYTES to operate in time mode */
|
||||||
gst_base_src_set_format (GST_BASE_SRC (niimaqsrc), GST_FORMAT_TIME);
|
gst_base_src_set_format (GST_BASE_SRC (niimaqsrc), GST_FORMAT_TIME);
|
||||||
|
|
||||||
/* initialize member variables */
|
/* initialize properties */
|
||||||
niimaqsrc->timestamp_offset = 0;
|
niimaqsrc->bufsize = DEFAULT_PROP_BUFSIZE;
|
||||||
niimaqsrc->bufsize = 10;
|
|
||||||
niimaqsrc->n_frames = 0;
|
|
||||||
niimaqsrc->cumbufnum = 0;
|
|
||||||
niimaqsrc->n_dropped_frames = 0;
|
|
||||||
niimaqsrc->buflist = 0;
|
|
||||||
niimaqsrc->sid = 0;
|
|
||||||
niimaqsrc->iid = 0;
|
|
||||||
niimaqsrc->camera_name = g_strdup (DEFAULT_PROP_INTERFACE);
|
|
||||||
niimaqsrc->interface_name = g_strdup (DEFAULT_PROP_INTERFACE);
|
niimaqsrc->interface_name = g_strdup (DEFAULT_PROP_INTERFACE);
|
||||||
niimaqsrc->session_started = FALSE;
|
|
||||||
niimaqsrc->format = GST_VIDEO_FORMAT_UNKNOWN;
|
|
||||||
niimaqsrc->width = 0;
|
|
||||||
niimaqsrc->height = 0;
|
|
||||||
niimaqsrc->rowpixels = 0;
|
|
||||||
|
|
||||||
niimaqsrc->timelist = NULL;
|
|
||||||
niimaqsrc->frametime_mutex = g_mutex_new ();
|
niimaqsrc->frametime_mutex = g_mutex_new ();
|
||||||
|
|
||||||
niimaqsrc->start_time = NULL;
|
|
||||||
niimaqsrc->start_time_sent = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -530,8 +506,6 @@ gst_niimaqsrc_dispose (GObject * object)
|
|||||||
gst_niimaqsrc_close_interface (niimaqsrc);
|
gst_niimaqsrc_close_interface (niimaqsrc);
|
||||||
|
|
||||||
/* free memory allocated */
|
/* free memory allocated */
|
||||||
g_free (niimaqsrc->camera_name);
|
|
||||||
niimaqsrc->camera_name = NULL;
|
|
||||||
g_free (niimaqsrc->interface_name);
|
g_free (niimaqsrc->interface_name);
|
||||||
niimaqsrc->interface_name = NULL;
|
niimaqsrc->interface_name = NULL;
|
||||||
g_slist_free (niimaqsrc->timelist);
|
g_slist_free (niimaqsrc->timelist);
|
||||||
@ -560,13 +534,6 @@ gst_niimaqsrc_set_property (GObject * object, guint prop_id,
|
|||||||
if (niimaqsrc->interface_name)
|
if (niimaqsrc->interface_name)
|
||||||
g_free (niimaqsrc->interface_name);
|
g_free (niimaqsrc->interface_name);
|
||||||
niimaqsrc->interface_name = g_strdup (g_value_get_string (value));
|
niimaqsrc->interface_name = g_strdup (g_value_get_string (value));
|
||||||
|
|
||||||
if (niimaqsrc->camera_name)
|
|
||||||
g_free (niimaqsrc->camera_name);
|
|
||||||
niimaqsrc->camera_name = g_strdup (g_value_get_string (value));
|
|
||||||
break;
|
|
||||||
case PROP_TIMESTAMP_OFFSET:
|
|
||||||
niimaqsrc->timestamp_offset = g_value_get_int64 (value);
|
|
||||||
break;
|
break;
|
||||||
case PROP_BUFSIZE:
|
case PROP_BUFSIZE:
|
||||||
niimaqsrc->bufsize = g_value_get_int (value);
|
niimaqsrc->bufsize = g_value_get_int (value);
|
||||||
@ -585,9 +552,6 @@ gst_niimaqsrc_get_property (GObject * object, guint prop_id, GValue * value,
|
|||||||
case PROP_INTERFACE:
|
case PROP_INTERFACE:
|
||||||
g_value_set_string (value, niimaqsrc->interface_name);
|
g_value_set_string (value, niimaqsrc->interface_name);
|
||||||
break;
|
break;
|
||||||
case PROP_TIMESTAMP_OFFSET:
|
|
||||||
g_value_set_int64 (value, niimaqsrc->timestamp_offset);
|
|
||||||
break;
|
|
||||||
case PROP_BUFSIZE:
|
case PROP_BUFSIZE:
|
||||||
g_value_set_int (value, niimaqsrc->bufsize);
|
g_value_set_int (value, niimaqsrc->bufsize);
|
||||||
break;
|
break;
|
||||||
@ -672,6 +636,26 @@ gst_niimaqsrc_get_times (GstBaseSrc * basesrc, GstBuffer * buffer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_niimaqsrc_reset (GstNiImaqSrc * niimaqsrc)
|
||||||
|
{
|
||||||
|
/* initialize member variables */
|
||||||
|
niimaqsrc->n_frames = 0;
|
||||||
|
niimaqsrc->cumbufnum = 0;
|
||||||
|
niimaqsrc->n_dropped_frames = 0;
|
||||||
|
niimaqsrc->buflist = 0;
|
||||||
|
niimaqsrc->sid = 0;
|
||||||
|
niimaqsrc->iid = 0;
|
||||||
|
niimaqsrc->session_started = FALSE;
|
||||||
|
niimaqsrc->format = GST_VIDEO_FORMAT_UNKNOWN;
|
||||||
|
niimaqsrc->width = 0;
|
||||||
|
niimaqsrc->height = 0;
|
||||||
|
niimaqsrc->rowpixels = 0;
|
||||||
|
niimaqsrc->timelist = NULL;
|
||||||
|
niimaqsrc->start_time = NULL;
|
||||||
|
niimaqsrc->start_time_sent = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_niimaqsrc_start_acquisition (GstNiImaqSrc * niimaqsrc)
|
gst_niimaqsrc_start_acquisition (GstNiImaqSrc * niimaqsrc)
|
||||||
{
|
{
|
||||||
@ -935,8 +919,7 @@ gst_niimaqsrc_start (GstBaseSrc * src)
|
|||||||
Int32 rval;
|
Int32 rval;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
niimaqsrc->iid = 0;
|
gst_niimaqsrc_reset (niimaqsrc);
|
||||||
niimaqsrc->sid = 0;
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (niimaqsrc, "Opening IMAQ interface: %s",
|
GST_DEBUG_OBJECT (niimaqsrc, "Opening IMAQ interface: %s",
|
||||||
niimaqsrc->interface_name);
|
niimaqsrc->interface_name);
|
||||||
|
|||||||
@ -56,7 +56,6 @@ struct _GstNiImaqSrc {
|
|||||||
int rowpixels;
|
int rowpixels;
|
||||||
|
|
||||||
/* private */
|
/* private */
|
||||||
gint64 timestamp_offset; /* base offset */
|
|
||||||
GstClockTime running_time; /* total running time */
|
GstClockTime running_time; /* total running time */
|
||||||
gint64 n_frames; /* total frames sent */
|
gint64 n_frames; /* total frames sent */
|
||||||
uInt32 cumbufnum;
|
uInt32 cumbufnum;
|
||||||
@ -65,7 +64,6 @@ struct _GstNiImaqSrc {
|
|||||||
gint bufsize;
|
gint bufsize;
|
||||||
guint32** buflist;
|
guint32** buflist;
|
||||||
|
|
||||||
gchar *camera_name;
|
|
||||||
gchar *interface_name;
|
gchar *interface_name;
|
||||||
INTERFACE_ID iid;
|
INTERFACE_ID iid;
|
||||||
SESSION_ID sid;
|
SESSION_ID sid;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user