Skip to content

Commit

Permalink
gst: make num-buffers a property
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Doyle authored and EmmanuelP committed Oct 30, 2014
1 parent 3fd3eea commit 2443757
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
22 changes: 19 additions & 3 deletions gst-0.10/gstaravis.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <time.h>
#include <string.h>

#define GST_ARAVIS_N_BUFFERS 50
#define GST_ARAVIS_DEFAULT_N_BUFFERS 50
#define GST_ARAVIS_BUFFER_TIMEOUT_DEFAULT 2000000

GST_DEBUG_CATEGORY_STATIC (aravis_debug);
Expand All @@ -57,7 +57,8 @@ enum
PROP_V_BINNING,
PROP_OFFSET_X,
PROP_OFFSET_Y,
PROP_PACKET_RESEND
PROP_PACKET_RESEND,
PROP_NUM_BUFFERS
};

GST_BOILERPLATE (GstAravis, gst_aravis, GstPushSrc, GST_TYPE_PUSH_SRC);
Expand Down Expand Up @@ -260,7 +261,7 @@ gst_aravis_set_caps (GstBaseSrc *src, GstCaps *caps)
else
g_object_set (gst_aravis->stream, "packet-resend", ARV_GV_STREAM_PACKET_RESEND_NEVER, NULL);

for (i = 0; i < GST_ARAVIS_N_BUFFERS; i++)
for (i = 0; i < gst_aravis->num_buffers; i++)
arv_stream_push_buffer (gst_aravis->stream,
arv_buffer_new (gst_aravis->payload, NULL));

Expand Down Expand Up @@ -469,6 +470,7 @@ gst_aravis_init (GstAravis *gst_aravis, GstAravisClass *g_class)
gst_aravis->h_binning = -1;
gst_aravis->v_binning = -1;
gst_aravis->packet_resend = TRUE;
gst_aravis->num_buffers = GST_ARAVIS_DEFAULT_N_BUFFERS;
gst_aravis->payload = 0;

gst_aravis->buffer_timeout_us = GST_ARAVIS_BUFFER_TIMEOUT_DEFAULT;
Expand Down Expand Up @@ -562,6 +564,9 @@ gst_aravis_set_property (GObject * object, guint prop_id,
case PROP_PACKET_RESEND:
gst_aravis->packet_resend = g_value_get_boolean (value);
break;
case PROP_NUM_BUFFERS:
gst_aravis->num_buffers = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
Expand Down Expand Up @@ -608,6 +613,9 @@ gst_aravis_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_PACKET_RESEND:
g_value_set_boolean (value, gst_aravis->packet_resend);
break;
case PROP_NUM_BUFFERS:
g_value_set_int (value, gst_aravis->num_buffers);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
Expand Down Expand Up @@ -727,6 +735,14 @@ gst_aravis_class_init (GstAravisClass * klass)
"Request dropped packets to be reissued by the camera",
TRUE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property
(gobject_class,
PROP_NUM_BUFFERS,
g_param_spec_int ("num-buffers",
"Number of Buffers",
"Number of video buffers to allocate for video frames",
1, G_MAXINT, GST_ARAVIS_DEFAULT_N_BUFFERS,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

GST_DEBUG_CATEGORY_INIT (aravis_debug, "aravissrc", 0, "Aravis interface");

Expand Down
1 change: 1 addition & 0 deletions gst-0.10/gstaravis.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct _GstAravis {
gint h_binning;
gint v_binning;
gboolean packet_resend;
gint num_buffers;

gint payload;

Expand Down
23 changes: 20 additions & 3 deletions gst/gstaravis.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <time.h>
#include <string.h>

#define GST_ARAVIS_N_BUFFERS 50
#define GST_ARAVIS_DEFAULT_N_BUFFERS 50
#define GST_ARAVIS_BUFFER_TIMEOUT_DEFAULT 2000000

GST_DEBUG_CATEGORY_STATIC (aravis_debug);
Expand All @@ -57,7 +57,8 @@ enum
PROP_V_BINNING,
PROP_OFFSET_X,
PROP_OFFSET_Y,
PROP_PACKET_RESEND
PROP_PACKET_RESEND,
PROP_NUM_BUFFERS
};

G_DEFINE_TYPE (GstAravis, gst_aravis, GST_TYPE_PUSH_SRC);
Expand Down Expand Up @@ -248,7 +249,7 @@ gst_aravis_set_caps (GstBaseSrc *src, GstCaps *caps)
else
g_object_set (gst_aravis->stream, "packet-resend", ARV_GV_STREAM_PACKET_RESEND_NEVER, NULL);

for (i = 0; i < GST_ARAVIS_N_BUFFERS; i++)
for (i = 0; i < gst_aravis->num_buffers; i++)
arv_stream_push_buffer (gst_aravis->stream,
arv_buffer_new (gst_aravis->payload, NULL));

Expand Down Expand Up @@ -445,6 +446,7 @@ gst_aravis_init (GstAravis *gst_aravis)
gst_aravis->h_binning = -1;
gst_aravis->v_binning = -1;
gst_aravis->packet_resend = TRUE;
gst_aravis->num_buffers = GST_ARAVIS_DEFAULT_N_BUFFERS;
gst_aravis->payload = 0;

gst_aravis->buffer_timeout_us = GST_ARAVIS_BUFFER_TIMEOUT_DEFAULT;
Expand Down Expand Up @@ -538,6 +540,9 @@ gst_aravis_set_property (GObject * object, guint prop_id,
case PROP_PACKET_RESEND:
gst_aravis->packet_resend = g_value_get_boolean (value);
break;
case PROP_NUM_BUFFERS:
gst_aravis->num_buffers = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
Expand Down Expand Up @@ -584,6 +589,9 @@ gst_aravis_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_PACKET_RESEND:
g_value_set_boolean (value, gst_aravis->packet_resend);
break;
case PROP_NUM_BUFFERS:
g_value_set_int (value, gst_aravis->num_buffers);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
Expand Down Expand Up @@ -692,6 +700,15 @@ gst_aravis_class_init (GstAravisClass * klass)
TRUE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

g_object_class_install_property
(gobject_class,
PROP_NUM_BUFFERS,
g_param_spec_int ("num-buffers",
"Number of Buffers",
"Number of video buffers to allocate for video frames",
1, G_MAXINT, GST_ARAVIS_DEFAULT_N_BUFFERS,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

GST_DEBUG_CATEGORY_INIT (aravis_debug, "aravissrc", 0, "Aravis interface");

gst_element_class_set_details_simple (element_class,
Expand Down
1 change: 1 addition & 0 deletions gst/gstaravis.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct _GstAravis {
gint h_binning;
gint v_binning;
gboolean packet_resend;
gint num_buffers;

gint payload;

Expand Down

0 comments on commit 2443757

Please sign in to comment.