rtpbuffer: Allow subbuffering of empty buffers

See https://bugzilla.gnome.org/show_bug.cgi?id=720162
This commit is contained in:
Sebastian Rasmussen 2013-12-10 00:56:07 +01:00 committed by Wim Taymans
parent 9ec4eaa866
commit c734f9fba8
2 changed files with 22 additions and 3 deletions

View file

@ -1044,7 +1044,7 @@ gst_rtp_buffer_set_timestamp (GstRTPBuffer * rtp, guint32 timestamp)
*
* Create a subbuffer of the payload of the RTP packet in @buffer. @offset bytes
* are skipped in the payload and the subbuffer will be of size @len.
* If @len is -1 the total payload starting from @offset if subbuffered.
* If @len is -1 the total payload starting from @offset is subbuffered.
*
* Returns: A new buffer with the specified data of the payload.
*/
@ -1056,7 +1056,7 @@ gst_rtp_buffer_get_payload_subbuffer (GstRTPBuffer * rtp, guint offset,
plen = gst_rtp_buffer_get_payload_len (rtp);
/* we can't go past the length */
if (G_UNLIKELY (offset >= plen))
if (G_UNLIKELY (offset > plen))
goto wrong_offset;
/* apply offset */
@ -1073,7 +1073,7 @@ gst_rtp_buffer_get_payload_subbuffer (GstRTPBuffer * rtp, guint offset,
/* ERRORS */
wrong_offset:
{
g_warning ("offset=%u should be less then plen=%u", offset, plen);
g_warning ("offset=%u should be less than plen=%u", offset, plen);
return NULL;
}
}

View file

@ -955,6 +955,24 @@ GST_START_TEST (test_rtp_buffer_get_payload_bytes)
GST_END_TEST;
GST_START_TEST (test_rtp_buffer_empty_payload)
{
GstRTPBuffer rtp = { NULL };
GstBuffer *paybuf, *outbuf;
paybuf = gst_rtp_buffer_new_allocate (0, 0, 0);
gst_rtp_buffer_map (paybuf, GST_MAP_READ, &rtp);
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
gst_rtp_buffer_unmap (&rtp);
gst_buffer_unref (paybuf);
gst_buffer_unref (outbuf);
}
GST_END_TEST;
static Suite *
rtp_suite (void)
{
@ -974,6 +992,7 @@ rtp_suite (void)
tcase_add_test (tc_chain, test_rtp_buffer_get_payload_bytes);
tcase_add_test (tc_chain, test_rtp_buffer_get_extension_bytes);
tcase_add_test (tc_chain, test_rtp_buffer_empty_payload);
//tcase_add_test (tc_chain, test_rtp_buffer_list);