style: run gst-indent
This commit is contained in:
@@ -79,11 +79,11 @@ static GstFlowReturn gst_euresys_create (GstPushSrc * src, GstBuffer ** buf);
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_BOARD_INDEX,
|
||||
PROP_CAMERA_TYPE,
|
||||
PROP_CONNECTOR
|
||||
/* FILL ME */
|
||||
PROP_0,
|
||||
PROP_BOARD_INDEX,
|
||||
PROP_CAMERA_TYPE,
|
||||
PROP_CONNECTOR
|
||||
/* FILL ME */
|
||||
};
|
||||
|
||||
#define DEFAULT_PROP_BOARD_INDEX 0
|
||||
@@ -93,15 +93,12 @@ enum
|
||||
/* pad templates */
|
||||
|
||||
static GstStaticPadTemplate gst_euresys_src_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (
|
||||
GST_VIDEO_CAPS_GRAY8 ";"
|
||||
GST_VIDEO_CAPS_RGB ";"
|
||||
GST_VIDEO_CAPS_ARGB ";"
|
||||
GST_VIDEO_CAPS_RGB_15 ";"
|
||||
GST_VIDEO_CAPS_RGB_16)
|
||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_GRAY8 ";"
|
||||
GST_VIDEO_CAPS_RGB ";"
|
||||
GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_RGB_15 ";" GST_VIDEO_CAPS_RGB_16)
|
||||
);
|
||||
|
||||
|
||||
@@ -140,15 +137,17 @@ gst_euresys_connector_get_type (void)
|
||||
{MC_Connector_X2, "X2", "X2 input"},
|
||||
{MC_Connector_Y1, "Y1", "Y1 input"},
|
||||
{MC_Connector_Y2, "Y2", "Y2 input"},
|
||||
{MC_Connector_A, "A", "A input (Grablink Expert 2 DuoCam mode, connector A)"},
|
||||
{MC_Connector_B, "B", "B input (Grablink Expert 2 DuoCam mode, connector B)"},
|
||||
{MC_Connector_A, "A",
|
||||
"A input (Grablink Expert 2 DuoCam mode, connector A)"},
|
||||
{MC_Connector_B, "B",
|
||||
"B input (Grablink Expert 2 DuoCam mode, connector B)"},
|
||||
{MC_Connector_M, "M", "M input (Grablink in MonoCam mode)"},
|
||||
{0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (!euresys_connector_type) {
|
||||
euresys_connector_type =
|
||||
g_enum_register_static ("GstEuresysConnector", euresys_connector);
|
||||
g_enum_register_static ("GstEuresysConnector", euresys_connector);
|
||||
}
|
||||
return euresys_connector_type;
|
||||
}
|
||||
@@ -168,7 +167,7 @@ gst_euresys_camera_get_type (void)
|
||||
|
||||
if (!euresys_camera_type) {
|
||||
euresys_camera_type =
|
||||
g_enum_register_static ("GstEuresysCamera", euresys_camera);
|
||||
g_enum_register_static ("GstEuresysCamera", euresys_camera);
|
||||
}
|
||||
return euresys_camera_type;
|
||||
}
|
||||
@@ -176,8 +175,7 @@ gst_euresys_camera_get_type (void)
|
||||
|
||||
/* class initialization */
|
||||
|
||||
GST_BOILERPLATE (GstEuresys, gst_euresys, GstPushSrc,
|
||||
GST_TYPE_PUSH_SRC);
|
||||
GST_BOILERPLATE (GstEuresys, gst_euresys, GstPushSrc, GST_TYPE_PUSH_SRC);
|
||||
|
||||
|
||||
static GstVideoFormat
|
||||
@@ -186,8 +184,8 @@ gst_euresys_color_format_to_video_format (INT32 color_format)
|
||||
switch (color_format) {
|
||||
case MC_ColorFormat_Y8:
|
||||
case MC_ColorFormat_RAW8:
|
||||
return GST_VIDEO_FORMAT_GRAY8;
|
||||
/* TODO: possibly use different formats for each of the following */
|
||||
return GST_VIDEO_FORMAT_GRAY8;
|
||||
/* TODO: possibly use different formats for each of the following */
|
||||
case MC_ColorFormat_Y10:
|
||||
case MC_ColorFormat_Y12:
|
||||
case MC_ColorFormat_Y14:
|
||||
@@ -199,13 +197,16 @@ gst_euresys_color_format_to_video_format (INT32 color_format)
|
||||
return GST_VIDEO_FORMAT_GRAY16_LE;
|
||||
case MC_ColorFormat_Y41P:
|
||||
case MC_ColorFormat_YUV411:
|
||||
return gst_video_format_from_fourcc (GST_MAKE_FOURCC ('Y', '4', '1', 'P'));
|
||||
return gst_video_format_from_fourcc (GST_MAKE_FOURCC ('Y', '4', '1',
|
||||
'P'));
|
||||
case MC_ColorFormat_YUV422:
|
||||
case MC_ColorFormat_Y42P:
|
||||
return gst_video_format_from_fourcc (GST_MAKE_FOURCC ('Y', '4', '2', 'P'));
|
||||
return gst_video_format_from_fourcc (GST_MAKE_FOURCC ('Y', '4', '2',
|
||||
'P'));
|
||||
case MC_ColorFormat_YUV444:
|
||||
case MC_ColorFormat_IYU2:
|
||||
return gst_video_format_from_fourcc (GST_MAKE_FOURCC ('I', 'Y', 'U', '2'));
|
||||
return gst_video_format_from_fourcc (GST_MAKE_FOURCC ('I', 'Y', 'U',
|
||||
'2'));
|
||||
case MC_ColorFormat_YUV411PL:
|
||||
case MC_ColorFormat_Y41B:
|
||||
return GST_VIDEO_FORMAT_Y41B;
|
||||
@@ -222,7 +223,8 @@ gst_euresys_color_format_to_video_format (INT32 color_format)
|
||||
case MC_ColorFormat_YUV411PL_DEC:
|
||||
case MC_ColorFormat_YUV9:
|
||||
case MC_ColorFormat_YVU9:
|
||||
return gst_video_format_from_fourcc (GST_MAKE_FOURCC ('Y', 'V', 'U', '9'));
|
||||
return gst_video_format_from_fourcc (GST_MAKE_FOURCC ('Y', 'V', 'U',
|
||||
'9'));
|
||||
case MC_ColorFormat_RGB15:
|
||||
return GST_VIDEO_FORMAT_RGB15;
|
||||
case MC_ColorFormat_RGB16:
|
||||
@@ -271,7 +273,8 @@ gst_euresys_class_init (GstEuresysClass * klass)
|
||||
base_src_class->get_size = GST_DEBUG_FUNCPTR (gst_euresys_get_size);
|
||||
base_src_class->is_seekable = GST_DEBUG_FUNCPTR (gst_euresys_is_seekable);
|
||||
base_src_class->query = GST_DEBUG_FUNCPTR (gst_euresys_query);
|
||||
base_src_class->check_get_range = GST_DEBUG_FUNCPTR (gst_euresys_check_get_range);
|
||||
base_src_class->check_get_range =
|
||||
GST_DEBUG_FUNCPTR (gst_euresys_check_get_range);
|
||||
base_src_class->fixate = GST_DEBUG_FUNCPTR (gst_euresys_fixate);
|
||||
|
||||
push_src_class->create = GST_DEBUG_FUNCPTR (gst_euresys_create);
|
||||
@@ -295,8 +298,8 @@ gst_euresys_class_init (GstEuresysClass * klass)
|
||||
static void
|
||||
gst_euresys_init (GstEuresys * euresys, GstEuresysClass * euresys_class)
|
||||
{
|
||||
euresys->srcpad = gst_pad_new_from_static_template (&gst_euresys_src_template
|
||||
, "src");
|
||||
euresys->srcpad =
|
||||
gst_pad_new_from_static_template (&gst_euresys_src_template, "src");
|
||||
|
||||
/* set source as live (no preroll) */
|
||||
gst_base_src_set_live (GST_BASE_SRC (euresys), TRUE);
|
||||
@@ -314,8 +317,8 @@ gst_euresys_init (GstEuresys * euresys, GstEuresysClass * euresys_class)
|
||||
|
||||
euresys->acq_started = FALSE;
|
||||
|
||||
euresys->last_time_code = -1;
|
||||
euresys->dropped_frame_count = 0;
|
||||
euresys->last_time_code = -1;
|
||||
euresys->dropped_frame_count = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -405,7 +408,9 @@ gst_euresys_get_caps (GstBaseSrc * src)
|
||||
|
||||
/* return template caps if we don't know the actual camera caps */
|
||||
if (!euresys->caps) {
|
||||
return gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (euresys)));
|
||||
return
|
||||
gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD
|
||||
(euresys)));
|
||||
}
|
||||
|
||||
return gst_caps_copy (euresys->caps);
|
||||
@@ -436,9 +441,7 @@ gst_euresys_set_caps (GstBaseSrc * src, GstCaps * caps)
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
|
||||
ret = gst_structure_get (structure,
|
||||
"width", G_TYPE_INT, &width,
|
||||
"height", G_TYPE_INT, &height,
|
||||
NULL);
|
||||
"width", G_TYPE_INT, &width, "height", G_TYPE_INT, &height, NULL);
|
||||
|
||||
if (!ret) {
|
||||
GST_DEBUG ("Failed to retrieve width and height");
|
||||
@@ -472,14 +475,16 @@ gst_euresys_start (GstBaseSrc * src)
|
||||
/* Open MultiCam driver */
|
||||
status = McOpenDriver (NULL);
|
||||
if (status != MC_OK) {
|
||||
GST_ELEMENT_ERROR (euresys, LIBRARY, INIT, (NULL), (NULL));
|
||||
return FALSE;
|
||||
GST_ELEMENT_ERROR (euresys, LIBRARY, INIT, (NULL), (NULL));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
status = McGetParamInt (MC_BOARD + euresys->boardIdx, MC_BoardType, &euresys->boardType);
|
||||
status =
|
||||
McGetParamInt (MC_BOARD + euresys->boardIdx, MC_BoardType,
|
||||
&euresys->boardType);
|
||||
if (status != MC_OK) {
|
||||
GST_ELEMENT_ERROR (euresys, RESOURCE, SETTINGS,
|
||||
(_("Failed to get board type.")), (NULL));
|
||||
(_("Failed to get board type.")), (NULL));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -488,9 +493,9 @@ gst_euresys_start (GstBaseSrc * src)
|
||||
|
||||
/* Set error log file */
|
||||
/* McSetParamStr (MC_CONFIGURATION, MC_ErrorLog, "mc_error.log"); */
|
||||
|
||||
|
||||
/* Create a channel */
|
||||
status = McCreate(MC_CHANNEL, &euresys->hChannel);
|
||||
status = McCreate (MC_CHANNEL, &euresys->hChannel);
|
||||
if (status != MC_OK) {
|
||||
GST_ELEMENT_ERROR (euresys, RESOURCE, FAILED,
|
||||
(_("Failed to create channel.")), (NULL));
|
||||
@@ -498,7 +503,7 @@ gst_euresys_start (GstBaseSrc * src)
|
||||
}
|
||||
|
||||
/* Link the channel to a board */
|
||||
status = McSetParamInt(euresys->hChannel, MC_DriverIndex, euresys->boardIdx);
|
||||
status = McSetParamInt (euresys->hChannel, MC_DriverIndex, euresys->boardIdx);
|
||||
if (status != MC_OK) {
|
||||
GST_ELEMENT_ERROR (euresys, RESOURCE, SETTINGS,
|
||||
(_("Failed to link channel to board.")), (NULL));
|
||||
@@ -508,7 +513,7 @@ gst_euresys_start (GstBaseSrc * src)
|
||||
}
|
||||
|
||||
/* Select the video connector */
|
||||
status = McSetParamInt(euresys->hChannel, MC_Connector, euresys->connector);
|
||||
status = McSetParamInt (euresys->hChannel, MC_Connector, euresys->connector);
|
||||
if (status != MC_OK) {
|
||||
GST_ELEMENT_ERROR (euresys, RESOURCE, SETTINGS,
|
||||
(_("Failed to set connector to channel.")), (NULL));
|
||||
@@ -518,7 +523,7 @@ gst_euresys_start (GstBaseSrc * src)
|
||||
}
|
||||
|
||||
/* Select the video signal type */
|
||||
status = McSetParamInt(euresys->hChannel, MC_Camera, euresys->cameraType);
|
||||
status = McSetParamInt (euresys->hChannel, MC_Camera, euresys->cameraType);
|
||||
if (status != MC_OK) {
|
||||
GST_ELEMENT_ERROR (euresys, RESOURCE, SETTINGS,
|
||||
(_("Failed to set camera type = %d."), euresys->cameraType), (NULL));
|
||||
@@ -528,10 +533,10 @@ gst_euresys_start (GstBaseSrc * src)
|
||||
}
|
||||
|
||||
/* Set the color format */
|
||||
status = McSetParamInt(euresys->hChannel, MC_ColorFormat, MC_ColorFormat_Y8);
|
||||
status = McSetParamInt (euresys->hChannel, MC_ColorFormat, MC_ColorFormat_Y8);
|
||||
if (status != MC_OK) {
|
||||
GST_ELEMENT_ERROR (euresys, RESOURCE, SETTINGS,
|
||||
(_("Failed to set color format = %d."), MC_ColorFormat_Y8), (NULL));
|
||||
(_("Failed to set color format = %d."), MC_ColorFormat_Y8), (NULL));
|
||||
McDelete (euresys->hChannel);
|
||||
euresys->hChannel = 0;
|
||||
return FALSE;
|
||||
@@ -548,11 +553,15 @@ gst_euresys_start (GstBaseSrc * src)
|
||||
}
|
||||
|
||||
/* Enable signals */
|
||||
status = McSetParamInt(euresys->hChannel, MC_SignalEnable + MC_SIG_SURFACE_PROCESSING, MC_SignalEnable_ON);
|
||||
status |= McSetParamInt(euresys->hChannel, MC_SignalEnable + MC_SIG_ACQUISITION_FAILURE, MC_SignalEnable_ON);
|
||||
status =
|
||||
McSetParamInt (euresys->hChannel,
|
||||
MC_SignalEnable + MC_SIG_SURFACE_PROCESSING, MC_SignalEnable_ON);
|
||||
status |=
|
||||
McSetParamInt (euresys->hChannel,
|
||||
MC_SignalEnable + MC_SIG_ACQUISITION_FAILURE, MC_SignalEnable_ON);
|
||||
if (status != MC_OK) {
|
||||
GST_ELEMENT_ERROR (euresys, RESOURCE, SETTINGS,
|
||||
(_("Failed to enable signals.")), (NULL));
|
||||
(_("Failed to enable signals.")), (NULL));
|
||||
McDelete (euresys->hChannel);
|
||||
euresys->hChannel = 0;
|
||||
return FALSE;
|
||||
@@ -564,7 +573,7 @@ gst_euresys_start (GstBaseSrc * src)
|
||||
status |= McGetParamInt (euresys->hChannel, MC_ImageSizeY, &height);
|
||||
if (status != MC_OK) {
|
||||
GST_ELEMENT_ERROR (euresys, RESOURCE, SETTINGS,
|
||||
(_("Failed to get color format, width, and height.")), (NULL));
|
||||
(_("Failed to get color format, width, and height.")), (NULL));
|
||||
McDelete (euresys->hChannel);
|
||||
euresys->hChannel = 0;
|
||||
return FALSE;
|
||||
@@ -581,16 +590,17 @@ gst_euresys_start (GstBaseSrc * src)
|
||||
|
||||
if (euresys->caps)
|
||||
gst_caps_unref (euresys->caps);
|
||||
euresys->caps = gst_video_format_new_caps (videoFormat, width, height, 30, 1, 1, 1);
|
||||
euresys->caps =
|
||||
gst_video_format_new_caps (videoFormat, width, height, 30, 1, 1, 1);
|
||||
|
||||
if (euresys->caps == NULL) {
|
||||
GST_ELEMENT_ERROR (euresys, STREAM, TOO_LAZY,
|
||||
(_("Failed to generate caps from video format.")), (NULL));
|
||||
(_("Failed to generate caps from video format.")), (NULL));
|
||||
McDelete (euresys->hChannel);
|
||||
euresys->hChannel = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -606,18 +616,18 @@ gst_euresys_stop (GstBaseSrc * src)
|
||||
McSetParamInt (euresys->hChannel, MC_ChannelState, MC_ChannelState_IDLE);
|
||||
|
||||
/* Close the MultiCam driver */
|
||||
McCloseDriver();
|
||||
McCloseDriver ();
|
||||
|
||||
/* Delete the channel */
|
||||
if (euresys->hChannel)
|
||||
McDelete(euresys->hChannel);
|
||||
McDelete (euresys->hChannel);
|
||||
euresys->hChannel = 0;
|
||||
|
||||
gst_caps_unref (euresys->caps);
|
||||
euresys->caps = NULL;
|
||||
|
||||
euresys->dropped_frame_count = 0;
|
||||
euresys->last_time_code = -1;
|
||||
euresys->dropped_frame_count = 0;
|
||||
euresys->last_time_code = -1;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -691,11 +701,13 @@ gst_euresys_create (GstPushSrc * src, GstBuffer ** buf)
|
||||
INT64 timeStamp;
|
||||
int newsize;
|
||||
GstFlowReturn ret;
|
||||
int dropped_frame_count;
|
||||
int dropped_frame_count;
|
||||
|
||||
/* Start acquisition */
|
||||
if (!euresys->acq_started) {
|
||||
status = McSetParamInt(euresys->hChannel, MC_ChannelState, MC_ChannelState_ACTIVE);
|
||||
status =
|
||||
McSetParamInt (euresys->hChannel, MC_ChannelState,
|
||||
MC_ChannelState_ACTIVE);
|
||||
if (status != MC_OK) {
|
||||
GST_ELEMENT_ERROR (euresys, RESOURCE, FAILED,
|
||||
(_("Failed to set channel state to ACTIVE.")), (NULL));
|
||||
@@ -710,48 +722,47 @@ gst_euresys_create (GstPushSrc * src, GstBuffer ** buf)
|
||||
status = McWaitSignal (euresys->hChannel, MC_SIG_ANY, 5000, &siginfo);
|
||||
if (status == MC_TIMEOUT) {
|
||||
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
||||
(_("Timeout waiting for signal.")), (_("Timeout waiting for signal.")));
|
||||
(_("Timeout waiting for signal.")),
|
||||
(_("Timeout waiting for signal.")));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
else if (siginfo.Signal == MC_SIG_ACQUISITION_FAILURE) {
|
||||
} else if (siginfo.Signal == MC_SIG_ACQUISITION_FAILURE) {
|
||||
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
||||
(_("Acquisition failure due to timeout.")), (NULL));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
else if (siginfo.Signal == MC_SIG_SURFACE_PROCESSING) {
|
||||
} else if (siginfo.Signal == MC_SIG_SURFACE_PROCESSING) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get pointer to image data and other info*/
|
||||
/* Get pointer to image data and other info */
|
||||
hSurface = (MCHANDLE) siginfo.SignalInfo;
|
||||
/* "number of bytes actually written into the surface" */
|
||||
/* "number of bytes actually written into the surface" */
|
||||
status = McGetParamInt (hSurface, MC_FillCount, &newsize);
|
||||
/* "Internal numbering of surface during acquisition sequence" (zero-based)*/
|
||||
/* "Internal numbering of surface during acquisition sequence" (zero-based) */
|
||||
status |= McGetParamInt (hSurface, MC_TimeCode, &timeCode);
|
||||
/* "number of microseconds elapsed since midnight (00:00:00),
|
||||
* January 1, 1970, coordinated universal time (UTC), according
|
||||
* to the system clock when the surface is filled" */
|
||||
/* "number of microseconds elapsed since midnight (00:00:00),
|
||||
* January 1, 1970, coordinated universal time (UTC), according
|
||||
* to the system clock when the surface is filled" */
|
||||
status |= McGetParamInt64 (hSurface, MC_TimeStamp_us, &timeStamp);
|
||||
status |= McGetParamPtr (hSurface, MC_SurfaceAddr, (PVOID*)&pImage);
|
||||
status |= McGetParamPtr (hSurface, MC_SurfaceAddr, (PVOID *) & pImage);
|
||||
if (G_UNLIKELY (status != MC_OK)) {
|
||||
GST_ELEMENT_ERROR (euresys, RESOURCE, FAILED,
|
||||
(_("Failed to read surface parameter.")), (NULL));
|
||||
(_("Failed to read surface parameter.")), (NULL));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
GST_INFO ("Got surface #%05d", timeCode);
|
||||
GST_INFO ("Got surface #%05d", timeCode);
|
||||
|
||||
dropped_frame_count = timeCode - (euresys->last_time_code + 1);
|
||||
if (dropped_frame_count != 0) {
|
||||
euresys->dropped_frame_count += dropped_frame_count;
|
||||
GST_WARNING ("Dropped %d frames (%d total)", dropped_frame_count, euresys->dropped_frame_count);
|
||||
/* TODO: emit message here about dropped frames */
|
||||
}
|
||||
euresys->last_time_code = timeCode;
|
||||
dropped_frame_count = timeCode - (euresys->last_time_code + 1);
|
||||
if (dropped_frame_count != 0) {
|
||||
euresys->dropped_frame_count += dropped_frame_count;
|
||||
GST_WARNING ("Dropped %d frames (%d total)", dropped_frame_count,
|
||||
euresys->dropped_frame_count);
|
||||
/* TODO: emit message here about dropped frames */
|
||||
}
|
||||
euresys->last_time_code = timeCode;
|
||||
|
||||
|
||||
/* Create the buffer */
|
||||
@@ -779,8 +790,8 @@ gst_euresys_create (GstPushSrc * src, GstBuffer ** buf)
|
||||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
GST_DEBUG_CATEGORY_INIT (gst_euresys_debug, "euresys", 0, \
|
||||
"debug category for euresys element");
|
||||
GST_DEBUG_CATEGORY_INIT (gst_euresys_debug, "euresys", 0,
|
||||
"debug category for euresys element");
|
||||
gst_element_register (plugin, "euresys", GST_RANK_NONE,
|
||||
gst_euresys_get_type ());
|
||||
|
||||
|
||||
@@ -70,9 +70,9 @@ static GstFlowReturn gst_iotechdaqx_create (GstPushSrc * src, GstBuffer ** buf);
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_BOARD_INDEX
|
||||
/* FILL ME */
|
||||
PROP_0,
|
||||
PROP_BOARD_INDEX
|
||||
/* FILL ME */
|
||||
};
|
||||
|
||||
#define DEFAULT_PROP_BOARD_INDEX 0
|
||||
@@ -84,47 +84,72 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (
|
||||
//GST_AUDIO_INT_PAD_TEMPLATE_CAPS)
|
||||
"audio/x-raw-int, " \
|
||||
"rate = (int) 10000, " \
|
||||
"channels = (int) 1, " \
|
||||
"endianness = (int) BYTE_ORDER, " \
|
||||
"width = (int) 16, " \
|
||||
"depth = (int) 16, " \
|
||||
"signed = (boolean) true")
|
||||
//GST_AUDIO_INT_PAD_TEMPLATE_CAPS)
|
||||
"audio/x-raw-int, "
|
||||
"rate = (int) 10000, "
|
||||
"channels = (int) 1, "
|
||||
"endianness = (int) BYTE_ORDER, "
|
||||
"width = (int) 16, " "depth = (int) 16, " "signed = (boolean) true")
|
||||
);
|
||||
|
||||
/* class initialization */
|
||||
|
||||
GST_BOILERPLATE (GstIOtechDaqX, gst_iotechdaqx, GstPushSrc,
|
||||
GST_TYPE_PUSH_SRC);
|
||||
GST_BOILERPLATE (GstIOtechDaqX, gst_iotechdaqx, GstPushSrc, GST_TYPE_PUSH_SRC);
|
||||
|
||||
|
||||
char* GetProtocol(DaqProtocol protocol){
|
||||
/*This function is used to display the protcol name; since the
|
||||
protcol itself is stored as a number, this function associates
|
||||
the protocol number with a string.
|
||||
*/
|
||||
char* protocolName[64];
|
||||
|
||||
switch (protocol)
|
||||
{
|
||||
case DaqProtocolNone: *protocolName="DaqProtocolNone";break;
|
||||
case DaqProtocol4: *protocolName="DaqProtocol4";break;
|
||||
case DaqProtocol8: *protocolName="DaqProtocol8";break;
|
||||
case DaqProtocolSMC666: *protocolName="DaqProtocolSMC666";break;
|
||||
case DaqProtocolFastEPP: *protocolName="DaqProtocolFastEPP";break;
|
||||
case DaqProtocolECP: *protocolName="DaqProtocolECP";break;
|
||||
case DaqProtocol8BitEPP: *protocolName="DaqProtocol8BitEPP";break;
|
||||
case DaqProtocolTCPIP: *protocolName="DaqProtocolTCPIP";break;
|
||||
case DaqProtocolISA: *protocolName="DaqProtocolISA";break;
|
||||
case DaqProtocolPcCard: *protocolName="DaqProtocolPcCard";break;
|
||||
case DaqProtocolUSB: *protocolName="DaqProtocolUSB";break;
|
||||
case DaqProtocolPCI: *protocolName="DaqProtocolPCI";break;
|
||||
case DaqProtocolCPCI: *protocolName="DaqProtocolCPCI";break;
|
||||
default: *protocolName="Unknown";break;
|
||||
}
|
||||
return *protocolName;
|
||||
char *GetProtocol (DaqProtocol protocol)
|
||||
{
|
||||
/*This function is used to display the protcol name; since the
|
||||
protcol itself is stored as a number, this function associates
|
||||
the protocol number with a string.
|
||||
*/
|
||||
char *protocolName[64];
|
||||
|
||||
switch (protocol) {
|
||||
case DaqProtocolNone:
|
||||
*protocolName = "DaqProtocolNone";
|
||||
break;
|
||||
case DaqProtocol4:
|
||||
*protocolName = "DaqProtocol4";
|
||||
break;
|
||||
case DaqProtocol8:
|
||||
*protocolName = "DaqProtocol8";
|
||||
break;
|
||||
case DaqProtocolSMC666:
|
||||
*protocolName = "DaqProtocolSMC666";
|
||||
break;
|
||||
case DaqProtocolFastEPP:
|
||||
*protocolName = "DaqProtocolFastEPP";
|
||||
break;
|
||||
case DaqProtocolECP:
|
||||
*protocolName = "DaqProtocolECP";
|
||||
break;
|
||||
case DaqProtocol8BitEPP:
|
||||
*protocolName = "DaqProtocol8BitEPP";
|
||||
break;
|
||||
case DaqProtocolTCPIP:
|
||||
*protocolName = "DaqProtocolTCPIP";
|
||||
break;
|
||||
case DaqProtocolISA:
|
||||
*protocolName = "DaqProtocolISA";
|
||||
break;
|
||||
case DaqProtocolPcCard:
|
||||
*protocolName = "DaqProtocolPcCard";
|
||||
break;
|
||||
case DaqProtocolUSB:
|
||||
*protocolName = "DaqProtocolUSB";
|
||||
break;
|
||||
case DaqProtocolPCI:
|
||||
*protocolName = "DaqProtocolPCI";
|
||||
break;
|
||||
case DaqProtocolCPCI:
|
||||
*protocolName = "DaqProtocolCPCI";
|
||||
break;
|
||||
default:
|
||||
*protocolName = "Unknown";
|
||||
break;
|
||||
}
|
||||
return *protocolName;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,8 +163,7 @@ gst_iotechdaqx_base_init (gpointer g_class)
|
||||
|
||||
gst_element_class_set_details_simple (element_class,
|
||||
"IOtechDaqX Data Source", "Source/Audio",
|
||||
"IOtechDaqX data source",
|
||||
"Joshua Doe <oss@nvl.army.mil>");
|
||||
"IOtechDaqX data source", "Joshua Doe <oss@nvl.army.mil>");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -162,7 +186,8 @@ gst_iotechdaqx_class_init (GstIOtechDaqXClass * klass)
|
||||
base_src_class->get_size = GST_DEBUG_FUNCPTR (gst_iotechdaqx_get_size);
|
||||
base_src_class->is_seekable = GST_DEBUG_FUNCPTR (gst_iotechdaqx_is_seekable);
|
||||
base_src_class->query = GST_DEBUG_FUNCPTR (gst_iotechdaqx_query);
|
||||
base_src_class->check_get_range = GST_DEBUG_FUNCPTR (gst_iotechdaqx_check_get_range);
|
||||
base_src_class->check_get_range =
|
||||
GST_DEBUG_FUNCPTR (gst_iotechdaqx_check_get_range);
|
||||
base_src_class->fixate = GST_DEBUG_FUNCPTR (gst_iotechdaqx_fixate);
|
||||
|
||||
push_src_class->create = GST_DEBUG_FUNCPTR (gst_iotechdaqx_create);
|
||||
@@ -176,10 +201,11 @@ gst_iotechdaqx_class_init (GstIOtechDaqXClass * klass)
|
||||
}
|
||||
|
||||
static void
|
||||
gst_iotechdaqx_init (GstIOtechDaqX * iotechdaqx, GstIOtechDaqXClass * iotechdaqx_class)
|
||||
gst_iotechdaqx_init (GstIOtechDaqX * iotechdaqx,
|
||||
GstIOtechDaqXClass * iotechdaqx_class)
|
||||
{
|
||||
iotechdaqx->srcpad = gst_pad_new_from_static_template (&gst_iotechdaqx_src_template
|
||||
, "src");
|
||||
iotechdaqx->srcpad =
|
||||
gst_pad_new_from_static_template (&gst_iotechdaqx_src_template, "src");
|
||||
|
||||
/* set source as live (no preroll) */
|
||||
gst_base_src_set_live (GST_BASE_SRC (iotechdaqx), TRUE);
|
||||
@@ -263,7 +289,9 @@ gst_iotechdaqx_get_caps (GstBaseSrc * src)
|
||||
|
||||
/* return template caps if we don't know the actual camera caps */
|
||||
if (!iotechdaqx->caps) {
|
||||
return gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (iotechdaqx)));
|
||||
return
|
||||
gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD
|
||||
(iotechdaqx)));
|
||||
}
|
||||
|
||||
return gst_caps_copy (iotechdaqx->caps);
|
||||
@@ -293,10 +321,9 @@ gst_iotechdaqx_set_caps (GstBaseSrc * src, GstCaps * caps)
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
|
||||
ret = gst_structure_get (structure,
|
||||
"width", G_TYPE_INT, &iotechdaqx->width,
|
||||
"rate", G_TYPE_INT, &iotechdaqx->rate,
|
||||
"channels", G_TYPE_INT, &iotechdaqx->channels,
|
||||
NULL);
|
||||
"width", G_TYPE_INT, &iotechdaqx->width,
|
||||
"rate", G_TYPE_INT, &iotechdaqx->rate,
|
||||
"channels", G_TYPE_INT, &iotechdaqx->channels, NULL);
|
||||
|
||||
if (!ret) {
|
||||
GST_DEBUG ("Failed to retrieve width and height");
|
||||
@@ -328,18 +355,18 @@ gst_iotechdaqx_start (GstBaseSrc * src)
|
||||
|
||||
|
||||
// Find out how many devices are installed and allocate memory for device list
|
||||
daqGetDeviceCount(&devCount);
|
||||
devList = (DaqDeviceListT*)malloc(sizeof(DaqDeviceListT)*devCount);
|
||||
daqGetDeviceCount (&devCount);
|
||||
devList = (DaqDeviceListT *) malloc (sizeof (DaqDeviceListT) * devCount);
|
||||
|
||||
GST_DEBUG ("Found %d devices", devCount);
|
||||
|
||||
// Get the names of all installed devices and the device count
|
||||
daqGetDeviceList(devList, &devCount);
|
||||
daqGetDeviceList (devList, &devCount);
|
||||
|
||||
deviceIndex = 0;
|
||||
do {
|
||||
// Get the device properties for each device
|
||||
daqGetDeviceProperties(devList[deviceIndex].daqName, &devProps);
|
||||
daqGetDeviceProperties (devList[deviceIndex].daqName, &devProps);
|
||||
|
||||
GST_DEBUG ("Device %i: %s", deviceIndex, devList[deviceIndex].daqName);
|
||||
deviceIndex++;
|
||||
@@ -348,14 +375,15 @@ gst_iotechdaqx_start (GstBaseSrc * src)
|
||||
} while (deviceIndex < devCount);
|
||||
|
||||
// We are done with the device list
|
||||
free(devList);
|
||||
free (devList);
|
||||
|
||||
iotechdaqx->handle = daqOpen(devProps.daqName);
|
||||
GST_DEBUG ("Connected to %s on LPT%d\n", devProps.daqName, devProps.basePortAddress+1);
|
||||
GST_DEBUG ("Protocol: %s \n", GetProtocol(devProps.protocol));
|
||||
iotechdaqx->handle = daqOpen (devProps.daqName);
|
||||
GST_DEBUG ("Connected to %s on LPT%d\n", devProps.daqName,
|
||||
devProps.basePortAddress + 1);
|
||||
GST_DEBUG ("Protocol: %s \n", GetProtocol (devProps.protocol));
|
||||
|
||||
//FIXME check for errors!
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -444,42 +472,46 @@ gst_iotechdaqx_create (GstPushSrc * src, GstBuffer ** buf)
|
||||
//GST_DEBUG ("create (handle=%d)", iotechdaqx->handle);
|
||||
|
||||
if (!iotechdaqx->opened) {
|
||||
DWORD channels[1] = {1};
|
||||
DaqAdcGain gains[1] = {DgainX1};
|
||||
DWORD flags[1] = {DafAnalog|DafBipolar};
|
||||
DWORD channels[1] = { 1 };
|
||||
DaqAdcGain gains[1] = { DgainX1 };
|
||||
DWORD flags[1] = { DafAnalog | DafBipolar };
|
||||
|
||||
GST_DEBUG ("Setting up acquisition: rate=%d", iotechdaqx->rate);
|
||||
|
||||
daqAdcSetScan (iotechdaqx->handle, channels, gains, flags, 1);
|
||||
daqAdcSetAcq (iotechdaqx->handle, DaamInfinitePost, 0, 0);
|
||||
daqSetTriggerEvent (iotechdaqx->handle, DatsSoftware, NULL, NULL, NULL, NULL, NULL, NULL, NULL, DaqStartEvent);
|
||||
daqSetTriggerEvent (iotechdaqx->handle, DatsSoftware, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL, DaqStartEvent);
|
||||
//daqSetTriggerEvent (iotechdaqx->handle, DatsSoftware, NULL, NULL, NULL, NULL, NULL, NULL, NULL, DaqStopEvent);
|
||||
daqAdcSetFreq (iotechdaqx->handle, (float)iotechdaqx->rate);
|
||||
daqAdcTransferSetBuffer (iotechdaqx->handle, NULL, 44100, DatmCycleOn|DatmDriverBuf);
|
||||
daqAdcSetFreq (iotechdaqx->handle, (float) iotechdaqx->rate);
|
||||
daqAdcTransferSetBuffer (iotechdaqx->handle, NULL, 44100,
|
||||
DatmCycleOn | DatmDriverBuf);
|
||||
|
||||
daqAdcTransferStart (iotechdaqx->handle);
|
||||
daqAdcArm (iotechdaqx->handle);
|
||||
daqAdcSoftTrig (iotechdaqx->handle); //FIXME: put in create() and use has_started flag
|
||||
daqAdcSoftTrig (iotechdaqx->handle); //FIXME: put in create() and use has_started flag
|
||||
|
||||
iotechdaqx->opened = TRUE;
|
||||
}
|
||||
|
||||
gst_pad_alloc_buffer_and_set_caps (GST_BASE_SRC_PAD (GST_BASE_SRC (src)), 0, 2048*2, iotechdaqx->caps, buf);
|
||||
gst_pad_alloc_buffer_and_set_caps (GST_BASE_SRC_PAD (GST_BASE_SRC (src)), 0,
|
||||
2048 * 2, iotechdaqx->caps, buf);
|
||||
|
||||
daqAdcTransferBufData (iotechdaqx->handle, GST_BUFFER_DATA(*buf), 2048, DabtmOldest|DabtmWait, &retCount);
|
||||
daqAdcTransferBufData (iotechdaqx->handle, GST_BUFFER_DATA (*buf), 2048,
|
||||
DabtmOldest | DabtmWait, &retCount);
|
||||
|
||||
//GST_DEBUG ("Asked for %d samples, got %d", 2048, retCount);
|
||||
|
||||
//memcpy(GST_BUFFER_DATA (*buf), tmp, 16*sizeof(SHORT));
|
||||
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
GST_DEBUG_CATEGORY_INIT (gst_iotechdaqx_debug, "iotechdaqx", 0, \
|
||||
"debug category for iotechdaqx element");
|
||||
GST_DEBUG_CATEGORY_INIT (gst_iotechdaqx_debug, "iotechdaqx", 0,
|
||||
"debug category for iotechdaqx element");
|
||||
gst_element_register (plugin, "iotechdaqx", GST_RANK_NONE,
|
||||
gst_iotechdaqx_get_type ());
|
||||
|
||||
|
||||
@@ -66,25 +66,22 @@ enum
|
||||
#define DEFAULT_PROP_BUFSIZE 10
|
||||
|
||||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (
|
||||
"video/x-raw-gray, "
|
||||
"bpp = (int) 8, "
|
||||
"depth = (int) 8, "
|
||||
"width = (int) [ 1, max ], "
|
||||
"height = (int) [ 1, max ], "
|
||||
"framerate = (fraction) [ 0, max ]"
|
||||
";"
|
||||
"video/x-raw-gray, "
|
||||
"bpp = (int) {10, 12, 14, 16}, "
|
||||
"depth = (int) 16, "
|
||||
"endianness = (int) LITTLE_ENDIAN, "
|
||||
"width = (int) [ 1, max ], "
|
||||
"height = (int) [ 1, max ], "
|
||||
"framerate = (fraction) [ 0, max ]"
|
||||
)
|
||||
);
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("video/x-raw-gray, "
|
||||
"bpp = (int) 8, "
|
||||
"depth = (int) 8, "
|
||||
"width = (int) [ 1, max ], "
|
||||
"height = (int) [ 1, max ], "
|
||||
"framerate = (fraction) [ 0, max ]"
|
||||
";"
|
||||
"video/x-raw-gray, "
|
||||
"bpp = (int) {10, 12, 14, 16}, "
|
||||
"depth = (int) 16, "
|
||||
"endianness = (int) LITTLE_ENDIAN, "
|
||||
"width = (int) [ 1, max ], "
|
||||
"height = (int) [ 1, max ], " "framerate = (fraction) [ 0, max ]")
|
||||
);
|
||||
|
||||
static void gst_niimaqsrc_init_interfaces (GType type);
|
||||
|
||||
@@ -107,13 +104,15 @@ static gboolean gst_niimaqsrc_start (GstBaseSrc * src);
|
||||
static gboolean gst_niimaqsrc_stop (GstBaseSrc * src);
|
||||
|
||||
/* GstPushSrc virtual methods */
|
||||
static GstFlowReturn gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer);
|
||||
static GstFlowReturn gst_niimaqsrc_create (GstPushSrc * psrc,
|
||||
GstBuffer ** buffer);
|
||||
|
||||
/* GstNiImaq methods */
|
||||
static gboolean gst_niimaqsrc_parse_caps (const GstCaps * caps,
|
||||
gint * width, gint * height, gint * depth, gint * bpp);
|
||||
|
||||
static gboolean gst_niimaqsrc_set_caps_color (GstStructure * gs, gint bpp, gint depth);
|
||||
static gboolean gst_niimaqsrc_set_caps_color (GstStructure * gs, gint bpp,
|
||||
gint depth);
|
||||
static gboolean gst_niimaqsrc_set_caps_framesize (GstStructure * gs, gint width,
|
||||
gint height);
|
||||
|
||||
@@ -121,7 +120,8 @@ static GstCaps *gst_niimaqsrc_get_cam_caps (GstNiImaqSrc * src);
|
||||
static void gst_niimaqsrc_close_interface (GstNiImaqSrc * niimaqsrc);
|
||||
|
||||
uInt32
|
||||
gst_niimaqsrc_report_imaq_error (uInt32 code) {
|
||||
gst_niimaqsrc_report_imaq_error (uInt32 code)
|
||||
{
|
||||
static char imaq_error_string[256];
|
||||
if (code) {
|
||||
imgShowError (code, imaq_error_string);
|
||||
@@ -132,19 +132,21 @@ gst_niimaqsrc_report_imaq_error (uInt32 code) {
|
||||
|
||||
typedef struct _GstNiImaqSrcFrameTime GstNiImaqSrcFrameTime;
|
||||
|
||||
struct _GstNiImaqSrcFrameTime {
|
||||
struct _GstNiImaqSrcFrameTime
|
||||
{
|
||||
guint32 number;
|
||||
GstClockTime time;
|
||||
};
|
||||
|
||||
uInt32 gst_niimaqsrc_frame_start_callback (SESSION_ID sid, IMG_ERR err,
|
||||
IMG_SIGNAL_TYPE signal_type, uInt32 signal_identifier, void * userdata)
|
||||
uInt32
|
||||
gst_niimaqsrc_frame_start_callback (SESSION_ID sid, IMG_ERR err,
|
||||
IMG_SIGNAL_TYPE signal_type, uInt32 signal_identifier, void *userdata)
|
||||
{
|
||||
GstNiImaqSrc *niimaqsrc = GST_NIIMAQSRC (userdata);
|
||||
GstClock *clock;
|
||||
GstNiImaqSrcFrameTime *frametime = g_new (GstNiImaqSrcFrameTime, 1);
|
||||
uInt32 val;
|
||||
|
||||
|
||||
/* get clock time and set to frametime struct */
|
||||
clock = gst_element_get_clock (GST_ELEMENT (niimaqsrc));
|
||||
frametime->time = gst_clock_get_time (clock);
|
||||
@@ -160,10 +162,10 @@ uInt32 gst_niimaqsrc_frame_start_callback (SESSION_ID sid, IMG_ERR err,
|
||||
g_mutex_unlock (niimaqsrc->frametime_mutex);
|
||||
|
||||
/* return 1 to rearm the callback */
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _____BEGIN_FUNCTIONS_____();
|
||||
static void _____BEGIN_FUNCTIONS_____ ();
|
||||
|
||||
/**
|
||||
* gst_niimaqsrc_probe_get_properties:
|
||||
@@ -180,7 +182,8 @@ gst_niimaqsrc_probe_get_properties (GstPropertyProbe * probe)
|
||||
static GList *list = NULL;
|
||||
|
||||
if (!list) {
|
||||
list = g_list_append (NULL, g_object_class_find_property (klass, "interface"));
|
||||
list =
|
||||
g_list_append (NULL, g_object_class_find_property (klass, "interface"));
|
||||
}
|
||||
|
||||
return list;
|
||||
@@ -219,7 +222,7 @@ gst_niimaqsrc_class_probe_interfaces (GstNiImaqSrcClass * klass, gboolean check)
|
||||
guint32 iid;
|
||||
guint32 nports;
|
||||
guint32 port;
|
||||
gchar * iname;
|
||||
gchar *iname;
|
||||
uInt32 rval;
|
||||
|
||||
/* get interface names until there are no more */
|
||||
@@ -245,7 +248,7 @@ gst_niimaqsrc_class_probe_interfaces (GstNiImaqSrcClass * klass, gboolean check)
|
||||
gst_niimaqsrc_report_imaq_error (rval);
|
||||
|
||||
/* iterate over all the available ports */
|
||||
for (port=0; port < nports; port++) {
|
||||
for (port = 0; port < nports; port++) {
|
||||
/* if the there are multiple ports append the port number */
|
||||
if (nports > 1)
|
||||
iname = g_strdup_printf ("%s::%d", name, port);
|
||||
@@ -305,7 +308,7 @@ gst_niimaqsrc_probe_probe_property (GstPropertyProbe * probe,
|
||||
*/
|
||||
static gboolean
|
||||
gst_niimaqsrc_probe_needs_probe (GstPropertyProbe * probe,
|
||||
guint prop_id, const GParamSpec * pspec)
|
||||
guint prop_id, const GParamSpec * pspec)
|
||||
{
|
||||
GstNiImaqSrcClass *klass = GST_NIIMAQSRC_GET_CLASS (probe);
|
||||
gboolean ret = FALSE;
|
||||
@@ -367,7 +370,7 @@ gst_niimaqsrc_class_list_interfaces (GstNiImaqSrcClass * klass)
|
||||
*/
|
||||
static GValueArray *
|
||||
gst_niimaqsrc_probe_get_values (GstPropertyProbe * probe,
|
||||
guint prop_id, const GParamSpec * pspec)
|
||||
guint prop_id, const GParamSpec * pspec)
|
||||
{
|
||||
GstNiImaqSrcClass *klass = GST_NIIMAQSRC_GET_CLASS (probe);
|
||||
GValueArray *array = NULL;
|
||||
@@ -415,7 +418,7 @@ gst_niimaqsrc_init_interfaces (GType type)
|
||||
};
|
||||
|
||||
g_type_add_interface_static (type,
|
||||
GST_TYPE_PROPERTY_PROBE, &niimaq_propertyprobe_info);
|
||||
GST_TYPE_PROPERTY_PROBE, &niimaq_propertyprobe_info);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -432,7 +435,7 @@ gst_niimaqsrc_base_init (gpointer g_class)
|
||||
gst_element_class_set_details (element_class, &niimaqsrc_details);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&src_factory));
|
||||
gst_static_pad_template_get (&src_factory));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -458,18 +461,19 @@ gst_niimaqsrc_class_init (GstNiImaqSrcClass * klass)
|
||||
/* install GObject properties */
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass),
|
||||
PROP_INTERFACE, g_param_spec_string ("interface",
|
||||
"Interface",
|
||||
"NI-IMAQ interface to open", DEFAULT_PROP_INTERFACE, G_PARAM_READWRITE));
|
||||
"Interface",
|
||||
"NI-IMAQ interface to open", DEFAULT_PROP_INTERFACE,
|
||||
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_param_spec_int ("buffer-size",
|
||||
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BUFSIZE,
|
||||
g_param_spec_int ("buffer-size",
|
||||
"Number of frames in the IMAQ ringbuffer",
|
||||
"The number of frames in the IMAQ ringbuffer", 1,
|
||||
G_MAXINT, DEFAULT_PROP_BUFSIZE, G_PARAM_READWRITE));
|
||||
"The number of frames in the IMAQ ringbuffer", 1, G_MAXINT,
|
||||
DEFAULT_PROP_BUFSIZE, G_PARAM_READWRITE));
|
||||
|
||||
/* install GstBaseSrc vmethod implementations */
|
||||
gstbasesrc_class->get_caps = gst_niimaqsrc_get_caps;
|
||||
@@ -541,7 +545,7 @@ gst_niimaqsrc_dispose (GObject * object)
|
||||
gst_caps_unref (niimaqsrc->caps);
|
||||
g_slist_free (niimaqsrc->timelist);
|
||||
g_mutex_free (niimaqsrc->frametime_mutex);
|
||||
|
||||
|
||||
|
||||
/* chain dispose fuction of parent class */
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
@@ -604,7 +608,9 @@ gst_niimaqsrc_get_caps (GstBaseSrc * bsrc)
|
||||
|
||||
/* return template caps if we don't know the actual camera caps */
|
||||
if (!niimaqsrc->caps) {
|
||||
return gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (niimaqsrc)));
|
||||
return
|
||||
gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD
|
||||
(niimaqsrc)));
|
||||
}
|
||||
|
||||
return gst_caps_copy (niimaqsrc->caps);
|
||||
@@ -631,7 +637,8 @@ gst_niimaqsrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
|
||||
niimaqsrc->caps = gst_caps_copy (caps);
|
||||
}
|
||||
|
||||
res = gst_niimaqsrc_parse_caps (niimaqsrc->caps, &width, &height, &depth, &bpp);
|
||||
res =
|
||||
gst_niimaqsrc_parse_caps (niimaqsrc->caps, &width, &height, &depth, &bpp);
|
||||
|
||||
if (res) {
|
||||
/* looks ok here */
|
||||
@@ -639,7 +646,7 @@ gst_niimaqsrc_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
|
||||
niimaqsrc->height = height;
|
||||
niimaqsrc->depth = depth;
|
||||
niimaqsrc->bpp = bpp;
|
||||
niimaqsrc->framesize = width * height * (depth/8);
|
||||
niimaqsrc->framesize = width * height * (depth / 8);
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -675,7 +682,7 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
||||
gpointer data;
|
||||
GstFlowReturn res = GST_FLOW_OK;
|
||||
guint i;
|
||||
GstNiImaqSrcFrameTime * frametime;
|
||||
GstNiImaqSrcFrameTime *frametime;
|
||||
GstClockTime timestamp = GST_CLOCK_TIME_NONE;
|
||||
GstClockTime timestamp2 = GST_CLOCK_TIME_NONE;
|
||||
GstClockTime duration = GST_CLOCK_TIME_NONE;
|
||||
@@ -684,7 +691,7 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
||||
uInt32 copied_index;
|
||||
Int32 rval;
|
||||
uInt32 dropped;
|
||||
|
||||
|
||||
/* start the IMAQ acquisition session if we haven't done so yet */
|
||||
if (!niimaqsrc->session_started) {
|
||||
GST_DEBUG_OBJECT (niimaqsrc, "Starting acquisition");
|
||||
@@ -694,8 +701,7 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
||||
rval = imgSessionStartAcquisition (niimaqsrc->sid);
|
||||
if (rval == 0) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
gst_niimaqsrc_report_imaq_error (rval);
|
||||
GST_LOG_OBJECT (niimaqsrc, "camera is still off , wait 50ms and retry");
|
||||
g_usleep (50000);
|
||||
@@ -705,21 +711,22 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
||||
/* we tried five times and failed, so we error */
|
||||
if (i >= 5) {
|
||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED,
|
||||
("Camera doesn't seem to want to turn on!"),
|
||||
("Camera doesn't seem to want to turn on!"));
|
||||
("Camera doesn't seem to want to turn on!"),
|
||||
("Camera doesn't seem to want to turn on!"));
|
||||
|
||||
gst_niimaqsrc_close_interface (niimaqsrc);
|
||||
gst_niimaqsrc_close_interface (niimaqsrc);
|
||||
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
niimaqsrc->session_started = TRUE;
|
||||
}
|
||||
|
||||
data = g_malloc(niimaqsrc->framesize);
|
||||
data = g_malloc (niimaqsrc->framesize);
|
||||
|
||||
GST_DEBUG_OBJECT(niimaqsrc, "Copying IMAQ buffer %d", niimaqsrc->cumbufnum);
|
||||
GST_DEBUG_OBJECT (niimaqsrc, "Copying IMAQ buffer %d", niimaqsrc->cumbufnum);
|
||||
|
||||
rval = imgSessionCopyBufferByNumber (niimaqsrc->sid, niimaqsrc->cumbufnum, data,
|
||||
rval =
|
||||
imgSessionCopyBufferByNumber (niimaqsrc->sid, niimaqsrc->cumbufnum, data,
|
||||
IMG_OVERWRITE_GET_OLDEST, &copied_number, &copied_index);
|
||||
if (rval) {
|
||||
gst_niimaqsrc_report_imaq_error (rval);
|
||||
@@ -731,11 +738,11 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
||||
|
||||
/* TODO, DEBUG: get running time now to compare to what the callback gives us */
|
||||
/*clock = gst_element_get_clock (GST_ELEMENT (niimaqsrc));
|
||||
timestamp2 =
|
||||
GST_CLOCK_DIFF (gst_element_get_base_time (GST_ELEMENT (niimaqsrc)), gst_clock_get_time (clock));
|
||||
gst_object_unref (clock);*/
|
||||
timestamp2 =
|
||||
GST_CLOCK_DIFF (gst_element_get_base_time (GST_ELEMENT (niimaqsrc)), gst_clock_get_time (clock));
|
||||
gst_object_unref (clock); */
|
||||
|
||||
GST_DEBUG_OBJECT(niimaqsrc, "Creating buffer");
|
||||
GST_DEBUG_OBJECT (niimaqsrc, "Creating buffer");
|
||||
|
||||
*buffer = gst_buffer_new ();
|
||||
|
||||
@@ -745,7 +752,7 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
||||
GST_BUFFER_OFFSET (*buffer) = copied_number;
|
||||
GST_BUFFER_OFFSET_END (*buffer) = copied_number;
|
||||
|
||||
GST_DEBUG_OBJECT(niimaqsrc, "Associating time with buffer");
|
||||
GST_DEBUG_OBJECT (niimaqsrc, "Associating time with buffer");
|
||||
|
||||
/* search linked list for frame time */
|
||||
g_mutex_lock (niimaqsrc->frametime_mutex);
|
||||
@@ -753,19 +760,20 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
||||
/* remove all old frametimes from the list */
|
||||
frametime = niimaqsrc->timelist->data;
|
||||
while (frametime->number < copied_number) {
|
||||
niimaqsrc->timelist = g_slist_delete_link (niimaqsrc->timelist, niimaqsrc->timelist);
|
||||
niimaqsrc->timelist =
|
||||
g_slist_delete_link (niimaqsrc->timelist, niimaqsrc->timelist);
|
||||
frametime = niimaqsrc->timelist->data;
|
||||
}
|
||||
|
||||
|
||||
if (frametime->number == copied_number) {
|
||||
timestamp = frametime->time;
|
||||
|
||||
/* remove frame time as we no longer need it */
|
||||
niimaqsrc->timelist = g_slist_delete_link (niimaqsrc->timelist, niimaqsrc->timelist);
|
||||
}
|
||||
else {
|
||||
niimaqsrc->timelist =
|
||||
g_slist_delete_link (niimaqsrc->timelist, niimaqsrc->timelist);
|
||||
} else {
|
||||
timestamp = GST_CLOCK_TIME_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
g_mutex_unlock (niimaqsrc->frametime_mutex);
|
||||
|
||||
@@ -774,25 +782,24 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
||||
GST_WARNING_OBJECT (niimaqsrc, "No timestamp found; callback failed?");
|
||||
timestamp = GST_CLOCK_TIME_NONE;
|
||||
/*clock = gst_element_get_clock (GST_ELEMENT (niimaqsrc));
|
||||
GST_BUFFER_TIMESTAMP (*buffer) =
|
||||
GST_CLOCK_DIFF (gst_element_get_base_time (GST_ELEMENT (niimaqsrc)), gst_clock_get_time (clock));
|
||||
gst_object_unref (clock);*/
|
||||
}
|
||||
else {
|
||||
GST_BUFFER_TIMESTAMP (*buffer) =
|
||||
GST_CLOCK_DIFF (gst_element_get_base_time (GST_ELEMENT (niimaqsrc)), gst_clock_get_time (clock));
|
||||
gst_object_unref (clock); */
|
||||
} else {
|
||||
timestamp =
|
||||
GST_CLOCK_DIFF (gst_element_get_base_time (GST_ELEMENT (niimaqsrc)), timestamp);
|
||||
GST_CLOCK_DIFF (gst_element_get_base_time (GST_ELEMENT (niimaqsrc)),
|
||||
timestamp);
|
||||
}
|
||||
|
||||
/* make guess of duration from timestamp and cumulative buffer number */
|
||||
if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
|
||||
duration = timestamp / (copied_number + 1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
duration = 33 * GST_MSECOND;
|
||||
}
|
||||
|
||||
/* TODO, DEBUG: set duration to see what the difference is between callback and create */
|
||||
/*duration = GST_CLOCK_DIFF (timestamp, timestamp2);*/
|
||||
/*duration = GST_CLOCK_DIFF (timestamp, timestamp2); */
|
||||
|
||||
|
||||
GST_BUFFER_TIMESTAMP (*buffer) = timestamp;
|
||||
@@ -802,17 +809,18 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
||||
gst_buffer_set_caps (*buffer, GST_PAD_CAPS (GST_BASE_SRC_PAD (niimaqsrc)));
|
||||
|
||||
/*GST_BUFFER_TIMESTAMP (outbuf) = src->timestamp_offset + src->running_time;
|
||||
if (src->rate_numerator != 0) {
|
||||
GST_BUFFER_DURATION (outbuf) = gst_util_uint64_scale_int (GST_SECOND,
|
||||
src->rate_denominator, src->rate_numerator);
|
||||
}*/
|
||||
if (src->rate_numerator != 0) {
|
||||
GST_BUFFER_DURATION (outbuf) = gst_util_uint64_scale_int (GST_SECOND,
|
||||
src->rate_denominator, src->rate_numerator);
|
||||
} */
|
||||
|
||||
dropped = copied_number - niimaqsrc->cumbufnum;
|
||||
if (dropped > 0) {
|
||||
niimaqsrc->n_dropped_frames += dropped;
|
||||
GST_WARNING_OBJECT (niimaqsrc, "Asked to copy buffer %d but was given %d",
|
||||
niimaqsrc->cumbufnum, copied_number);
|
||||
GST_WARNING_OBJECT (niimaqsrc, "Dropped %d frames (%d total)", dropped, niimaqsrc->n_dropped_frames);
|
||||
GST_WARNING_OBJECT (niimaqsrc, "Dropped %d frames (%d total)", dropped,
|
||||
niimaqsrc->n_dropped_frames);
|
||||
}
|
||||
|
||||
/* set cumulative buffer number to get next frame */
|
||||
@@ -820,9 +828,9 @@ gst_niimaqsrc_create (GstPushSrc * psrc, GstBuffer ** buffer)
|
||||
niimaqsrc->n_frames++;
|
||||
|
||||
/*if (src->rate_numerator != 0) {
|
||||
src->running_time = gst_util_uint64_scale_int (src->n_frames * GST_SECOND,
|
||||
src->rate_denominator, src->rate_numerator);
|
||||
}*/
|
||||
src->running_time = gst_util_uint64_scale_int (src->n_frames * GST_SECOND,
|
||||
src->rate_denominator, src->rate_numerator);
|
||||
} */
|
||||
|
||||
return res;
|
||||
|
||||
@@ -859,9 +867,7 @@ gst_niimaqsrc_parse_caps (const GstCaps * caps, gint * width, gint * height,
|
||||
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);
|
||||
"depth", G_TYPE_INT, depth, "bpp", G_TYPE_INT, bpp, NULL);
|
||||
|
||||
if (!ret) {
|
||||
GST_DEBUG ("Failed to retrieve width, height, depth, or bpp");
|
||||
@@ -888,12 +894,9 @@ gst_niimaqsrc_set_caps_color (GstStructure * gs, gint bpp, gint depth)
|
||||
|
||||
gst_structure_set_name (gs, "video/x-raw-gray");
|
||||
gst_structure_set (gs,
|
||||
"bpp", G_TYPE_INT, bpp,
|
||||
"depth", G_TYPE_INT, depth, NULL);
|
||||
"bpp", G_TYPE_INT, bpp, "depth", G_TYPE_INT, depth, NULL);
|
||||
if (depth > 8) {
|
||||
gst_structure_set(gs,
|
||||
"endianness", G_TYPE_INT, G_LITTLE_ENDIAN,
|
||||
NULL);
|
||||
gst_structure_set (gs, "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, NULL);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -913,9 +916,7 @@ static gboolean
|
||||
gst_niimaqsrc_set_caps_framesize (GstStructure * gs, gint width, gint height)
|
||||
{
|
||||
gst_structure_set (gs,
|
||||
"width", G_TYPE_INT, width,
|
||||
"height", G_TYPE_INT, height,
|
||||
NULL);
|
||||
"width", G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -940,8 +941,8 @@ gst_niimaqsrc_get_cam_caps (GstNiImaqSrc * niimaqsrc)
|
||||
gcaps = gst_caps_new_empty ();
|
||||
|
||||
if (!niimaqsrc->iid) {
|
||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED, ("Camera interface not open"),
|
||||
("Camera interface not open"));
|
||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED,
|
||||
("Camera interface not open"), ("Camera interface not open"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -951,7 +952,7 @@ gst_niimaqsrc_get_cam_caps (GstNiImaqSrc * niimaqsrc)
|
||||
bpp = val;
|
||||
rval &= imgGetAttribute (niimaqsrc->iid, IMG_ATTR_BYTESPERPIXEL, &val);
|
||||
gst_niimaqsrc_report_imaq_error (rval);
|
||||
depth = val*8;
|
||||
depth = val * 8;
|
||||
rval &= imgGetAttribute (niimaqsrc->iid, IMG_ATTR_ROI_WIDTH, &val);
|
||||
gst_niimaqsrc_report_imaq_error (rval);
|
||||
width = val;
|
||||
@@ -969,19 +970,20 @@ gst_niimaqsrc_get_cam_caps (GstNiImaqSrc * niimaqsrc)
|
||||
/* create new structure and set caps we got from IMAQ */
|
||||
gs = gst_structure_empty_new ("video");
|
||||
if (!gst_niimaqsrc_set_caps_color (gs, bpp, depth) ||
|
||||
!gst_niimaqsrc_set_caps_framesize (gs, width, height)) {
|
||||
!gst_niimaqsrc_set_caps_framesize (gs, width, height)) {
|
||||
GST_ELEMENT_ERROR (niimaqsrc, STREAM, FAILED,
|
||||
("attempt to set caps %dx%dx%d (%d) failed", width, height, depth, bpp),
|
||||
("attempt to set caps %dx%dx%d (%d) failed", width, height, depth, bpp));
|
||||
("attempt to set caps %dx%dx%d (%d) failed", width, height, depth,
|
||||
bpp));
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
/* hard code framerate to 30Hz as IMAQ doesn't tell us anything about it */
|
||||
GST_DEBUG_OBJECT (niimaqsrc, "Setting framerate to 30 fps");
|
||||
gst_structure_set (gs, "framerate", GST_TYPE_FRACTION, 30, 1, NULL);
|
||||
|
||||
GST_DEBUG_OBJECT (gs, "is the basic structure");
|
||||
|
||||
|
||||
gst_caps_append_structure (gcaps, gst_structure_copy (gs));
|
||||
|
||||
/* if (8 < bpp < 16), then append structure with bpp=16 so ffmpegcolorspace
|
||||
@@ -1017,32 +1019,36 @@ error:
|
||||
static gboolean
|
||||
gst_niimaqsrc_start (GstBaseSrc * src)
|
||||
{
|
||||
GstNiImaqSrc* niimaqsrc = GST_NIIMAQSRC(src);
|
||||
GstNiImaqSrc *niimaqsrc = GST_NIIMAQSRC (src);
|
||||
Int32 rval;
|
||||
gint i;
|
||||
|
||||
niimaqsrc->iid = 0;
|
||||
niimaqsrc->sid = 0;
|
||||
|
||||
GST_DEBUG_OBJECT (niimaqsrc, "Opening IMAQ interface: %s", niimaqsrc->interface_name);
|
||||
GST_DEBUG_OBJECT (niimaqsrc, "Opening IMAQ interface: %s",
|
||||
niimaqsrc->interface_name);
|
||||
|
||||
/* open IMAQ interface */
|
||||
rval=imgInterfaceOpen(niimaqsrc->interface_name,&(niimaqsrc->iid));
|
||||
rval = imgInterfaceOpen (niimaqsrc->interface_name, &(niimaqsrc->iid));
|
||||
if (rval) {
|
||||
gst_niimaqsrc_report_imaq_error (rval);
|
||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED, ("Failed to open IMAQ interface"),
|
||||
("Failed to open camera interface %s", niimaqsrc->interface_name));
|
||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED,
|
||||
("Failed to open IMAQ interface"),
|
||||
("Failed to open camera interface %s", niimaqsrc->interface_name));
|
||||
goto error;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (niimaqsrc, "Opening IMAQ session: %s", niimaqsrc->interface_name);
|
||||
GST_DEBUG_OBJECT (niimaqsrc, "Opening IMAQ session: %s",
|
||||
niimaqsrc->interface_name);
|
||||
|
||||
/* open IMAQ session */
|
||||
rval=imgSessionOpen(niimaqsrc->iid, &(niimaqsrc->sid));
|
||||
rval = imgSessionOpen (niimaqsrc->iid, &(niimaqsrc->sid));
|
||||
if (rval) {
|
||||
gst_niimaqsrc_report_imaq_error (rval);
|
||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED, ("Failed to open IMAQ session"),
|
||||
("Failed to open IMAQ session %d", niimaqsrc->sid));
|
||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED,
|
||||
("Failed to open IMAQ session"), ("Failed to open IMAQ session %d",
|
||||
niimaqsrc->sid));
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1052,27 +1058,31 @@ gst_niimaqsrc_start (GstBaseSrc * src)
|
||||
}
|
||||
|
||||
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"));
|
||||
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", niimaqsrc->bufsize);
|
||||
GST_LOG_OBJECT (niimaqsrc, "Creating ring with %d buffers",
|
||||
niimaqsrc->bufsize);
|
||||
|
||||
/* create array of pointers to give to IMAQ for creating internal buffers */
|
||||
niimaqsrc->buflist = g_new (guint32*, niimaqsrc->bufsize);
|
||||
for (i=0; i < niimaqsrc->bufsize; i++) {
|
||||
niimaqsrc->buflist = g_new (guint32 *, niimaqsrc->bufsize);
|
||||
for (i = 0; i < niimaqsrc->bufsize; i++) {
|
||||
niimaqsrc->buflist[i] = 0;
|
||||
}
|
||||
rval=imgRingSetup (niimaqsrc->sid, niimaqsrc->bufsize, (void**)(niimaqsrc->buflist), 0, FALSE);
|
||||
rval =
|
||||
imgRingSetup (niimaqsrc->sid, niimaqsrc->bufsize,
|
||||
(void **) (niimaqsrc->buflist), 0, FALSE);
|
||||
if (rval) {
|
||||
gst_niimaqsrc_report_imaq_error (rval);
|
||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED, ("Failed to create ring buffer"),
|
||||
("Failed to create ring buffer with %d buffers", niimaqsrc->bufsize));
|
||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED,
|
||||
("Failed to create ring buffer"),
|
||||
("Failed to create ring buffer with %d buffers", niimaqsrc->bufsize));
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1082,8 +1092,9 @@ gst_niimaqsrc_start (GstBaseSrc * src)
|
||||
gst_niimaqsrc_frame_start_callback, niimaqsrc);
|
||||
if (rval) {
|
||||
gst_niimaqsrc_report_imaq_error (rval);
|
||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED, ("Failed to register BUF_COMPLETE callback"),
|
||||
("Failed to register BUF_COMPLETE callback"));
|
||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED,
|
||||
("Failed to register BUF_COMPLETE callback"),
|
||||
("Failed to register BUF_COMPLETE callback"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1107,22 +1118,22 @@ error:
|
||||
static gboolean
|
||||
gst_niimaqsrc_stop (GstBaseSrc * src)
|
||||
{
|
||||
GstNiImaqSrc* niimaqsrc = GST_NIIMAQSRC (src);
|
||||
GstNiImaqSrc *niimaqsrc = GST_NIIMAQSRC (src);
|
||||
Int32 rval;
|
||||
|
||||
/* stop IMAQ session */
|
||||
if (niimaqsrc->session_started) {
|
||||
rval = imgSessionStopAcquisition (niimaqsrc->sid);
|
||||
if (rval) {
|
||||
gst_niimaqsrc_report_imaq_error (rval);
|
||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED, ("Unable to stop acquisition"),
|
||||
("Unable to stop acquisition"));
|
||||
rval = imgSessionStopAcquisition (niimaqsrc->sid);
|
||||
if (rval) {
|
||||
gst_niimaqsrc_report_imaq_error (rval);
|
||||
GST_ELEMENT_ERROR (niimaqsrc, RESOURCE, FAILED,
|
||||
("Unable to stop acquisition"), ("Unable to stop acquisition"));
|
||||
}
|
||||
niimaqsrc->session_started = FALSE;
|
||||
GST_DEBUG_OBJECT (niimaqsrc, "Acquisition stopped");
|
||||
}
|
||||
|
||||
gst_niimaqsrc_close_interface(niimaqsrc);
|
||||
gst_niimaqsrc_close_interface (niimaqsrc);
|
||||
|
||||
if (niimaqsrc->caps) {
|
||||
gst_caps_unref (niimaqsrc->caps);
|
||||
@@ -1143,14 +1154,14 @@ gst_niimaqsrc_close_interface (GstNiImaqSrc * niimaqsrc)
|
||||
Int32 rval;
|
||||
|
||||
/* close IMAQ session and interface */
|
||||
if(niimaqsrc->sid) {
|
||||
rval = imgClose(niimaqsrc->sid,TRUE);
|
||||
if (niimaqsrc->sid) {
|
||||
rval = imgClose (niimaqsrc->sid, TRUE);
|
||||
gst_niimaqsrc_report_imaq_error (rval);
|
||||
niimaqsrc->sid = 0;
|
||||
GST_DEBUG_OBJECT (niimaqsrc, "IMAQ session closed");
|
||||
}
|
||||
if(niimaqsrc->iid) {
|
||||
rval = imgClose(niimaqsrc->iid,TRUE);
|
||||
if (niimaqsrc->iid) {
|
||||
rval = imgClose (niimaqsrc->iid, TRUE);
|
||||
gst_niimaqsrc_report_imaq_error (rval);
|
||||
niimaqsrc->iid = 0;
|
||||
GST_DEBUG_OBJECT (niimaqsrc, "IMAQ interface closed");
|
||||
@@ -1168,11 +1179,12 @@ gst_niimaqsrc_close_interface (GstNiImaqSrc * niimaqsrc)
|
||||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
GST_DEBUG_CATEGORY_INIT (niimaqsrc_debug, "niimaqsrc", 0, "NI-IMAQ interface");
|
||||
GST_DEBUG_CATEGORY_INIT (niimaqsrc_debug, "niimaqsrc", 0,
|
||||
"NI-IMAQ interface");
|
||||
|
||||
/* we only have one element in this plugin */
|
||||
return gst_element_register (plugin, "niimaqsrc", GST_RANK_NONE,
|
||||
GST_TYPE_NIIMAQSRC);
|
||||
GST_TYPE_NIIMAQSRC);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -77,34 +77,30 @@ static GstFlowReturn gst_phoenixsrc_create (GstPushSrc * src, GstBuffer ** buf);
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_CAMERA_CONFIG_FILEPATH,
|
||||
PROP_NUM_CAPTURE_BUFFERS
|
||||
PROP_0,
|
||||
PROP_CAMERA_CONFIG_FILEPATH,
|
||||
PROP_NUM_CAPTURE_BUFFERS
|
||||
};
|
||||
|
||||
#define DEFAULT_PROP_CAMERA_CONFIG_FILEPATH NULL /* defaults to 640x480x8bpp */
|
||||
#define DEFAULT_PROP_CAMERA_CONFIG_FILEPATH NULL /* defaults to 640x480x8bpp */
|
||||
#define DEFAULT_PROP_NUM_CAPTURE_BUFFERS 2
|
||||
|
||||
/* pad templates */
|
||||
|
||||
static GstStaticPadTemplate gst_phoenixsrc_src_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_STATIC_PAD_TEMPLATE ("src",
|
||||
GST_PAD_SRC,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (
|
||||
GST_VIDEO_CAPS_GRAY8 ";"
|
||||
GST_VIDEO_CAPS_GRAY16("BIG_ENDIAN") ";"
|
||||
GST_VIDEO_CAPS_GRAY16("LITTLE_ENDIAN") ";"
|
||||
GST_VIDEO_CAPS_RGB ";"
|
||||
GST_VIDEO_CAPS_xRGB ";"
|
||||
GST_VIDEO_CAPS_RGB_15 ";"
|
||||
GST_VIDEO_CAPS_RGB_16)
|
||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_GRAY8 ";"
|
||||
GST_VIDEO_CAPS_GRAY16 ("BIG_ENDIAN") ";"
|
||||
GST_VIDEO_CAPS_GRAY16 ("LITTLE_ENDIAN") ";"
|
||||
GST_VIDEO_CAPS_RGB ";"
|
||||
GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGB_15 ";" GST_VIDEO_CAPS_RGB_16)
|
||||
);
|
||||
|
||||
/* class initialization */
|
||||
|
||||
GST_BOILERPLATE (GstPhoenixSrc, gst_phoenixsrc, GstPushSrc,
|
||||
GST_TYPE_PUSH_SRC);
|
||||
GST_BOILERPLATE (GstPhoenixSrc, gst_phoenixsrc, GstPushSrc, GST_TYPE_PUSH_SRC);
|
||||
|
||||
|
||||
static GstVideoFormat
|
||||
@@ -112,8 +108,8 @@ gst_phoenixsrc_color_format_to_video_format (int dst_format, int dst_endian)
|
||||
{
|
||||
switch (dst_format) {
|
||||
case PHX_DST_FORMAT_Y8:
|
||||
return GST_VIDEO_FORMAT_GRAY8;
|
||||
/* TODO: possibly use different formats for each of the following */
|
||||
return GST_VIDEO_FORMAT_GRAY8;
|
||||
/* TODO: possibly use different formats for each of the following */
|
||||
case PHX_DST_FORMAT_Y10:
|
||||
case PHX_DST_FORMAT_Y12:
|
||||
case PHX_DST_FORMAT_Y14:
|
||||
@@ -124,7 +120,7 @@ gst_phoenixsrc_color_format_to_video_format (int dst_format, int dst_endian)
|
||||
return GST_VIDEO_FORMAT_GRAY16_BE;
|
||||
else
|
||||
return GST_VIDEO_FORMAT_UNKNOWN;
|
||||
/* TODO: Bayer here */
|
||||
/* TODO: Bayer here */
|
||||
case PHX_DST_FORMAT_RGB15:
|
||||
return GST_VIDEO_FORMAT_RGB15;
|
||||
case PHX_DST_FORMAT_RGB16:
|
||||
@@ -173,7 +169,8 @@ gst_phoenixsrc_class_init (GstPhoenixSrcClass * klass)
|
||||
base_src_class->get_size = GST_DEBUG_FUNCPTR (gst_phoenixsrc_get_size);
|
||||
base_src_class->is_seekable = GST_DEBUG_FUNCPTR (gst_phoenixsrc_is_seekable);
|
||||
base_src_class->query = GST_DEBUG_FUNCPTR (gst_phoenixsrc_query);
|
||||
base_src_class->check_get_range = GST_DEBUG_FUNCPTR (gst_phoenixsrc_check_get_range);
|
||||
base_src_class->check_get_range =
|
||||
GST_DEBUG_FUNCPTR (gst_phoenixsrc_check_get_range);
|
||||
base_src_class->fixate = GST_DEBUG_FUNCPTR (gst_phoenixsrc_fixate);
|
||||
|
||||
push_src_class->create = GST_DEBUG_FUNCPTR (gst_phoenixsrc_create);
|
||||
@@ -187,15 +184,16 @@ gst_phoenixsrc_class_init (GstPhoenixSrcClass * klass)
|
||||
g_param_spec_uint ("num-capture-buffers", "Number of capture buffers",
|
||||
"Number of capture buffers", 1, G_MAXUINT,
|
||||
DEFAULT_PROP_NUM_CAPTURE_BUFFERS,
|
||||
(GParamFlags) (G_PARAM_READWRITE |G_PARAM_STATIC_STRINGS)));
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gst_phoenixsrc_init (GstPhoenixSrc * phoenixsrc, GstPhoenixSrcClass * phoenixsrc_class)
|
||||
gst_phoenixsrc_init (GstPhoenixSrc * phoenixsrc,
|
||||
GstPhoenixSrcClass * phoenixsrc_class)
|
||||
{
|
||||
phoenixsrc->srcpad = gst_pad_new_from_static_template (&gst_phoenixsrc_src_template
|
||||
, "src");
|
||||
phoenixsrc->srcpad =
|
||||
gst_pad_new_from_static_template (&gst_phoenixsrc_src_template, "src");
|
||||
|
||||
/* set source as live (no preroll) */
|
||||
gst_base_src_set_live (GST_BASE_SRC (phoenixsrc), TRUE);
|
||||
@@ -208,8 +206,10 @@ gst_phoenixsrc_init (GstPhoenixSrc * phoenixsrc, GstPhoenixSrcClass * phoenixsrc
|
||||
phoenixsrc->num_capture_buffers = DEFAULT_PROP_NUM_CAPTURE_BUFFERS;
|
||||
|
||||
phoenixsrc->first_phoenix_ts = GST_CLOCK_TIME_NONE;
|
||||
phoenixsrc->frame_start_times = g_new (guint64, phoenixsrc->num_capture_buffers);
|
||||
phoenixsrc->frame_end_times = g_new (guint64, phoenixsrc->num_capture_buffers);
|
||||
phoenixsrc->frame_start_times =
|
||||
g_new (guint64, phoenixsrc->num_capture_buffers);
|
||||
phoenixsrc->frame_end_times =
|
||||
g_new (guint64, phoenixsrc->num_capture_buffers);
|
||||
phoenixsrc->buffer_ready = FALSE;
|
||||
phoenixsrc->timeout_occurred = FALSE;
|
||||
phoenixsrc->fifo_overflow_occurred = FALSE;
|
||||
@@ -218,7 +218,7 @@ gst_phoenixsrc_init (GstPhoenixSrc * phoenixsrc, GstPhoenixSrcClass * phoenixsrc
|
||||
phoenixsrc->buffer_processed_count = 0;
|
||||
phoenixsrc->frame_end_count = 0;
|
||||
phoenixsrc->frame_start_count = 0;
|
||||
/*phoenixsrc->frame_count = 0;*/
|
||||
/*phoenixsrc->frame_count = 0; */
|
||||
|
||||
phoenixsrc->mutex = g_mutex_new ();
|
||||
phoenixsrc->cond = g_cond_new ();
|
||||
@@ -243,15 +243,16 @@ gst_phoenixsrc_set_property (GObject * object, guint property_id,
|
||||
GST_ELEMENT_WARNING (phoenixsrc, RESOURCE, SETTINGS,
|
||||
("Number of capture buffers cannot be changed after acquisition has started."),
|
||||
(NULL));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
phoenixsrc->num_capture_buffers = g_value_get_uint (value);
|
||||
|
||||
|
||||
g_free (phoenixsrc->frame_start_times);
|
||||
phoenixsrc->frame_start_times = g_new (guint64, phoenixsrc->num_capture_buffers);
|
||||
phoenixsrc->frame_start_times =
|
||||
g_new (guint64, phoenixsrc->num_capture_buffers);
|
||||
|
||||
g_free (phoenixsrc->frame_end_times);
|
||||
phoenixsrc->frame_end_times = g_new (guint64, phoenixsrc->num_capture_buffers);
|
||||
phoenixsrc->frame_end_times =
|
||||
g_new (guint64, phoenixsrc->num_capture_buffers);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -325,7 +326,9 @@ gst_phoenixsrc_get_caps (GstBaseSrc * src)
|
||||
|
||||
/* return template caps if we don't know the actual camera caps */
|
||||
if (!phoenixsrc->caps) {
|
||||
return gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (phoenixsrc)));
|
||||
return
|
||||
gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD
|
||||
(phoenixsrc)));
|
||||
}
|
||||
|
||||
return gst_caps_copy (phoenixsrc->caps);
|
||||
@@ -356,9 +359,7 @@ gst_phoenixsrc_set_caps (GstBaseSrc * src, GstCaps * caps)
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
|
||||
ret = gst_structure_get (structure,
|
||||
"width", G_TYPE_INT, &width,
|
||||
"height", G_TYPE_INT, &height,
|
||||
NULL);
|
||||
"width", G_TYPE_INT, &width, "height", G_TYPE_INT, &height, NULL);
|
||||
|
||||
if (!ret) {
|
||||
GST_DEBUG ("Failed to retrieve width and height");
|
||||
@@ -379,7 +380,7 @@ gst_phoenixsrc_newsegment (GstBaseSrc * src)
|
||||
}
|
||||
|
||||
static inline GstClockTime
|
||||
gst_phoenix_get_timestamp (GstPhoenixSrc *phoenixsrc)
|
||||
gst_phoenix_get_timestamp (GstPhoenixSrc * phoenixsrc)
|
||||
{
|
||||
ui32 dwParam;
|
||||
guint64 timestamp;
|
||||
@@ -387,7 +388,7 @@ gst_phoenix_get_timestamp (GstPhoenixSrc *phoenixsrc)
|
||||
/* get time in microseconds from start of acquisition */
|
||||
/* TODO: check for rollover */
|
||||
PHX_ParameterGet (phoenixsrc->hCamera, PHX_EVENTCOUNT, &dwParam);
|
||||
timestamp = (guint64)1000 * dwParam;
|
||||
timestamp = (guint64) 1000 *dwParam;
|
||||
|
||||
if (phoenixsrc->first_phoenix_ts == GST_CLOCK_TIME_NONE) {
|
||||
phoenixsrc->first_phoenix_ts = timestamp;
|
||||
@@ -397,7 +398,7 @@ gst_phoenix_get_timestamp (GstPhoenixSrc *phoenixsrc)
|
||||
|
||||
/* Callback function to handle image capture events. */
|
||||
void
|
||||
phx_callback (tHandle hCamera, ui32 dwMask, void* pvParams )
|
||||
phx_callback (tHandle hCamera, ui32 dwMask, void *pvParams)
|
||||
{
|
||||
GstPhoenixSrc *phoenixsrc = GST_PHOENIX_SRC (pvParams);
|
||||
GstClockTime ct = gst_phoenix_get_timestamp (phoenixsrc);
|
||||
@@ -456,9 +457,9 @@ static gboolean
|
||||
gst_phoenixsrc_start (GstBaseSrc * src)
|
||||
{
|
||||
GstPhoenixSrc *phoenixsrc = GST_PHOENIX_SRC (src);
|
||||
etStat eStat = PHX_OK; /* Status variable */
|
||||
etParamValue eParamValue = 0;
|
||||
ui32 dwParamValue = 0;
|
||||
etStat eStat = PHX_OK; /* Status variable */
|
||||
etParamValue eParamValue = 0;
|
||||
ui32 dwParamValue = 0;
|
||||
guint32 phx_format, phx_endian, width, height;
|
||||
GstVideoFormat videoFormat;
|
||||
ui32 dwBufferWidth, dwBufferHeight;
|
||||
@@ -466,9 +467,9 @@ gst_phoenixsrc_start (GstBaseSrc * src)
|
||||
GST_DEBUG_OBJECT (phoenixsrc, "start");
|
||||
|
||||
if (phoenixsrc->config_filepath == NULL) {
|
||||
GST_WARNING_OBJECT (phoenixsrc, "No config file set, using default 640x480x8bpp");
|
||||
}
|
||||
else if (!g_file_test (phoenixsrc->config_filepath, G_FILE_TEST_EXISTS)) {
|
||||
GST_WARNING_OBJECT (phoenixsrc,
|
||||
"No config file set, using default 640x480x8bpp");
|
||||
} else if (!g_file_test (phoenixsrc->config_filepath, G_FILE_TEST_EXISTS)) {
|
||||
GST_ELEMENT_ERROR (phoenixsrc, RESOURCE, NOT_FOUND,
|
||||
("Camera config file does not exist: %s", phoenixsrc->config_filepath),
|
||||
(NULL));
|
||||
@@ -477,7 +478,8 @@ gst_phoenixsrc_start (GstBaseSrc * src)
|
||||
|
||||
/* Initialize board */
|
||||
/* TODO: this picks first digital board using default settings, parameterize this! */
|
||||
eStat = PHX_CameraConfigLoad (&phoenixsrc->hCamera, phoenixsrc->config_filepath,
|
||||
eStat =
|
||||
PHX_CameraConfigLoad (&phoenixsrc->hCamera, phoenixsrc->config_filepath,
|
||||
PHX_BOARD_AUTO | PHX_DIGITAL, PHX_ErrHandlerDefault);
|
||||
if (eStat != PHX_OK) {
|
||||
GST_ELEMENT_ERROR (phoenixsrc, LIBRARY, INIT, (NULL), (NULL));
|
||||
@@ -486,48 +488,70 @@ gst_phoenixsrc_start (GstBaseSrc * src)
|
||||
|
||||
/* capture frames continuously */
|
||||
eParamValue = PHX_ENABLE;
|
||||
eStat = PHX_ParameterSet (phoenixsrc->hCamera, PHX_ACQ_CONTINUOUS, &eParamValue);
|
||||
if (PHX_OK != eStat) goto ResourceSettingsError;
|
||||
eStat =
|
||||
PHX_ParameterSet (phoenixsrc->hCamera, PHX_ACQ_CONTINUOUS, &eParamValue);
|
||||
if (PHX_OK != eStat)
|
||||
goto ResourceSettingsError;
|
||||
|
||||
/* capture in blocking fashion, i.e. don't overwrite un-processed buffers */
|
||||
eParamValue = PHX_DISABLE;
|
||||
eStat = PHX_ParameterSet (phoenixsrc->hCamera, PHX_ACQ_BLOCKING, &eParamValue);
|
||||
if (PHX_OK != eStat) goto ResourceSettingsError;
|
||||
eStat =
|
||||
PHX_ParameterSet (phoenixsrc->hCamera, PHX_ACQ_BLOCKING, &eParamValue);
|
||||
if (PHX_OK != eStat)
|
||||
goto ResourceSettingsError;
|
||||
|
||||
/* use event counter to count time from start of acquisition */
|
||||
eParamValue = PHX_EVENTCOUNT_TIME;
|
||||
eStat = PHX_ParameterSet (phoenixsrc->hCamera, PHX_EVENTCOUNT_SRC, &eParamValue);
|
||||
if (PHX_OK != eStat) goto ResourceSettingsError;
|
||||
eStat =
|
||||
PHX_ParameterSet (phoenixsrc->hCamera, PHX_EVENTCOUNT_SRC, &eParamValue);
|
||||
if (PHX_OK != eStat)
|
||||
goto ResourceSettingsError;
|
||||
eParamValue = PHX_EVENTGATE_ACQ;
|
||||
eStat = PHX_ParameterSet (phoenixsrc->hCamera, PHX_EVENTGATE_SRC, &eParamValue);
|
||||
if (PHX_OK != eStat) goto ResourceSettingsError;
|
||||
eStat =
|
||||
PHX_ParameterSet (phoenixsrc->hCamera, PHX_EVENTGATE_SRC, &eParamValue);
|
||||
if (PHX_OK != eStat)
|
||||
goto ResourceSettingsError;
|
||||
|
||||
|
||||
/* Get format (mono, Bayer, RBG, etc.) */
|
||||
eStat = PHX_ParameterGet (phoenixsrc->hCamera, PHX_DST_FORMAT, &dwParamValue);
|
||||
if (PHX_OK != eStat) goto ResourceSettingsError;
|
||||
if (PHX_OK != eStat)
|
||||
goto ResourceSettingsError;
|
||||
phx_format = dwParamValue;
|
||||
|
||||
|
||||
/* Get endianness */
|
||||
eStat = PHX_ParameterGet (phoenixsrc->hCamera, PHX_DST_ENDIAN, &dwParamValue);
|
||||
if (PHX_OK != eStat) goto ResourceSettingsError;
|
||||
if (PHX_OK != eStat)
|
||||
goto ResourceSettingsError;
|
||||
phx_endian = dwParamValue;
|
||||
|
||||
/* get width */
|
||||
eStat = PHX_ParameterGet (phoenixsrc->hCamera, PHX_ROI_XLENGTH_SCALED, &dwParamValue);
|
||||
if (PHX_OK != eStat) goto ResourceSettingsError;
|
||||
eStat =
|
||||
PHX_ParameterGet (phoenixsrc->hCamera, PHX_ROI_XLENGTH_SCALED,
|
||||
&dwParamValue);
|
||||
if (PHX_OK != eStat)
|
||||
goto ResourceSettingsError;
|
||||
width = dwParamValue;
|
||||
|
||||
/* get height */
|
||||
eStat = PHX_ParameterGet (phoenixsrc->hCamera, PHX_ROI_YLENGTH_SCALED, &dwParamValue);
|
||||
if (PHX_OK != eStat) goto ResourceSettingsError;
|
||||
eStat =
|
||||
PHX_ParameterGet (phoenixsrc->hCamera, PHX_ROI_YLENGTH_SCALED,
|
||||
&dwParamValue);
|
||||
if (PHX_OK != eStat)
|
||||
goto ResourceSettingsError;
|
||||
height = dwParamValue;
|
||||
|
||||
/* get buffer size; width (in bytes) and height (in lines) */
|
||||
eStat = PHX_ParameterGet (phoenixsrc->hCamera, PHX_BUF_DST_XLENGTH, &dwBufferWidth);
|
||||
if (PHX_OK != eStat) goto ResourceSettingsError;
|
||||
eStat = PHX_ParameterGet (phoenixsrc->hCamera, PHX_BUF_DST_YLENGTH, &dwBufferHeight);
|
||||
if (PHX_OK != eStat) goto ResourceSettingsError;
|
||||
eStat =
|
||||
PHX_ParameterGet (phoenixsrc->hCamera, PHX_BUF_DST_XLENGTH,
|
||||
&dwBufferWidth);
|
||||
if (PHX_OK != eStat)
|
||||
goto ResourceSettingsError;
|
||||
eStat =
|
||||
PHX_ParameterGet (phoenixsrc->hCamera, PHX_BUF_DST_YLENGTH,
|
||||
&dwBufferHeight);
|
||||
if (PHX_OK != eStat)
|
||||
goto ResourceSettingsError;
|
||||
phoenixsrc->buffer_size = dwBufferHeight * dwBufferWidth;
|
||||
|
||||
/* Tell Phoenix to use N buffers. */
|
||||
@@ -536,41 +560,52 @@ gst_phoenixsrc_start (GstBaseSrc * src)
|
||||
|
||||
/* Setup a one second timeout value (milliseconds) */
|
||||
dwParamValue = 1000;
|
||||
eStat = PHX_ParameterSet (phoenixsrc->hCamera, PHX_TIMEOUT_DMA, (void *) &dwParamValue);
|
||||
if (PHX_OK != eStat) goto ResourceSettingsError;
|
||||
eStat =
|
||||
PHX_ParameterSet (phoenixsrc->hCamera, PHX_TIMEOUT_DMA,
|
||||
(void *) &dwParamValue);
|
||||
if (PHX_OK != eStat)
|
||||
goto ResourceSettingsError;
|
||||
|
||||
/* The BUFFER_READY interrupt is already enabled by default,
|
||||
* but we must enable other interrupts here. */
|
||||
eParamValue = PHX_INTRPT_TIMEOUT | PHX_INTRPT_FIFO_OVERFLOW | PHX_INTRPT_FRAME_END | PHX_INTRPT_FRAME_START;
|
||||
eStat = PHX_ParameterSet (phoenixsrc->hCamera, PHX_INTRPT_SET, (void *) &eParamValue);
|
||||
if (PHX_OK != eStat) goto ResourceSettingsError;
|
||||
* but we must enable other interrupts here. */
|
||||
eParamValue =
|
||||
PHX_INTRPT_TIMEOUT | PHX_INTRPT_FIFO_OVERFLOW | PHX_INTRPT_FRAME_END |
|
||||
PHX_INTRPT_FRAME_START;
|
||||
eStat =
|
||||
PHX_ParameterSet (phoenixsrc->hCamera, PHX_INTRPT_SET,
|
||||
(void *) &eParamValue);
|
||||
if (PHX_OK != eStat)
|
||||
goto ResourceSettingsError;
|
||||
|
||||
videoFormat = gst_phoenixsrc_color_format_to_video_format (phx_format, phx_endian);
|
||||
videoFormat =
|
||||
gst_phoenixsrc_color_format_to_video_format (phx_format, phx_endian);
|
||||
if (videoFormat == GST_VIDEO_FORMAT_UNKNOWN) {
|
||||
GST_ELEMENT_ERROR (phoenixsrc, STREAM, WRONG_TYPE,
|
||||
(_("Unknown or unsupported color format.")), (NULL));
|
||||
(_("Unknown or unsupported color format.")), (NULL));
|
||||
goto Error;
|
||||
}
|
||||
|
||||
if (phoenixsrc->caps)
|
||||
gst_caps_unref (phoenixsrc->caps);
|
||||
phoenixsrc->caps = gst_video_format_new_caps (videoFormat, width, height, 30, 1, 1, 1);
|
||||
phoenixsrc->caps =
|
||||
gst_video_format_new_caps (videoFormat, width, height, 30, 1, 1, 1);
|
||||
|
||||
if (phoenixsrc->caps == NULL) {
|
||||
GST_ELEMENT_ERROR (phoenixsrc, STREAM, TOO_LAZY,
|
||||
(_("Failed to generate caps from video format.")), (NULL));
|
||||
(_("Failed to generate caps from video format.")), (NULL));
|
||||
goto Error;
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
|
||||
ResourceSettingsError:
|
||||
GST_ELEMENT_ERROR (phoenixsrc, RESOURCE, SETTINGS,
|
||||
(_("Failed to get Phoenix parameters.")), (NULL));
|
||||
(_("Failed to get Phoenix parameters.")), (NULL));
|
||||
|
||||
Error:
|
||||
/* Now cease all captures */
|
||||
if (phoenixsrc->hCamera) PHX_Acquire(phoenixsrc->hCamera, PHX_ABORT, NULL );
|
||||
if (phoenixsrc->hCamera)
|
||||
PHX_Acquire (phoenixsrc->hCamera, PHX_ABORT, NULL);
|
||||
|
||||
/* TODO Free all the user allocated memory */
|
||||
//psImageBuff = pasImageBuffs;
|
||||
@@ -583,7 +618,8 @@ Error:
|
||||
//}
|
||||
|
||||
/* Release the Phoenix board */
|
||||
if (phoenixsrc->hCamera) PHX_CameraRelease(&phoenixsrc->hCamera);
|
||||
if (phoenixsrc->hCamera)
|
||||
PHX_CameraRelease (&phoenixsrc->hCamera);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -607,8 +643,8 @@ gst_phoenixsrc_stop (GstBaseSrc * src)
|
||||
gst_caps_unref (phoenixsrc->caps);
|
||||
phoenixsrc->caps = NULL;
|
||||
|
||||
phoenixsrc->dropped_frame_count = 0;
|
||||
/*phoenixsrc->last_time_code = -1;*/
|
||||
phoenixsrc->dropped_frame_count = 0;
|
||||
/*phoenixsrc->last_time_code = -1; */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -675,8 +711,8 @@ gst_phoenixsrc_create (GstPushSrc * src, GstBuffer ** buf)
|
||||
{
|
||||
GstPhoenixSrc *phoenixsrc = GST_PHOENIX_SRC (src);
|
||||
GstFlowReturn ret;
|
||||
etStat eStat = PHX_OK; /* Phoenix status variable */
|
||||
ui32 dwParamValue = 0; /* Phoenix Get/Set intermediate variable */
|
||||
etStat eStat = PHX_OK; /* Phoenix status variable */
|
||||
ui32 dwParamValue = 0; /* Phoenix Get/Set intermediate variable */
|
||||
stImageBuff phx_buffer;
|
||||
guint dropped_frame_count = 0;
|
||||
guint new_dropped_frames;
|
||||
@@ -684,23 +720,24 @@ gst_phoenixsrc_create (GstPushSrc * src, GstBuffer ** buf)
|
||||
|
||||
/* Create and allocate the buffer */
|
||||
ret = gst_pad_alloc_buffer (GST_BASE_SRC_PAD (GST_BASE_SRC (src)),
|
||||
GST_BUFFER_OFFSET_NONE, phoenixsrc->buffer_size,
|
||||
GST_PAD_CAPS (GST_BASE_SRC_PAD (GST_BASE_SRC (src))), buf);
|
||||
GST_BUFFER_OFFSET_NONE, phoenixsrc->buffer_size,
|
||||
GST_PAD_CAPS (GST_BASE_SRC_PAD (GST_BASE_SRC (src))), buf);
|
||||
if (G_UNLIKELY (ret != GST_FLOW_OK)) {
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
/* Start acquisition */
|
||||
if (!phoenixsrc->acq_started) {
|
||||
/* make class instance pointer available to the callback, and flush cache*/
|
||||
PHX_ParameterSet (phoenixsrc->hCamera, PHX_EVENT_CONTEXT | PHX_CACHE_FLUSH, (void *) phoenixsrc);
|
||||
/* make class instance pointer available to the callback, and flush cache */
|
||||
PHX_ParameterSet (phoenixsrc->hCamera, PHX_EVENT_CONTEXT | PHX_CACHE_FLUSH,
|
||||
(void *) phoenixsrc);
|
||||
|
||||
/* Now start our capture */
|
||||
eStat = PHX_Acquire (phoenixsrc->hCamera, PHX_START, (void*)phx_callback);
|
||||
eStat = PHX_Acquire (phoenixsrc->hCamera, PHX_START, (void *) phx_callback);
|
||||
if (PHX_OK != eStat) {
|
||||
GST_ELEMENT_ERROR (phoenixsrc, RESOURCE, FAILED,
|
||||
(_("Failed to start acquisition.")), (NULL));
|
||||
return GST_FLOW_ERROR; /* TODO: make sure _stop is called if this happens to release resources*/
|
||||
return GST_FLOW_ERROR; /* TODO: make sure _stop is called if this happens to release resources */
|
||||
}
|
||||
phoenixsrc->acq_started = TRUE;
|
||||
}
|
||||
@@ -729,29 +766,34 @@ gst_phoenixsrc_create (GstPushSrc * src, GstBuffer ** buf)
|
||||
|
||||
if (!phoenixsrc->buffer_ready) {
|
||||
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
||||
(_("You should not see this error, something very bad happened.")), (NULL));
|
||||
(_("You should not see this error, something very bad happened.")),
|
||||
(NULL));
|
||||
g_mutex_unlock (phoenixsrc->mutex);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
GST_INFO_OBJECT (phoenixsrc, "Processing new buffer %d (Frame start: %d), ready-processed = %d",
|
||||
phoenixsrc->buffer_ready_count, phoenixsrc->frame_start_count, phoenixsrc->buffer_ready_count-phoenixsrc->buffer_processed_count);
|
||||
GST_INFO_OBJECT (phoenixsrc,
|
||||
"Processing new buffer %d (Frame start: %d), ready-processed = %d",
|
||||
phoenixsrc->buffer_ready_count, phoenixsrc->frame_start_count,
|
||||
phoenixsrc->buffer_ready_count - phoenixsrc->buffer_processed_count);
|
||||
phoenixsrc->buffer_ready = FALSE;
|
||||
|
||||
/* frame_start is always >= buffer_ready */
|
||||
dropped_frame_count = phoenixsrc->frame_start_count - phoenixsrc->buffer_ready_count;
|
||||
dropped_frame_count =
|
||||
phoenixsrc->frame_start_count - phoenixsrc->buffer_ready_count;
|
||||
|
||||
g_mutex_unlock (phoenixsrc->mutex);
|
||||
|
||||
eStat = PHX_Acquire (phoenixsrc->hCamera, PHX_BUFFER_GET, &phx_buffer);
|
||||
if (PHX_OK != eStat) {
|
||||
GST_ELEMENT_ERROR (src, RESOURCE, FAILED,
|
||||
(_("Failed to get buffer.")), (NULL));
|
||||
(_("Failed to get buffer.")), (NULL));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
||||
/* Copy image to buffer from surface TODO: use orc_memcpy*/
|
||||
memcpy (GST_BUFFER_DATA (*buf), phx_buffer.pvAddress, phoenixsrc->buffer_size);
|
||||
/* Copy image to buffer from surface TODO: use orc_memcpy */
|
||||
memcpy (GST_BUFFER_DATA (*buf), phx_buffer.pvAddress,
|
||||
phoenixsrc->buffer_size);
|
||||
|
||||
/* Having processed the data, release the buffer ready for further image data */
|
||||
eStat = PHX_Acquire (phoenixsrc->hCamera, PHX_BUFFER_RELEASE, NULL);
|
||||
@@ -759,19 +801,20 @@ gst_phoenixsrc_create (GstPushSrc * src, GstBuffer ** buf)
|
||||
|
||||
/* check for dropped frames (can only detect more than one) */
|
||||
new_dropped_frames = dropped_frame_count - phoenixsrc->dropped_frame_count;
|
||||
if (new_dropped_frames > 0) {
|
||||
phoenixsrc->dropped_frame_count = dropped_frame_count;
|
||||
GST_WARNING ("Dropped %d frames (%d total)", new_dropped_frames,
|
||||
if (new_dropped_frames > 0) {
|
||||
phoenixsrc->dropped_frame_count = dropped_frame_count;
|
||||
GST_WARNING ("Dropped %d frames (%d total)", new_dropped_frames,
|
||||
phoenixsrc->dropped_frame_count);
|
||||
/* TODO: emit message here about dropped frames */
|
||||
}
|
||||
/* TODO: emit message here about dropped frames */
|
||||
}
|
||||
|
||||
GST_BUFFER_SIZE (*buf) = phoenixsrc->buffer_size;
|
||||
/* use time from capture board */
|
||||
n = (phoenixsrc->buffer_processed_count - 1) % phoenixsrc->num_capture_buffers;
|
||||
n = (phoenixsrc->buffer_processed_count -
|
||||
1) % phoenixsrc->num_capture_buffers;
|
||||
GST_BUFFER_TIMESTAMP (*buf) = phoenixsrc->frame_start_times[n];
|
||||
GST_BUFFER_DURATION (*buf) = GST_CLOCK_DIFF (phoenixsrc->frame_start_times[n],
|
||||
phoenixsrc->frame_end_times[n]);
|
||||
phoenixsrc->frame_end_times[n]);
|
||||
GST_BUFFER_OFFSET (*buf) = phoenixsrc->buffer_processed_count - 1;
|
||||
GST_BUFFER_OFFSET_END (*buf) = GST_BUFFER_OFFSET (*buf);
|
||||
|
||||
@@ -782,8 +825,8 @@ gst_phoenixsrc_create (GstPushSrc * src, GstBuffer ** buf)
|
||||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
GST_DEBUG_CATEGORY_INIT (gst_phoenixsrc_debug, "phoenixsrc", 0, \
|
||||
"debug category for phoenixsrc element");
|
||||
GST_DEBUG_CATEGORY_INIT (gst_phoenixsrc_debug, "phoenixsrc", 0,
|
||||
"debug category for phoenixsrc element");
|
||||
gst_element_register (plugin, "phoenixsrc", GST_RANK_NONE,
|
||||
gst_phoenixsrc_get_type ());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user