niimaq: more cleanup, rely more on base and video libraries
This commit is contained in:
parent
7c251fa83a
commit
48ea4b565d
@ -59,7 +59,6 @@ enum
|
|||||||
PROP_INTERFACE,
|
PROP_INTERFACE,
|
||||||
PROP_TIMESTAMP_OFFSET,
|
PROP_TIMESTAMP_OFFSET,
|
||||||
PROP_BUFSIZE
|
PROP_BUFSIZE
|
||||||
/* FILL ME */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_PROP_INTERFACE "img0"
|
#define DEFAULT_PROP_INTERFACE "img0"
|
||||||
@ -98,9 +97,6 @@ static GstFlowReturn gst_niimaqsrc_create (GstPushSrc * psrc,
|
|||||||
GstBuffer ** buffer);
|
GstBuffer ** buffer);
|
||||||
|
|
||||||
/* GstNiImaq methods */
|
/* GstNiImaq methods */
|
||||||
static gboolean gst_niimaqsrc_parse_caps (const GstCaps * caps,
|
|
||||||
gint * width, gint * height, gint * depth, gint * bpp);
|
|
||||||
|
|
||||||
static GstCaps *gst_niimaqsrc_get_cam_caps (GstNiImaqSrc * src);
|
static GstCaps *gst_niimaqsrc_get_cam_caps (GstNiImaqSrc * src);
|
||||||
static void gst_niimaqsrc_close_interface (GstNiImaqSrc * niimaqsrc);
|
static void gst_niimaqsrc_close_interface (GstNiImaqSrc * niimaqsrc);
|
||||||
|
|
||||||
@ -498,7 +494,6 @@ gst_niimaqsrc_init (GstNiImaqSrc * niimaqsrc, GstNiImaqSrcClass * g_class)
|
|||||||
|
|
||||||
/* initialize member variables */
|
/* initialize member variables */
|
||||||
niimaqsrc->timestamp_offset = 0;
|
niimaqsrc->timestamp_offset = 0;
|
||||||
niimaqsrc->caps = NULL;
|
|
||||||
niimaqsrc->bufsize = 10;
|
niimaqsrc->bufsize = 10;
|
||||||
niimaqsrc->n_frames = 0;
|
niimaqsrc->n_frames = 0;
|
||||||
niimaqsrc->cumbufnum = 0;
|
niimaqsrc->cumbufnum = 0;
|
||||||
@ -546,11 +541,6 @@ gst_niimaqsrc_dispose (GObject * object)
|
|||||||
niimaqsrc->start_time = NULL;
|
niimaqsrc->start_time = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (niimaqsrc->caps) {
|
|
||||||
gst_caps_unref (niimaqsrc->caps);
|
|
||||||
niimaqsrc->caps = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* chain dispose fuction of parent class */
|
/* chain dispose fuction of parent class */
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
@ -610,48 +600,26 @@ gst_niimaqsrc_get_caps (GstBaseSrc * bsrc)
|
|||||||
|
|
||||||
GST_DEBUG_OBJECT (bsrc, "Entering function get_caps");
|
GST_DEBUG_OBJECT (bsrc, "Entering function get_caps");
|
||||||
|
|
||||||
/* return template caps if we don't know the actual camera caps */
|
/* return template caps if the session hasn't started yet */
|
||||||
if (!niimaqsrc->caps) {
|
if (!niimaqsrc->sid) {
|
||||||
return
|
return
|
||||||
gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD
|
gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD
|
||||||
(niimaqsrc)));
|
(niimaqsrc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return gst_caps_copy (niimaqsrc->caps);
|
return gst_niimaqsrc_get_cam_caps (niimaqsrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_niimaqsrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
|
gst_niimaqsrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
|
||||||
{
|
{
|
||||||
|
GstNiImaqSrc *niimaqsrc = GST_NIIMAQSRC (bsrc);
|
||||||
gboolean res = TRUE;
|
gboolean res = TRUE;
|
||||||
GstNiImaqSrc *niimaqsrc;
|
|
||||||
gint width, height;
|
|
||||||
gint bpp, depth;
|
|
||||||
|
|
||||||
niimaqsrc = GST_NIIMAQSRC (bsrc);
|
res = gst_video_get_size_from_caps (caps, &niimaqsrc->framesize);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (bsrc, "Entering function set_caps");
|
GST_DEBUG_OBJECT (niimaqsrc, "Caps set, framesize=%d", niimaqsrc->framesize);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (caps, "are the caps being set");
|
|
||||||
|
|
||||||
if (niimaqsrc->caps) {
|
|
||||||
gst_caps_unref (niimaqsrc->caps);
|
|
||||||
niimaqsrc->caps = gst_caps_copy (caps);
|
|
||||||
}
|
|
||||||
|
|
||||||
res =
|
|
||||||
gst_niimaqsrc_parse_caps (niimaqsrc->caps, &width, &height, &depth, &bpp);
|
|
||||||
|
|
||||||
if (res) {
|
|
||||||
/* looks ok here */
|
|
||||||
niimaqsrc->width = width;
|
|
||||||
niimaqsrc->height = height;
|
|
||||||
niimaqsrc->depth = depth;
|
|
||||||
niimaqsrc->bpp = bpp;
|
|
||||||
niimaqsrc->framesize = width * height * (depth / 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -845,9 +813,11 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
|||||||
GstTagList *tl =
|
GstTagList *tl =
|
||||||
gst_tag_list_new_full (GST_TAG_DATE_TIME, niimaqsrc->start_time, NULL);
|
gst_tag_list_new_full (GST_TAG_DATE_TIME, niimaqsrc->start_time, NULL);
|
||||||
GstEvent *e = gst_event_new_tag (tl);
|
GstEvent *e = gst_event_new_tag (tl);
|
||||||
gst_pad_push_event (GST_PAD (GST_BASE_SRC_PAD (niimaqsrc)), e);
|
GST_DEBUG_OBJECT (niimaqsrc, "Sending start time event: %" GST_PTR_FORMAT,
|
||||||
|
e);
|
||||||
|
gst_pad_push_event (GST_BASE_SRC_PAD (niimaqsrc), e);
|
||||||
|
niimaqsrc->start_time_sent = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -856,43 +826,6 @@ error:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gst_niimaqsrc_parse_caps:
|
|
||||||
* caps: a #GstCaps to parse
|
|
||||||
* width:
|
|
||||||
* height:
|
|
||||||
* depth:
|
|
||||||
* bpp:
|
|
||||||
*
|
|
||||||
* Parses a given caps and sets critical values.
|
|
||||||
*
|
|
||||||
* Returns: TRUE on success
|
|
||||||
*/
|
|
||||||
static gboolean
|
|
||||||
gst_niimaqsrc_parse_caps (const GstCaps * caps, gint * width, gint * height,
|
|
||||||
gint * depth, gint * bpp)
|
|
||||||
{
|
|
||||||
GstStructure *structure;
|
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
if (gst_caps_get_size (caps) < 1)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
|
||||||
|
|
||||||
ret = gst_structure_get (structure,
|
|
||||||
"width", G_TYPE_INT, width,
|
|
||||||
"height", G_TYPE_INT, height,
|
|
||||||
"depth", G_TYPE_INT, depth, "bpp", G_TYPE_INT, bpp, NULL);
|
|
||||||
|
|
||||||
if (!ret) {
|
|
||||||
GST_DEBUG ("Failed to retrieve width, height, depth, or bpp");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_niimaqsrc_get_cam_caps:
|
* gst_niimaqsrc_get_cam_caps:
|
||||||
* src: #GstNiImaq instance
|
* src: #GstNiImaq instance
|
||||||
@ -1006,21 +939,6 @@ gst_niimaqsrc_start (GstBaseSrc * src)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (niimaqsrc->caps) {
|
|
||||||
gst_caps_unref (niimaqsrc->caps);
|
|
||||||
niimaqsrc->caps = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (niimaqsrc, "Getting caps from camera");
|
|
||||||
|
|
||||||
/* get caps from camera and set to src pad */
|
|
||||||
niimaqsrc->caps = gst_niimaqsrc_get_cam_caps (niimaqsrc);
|
|
||||||
if (niimaqsrc->caps == NULL) {
|
|
||||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED,
|
|
||||||
("Failed to get caps from IMAQ"), ("Failed to get caps from IMAQ"));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (niimaqsrc, "Creating ring with %d buffers",
|
GST_LOG_OBJECT (niimaqsrc, "Creating ring with %d buffers",
|
||||||
niimaqsrc->bufsize);
|
niimaqsrc->bufsize);
|
||||||
|
|
||||||
@ -1089,11 +1007,6 @@ gst_niimaqsrc_stop (GstBaseSrc * src)
|
|||||||
|
|
||||||
gst_niimaqsrc_close_interface (niimaqsrc);
|
gst_niimaqsrc_close_interface (niimaqsrc);
|
||||||
|
|
||||||
if (niimaqsrc->caps) {
|
|
||||||
gst_caps_unref (niimaqsrc->caps);
|
|
||||||
niimaqsrc->caps = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -47,11 +47,6 @@ typedef struct _GstNiImaqSrcClass GstNiImaqSrcClass;
|
|||||||
struct _GstNiImaqSrc {
|
struct _GstNiImaqSrc {
|
||||||
GstPushSrc element;
|
GstPushSrc element;
|
||||||
|
|
||||||
/* video state */
|
|
||||||
gint width;
|
|
||||||
gint height;
|
|
||||||
gint depth;
|
|
||||||
gint bpp;
|
|
||||||
gint framesize;
|
gint framesize;
|
||||||
|
|
||||||
/* private */
|
/* private */
|
||||||
@ -71,8 +66,6 @@ struct _GstNiImaqSrc {
|
|||||||
|
|
||||||
gboolean session_started;
|
gboolean session_started;
|
||||||
|
|
||||||
GstCaps *caps;
|
|
||||||
|
|
||||||
GSList *timelist;
|
GSList *timelist;
|
||||||
GMutex *frametime_mutex;
|
GMutex *frametime_mutex;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user