diff --git a/gst/rtp/gstrtpopuspay.c b/gst/rtp/gstrtpopuspay.c index bb3bf6d5df..0bcdc6a948 100644 --- a/gst/rtp/gstrtpopuspay.c +++ b/gst/rtp/gstrtpopuspay.c @@ -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); } diff --git a/gst/rtp/gstrtpopuspay.h b/gst/rtp/gstrtpopuspay.h index c7dbab10d4..b862913af4 100644 --- a/gst/rtp/gstrtpopuspay.h +++ b/gst/rtp/gstrtpopuspay.h @@ -46,6 +46,9 @@ struct _GstRtpOPUSPay GstRTPBasePayload payload; gboolean dtx; + + /* if the next produced buffer should have the MARKER flag */ + gboolean marker; }; struct _GstRtpOPUSPayClass diff --git a/tests/check/elements/rtp-payloading.c b/tests/check/elements/rtp-payloading.c index 038fac4584..d262610116 100644 --- a/tests/check/elements/rtp-payloading.c +++ b/tests/check/elements/rtp-payloading.c @@ -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);