mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-11 16:55:23 +00:00
rtpbin: propagate buffer-mode property
Propagate buffer-mode property to the jitterbuffers. Intercept BUFFERING messages in rtpbin
This commit is contained in:
parent
d3db9574a9
commit
a5b9d3f917
5 changed files with 74 additions and 28 deletions
|
@ -246,6 +246,7 @@ enum
|
||||||
#define DEFAULT_DO_LOST FALSE
|
#define DEFAULT_DO_LOST FALSE
|
||||||
#define DEFAULT_IGNORE_PT FALSE
|
#define DEFAULT_IGNORE_PT FALSE
|
||||||
#define DEFAULT_AUTOREMOVE FALSE
|
#define DEFAULT_AUTOREMOVE FALSE
|
||||||
|
#define DEFAULT_BUFFER_MODE RTP_JITTER_BUFFER_MODE_SLAVE
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -255,6 +256,7 @@ enum
|
||||||
PROP_DO_LOST,
|
PROP_DO_LOST,
|
||||||
PROP_IGNORE_PT,
|
PROP_IGNORE_PT,
|
||||||
PROP_AUTOREMOVE,
|
PROP_AUTOREMOVE,
|
||||||
|
PROP_BUFFER_MODE,
|
||||||
PROP_LAST
|
PROP_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -295,6 +297,7 @@ struct _GstRtpBinStream
|
||||||
gulong buffer_handlesync_sig;
|
gulong buffer_handlesync_sig;
|
||||||
gulong buffer_ptreq_sig;
|
gulong buffer_ptreq_sig;
|
||||||
gulong buffer_ntpstop_sig;
|
gulong buffer_ntpstop_sig;
|
||||||
|
gboolean buffering;
|
||||||
|
|
||||||
/* the PT demuxer of the SSRC */
|
/* the PT demuxer of the SSRC */
|
||||||
GstElement *demux;
|
GstElement *demux;
|
||||||
|
@ -1175,6 +1178,7 @@ create_stream (GstRtpBinSession * session, guint32 ssrc)
|
||||||
/* configure latency and packet lost */
|
/* configure latency and packet lost */
|
||||||
g_object_set (buffer, "latency", rtpbin->latency, NULL);
|
g_object_set (buffer, "latency", rtpbin->latency, NULL);
|
||||||
g_object_set (buffer, "do-lost", rtpbin->do_lost, NULL);
|
g_object_set (buffer, "do-lost", rtpbin->do_lost, NULL);
|
||||||
|
g_object_set (buffer, "mode", rtpbin->buffer_mode, NULL);
|
||||||
|
|
||||||
if (!rtpbin->ignore_pt)
|
if (!rtpbin->ignore_pt)
|
||||||
gst_bin_add (GST_BIN_CAST (rtpbin), demux);
|
gst_bin_add (GST_BIN_CAST (rtpbin), demux);
|
||||||
|
@ -1522,16 +1526,28 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
|
||||||
"Send an event downstream when a packet is lost", DEFAULT_DO_LOST,
|
"Send an event downstream when a packet is lost", DEFAULT_DO_LOST,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_IGNORE_PT,
|
|
||||||
g_param_spec_boolean ("ignore-pt", "Ignore PT",
|
|
||||||
"Do not demultiplex based on PT values", DEFAULT_IGNORE_PT,
|
|
||||||
G_PARAM_READWRITE));
|
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_AUTOREMOVE,
|
g_object_class_install_property (gobject_class, PROP_AUTOREMOVE,
|
||||||
g_param_spec_boolean ("autoremove", "Auto Remove",
|
g_param_spec_boolean ("autoremove", "Auto Remove",
|
||||||
"Automatically removed timed out sources", DEFAULT_AUTOREMOVE,
|
"Automatically removed timed out sources", DEFAULT_AUTOREMOVE,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_IGNORE_PT,
|
||||||
|
g_param_spec_boolean ("ignore_pt", "Ignore PT",
|
||||||
|
"Do not demultiplex based on PT values", DEFAULT_IGNORE_PT,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
/**
|
||||||
|
* GstRtpBin::buffer-mode:
|
||||||
|
*
|
||||||
|
* Control the buffering and timestamping mode used by the jitterbuffer.
|
||||||
|
*
|
||||||
|
* Since: 0.10.17
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (gobject_class, PROP_BUFFER_MODE,
|
||||||
|
g_param_spec_enum ("buffer-mode", "Buffer Mode",
|
||||||
|
"Control the buffering algorithm in use", RTP_TYPE_JITTER_BUFFER_MODE,
|
||||||
|
DEFAULT_BUFFER_MODE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_bin_change_state);
|
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_bin_change_state);
|
||||||
gstelement_class->request_new_pad =
|
gstelement_class->request_new_pad =
|
||||||
GST_DEBUG_FUNCPTR (gst_rtp_bin_request_new_pad);
|
GST_DEBUG_FUNCPTR (gst_rtp_bin_request_new_pad);
|
||||||
|
@ -1560,6 +1576,7 @@ gst_rtp_bin_init (GstRtpBin * rtpbin, GstRtpBinClass * klass)
|
||||||
rtpbin->do_lost = DEFAULT_DO_LOST;
|
rtpbin->do_lost = DEFAULT_DO_LOST;
|
||||||
rtpbin->ignore_pt = DEFAULT_IGNORE_PT;
|
rtpbin->ignore_pt = DEFAULT_IGNORE_PT;
|
||||||
rtpbin->priv->autoremove = DEFAULT_AUTOREMOVE;
|
rtpbin->priv->autoremove = DEFAULT_AUTOREMOVE;
|
||||||
|
rtpbin->buffer_mode = DEFAULT_BUFFER_MODE;
|
||||||
|
|
||||||
/* some default SDES entries */
|
/* some default SDES entries */
|
||||||
str = g_strdup_printf ("%s@%s", g_get_user_name (), g_get_host_name ());
|
str = g_strdup_printf ("%s@%s", g_get_user_name (), g_get_host_name ());
|
||||||
|
@ -1672,6 +1689,13 @@ gst_rtp_bin_set_property (GObject * object, guint prop_id,
|
||||||
case PROP_AUTOREMOVE:
|
case PROP_AUTOREMOVE:
|
||||||
rtpbin->priv->autoremove = g_value_get_boolean (value);
|
rtpbin->priv->autoremove = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_BUFFER_MODE:
|
||||||
|
GST_RTP_BIN_LOCK (rtpbin);
|
||||||
|
rtpbin->buffer_mode = g_value_get_enum (value);
|
||||||
|
GST_RTP_BIN_UNLOCK (rtpbin);
|
||||||
|
/* propagate the property down to the jitterbuffer */
|
||||||
|
gst_rtp_bin_propagate_property_to_jitterbuffer (rtpbin, "mode", value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -1706,6 +1730,9 @@ gst_rtp_bin_get_property (GObject * object, guint prop_id,
|
||||||
case PROP_AUTOREMOVE:
|
case PROP_AUTOREMOVE:
|
||||||
g_value_set_boolean (value, rtpbin->priv->autoremove);
|
g_value_set_boolean (value, rtpbin->priv->autoremove);
|
||||||
break;
|
break;
|
||||||
|
case PROP_BUFFER_MODE:
|
||||||
|
g_value_set_enum (value, rtpbin->buffer_mode);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -1746,7 +1773,17 @@ gst_rtp_bin_handle_message (GstBin * bin, GstMessage * message)
|
||||||
}
|
}
|
||||||
GST_RTP_BIN_UNLOCK (rtpbin);
|
GST_RTP_BIN_UNLOCK (rtpbin);
|
||||||
}
|
}
|
||||||
/* fallthrough to forward the modified message to the parent */
|
GST_BIN_CLASS (parent_class)->handle_message (bin, message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GST_MESSAGE_BUFFERING:
|
||||||
|
{
|
||||||
|
gint percent;
|
||||||
|
|
||||||
|
gst_message_parse_buffering (message, &percent);
|
||||||
|
|
||||||
|
GST_BIN_CLASS (parent_class)->handle_message (bin, message);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
#include "rtpsession.h"
|
#include "rtpsession.h"
|
||||||
|
#include "rtpjitterbuffer.h"
|
||||||
|
|
||||||
#define GST_TYPE_RTP_BIN \
|
#define GST_TYPE_RTP_BIN \
|
||||||
(gst_rtp_bin_get_type())
|
(gst_rtp_bin_get_type())
|
||||||
|
@ -47,6 +48,7 @@ struct _GstRtpBin {
|
||||||
guint latency;
|
guint latency;
|
||||||
gboolean do_lost;
|
gboolean do_lost;
|
||||||
gboolean ignore_pt;
|
gboolean ignore_pt;
|
||||||
|
RTPJitterBufferMode buffer_mode;
|
||||||
/* a list of session */
|
/* a list of session */
|
||||||
GSList *sessions;
|
GSList *sessions;
|
||||||
|
|
||||||
|
|
|
@ -88,26 +88,6 @@ enum
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RTP_TYPE_JITTER_BUFFER_MODE (rtp_jitter_buffer_mode_get_type())
|
|
||||||
static GType
|
|
||||||
rtp_jitter_buffer_mode_get_type (void)
|
|
||||||
{
|
|
||||||
static GType jitter_buffer_mode_type = 0;
|
|
||||||
static const GEnumValue jitter_buffer_modes[] = {
|
|
||||||
{RTP_JITTER_BUFFER_MODE_NONE, "Only use RTP timestamps", "none"},
|
|
||||||
{RTP_JITTER_BUFFER_MODE_SLAVE, "Slave receiver to sender clock", "slave"},
|
|
||||||
{RTP_JITTER_BUFFER_MODE_BUFFER, "Do low/high watermark buffering",
|
|
||||||
"buffer"},
|
|
||||||
{0, NULL, NULL},
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!jitter_buffer_mode_type) {
|
|
||||||
jitter_buffer_mode_type =
|
|
||||||
g_enum_register_static ("RTPJitterBufferMode", jitter_buffer_modes);
|
|
||||||
}
|
|
||||||
return jitter_buffer_mode_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DEFAULT_LATENCY_MS 200
|
#define DEFAULT_LATENCY_MS 200
|
||||||
#define DEFAULT_DROP_ON_LATENCY FALSE
|
#define DEFAULT_DROP_ON_LATENCY FALSE
|
||||||
#define DEFAULT_TS_OFFSET 0
|
#define DEFAULT_TS_OFFSET 0
|
||||||
|
|
|
@ -44,6 +44,25 @@ enum
|
||||||
/* GObject vmethods */
|
/* GObject vmethods */
|
||||||
static void rtp_jitter_buffer_finalize (GObject * object);
|
static void rtp_jitter_buffer_finalize (GObject * object);
|
||||||
|
|
||||||
|
GType
|
||||||
|
rtp_jitter_buffer_mode_get_type (void)
|
||||||
|
{
|
||||||
|
static GType jitter_buffer_mode_type = 0;
|
||||||
|
static const GEnumValue jitter_buffer_modes[] = {
|
||||||
|
{RTP_JITTER_BUFFER_MODE_NONE, "Only use RTP timestamps", "none"},
|
||||||
|
{RTP_JITTER_BUFFER_MODE_SLAVE, "Slave receiver to sender clock", "slave"},
|
||||||
|
{RTP_JITTER_BUFFER_MODE_BUFFER, "Do low/high watermark buffering",
|
||||||
|
"buffer"},
|
||||||
|
{0, NULL, NULL},
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!jitter_buffer_mode_type) {
|
||||||
|
jitter_buffer_mode_type =
|
||||||
|
g_enum_register_static ("RTPJitterBufferMode", jitter_buffer_modes);
|
||||||
|
}
|
||||||
|
return jitter_buffer_mode_type;
|
||||||
|
}
|
||||||
|
|
||||||
/* static guint rtp_jitter_buffer_signals[LAST_SIGNAL] = { 0 }; */
|
/* static guint rtp_jitter_buffer_signals[LAST_SIGNAL] = { 0 }; */
|
||||||
|
|
||||||
G_DEFINE_TYPE (RTPJitterBuffer, rtp_jitter_buffer, G_TYPE_OBJECT);
|
G_DEFINE_TYPE (RTPJitterBuffer, rtp_jitter_buffer, G_TYPE_OBJECT);
|
||||||
|
@ -243,9 +262,14 @@ update_buffer_level (RTPJitterBuffer * jbuf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (post) {
|
if (post) {
|
||||||
gint percent = (jbuf->level * 100 / jbuf->delay);
|
gint percent;
|
||||||
|
|
||||||
|
if (jbuf->buffering) {
|
||||||
|
percent = (jbuf->level * 100 / jbuf->delay);
|
||||||
percent = MIN (percent, 100);
|
percent = MIN (percent, 100);
|
||||||
|
} else {
|
||||||
|
percent = 100;
|
||||||
|
}
|
||||||
|
|
||||||
if (jbuf->stats_cb)
|
if (jbuf->stats_cb)
|
||||||
jbuf->stats_cb (jbuf, percent, jbuf->stats_data);
|
jbuf->stats_cb (jbuf, percent, jbuf->stats_data);
|
||||||
|
|
|
@ -55,6 +55,9 @@ typedef enum {
|
||||||
RTP_JITTER_BUFFER_MODE_LAST
|
RTP_JITTER_BUFFER_MODE_LAST
|
||||||
} RTPJitterBufferMode;
|
} RTPJitterBufferMode;
|
||||||
|
|
||||||
|
#define RTP_TYPE_JITTER_BUFFER_MODE (rtp_jitter_buffer_mode_get_type())
|
||||||
|
GType rtp_jitter_buffer_mode_get_type (void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RTPBufferingStats:
|
* RTPBufferingStats:
|
||||||
* @jbuf: an #RTPJitterBuffer
|
* @jbuf: an #RTPJitterBuffer
|
||||||
|
|
Loading…
Reference in a new issue