mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 11:10:37 +00:00
rtpbuffer: Add map flag to skip padding
Encrypted RTP buffers may contain encrypted padding, hence it's necessary to have an option to relax the validation in order to successfully map the buffer. When the flag GST_RTP_BUFFER_MAP_FLAG_SKIP_PADDING is set gst_rtp_buffer_map() will map the buffer like if padding is not present. https://bugzilla.gnome.org/show_bug.cgi?id=752705
This commit is contained in:
parent
79d4765525
commit
0a668c1866
3 changed files with 50 additions and 2 deletions
|
@ -399,8 +399,9 @@ gst_rtp_buffer_map (GstBuffer * buffer, GstMapFlags flags, GstRTPBuffer * rtp)
|
|||
rtp->size[1] = 0;
|
||||
}
|
||||
|
||||
/* check for padding */
|
||||
if (data[0] & 0x20) {
|
||||
/* check for padding unless flags says to skip */
|
||||
if ((data[0] & 0x20) != 0 &&
|
||||
(flags & GST_RTP_BUFFER_MAP_FLAG_SKIP_PADDING) == 0) {
|
||||
/* find memory for the padding bits */
|
||||
if (!gst_buffer_find_memory (buffer, bufsize - 1, 1, &idx, &length, &skip))
|
||||
goto wrong_length;
|
||||
|
|
|
@ -150,6 +150,22 @@ gboolean gst_rtp_buffer_add_extension_twobytes_header (GstRTPBuffer *rtp,
|
|||
gpointer data,
|
||||
guint size);
|
||||
|
||||
/**
|
||||
* GstRTPBufferMapFlags:
|
||||
* @GST_RTP_BUFFER_MAP_FLAG_SKIP_PADDING: Skip mapping and validation of RTP
|
||||
* padding and RTP pad count when present. Useful for buffers where
|
||||
* the padding may be encrypted.
|
||||
* @GST_RTP_BUFFER_MAP_FLAG_LAST: Offset to define more flags
|
||||
*
|
||||
* Additional mapping flags for gst_rtp_buffer_map().
|
||||
*
|
||||
* Since: 1.8
|
||||
*/
|
||||
typedef enum {
|
||||
GST_RTP_BUFFER_MAP_FLAG_SKIP_PADDING = (GST_MAP_FLAG_LAST << 0),
|
||||
GST_RTP_BUFFER_MAP_FLAG_LAST = (GST_MAP_FLAG_LAST << 8)
|
||||
/* 8 more flags possible afterwards */
|
||||
} GstRTPBufferMapFlags;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -171,6 +171,36 @@ GST_START_TEST (test_rtp_buffer_validate_corrupt)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_rtp_buffer_validate_padding)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
guint8 packet_with_padding[] = {
|
||||
0xa0, 0x60, 0x6c, 0x49, 0x58, 0xab, 0xaa, 0x65, 0x65, 0x2e, 0xaf, 0xce,
|
||||
0x68, 0xce, 0x3c, 0x80, 0x00, 0x00, 0x00, 0x04
|
||||
};
|
||||
GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
|
||||
|
||||
buf = gst_buffer_new_and_alloc (sizeof (packet_with_padding));
|
||||
gst_buffer_fill (buf, 0, packet_with_padding, sizeof (packet_with_padding));
|
||||
fail_unless (gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp));
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
gst_buffer_unref (buf);
|
||||
|
||||
/* Set the padding to something invalid */
|
||||
buf = gst_buffer_new_and_alloc (sizeof (packet_with_padding));
|
||||
gst_buffer_fill (buf, 0, packet_with_padding, sizeof (packet_with_padding));
|
||||
gst_buffer_memset (buf, gst_buffer_get_size (buf) - 1, 0xff, 1);
|
||||
fail_if (gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp));
|
||||
|
||||
memset (&rtp, 0, sizeof (rtp));
|
||||
fail_unless (gst_rtp_buffer_map (buf, GST_MAP_READ |
|
||||
GST_RTP_BUFFER_MAP_FLAG_SKIP_PADDING, &rtp));
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
#if 0
|
||||
GST_START_TEST (test_rtp_buffer_list)
|
||||
{
|
||||
|
@ -1179,6 +1209,7 @@ rtp_suite (void)
|
|||
suite_add_tcase (s, tc_chain);
|
||||
tcase_add_test (tc_chain, test_rtp_buffer);
|
||||
tcase_add_test (tc_chain, test_rtp_buffer_validate_corrupt);
|
||||
tcase_add_test (tc_chain, test_rtp_buffer_validate_padding);
|
||||
tcase_add_test (tc_chain, test_rtp_buffer_set_extension_data);
|
||||
//tcase_add_test (tc_chain, test_rtp_buffer_list_set_extension);
|
||||
tcase_add_test (tc_chain, test_rtp_seqnum_compare);
|
||||
|
|
Loading…
Reference in a new issue