mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
tests/rtp/payload: add test for shrinking extension data
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1146>
This commit is contained in:
parent
b7d4d371f9
commit
49af6a831d
3 changed files with 66 additions and 8 deletions
|
@ -1651,6 +1651,9 @@ write_header_extension (GstRTPHeaderExtension * ext, gpointer user_data)
|
||||||
hdr->payload->priv->input_meta_buffer, hdr->flags, hdr->output,
|
hdr->payload->priv->input_meta_buffer, hdr->flags, hdr->output,
|
||||||
&hdr->data[offset], remaining);
|
&hdr->data[offset], remaining);
|
||||||
|
|
||||||
|
GST_TRACE_OBJECT (hdr->payload, "extension %" GST_PTR_FORMAT " wrote %"
|
||||||
|
G_GSIZE_FORMAT, ext, written);
|
||||||
|
|
||||||
if (written == 0) {
|
if (written == 0) {
|
||||||
/* extension wrote no data */
|
/* extension wrote no data */
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -111,9 +111,7 @@ gst_rtp_dummy_pay_handle_buffer (GstRTPBasePayload * pay, GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstBuffer *paybuffer;
|
GstBuffer *paybuffer;
|
||||||
|
|
||||||
GST_LOG ("payloading buffer pts=%" GST_TIME_FORMAT " offset=%"
|
GST_LOG ("payloading %" GST_PTR_FORMAT, buffer);
|
||||||
G_GUINT64_FORMAT, GST_TIME_ARGS (GST_BUFFER_PTS (buffer)),
|
|
||||||
GST_BUFFER_OFFSET (buffer));
|
|
||||||
|
|
||||||
if (!gst_pad_has_current_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (pay))) {
|
if (!gst_pad_has_current_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (pay))) {
|
||||||
if (!gst_rtp_base_payload_set_outcaps (GST_RTP_BASE_PAYLOAD (pay),
|
if (!gst_rtp_base_payload_set_outcaps (GST_RTP_BASE_PAYLOAD (pay),
|
||||||
|
@ -132,9 +130,7 @@ gst_rtp_dummy_pay_handle_buffer (GstRTPBasePayload * pay, GstBuffer * buffer)
|
||||||
|
|
||||||
gst_buffer_append (paybuffer, buffer);
|
gst_buffer_append (paybuffer, buffer);
|
||||||
|
|
||||||
GST_LOG ("payloaded buffer pts=%" GST_TIME_FORMAT " offset=%"
|
GST_LOG ("payloaded %" GST_PTR_FORMAT, paybuffer);
|
||||||
G_GUINT64_FORMAT, GST_TIME_ARGS (GST_BUFFER_PTS (paybuffer)),
|
|
||||||
GST_BUFFER_OFFSET (paybuffer));
|
|
||||||
|
|
||||||
if (GST_BUFFER_PTS (paybuffer) < BUFFER_BEFORE_LIST) {
|
if (GST_BUFFER_PTS (paybuffer) < BUFFER_BEFORE_LIST) {
|
||||||
return gst_rtp_base_payload_push (pay, paybuffer);
|
return gst_rtp_base_payload_push (pay, paybuffer);
|
||||||
|
@ -342,7 +338,7 @@ static void
|
||||||
push_buffer_full (State * state, GstFlowReturn expected,
|
push_buffer_full (State * state, GstFlowReturn expected,
|
||||||
const gchar * field, ...)
|
const gchar * field, ...)
|
||||||
{
|
{
|
||||||
GstBuffer *buf = gst_rtp_buffer_new_allocate (0, 0, 0);
|
GstBuffer *buf = gst_buffer_new_allocate (0, 0, 0);
|
||||||
GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
|
GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
|
||||||
gboolean mapped = FALSE;
|
gboolean mapped = FALSE;
|
||||||
va_list var_args;
|
va_list var_args;
|
||||||
|
@ -478,6 +474,10 @@ validate_buffer_valist (GstBuffer * buf, const gchar * field, va_list var_args)
|
||||||
} else {
|
} else {
|
||||||
fail_if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT));
|
fail_if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT));
|
||||||
}
|
}
|
||||||
|
} else if (!g_strcmp0 (field, "size")) {
|
||||||
|
gsize expected_size = va_arg (var_args, gsize);
|
||||||
|
fail_unless_equals_int64 ((guint64) expected_size,
|
||||||
|
gst_buffer_get_size (buf));
|
||||||
} else {
|
} else {
|
||||||
if (!mapped) {
|
if (!mapped) {
|
||||||
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
|
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
|
||||||
|
@ -503,6 +503,17 @@ validate_buffer_valist (GstBuffer * buf, const gchar * field, va_list var_args)
|
||||||
guint csrc_count = va_arg (var_args, guint);
|
guint csrc_count = va_arg (var_args, guint);
|
||||||
fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (&rtp),
|
fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (&rtp),
|
||||||
csrc_count);
|
csrc_count);
|
||||||
|
} else if (!g_strcmp0 (field, "ext-data")) {
|
||||||
|
guint expected_bits = va_arg (var_args, guint) & 0xFFFF;
|
||||||
|
gsize expected_size = va_arg (var_args, gsize);
|
||||||
|
gpointer data;
|
||||||
|
guint word_len;
|
||||||
|
guint16 ext_bits;
|
||||||
|
gst_rtp_buffer_get_extension_data (&rtp, &ext_bits, &data, &word_len);
|
||||||
|
GST_MEMDUMP ("ext data", data, word_len * 4);
|
||||||
|
fail_unless_equals_int (expected_bits, ext_bits);
|
||||||
|
fail_unless_equals_int64 ((guint64) expected_size,
|
||||||
|
(guint64) word_len * 4);
|
||||||
} else {
|
} else {
|
||||||
fail ("test cannot validate unknown buffer field '%s'", field);
|
fail ("test cannot validate unknown buffer field '%s'", field);
|
||||||
}
|
}
|
||||||
|
@ -2260,6 +2271,44 @@ GST_START_TEST (rtp_base_payload_extensions_in_output_caps)
|
||||||
destroy_payloader (state);
|
destroy_payloader (state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GST_START_TEST (rtp_base_payload_extensions_shrink_ext_data)
|
||||||
|
{
|
||||||
|
GstRTPHeaderExtension *ext;
|
||||||
|
State *state;
|
||||||
|
|
||||||
|
state = create_payloader ("application/x-rtp", &sinktmpl, NULL);
|
||||||
|
ext = rtp_dummy_hdr_ext_new ();
|
||||||
|
GST_RTP_DUMMY_HDR_EXT (ext)->supported_flags =
|
||||||
|
GST_RTP_HEADER_EXTENSION_ONE_BYTE;
|
||||||
|
GST_RTP_DUMMY_HDR_EXT (ext)->max_size = 5;
|
||||||
|
gst_rtp_header_extension_set_id (ext, 1);
|
||||||
|
|
||||||
|
g_signal_emit_by_name (state->element, "add-extension", ext);
|
||||||
|
|
||||||
|
set_state (state, GST_STATE_PLAYING);
|
||||||
|
|
||||||
|
push_buffer (state, "pts", 0 * GST_SECOND, NULL);
|
||||||
|
|
||||||
|
set_state (state, GST_STATE_NULL);
|
||||||
|
|
||||||
|
validate_buffers_received (1);
|
||||||
|
|
||||||
|
validate_buffer (0, "pts", 0 * GST_SECOND, "size", (gsize) 20, "ext-data",
|
||||||
|
(guint) 0xBEDE, (gsize) 4, NULL);
|
||||||
|
|
||||||
|
validate_events_received (3);
|
||||||
|
|
||||||
|
validate_normal_start_events (0);
|
||||||
|
|
||||||
|
fail_unless_equals_int (GST_RTP_DUMMY_HDR_EXT (ext)->write_count, 1);
|
||||||
|
gst_object_unref (ext);
|
||||||
|
ext = NULL;
|
||||||
|
|
||||||
|
destroy_payloader (state);
|
||||||
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
static Suite *
|
static Suite *
|
||||||
rtp_basepayloading_suite (void)
|
rtp_basepayloading_suite (void)
|
||||||
|
@ -2310,6 +2359,7 @@ rtp_basepayloading_suite (void)
|
||||||
tcase_add_test (tc_chain, rtp_base_payload_caps_request);
|
tcase_add_test (tc_chain, rtp_base_payload_caps_request);
|
||||||
tcase_add_test (tc_chain, rtp_base_payload_caps_request_ignored);
|
tcase_add_test (tc_chain, rtp_base_payload_caps_request_ignored);
|
||||||
tcase_add_test (tc_chain, rtp_base_payload_extensions_in_output_caps);
|
tcase_add_test (tc_chain, rtp_base_payload_extensions_in_output_caps);
|
||||||
|
tcase_add_test (tc_chain, rtp_base_payload_extensions_shrink_ext_data);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,8 @@ struct _GstRTPDummyHdrExt
|
||||||
guint caps_field_value;
|
guint caps_field_value;
|
||||||
|
|
||||||
gchar *attributes;
|
gchar *attributes;
|
||||||
|
|
||||||
|
gsize max_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstRTPDummyHdrExtClass
|
struct _GstRTPDummyHdrExtClass
|
||||||
|
@ -129,6 +131,7 @@ gst_rtp_dummy_hdr_ext_init (GstRTPDummyHdrExt * dummy)
|
||||||
{
|
{
|
||||||
dummy->supported_flags =
|
dummy->supported_flags =
|
||||||
GST_RTP_HEADER_EXTENSION_ONE_BYTE | GST_RTP_HEADER_EXTENSION_TWO_BYTE;
|
GST_RTP_HEADER_EXTENSION_ONE_BYTE | GST_RTP_HEADER_EXTENSION_TWO_BYTE;
|
||||||
|
dummy->max_size = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -160,7 +163,9 @@ static gsize
|
||||||
gst_rtp_dummy_hdr_ext_get_max_size (GstRTPHeaderExtension * ext,
|
gst_rtp_dummy_hdr_ext_get_max_size (GstRTPHeaderExtension * ext,
|
||||||
const GstBuffer * input_meta)
|
const GstBuffer * input_meta)
|
||||||
{
|
{
|
||||||
return 1;
|
GstRTPDummyHdrExt *dummy = GST_RTP_DUMMY_HDR_EXT (ext);
|
||||||
|
|
||||||
|
return dummy->max_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TEST_DATA_BYTE 0x9d
|
#define TEST_DATA_BYTE 0x9d
|
||||||
|
|
Loading…
Reference in a new issue