[aravis] gst: allow frame rate setting.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] gst: allow frame rate setting.
- Date: Thu, 20 May 2010 14:35:46 +0000 (UTC)
commit e12b8dca5214325eed604b86ef9730bbb59aa06f
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Thu May 20 16:35:27 2010 +0200
gst: allow frame rate setting.
gst/gstaravis.c | 25 ++++++++++++++++++++++---
gst/gstaravis.h | 2 ++
src/arvcamera.c | 17 ++++++++++++++++-
src/arvcamera.h | 3 ++-
src/arvcameratest.c | 2 +-
test/pipelines.txt | 2 +-
6 files changed, 44 insertions(+), 7 deletions(-)
---
diff --git a/gst/gstaravis.c b/gst/gstaravis.c
index 91d6440..b10b724 100644
--- a/gst/gstaravis.c
+++ b/gst/gstaravis.c
@@ -52,6 +52,7 @@ enum
{
PROP_0,
PROP_CAMERA_NAME,
+ PROP_FRAME_RATE,
PROP_WIDTH,
PROP_HEIGHT,
PROP_H_BINNING,
@@ -70,6 +71,7 @@ gst_aravis_get_camera_caps (GstAravis *gst_aravis)
{
GstCaps *gcaps = NULL;
GstStructure *gs;
+ double frame_rate;
int height, width;
GST_LOG_OBJECT (gst_aravis, "Get camera caps");
@@ -87,7 +89,9 @@ gst_aravis_get_camera_caps (GstAravis *gst_aravis)
"height", G_TYPE_INT, height,
NULL);
- gst_structure_set(gs, "framerate", GST_TYPE_FRACTION, 50, 1, NULL);
+ frame_rate = arv_camera_get_frame_rate (gst_aravis->camera);
+
+ gst_structure_set(gs, "framerate", GST_TYPE_FRACTION, (gint) (100.0 * frame_rate), 100, NULL);
gst_caps_append_structure (gcaps, gs);
return gcaps;
@@ -110,8 +114,6 @@ gst_aravis_start (GstBaseSrc *src)
GstAravis* gst_aravis = GST_ARAVIS(src);
int i;
- g_message ("start");
-
GST_LOG_OBJECT (gst_aravis, "Opening first available camera");
if (gst_aravis->camera != NULL)
@@ -124,6 +126,8 @@ gst_aravis_start (GstBaseSrc *src)
arv_camera_set_region (gst_aravis->camera, 0, 0, gst_aravis->width, gst_aravis->height);
arv_camera_set_binning (gst_aravis->camera, gst_aravis->h_binning, gst_aravis->v_binning);
+ arv_camera_set_pixel_format (gst_aravis->camera, ARV_PIXEL_FORMAT_MONO_8);
+ arv_camera_set_frame_rate (gst_aravis->camera, gst_aravis->frame_rate);
gst_aravis->payload = arv_camera_get_payload (gst_aravis->camera);
gst_aravis->caps = gst_aravis_get_camera_caps (gst_aravis);
@@ -209,6 +213,7 @@ gst_aravis_init (GstAravis *gst_aravis, GstAravisClass *g_class)
gst_aravis->camera_name = NULL;
+ gst_aravis->frame_rate = 25.0;
gst_aravis->width = 320;
gst_aravis->height = 200;
gst_aravis->h_binning = 1;
@@ -256,6 +261,9 @@ gst_aravis_set_property (GObject * object, guint prop_id,
g_free (gst_aravis->camera_name);
gst_aravis->camera_name = g_strdup (g_value_get_string (value));
break;
+ case PROP_FRAME_RATE:
+ gst_aravis->frame_rate = g_value_get_double (value);
+ break;
case PROP_WIDTH:
gst_aravis->width = g_value_get_int (value);
break;
@@ -284,6 +292,9 @@ gst_aravis_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_CAMERA_NAME:
g_value_set_string (value, gst_aravis->camera_name);
break;
+ case PROP_FRAME_RATE:
+ g_value_set_double (value, gst_aravis->frame_rate);
+ break;
case PROP_WIDTH:
g_value_set_int (value, gst_aravis->width);
break;
@@ -334,6 +345,14 @@ gst_aravis_class_init (GstAravisClass * klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property
(gobject_class,
+ PROP_FRAME_RATE,
+ g_param_spec_double ("frame-rate",
+ "Frame rate",
+ "Acquisition frame rate (in Hz)",
+ 0.0, 500.0, 25.0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property
+ (gobject_class,
PROP_WIDTH,
g_param_spec_int ("width",
"Image width",
diff --git a/gst/gstaravis.h b/gst/gstaravis.h
index bb3577e..0c32451 100644
--- a/gst/gstaravis.h
+++ b/gst/gstaravis.h
@@ -43,6 +43,8 @@ struct _GstAravis {
char *camera_name;
+ double frame_rate;
+
gint width;
gint height;
gint h_binning;
diff --git a/src/arvcamera.c b/src/arvcamera.c
index aeb95bc..23cc083 100644
--- a/src/arvcamera.c
+++ b/src/arvcamera.c
@@ -195,7 +195,7 @@ arv_camera_get_acquisition_mode (ArvCamera *camera)
}
void
-arv_camera_set_fixed_frame_rate (ArvCamera *camera, double frame_rate)
+arv_camera_set_frame_rate (ArvCamera *camera, double frame_rate)
{
g_return_if_fail (ARV_IS_CAMERA (camera));
@@ -225,6 +225,21 @@ arv_camera_set_fixed_frame_rate (ArvCamera *camera, double frame_rate)
}
}
+double
+arv_camera_get_frame_rate (ArvCamera *camera)
+{
+ g_return_val_if_fail (ARV_IS_CAMERA (camera), -1);
+
+ switch (camera->priv->vendor) {
+ case ARV_CAMERA_VENDOR_BASLER:
+ case ARV_CAMERA_VENDOR_PROSILICA:
+ return arv_device_get_float_feature_value (camera->priv->device, "AcquisitionFrameRateAbs");
+ case ARV_CAMERA_VENDOR_UNKNOWN:
+ default:
+ return arv_device_get_float_feature_value (camera->priv->device, "AcquisitionFrameRate");
+ }
+}
+
void
arv_camera_set_trigger (ArvCamera *camera, const char *source)
{
diff --git a/src/arvcamera.h b/src/arvcamera.h
index ec8b495..2ef9d74 100644
--- a/src/arvcamera.h
+++ b/src/arvcamera.h
@@ -84,7 +84,8 @@ void arv_camera_stop_acquisition (ArvCamera *camera);
void arv_camera_set_acquisition_mode (ArvCamera *camera, ArvAcquisitionMode value);
ArvAcquisitionMode arv_camera_get_acquisition_mode (ArvCamera *camera);
-void arv_camera_set_fixed_frame_rate (ArvCamera *camera, double frame_rate);
+void arv_camera_set_frame_rate (ArvCamera *camera, double frame_rate);
+double arv_camera_get_frame_rate (ArvCamera *camera);
void arv_camera_set_trigger (ArvCamera *camera, const char *source);
void arv_camera_set_exposure_time (ArvCamera *camera, double exposure_time_us);
diff --git a/src/arvcameratest.c b/src/arvcameratest.c
index 5f2db65..445d507 100644
--- a/src/arvcameratest.c
+++ b/src/arvcameratest.c
@@ -116,7 +116,7 @@ main (int argc, char **argv)
arv_camera_set_acquisition_mode (camera, ARV_ACQUISITION_MODE_CONTINUOUS);
if (arv_option_frequency > 0.0)
- arv_camera_set_fixed_frame_rate (camera, arv_option_frequency);
+ arv_camera_set_frame_rate (camera, arv_option_frequency);
if (arv_option_trigger != NULL)
arv_camera_set_trigger (camera, arv_option_trigger);
diff --git a/test/pipelines.txt b/test/pipelines.txt
index ce1aa73..7e2f69d 100644
--- a/test/pipelines.txt
+++ b/test/pipelines.txt
@@ -1,7 +1,7 @@
Theora - udp
~~~~~~~~~~~~
-aravissrc width=256 height=256 v-binning=4 h-binning=4 ! ffmpegcolorspace ! theoraenc bitrate=150 ! udpsink host=127.0.0.1 port=1234
+aravissrc width=256 height=256 v-binning=4 h-binning=4 frame-rate=25.0 ! ffmpegcolorspace ! theoraenc bitrate=150 ! udpsink host=127.0.0.1 port=1234
udpsrc port=1234 ! theoradec ! xvimagesink
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]