summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2011-11-08 11:48:25 (GMT)
committerOlivier CrĂȘte <olivier.crete@collabora.com>2011-11-14 18:33:18 (GMT)
commit7a8dd5ef57afc9dd279366b6c07a38c30493f927 (patch)
tree632ee5e7c7f438a490e4ac0d1b08f61e46168c57
parentec877c7a4df94e5ba419ff3c706481a2223c29b8 (diff)
downloadfarstream-7a8dd5ef57afc9dd279366b6c07a38c30493f927.tar.gz
farstream-7a8dd5ef57afc9dd279366b6c07a38c30493f927.tar.xz
shm-stream-transmitter: Add property to control the buffer-time
Allow the transmitter to buffer how much can be maximally queued in the shmsink before blocking. Default to 20 miliseconds. For audio network packets tend to be around 20ms is size, so 20ms is a suitable size for audio. For video, 20 miliseconds is less then one frame at 30 fps, so with 20ms as default at most one video frame will be queued up in the shm sink.
-rw-r--r--transmitters/shm/fs-shm-stream-transmitter.c21
-rw-r--r--transmitters/shm/fs-shm-transmitter.c12
-rw-r--r--transmitters/shm/fs-shm-transmitter.h1
3 files changed, 32 insertions, 2 deletions
diff --git a/transmitters/shm/fs-shm-stream-transmitter.c b/transmitters/shm/fs-shm-stream-transmitter.c
index 23c45f2..4568258 100644
--- a/transmitters/shm/fs-shm-stream-transmitter.c
+++ b/transmitters/shm/fs-shm-stream-transmitter.c
@@ -98,6 +98,7 @@ enum
PROP_SENDING,
PROP_PREFERRED_LOCAL_CANDIDATES,
PROP_CREATE_LOCAL_CANDIDATES,
+ PROP_BUFFER_TIME,
};
struct _FsShmStreamTransmitterPrivate
@@ -127,6 +128,8 @@ struct _FsShmStreamTransmitterPrivate
ShmSrc **shm_src;
ShmSink **shm_sink;
+
+ guint64 buffer_time;
};
#define FS_SHM_STREAM_TRANSMITTER_GET_PRIVATE(o) \
@@ -227,6 +230,12 @@ fs_shm_stream_transmitter_class_init (FsShmStreamTransmitterClass *klass)
PROP_CREATE_LOCAL_CANDIDATES,
pspec);
+ pspec = g_param_spec_uint64 ("buffer-time",
+ "BufferTime",
+ "Maximum Size of the outgoing buffer in nanoseconds",
+ 0, G_MAXUINT64, 20 * GST_MSECOND,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (gobject_class, PROP_BUFFER_TIME, pspec);
gobject_class->dispose = fs_shm_stream_transmitter_dispose;
gobject_class->finalize = fs_shm_stream_transmitter_finalize;
@@ -309,6 +318,9 @@ fs_shm_stream_transmitter_get_property (GObject *object,
case PROP_CREATE_LOCAL_CANDIDATES:
g_value_set_boolean (value, self->priv->create_local_candidates);
break;
+ case PROP_BUFFER_TIME:
+ g_value_set_uint64 (value, self->priv->buffer_time);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -344,6 +356,9 @@ fs_shm_stream_transmitter_set_property (GObject *object,
case PROP_CREATE_LOCAL_CANDIDATES:
self->priv->create_local_candidates = g_value_get_boolean (value);
break;
+ case PROP_BUFFER_TIME:
+ self->priv->buffer_time = g_value_get_uint64 (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -414,7 +429,8 @@ fs_shm_stream_transmitter_add_sink (FsShmStreamTransmitter *self,
self->priv->shm_sink[candidate->component_id] =
fs_shm_transmitter_get_shm_sink (self->priv->transmitter,
- candidate->component_id, candidate->ip, ready_cb, connected_cb,
+ candidate->component_id, candidate->ip, self->priv->buffer_time,
+ ready_cb, connected_cb,
self, error);
if (self->priv->shm_sink[candidate->component_id] == NULL)
@@ -571,7 +587,8 @@ fs_shm_stream_transmitter_gather_local_candidates (
self->priv->shm_sink[c] =
fs_shm_transmitter_get_shm_sink (self->priv->transmitter,
- c, path, ready_cb, connected_cb, self, error);
+ c, path, self->priv->buffer_time,
+ ready_cb, connected_cb, self, error);
g_free (path);
if (self->priv->shm_sink[c] == NULL)
diff --git a/transmitters/shm/fs-shm-transmitter.c b/transmitters/shm/fs-shm-transmitter.c
index 5bd049f..e0b1106 100644
--- a/transmitters/shm/fs-shm-transmitter.c
+++ b/transmitters/shm/fs-shm-transmitter.c
@@ -732,6 +732,7 @@ ShmSink *
fs_shm_transmitter_get_shm_sink (FsShmTransmitter *self,
guint component,
const gchar *path,
+ guint64 buffer_time,
ready ready_func,
connection connected_func,
gpointer cb_data,
@@ -767,6 +768,17 @@ fs_shm_transmitter_get_shm_sink (FsShmTransmitter *self,
"sync" , FALSE,
NULL);
+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (elem), "buffer-time"))
+ {
+ GST_DEBUG ("Configured shmsink with a %"G_GUINT64_FORMAT" buffer-time",
+ buffer_time);
+ g_object_set (elem, "buffer-time", buffer_time, NULL);
+ }
+ else
+ {
+ GST_DEBUG ("No buffer-time property in shmsink, not setting");
+ }
+
if (ready_func)
g_signal_connect (self->priv->gst_sink, "ready", G_CALLBACK (ready_cb),
shm);
diff --git a/transmitters/shm/fs-shm-transmitter.h b/transmitters/shm/fs-shm-transmitter.h
index 978c304..9fccb39 100644
--- a/transmitters/shm/fs-shm-transmitter.h
+++ b/transmitters/shm/fs-shm-transmitter.h
@@ -106,6 +106,7 @@ gboolean fs_shm_transmitter_check_shm_src (FsShmTransmitter *self,
ShmSink *fs_shm_transmitter_get_shm_sink (FsShmTransmitter *self,
guint component,
const gchar *path,
+ guint64 buffer_time,
ready ready_func,
connection connected_fubnc,
gpointer cb_data,