mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
rtpopuspay: set MARKER flag
Set MARKER flag on first buffer after DTX. According to RFC 3551 section 4.1 the marker bit needs to be set on "the first packet after a silence period during which packets have not been transmitted contiguously". Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/967>
This commit is contained in:
parent
41ba8c1b00
commit
5fa3325335
3 changed files with 46 additions and 4 deletions
|
@ -131,6 +131,32 @@ gst_rtp_opus_pay_get_property (GObject * object,
|
|||
}
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_rtp_opus_pay_change_state (GstElement * element, GstStateChange transition)
|
||||
{
|
||||
GstRtpOPUSPay *self = GST_RTP_OPUS_PAY (element);
|
||||
GstStateChangeReturn ret;
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||
self->marker = TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ret =
|
||||
GST_ELEMENT_CLASS (gst_rtp_opus_pay_parent_class)->change_state (element,
|
||||
transition);
|
||||
|
||||
switch (transition) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_opus_pay_class_init (GstRtpOPUSPayClass * klass)
|
||||
{
|
||||
|
@ -142,6 +168,8 @@ gst_rtp_opus_pay_class_init (GstRtpOPUSPayClass * klass)
|
|||
element_class = GST_ELEMENT_CLASS (klass);
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
|
||||
element_class->change_state = gst_rtp_opus_pay_change_state;
|
||||
|
||||
gstbasertppayload_class->set_caps = gst_rtp_opus_pay_setcaps;
|
||||
gstbasertppayload_class->get_caps = gst_rtp_opus_pay_getcaps;
|
||||
gstbasertppayload_class->handle_buffer = gst_rtp_opus_pay_handle_buffer;
|
||||
|
@ -305,6 +333,7 @@ gst_rtp_opus_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
if (self->dtx && gst_buffer_get_size (buffer) <= 2) {
|
||||
GST_LOG_OBJECT (self,
|
||||
"discard empty buffer as DTX is enabled: %" GST_PTR_FORMAT, buffer);
|
||||
self->marker = TRUE;
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
@ -323,6 +352,11 @@ gst_rtp_opus_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
GST_BUFFER_DTS (outbuf) = dts;
|
||||
GST_BUFFER_DURATION (outbuf) = duration;
|
||||
|
||||
if (self->marker) {
|
||||
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_MARKER);
|
||||
self->marker = FALSE;
|
||||
}
|
||||
|
||||
/* Push out */
|
||||
return gst_rtp_base_payload_push (basepayload, outbuf);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,9 @@ struct _GstRtpOPUSPay
|
|||
GstRTPBasePayload payload;
|
||||
|
||||
gboolean dtx;
|
||||
|
||||
/* if the next produced buffer should have the MARKER flag */
|
||||
gboolean marker;
|
||||
};
|
||||
|
||||
struct _GstRtpOPUSPayClass
|
||||
|
|
|
@ -1672,7 +1672,7 @@ GST_START_TEST (rtp_vorbis_renegotiate)
|
|||
GST_END_TEST;
|
||||
|
||||
static guint16
|
||||
pull_rtp_buffer (GstHarness * h)
|
||||
pull_rtp_buffer (GstHarness * h, gboolean has_marker)
|
||||
{
|
||||
gint16 seq;
|
||||
GstBuffer *buf;
|
||||
|
@ -1685,6 +1685,11 @@ pull_rtp_buffer (GstHarness * h)
|
|||
seq = gst_rtp_buffer_get_seq (&rtp);
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
if (has_marker)
|
||||
fail_unless (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_MARKER));
|
||||
else
|
||||
fail_if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_MARKER));
|
||||
|
||||
gst_buffer_unref (buf);
|
||||
return seq;
|
||||
}
|
||||
|
@ -1715,7 +1720,7 @@ test_rtp_opus_dtx (gboolean dtx)
|
|||
gst_buffer_new_wrapped (g_memdup (opus_frame, sizeof (opus_frame)),
|
||||
sizeof (opus_frame));
|
||||
fail_unless_equals_int (gst_harness_push (h, buf), GST_FLOW_OK);
|
||||
seq = pull_rtp_buffer (h);
|
||||
seq = pull_rtp_buffer (h, TRUE);
|
||||
expected_seq = seq + 1;
|
||||
|
||||
/* push empty frame */
|
||||
|
@ -1728,7 +1733,7 @@ test_rtp_opus_dtx (gboolean dtx)
|
|||
buf = gst_harness_try_pull (h);
|
||||
fail_if (buf);
|
||||
} else {
|
||||
seq = pull_rtp_buffer (h);
|
||||
seq = pull_rtp_buffer (h, FALSE);
|
||||
fail_unless_equals_int (seq, expected_seq);
|
||||
expected_seq++;
|
||||
}
|
||||
|
@ -1738,7 +1743,7 @@ test_rtp_opus_dtx (gboolean dtx)
|
|||
gst_buffer_new_wrapped (g_memdup (opus_frame, sizeof (opus_frame)),
|
||||
sizeof (opus_frame));
|
||||
fail_unless_equals_int (gst_harness_push (h, buf), GST_FLOW_OK);
|
||||
seq = pull_rtp_buffer (h);
|
||||
seq = pull_rtp_buffer (h, dtx);
|
||||
fail_unless_equals_int (seq, expected_seq);
|
||||
|
||||
gst_harness_teardown (h);
|
||||
|
|
Loading…
Reference in a new issue