mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 15:51:11 +00:00
rtpbin: pass running_time to jitterbuffer pause
Pass the current running time to the jitterbuffer when pausing or resuming so that it calculate the right offsets. Small cleanups and comments. Set the default rtspsrc latency to 2 seconds.
This commit is contained in:
parent
bf697b12e3
commit
8d814f3782
4 changed files with 34 additions and 24 deletions
|
@ -1176,8 +1176,8 @@ create_stream (GstRtpBinSession * session, guint32 ssrc)
|
||||||
stream->buffer_ntpstop_sig = g_signal_connect (buffer, "on-npt-stop",
|
stream->buffer_ntpstop_sig = g_signal_connect (buffer, "on-npt-stop",
|
||||||
(GCallback) on_npt_stop, stream);
|
(GCallback) on_npt_stop, stream);
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (buffer), "GstRtpBinSession", session);
|
g_object_set_data (G_OBJECT (buffer), "GstRTPBin.session", session);
|
||||||
g_object_set_data (G_OBJECT (buffer), "GstRtpBinStream", stream);
|
g_object_set_data (G_OBJECT (buffer), "GstRTPBin.stream", stream);
|
||||||
|
|
||||||
/* 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);
|
||||||
|
@ -1757,23 +1757,17 @@ gst_rtp_bin_handle_message (GstBin * bin, GstMessage * message)
|
||||||
|
|
||||||
/* we change the structure name and add the session ID to it */
|
/* we change the structure name and add the session ID to it */
|
||||||
if (gst_structure_has_name (s, "application/x-rtp-source-sdes")) {
|
if (gst_structure_has_name (s, "application/x-rtp-source-sdes")) {
|
||||||
GSList *walk;
|
GstRtpBinSession *sess;
|
||||||
|
|
||||||
/* find the session, the message source has it */
|
/* find the session we set it as object data */
|
||||||
GST_RTP_BIN_LOCK (rtpbin);
|
sess = g_object_get_data (G_OBJECT (GST_MESSAGE_SRC (message)),
|
||||||
for (walk = rtpbin->sessions; walk; walk = g_slist_next (walk)) {
|
"GstRTPBin.session");
|
||||||
GstRtpBinSession *sess = (GstRtpBinSession *) walk->data;
|
|
||||||
|
|
||||||
/* if we found the session, change message. else we exit the loop and
|
if (G_LIKELY (sess)) {
|
||||||
* leave the message unchanged */
|
|
||||||
if (GST_OBJECT_CAST (sess->session) == GST_MESSAGE_SRC (message)) {
|
|
||||||
message = gst_message_make_writable (message);
|
message = gst_message_make_writable (message);
|
||||||
s = gst_message_get_structure (message);
|
s = gst_message_get_structure (message);
|
||||||
|
|
||||||
gst_structure_set ((GstStructure *) s, "session", G_TYPE_UINT,
|
gst_structure_set ((GstStructure *) s, "session", G_TYPE_UINT,
|
||||||
sess->id, NULL);
|
sess->id, NULL);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
GST_RTP_BIN_UNLOCK (rtpbin);
|
GST_RTP_BIN_UNLOCK (rtpbin);
|
||||||
}
|
}
|
||||||
|
@ -1786,23 +1780,23 @@ gst_rtp_bin_handle_message (GstBin * bin, GstMessage * message)
|
||||||
gint min_percent = 100;
|
gint min_percent = 100;
|
||||||
GSList *sessions, *streams, *elements = NULL;
|
GSList *sessions, *streams, *elements = NULL;
|
||||||
GstRtpBinStream *stream;
|
GstRtpBinStream *stream;
|
||||||
guint64 base_time = 0;
|
|
||||||
gboolean change = FALSE, active = FALSE;
|
gboolean change = FALSE, active = FALSE;
|
||||||
|
|
||||||
gst_message_parse_buffering (message, &percent);
|
gst_message_parse_buffering (message, &percent);
|
||||||
|
|
||||||
stream =
|
stream =
|
||||||
g_object_get_data (G_OBJECT (GST_MESSAGE_SRC (message)),
|
g_object_get_data (G_OBJECT (GST_MESSAGE_SRC (message)),
|
||||||
"GstRtpBinStream");
|
"GstRTPBin.stream");
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (bin, "got percent %d from stream %p", percent, stream);
|
GST_DEBUG_OBJECT (bin, "got percent %d from stream %p", percent, stream);
|
||||||
|
|
||||||
/* get the stream */
|
/* get the stream */
|
||||||
if (stream) {
|
if (G_LIKELY (stream)) {
|
||||||
GST_RTP_BIN_LOCK (rtpbin);
|
GST_RTP_BIN_LOCK (rtpbin);
|
||||||
/* fill in the percent */
|
/* fill in the percent */
|
||||||
stream->percent = percent;
|
stream->percent = percent;
|
||||||
|
|
||||||
|
/* calculate the min value for all streams */
|
||||||
for (sessions = rtpbin->sessions; sessions;
|
for (sessions = rtpbin->sessions; sessions;
|
||||||
sessions = g_slist_next (sessions)) {
|
sessions = g_slist_next (sessions)) {
|
||||||
GstRtpBinSession *session = (GstRtpBinSession *) sessions->data;
|
GstRtpBinSession *session = (GstRtpBinSession *) sessions->data;
|
||||||
|
@ -1846,12 +1840,25 @@ gst_rtp_bin_handle_message (GstBin * bin, GstMessage * message)
|
||||||
message =
|
message =
|
||||||
gst_message_new_buffering (GST_OBJECT_CAST (bin), min_percent);
|
gst_message_new_buffering (GST_OBJECT_CAST (bin), min_percent);
|
||||||
|
|
||||||
if (change) {
|
if (G_UNLIKELY (change)) {
|
||||||
while (elements) {
|
GstClock *clock;
|
||||||
|
guint64 running_time, base_time, now;
|
||||||
|
|
||||||
|
/* figure out a new base_time */
|
||||||
|
clock = gst_element_get_clock (GST_ELEMENT_CAST (bin));
|
||||||
|
if (G_LIKELY (clock)) {
|
||||||
|
now = gst_clock_get_time (clock);
|
||||||
|
base_time = gst_element_get_base_time (GST_ELEMENT_CAST (bin));
|
||||||
|
running_time = now - base_time;
|
||||||
|
} else {
|
||||||
|
running_time = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (G_LIKELY (elements)) {
|
||||||
GstElement *element = elements->data;
|
GstElement *element = elements->data;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (bin, "setting %p to %d", element, active);
|
GST_DEBUG_OBJECT (bin, "setting %p to %d", element, active);
|
||||||
g_signal_emit_by_name (element, "set-active", active, base_time,
|
g_signal_emit_by_name (element, "set-active", active, running_time,
|
||||||
NULL);
|
NULL);
|
||||||
gst_object_unref (element);
|
gst_object_unref (element);
|
||||||
elements = g_slist_delete_link (elements, elements);
|
elements = g_slist_delete_link (elements, elements);
|
||||||
|
|
|
@ -50,6 +50,7 @@ struct _GstRtpBin {
|
||||||
gboolean ignore_pt;
|
gboolean ignore_pt;
|
||||||
RTPJitterBufferMode buffer_mode;
|
RTPJitterBufferMode buffer_mode;
|
||||||
gboolean buffering;
|
gboolean buffering;
|
||||||
|
GstClockTime buffer_start;
|
||||||
/* a list of session */
|
/* a list of session */
|
||||||
GSList *sessions;
|
GSList *sessions;
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,8 @@ rtp_jitter_buffer_set_delay (RTPJitterBuffer * jbuf, GstClockTime delay)
|
||||||
{
|
{
|
||||||
jbuf->delay = delay;
|
jbuf->delay = delay;
|
||||||
jbuf->low_level = (delay * 15) / 100;
|
jbuf->low_level = (delay * 15) / 100;
|
||||||
|
/* the high level is at 90% in order to release packets before we fill up the
|
||||||
|
* buffer up to the latency */
|
||||||
jbuf->high_level = (delay * 90) / 100;
|
jbuf->high_level = (delay * 90) / 100;
|
||||||
|
|
||||||
GST_DEBUG ("delay %" GST_TIME_FORMAT ", min %" GST_TIME_FORMAT ", max %"
|
GST_DEBUG ("delay %" GST_TIME_FORMAT ", min %" GST_TIME_FORMAT ", max %"
|
||||||
|
|
|
@ -144,7 +144,7 @@ enum
|
||||||
#define DEFAULT_RETRY 20
|
#define DEFAULT_RETRY 20
|
||||||
#define DEFAULT_TIMEOUT 5000000
|
#define DEFAULT_TIMEOUT 5000000
|
||||||
#define DEFAULT_TCP_TIMEOUT 20000000
|
#define DEFAULT_TCP_TIMEOUT 20000000
|
||||||
#define DEFAULT_LATENCY_MS 3000
|
#define DEFAULT_LATENCY_MS 2000
|
||||||
#define DEFAULT_CONNECTION_SPEED 0
|
#define DEFAULT_CONNECTION_SPEED 0
|
||||||
#define DEFAULT_NAT_METHOD GST_RTSP_NAT_DUMMY
|
#define DEFAULT_NAT_METHOD GST_RTSP_NAT_DUMMY
|
||||||
#define DEFAULT_DO_RTCP TRUE
|
#define DEFAULT_DO_RTCP TRUE
|
||||||
|
|
Loading…
Reference in a new issue