rtmp2sink: Add a property for the outgoing chunk size
This commit is contained in:
parent
f7bb2cdeb7
commit
0c344a7efb
@ -65,6 +65,7 @@ typedef struct
|
|||||||
GstRtmpLocation location;
|
GstRtmpLocation location;
|
||||||
gboolean async_connect;
|
gboolean async_connect;
|
||||||
guint peak_kbps;
|
guint peak_kbps;
|
||||||
|
guint32 chunk_size;
|
||||||
|
|
||||||
/* If both self->lock and OBJECT_LOCK are needed,
|
/* If both self->lock and OBJECT_LOCK are needed,
|
||||||
* self->lock must be taken first */
|
* self->lock must be taken first */
|
||||||
@ -120,6 +121,7 @@ static void connect_task_done (GObject * object, GAsyncResult * result,
|
|||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
static void set_pacing_rate (GstRtmp2Sink * self);
|
static void set_pacing_rate (GstRtmp2Sink * self);
|
||||||
|
static void set_chunk_size (GstRtmp2Sink * self);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -138,6 +140,7 @@ enum
|
|||||||
PROP_TLS_VALIDATION_FLAGS,
|
PROP_TLS_VALIDATION_FLAGS,
|
||||||
PROP_ASYNC_CONNECT,
|
PROP_ASYNC_CONNECT,
|
||||||
PROP_PEAK_KBPS,
|
PROP_PEAK_KBPS,
|
||||||
|
PROP_CHUNK_SIZE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* pad templates */
|
/* pad templates */
|
||||||
@ -206,6 +209,12 @@ gst_rtmp2_sink_class_init (GstRtmp2SinkClass * klass)
|
|||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||||
GST_PARAM_MUTABLE_PLAYING));
|
GST_PARAM_MUTABLE_PLAYING));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_CHUNK_SIZE,
|
||||||
|
g_param_spec_uint ("chunk-size", "Chunk size", "RTMP chunk size",
|
||||||
|
GST_RTMP_MINIMUM_CHUNK_SIZE, GST_RTMP_MAXIMUM_CHUNK_SIZE,
|
||||||
|
GST_RTMP_DEFAULT_CHUNK_SIZE, G_PARAM_READWRITE |
|
||||||
|
G_PARAM_STATIC_STRINGS | GST_PARAM_MUTABLE_PLAYING));
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_rtmp2_sink_debug_category, "rtmp2sink", 0,
|
GST_DEBUG_CATEGORY_INIT (gst_rtmp2_sink_debug_category, "rtmp2sink", 0,
|
||||||
"debug category for rtmp2sink element");
|
"debug category for rtmp2sink element");
|
||||||
}
|
}
|
||||||
@ -215,6 +224,7 @@ gst_rtmp2_sink_init (GstRtmp2Sink * self)
|
|||||||
{
|
{
|
||||||
self->location.flash_ver = g_strdup ("FMLE/3.0 (compatible; FMSc/1.0)");
|
self->location.flash_ver = g_strdup ("FMLE/3.0 (compatible; FMSc/1.0)");
|
||||||
self->async_connect = TRUE;
|
self->async_connect = TRUE;
|
||||||
|
self->chunk_size = GST_RTMP_DEFAULT_CHUNK_SIZE;
|
||||||
|
|
||||||
g_mutex_init (&self->lock);
|
g_mutex_init (&self->lock);
|
||||||
g_cond_init (&self->cond);
|
g_cond_init (&self->cond);
|
||||||
@ -320,6 +330,16 @@ gst_rtmp2_sink_set_property (GObject * object, guint property_id,
|
|||||||
set_pacing_rate (self);
|
set_pacing_rate (self);
|
||||||
g_mutex_unlock (&self->lock);
|
g_mutex_unlock (&self->lock);
|
||||||
break;
|
break;
|
||||||
|
case PROP_CHUNK_SIZE:
|
||||||
|
g_mutex_lock (&self->lock);
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (self);
|
||||||
|
self->chunk_size = g_value_get_uint (value);
|
||||||
|
GST_OBJECT_UNLOCK (self);
|
||||||
|
|
||||||
|
set_chunk_size (self);
|
||||||
|
g_mutex_unlock (&self->lock);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -404,6 +424,11 @@ gst_rtmp2_sink_get_property (GObject * object, guint property_id,
|
|||||||
g_value_set_uint (value, self->peak_kbps);
|
g_value_set_uint (value, self->peak_kbps);
|
||||||
GST_OBJECT_UNLOCK (self);
|
GST_OBJECT_UNLOCK (self);
|
||||||
break;
|
break;
|
||||||
|
case PROP_CHUNK_SIZE:
|
||||||
|
GST_OBJECT_LOCK (self);
|
||||||
|
g_value_set_uint (value, self->chunk_size);
|
||||||
|
GST_OBJECT_UNLOCK (self);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -1006,6 +1031,7 @@ connect_task_done (GObject * object, GAsyncResult * result, gpointer user_data)
|
|||||||
self->connection = g_task_propagate_pointer (task, &error);
|
self->connection = g_task_propagate_pointer (task, &error);
|
||||||
if (self->connection) {
|
if (self->connection) {
|
||||||
set_pacing_rate (self);
|
set_pacing_rate (self);
|
||||||
|
set_chunk_size (self);
|
||||||
gst_rtmp_connection_set_output_handler (self->connection,
|
gst_rtmp_connection_set_output_handler (self->connection,
|
||||||
put_chunk, g_object_ref (self), g_object_unref);
|
put_chunk, g_object_ref (self), g_object_unref);
|
||||||
g_signal_connect_object (self->connection, "error",
|
g_signal_connect_object (self->connection, "error",
|
||||||
@ -1061,3 +1087,19 @@ set_pacing_rate (GstRtmp2Sink * self)
|
|||||||
|
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_chunk_size (GstRtmp2Sink * self)
|
||||||
|
{
|
||||||
|
guint32 chunk_size;
|
||||||
|
|
||||||
|
if (!self->connection)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (self);
|
||||||
|
chunk_size = self->chunk_size;
|
||||||
|
GST_OBJECT_UNLOCK (self);
|
||||||
|
|
||||||
|
gst_rtmp_connection_set_chunk_size (self->connection, chunk_size);
|
||||||
|
GST_INFO_OBJECT (self, "Set chunk size to %" G_GUINT32_FORMAT, chunk_size);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user