g_string_append_printf (str, "RTSP/1.0 %d %s\r\n",
message->type_data.response.code, message->type_data.response.reason);
break;
+ case GST_RTSP_MESSAGE_HTTP_REQUEST:
+ /* create request string */
+ g_string_append_printf (str, "%s %s HTTP/%s\r\n",
+ gst_rtsp_method_as_text (message->type_data.request.method),
+ message->type_data.request.uri,
+ gst_rtsp_version_as_text (message->type_data.request.version));
+ /* add any authentication headers */
+ add_auth_header (conn, message);
+ break;
+ case GST_RTSP_MESSAGE_HTTP_RESPONSE:
+ /* create response string */
+ g_string_append_printf (str, "HTTP/%s %d %s\r\n",
+ gst_rtsp_version_as_text (message->type_data.request.version),
+ message->type_data.response.code, message->type_data.response.reason);
+ break;
case GST_RTSP_MESSAGE_DATA:
{
guint8 data_header[4];
* GstRTSPVersion:
* @GST_RTSP_VERSION_INVALID: unknown/invalid version
* @GST_RTSP_VERSION_1_0: version 1.0
+ * @GST_RTSP_VERSION_1_1: version 1.1
*
* The supported RTSP versions.
*/
typedef enum {
GST_RTSP_VERSION_INVALID = 0x00,
- GST_RTSP_VERSION_1_0 = 0x10
+ GST_RTSP_VERSION_1_0 = 0x10,
+ GST_RTSP_VERSION_1_1 = 0x11
} GstRTSPVersion;
/**
* @GST_RTSP_SETUP: the SETUP method
* @GST_RTSP_SET_PARAMETER: the SET_PARAMETER method
* @GST_RTSP_TEARDOWN: the TEARDOWN method
+ * @GST_RTSP_GET: the GET method (HTTP)
+ * @GST_RTSP_POST: the POST method (HTTP)
*
* The different supported RTSP methods.
*/
GST_RTSP_REDIRECT = (1 << 7),
GST_RTSP_SETUP = (1 << 8),
GST_RTSP_SET_PARAMETER = (1 << 9),
- GST_RTSP_TEARDOWN = (1 << 10)
+ GST_RTSP_TEARDOWN = (1 << 10),
+ GST_RTSP_GET = (1 << 11),
+ GST_RTSP_POST = (1 << 12)
} GstRTSPMethod;
/**
/* Since 0.10.25 */
GST_RTSP_HDR_AUTHENTICATION_INFO, /* Authentication-Info */
+ GST_RTSP_HDR_HOST, /* Host */
+ GST_RTSP_HDR_X_SESSIONCOOKIE, /* X-Sessioncookie */
GST_RTSP_HDR_LAST
} GstRTSPHeaderField;
GstRTSPMethod * method, const gchar ** uri, GstRTSPVersion * version)
{
g_return_val_if_fail (msg != NULL, GST_RTSP_EINVAL);
- g_return_val_if_fail (msg->type == GST_RTSP_MESSAGE_REQUEST, GST_RTSP_EINVAL);
+ g_return_val_if_fail (msg->type == GST_RTSP_MESSAGE_REQUEST ||
+ msg->type == GST_RTSP_MESSAGE_HTTP_REQUEST, GST_RTSP_EINVAL);
if (method)
*method = msg->type_data.request.method;
msg->hdr_fields = g_array_new (FALSE, FALSE, sizeof (RTSPKeyValue));
if (request) {
- gchar *header;
-
- /* copy CSEQ */
- if (gst_rtsp_message_get_header (request, GST_RTSP_HDR_CSEQ, &header,
- 0) == GST_RTSP_OK) {
- gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CSEQ, header);
- }
+ if (request->type == GST_RTSP_MESSAGE_HTTP_REQUEST) {
+ msg->type = GST_RTSP_MESSAGE_HTTP_RESPONSE;
+ if (request->type_data.request.version != GST_RTSP_VERSION_INVALID)
+ msg->type_data.response.version = request->type_data.request.version;
+ else
+ msg->type_data.response.version = GST_RTSP_VERSION_1_1;
+ } else {
+ gchar *header;
- /* copy session id */
- if (gst_rtsp_message_get_header (request, GST_RTSP_HDR_SESSION, &header,
- 0) == GST_RTSP_OK) {
- char *pos;
+ /* copy CSEQ */
+ if (gst_rtsp_message_get_header (request, GST_RTSP_HDR_CSEQ, &header,
+ 0) == GST_RTSP_OK) {
+ gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CSEQ, header);
+ }
- header = g_strdup (header);
- if ((pos = strchr (header, ';'))) {
- *pos = '\0';
+ /* copy session id */
+ if (gst_rtsp_message_get_header (request, GST_RTSP_HDR_SESSION, &header,
+ 0) == GST_RTSP_OK) {
+ char *pos;
+
+ header = g_strdup (header);
+ if ((pos = strchr (header, ';'))) {
+ *pos = '\0';
+ }
+ g_strchomp (header);
+ gst_rtsp_message_take_header (msg, GST_RTSP_HDR_SESSION, header);
}
- g_strchomp (header);
- gst_rtsp_message_take_header (msg, GST_RTSP_HDR_SESSION, header);
- }
- /* FIXME copy more headers? */
+ /* FIXME copy more headers? */
+ }
}
return GST_RTSP_OK;
}
-
/**
* gst_rtsp_message_parse_response:
* @msg: a #GstRTSPMessage
GstRTSPStatusCode * code, const gchar ** reason, GstRTSPVersion * version)
{
g_return_val_if_fail (msg != NULL, GST_RTSP_EINVAL);
- g_return_val_if_fail (msg->type == GST_RTSP_MESSAGE_RESPONSE,
- GST_RTSP_EINVAL);
+ g_return_val_if_fail (msg->type == GST_RTSP_MESSAGE_RESPONSE ||
+ msg->type == GST_RTSP_MESSAGE_HTTP_RESPONSE, GST_RTSP_EINVAL);
if (code)
*code = msg->type_data.response.code;
case GST_RTSP_MESSAGE_INVALID:
break;
case GST_RTSP_MESSAGE_REQUEST:
+ case GST_RTSP_MESSAGE_HTTP_REQUEST:
g_free (msg->type_data.request.uri);
break;
case GST_RTSP_MESSAGE_RESPONSE:
+ case GST_RTSP_MESSAGE_HTTP_RESPONSE:
g_free (msg->type_data.response.reason);
break;
case GST_RTSP_MESSAGE_DATA:
g_print (" body: length %d\n", size);
gst_util_dump_mem (data, size);
break;
+ case GST_RTSP_MESSAGE_HTTP_REQUEST:
+ g_print ("HTTP request message %p\n", msg);
+ g_print (" request line:\n");
+ g_print (" method: '%s'\n",
+ gst_rtsp_method_as_text (msg->type_data.request.method));
+ g_print (" uri: '%s'\n", msg->type_data.request.uri);
+ g_print (" version: '%s'\n",
+ gst_rtsp_version_as_text (msg->type_data.request.version));
+ g_print (" headers:\n");
+ key_value_foreach (msg->hdr_fields, dump_key_value, NULL);
+ g_print (" body:\n");
+ gst_rtsp_message_get_body (msg, &data, &size);
+ gst_util_dump_mem (data, size);
+ break;
+ case GST_RTSP_MESSAGE_HTTP_RESPONSE:
+ g_print ("HTTP response message %p\n", msg);
+ g_print (" status line:\n");
+ g_print (" code: '%d'\n", msg->type_data.response.code);
+ g_print (" reason: '%s'\n", msg->type_data.response.reason);
+ g_print (" version: '%s'\n",
+ gst_rtsp_version_as_text (msg->type_data.response.version));
+ g_print (" headers:\n");
+ key_value_foreach (msg->hdr_fields, dump_key_value, NULL);
+ gst_rtsp_message_get_body (msg, &data, &size);
+ g_print (" body: length %d\n", size);
+ gst_util_dump_mem (data, size);
+ break;
case GST_RTSP_MESSAGE_DATA:
g_print ("RTSP data message %p\n", msg);
g_print (" channel: '%d'\n", msg->type_data.data.channel);