mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
rtspmessage: map headers we know that are added by string to their enum
That way we can look them up by their field enum later as well.
This commit is contained in:
parent
ef7f537a80
commit
1b4bd6e451
2 changed files with 33 additions and 0 deletions
|
@ -637,10 +637,16 @@ GstRTSPResult
|
||||||
gst_rtsp_message_add_header_by_name (GstRTSPMessage * msg,
|
gst_rtsp_message_add_header_by_name (GstRTSPMessage * msg,
|
||||||
const gchar * header, const gchar * value)
|
const gchar * header, const gchar * value)
|
||||||
{
|
{
|
||||||
|
GstRTSPHeaderField field;
|
||||||
|
|
||||||
g_return_val_if_fail (msg != NULL, GST_RTSP_EINVAL);
|
g_return_val_if_fail (msg != NULL, GST_RTSP_EINVAL);
|
||||||
g_return_val_if_fail (header != NULL, GST_RTSP_EINVAL);
|
g_return_val_if_fail (header != NULL, GST_RTSP_EINVAL);
|
||||||
g_return_val_if_fail (value != NULL, GST_RTSP_EINVAL);
|
g_return_val_if_fail (value != NULL, GST_RTSP_EINVAL);
|
||||||
|
|
||||||
|
field = gst_rtsp_find_header_field (header);
|
||||||
|
if (field != GST_RTSP_HDR_INVALID)
|
||||||
|
return gst_rtsp_message_take_header (msg, field, g_strdup (value));
|
||||||
|
|
||||||
return gst_rtsp_message_take_header_by_name (msg, header, g_strdup (value));
|
return gst_rtsp_message_take_header_by_name (msg, header, g_strdup (value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -617,10 +617,37 @@ GST_START_TEST (test_rtsp_message)
|
||||||
fail_unless_equals_int (res, GST_RTSP_OK);
|
fail_unless_equals_int (res, GST_RTSP_OK);
|
||||||
fail_unless_equals_string (val, "bar.0");
|
fail_unless_equals_string (val, "bar.0");
|
||||||
|
|
||||||
|
/* remove all headers for a name */
|
||||||
|
res = gst_rtsp_message_remove_header_by_name (msg, "FOO99-Version", -1);
|
||||||
|
fail_unless_equals_int (res, GST_RTSP_OK);
|
||||||
|
res = gst_rtsp_message_get_header_by_name (msg, "FOO99-Version", &val, 0);
|
||||||
|
fail_unless_equals_int (res, GST_RTSP_ENOTIMPL);
|
||||||
|
|
||||||
/* gst_rtsp_message_dump (msg); */
|
/* gst_rtsp_message_dump (msg); */
|
||||||
|
|
||||||
res = gst_rtsp_message_free (msg);
|
res = gst_rtsp_message_free (msg);
|
||||||
fail_unless_equals_int (res, GST_RTSP_OK);
|
fail_unless_equals_int (res, GST_RTSP_OK);
|
||||||
|
|
||||||
|
/* === */
|
||||||
|
|
||||||
|
res = gst_rtsp_message_new_request (&msg, GST_RTSP_PLAY,
|
||||||
|
"rtsp://foo.bar:8554/test");
|
||||||
|
fail_unless_equals_int (res, GST_RTSP_OK);
|
||||||
|
|
||||||
|
res = gst_rtsp_message_add_header_by_name (msg, "CSeq", "3");
|
||||||
|
fail_unless_equals_int (res, GST_RTSP_OK);
|
||||||
|
|
||||||
|
res = gst_rtsp_message_get_header (msg, GST_RTSP_HDR_CSEQ, &val, 0);
|
||||||
|
fail_unless_equals_int (res, GST_RTSP_OK);
|
||||||
|
fail_unless_equals_string (val, "3");
|
||||||
|
|
||||||
|
val = NULL;
|
||||||
|
res = gst_rtsp_message_get_header_by_name (msg, "cseq", &val, 0);
|
||||||
|
fail_unless_equals_int (res, GST_RTSP_OK);
|
||||||
|
fail_unless_equals_string (val, "3");
|
||||||
|
|
||||||
|
res = gst_rtsp_message_free (msg);
|
||||||
|
fail_unless_equals_int (res, GST_RTSP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
Loading…
Reference in a new issue