diff --git a/gst/rtp/gstrtph265pay.c b/gst/rtp/gstrtph265pay.c index e0be54df0a..95d2aebb89 100644 --- a/gst/rtp/gstrtph265pay.c +++ b/gst/rtp/gstrtph265pay.c @@ -969,7 +969,7 @@ gst_rtp_h265_pay_reset_bundle (GstRtpH265Pay * rtph265pay) { g_clear_pointer (&rtph265pay->bundle, gst_buffer_list_unref); rtph265pay->bundle_size = 0; - rtph265pay->bundle_contains_vcl = FALSE; + rtph265pay->bundle_contains_vcl_or_suffix = FALSE; } static GstFlowReturn @@ -1385,7 +1385,7 @@ gst_rtp_h265_pay_payload_nal_bundle (GstRTPBasePayload * basepayload, GST_DEBUG_OBJECT (rtph265pay, "creating new AP aggregate"); bundle = rtph265pay->bundle = gst_buffer_list_new (); bundle_size = rtph265pay->bundle_size = 2; - rtph265pay->bundle_contains_vcl = FALSE; + rtph265pay->bundle_contains_vcl_or_suffix = FALSE; } GST_DEBUG_OBJECT (rtph265pay, @@ -1401,8 +1401,10 @@ gst_rtp_h265_pay_payload_nal_bundle (GstRTPBasePayload * basepayload, ret = GST_FLOW_OK; /* In H.265, all VCL NAL units are < 32 */ - if (nal_type < 32) - rtph265pay->bundle_contains_vcl = TRUE; + if (nal_type < 32 || nal_type == GST_H265_NAL_EOS || + nal_type == GST_H265_NAL_EOB || nal_type == GST_H265_NAL_SUFFIX_SEI || + (nal_type >= 45 && nal_type <= 47) || (nal_type >= 56 && nal_type < 63)) + rtph265pay->bundle_contains_vcl_or_suffix = TRUE; if (marker) { GST_DEBUG_OBJECT (rtph265pay, "sending bundle at marker"); @@ -1650,7 +1652,7 @@ gst_rtp_h265_pay_handle_buffer (GstRTPBasePayload * basepayload, if (ret == GST_FLOW_OK && rtph265pay->bundle_size > 0 && rtph265pay->aggregate_mode == GST_RTP_H265_AGGREGATE_ZERO_LATENCY && - rtph265pay->bundle_contains_vcl) { + rtph265pay->bundle_contains_vcl_or_suffix) { GST_DEBUG_OBJECT (rtph265pay, "sending bundle at end incoming packet"); ret = gst_rtp_h265_pay_send_bundle (rtph265pay, FALSE); } diff --git a/gst/rtp/gstrtph265pay.h b/gst/rtp/gstrtph265pay.h index 070bc59b55..6d14095581 100644 --- a/gst/rtp/gstrtph265pay.h +++ b/gst/rtp/gstrtph265pay.h @@ -76,7 +76,7 @@ struct _GstRtpH265Pay /* aggregate buffers with AP */ GstBufferList *bundle; guint bundle_size; - gboolean bundle_contains_vcl; + gboolean bundle_contains_vcl_or_suffix; GstRTPH265AggregateMode aggregate_mode; }; diff --git a/tests/check/elements/rtph265.c b/tests/check/elements/rtph265.c index 07155ad4c8..ea07c59b09 100644 --- a/tests/check/elements/rtph265.c +++ b/tests/check/elements/rtph265.c @@ -459,6 +459,7 @@ static guint8 h265_idr_slice_2[] = { 0x00, 0x3e, 0x40, 0x92, 0x0c, 0x78 }; + GST_START_TEST (test_rtph265pay_two_slices_timestamp) { GstHarness *h = gst_harness_new_parse ("rtph265pay timestamp-offset=123"); @@ -928,6 +929,11 @@ GST_START_TEST (test_rtph265pay_aggregate_with_discont) GST_END_TEST; +/* EOS */ +static guint8 h265_eos[] = { + 0x00, 0x00, 0x00, 0x01, (36 << 1), 0x00 +}; + GST_START_TEST (test_rtph265pay_aggregate_until_vcl) { @@ -957,7 +963,6 @@ GST_START_TEST (test_rtph265pay_aggregate_until_vcl) ret = gst_harness_push (h, buffer); fail_unless_equals_int (ret, GST_FLOW_OK); - fail_unless_equals_int (gst_harness_buffers_in_queue (h), 1); buffer = gst_harness_pull (h); @@ -972,6 +977,23 @@ GST_START_TEST (test_rtph265pay_aggregate_until_vcl) gst_rtp_buffer_unmap (&rtp); gst_buffer_unref (buffer); + /* Push EOS now */ + + buffer = wrap_static_buffer_with_pts (h265_eos, sizeof (h265_eos), 0); + ret = gst_harness_push (h, buffer); + fail_unless_equals_int (ret, GST_FLOW_OK); + + fail_unless_equals_int (gst_harness_buffers_in_queue (h), 1); + + buffer = gst_harness_pull (h); + fail_unless (gst_rtp_buffer_map (buffer, GST_MAP_READ, &rtp)); + fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 0); + fail_unless_equals_uint64 (gst_rtp_buffer_get_timestamp (&rtp), 123); + fail_unless_equals_int (gst_buffer_get_size (buffer), 12 + + sizeof (h265_eos) - 4); + gst_rtp_buffer_unmap (&rtp); + gst_buffer_unref (buffer); + gst_harness_teardown (h); }