mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-04 01:32:42 +00:00
rtsp: Rewrote gen_tunnel_reply().
Rewrote gen_tunnel_reply() to generate a normal GstRTSPMessage rather than a hard coded string.
This commit is contained in:
parent
e1b3393d6b
commit
c18e2eec88
3 changed files with 41 additions and 38 deletions
|
@ -2001,38 +2001,40 @@ read_error:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GString *
|
static GstRTSPMessage *
|
||||||
gen_tunnel_reply (GstRTSPConnection * conn, GstRTSPStatusCode code)
|
gen_tunnel_reply (GstRTSPConnection * conn, GstRTSPStatusCode code,
|
||||||
|
const GstRTSPMessage * request)
|
||||||
{
|
{
|
||||||
GString *str;
|
GstRTSPMessage *msg;
|
||||||
gchar date_string[100];
|
GstRTSPResult res;
|
||||||
const gchar *status;
|
|
||||||
|
|
||||||
gen_date_string (date_string, sizeof (date_string));
|
if (gst_rtsp_status_as_text (code) == NULL)
|
||||||
|
|
||||||
status = gst_rtsp_status_as_text (code);
|
|
||||||
if (status == NULL) {
|
|
||||||
code = GST_RTSP_STS_INTERNAL_SERVER_ERROR;
|
code = GST_RTSP_STS_INTERNAL_SERVER_ERROR;
|
||||||
status = "Internal Server Error";
|
|
||||||
}
|
|
||||||
|
|
||||||
str = g_string_new ("");
|
GST_RTSP_CHECK (gst_rtsp_message_new_response (&msg, code, NULL, request),
|
||||||
|
no_message);
|
||||||
|
|
||||||
|
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_SERVER,
|
||||||
|
"GStreamer RTSP Server");
|
||||||
|
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CONNECTION, "close");
|
||||||
|
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CACHE_CONTROL, "no-store");
|
||||||
|
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_PRAGMA, "no-cache");
|
||||||
|
|
||||||
/* */
|
|
||||||
g_string_append_printf (str, "HTTP/1.0 %d %s\r\n", code, status);
|
|
||||||
g_string_append_printf (str,
|
|
||||||
"Server: GStreamer RTSP Server\r\n"
|
|
||||||
"Date: %s\r\n"
|
|
||||||
"Connection: close\r\n"
|
|
||||||
"Cache-Control: no-store\r\n" "Pragma: no-cache\r\n", date_string);
|
|
||||||
if (code == GST_RTSP_STS_OK) {
|
if (code == GST_RTSP_STS_OK) {
|
||||||
if (conn->ip)
|
if (conn->ip)
|
||||||
g_string_append_printf (str, "x-server-ip-address: %s\r\n", conn->ip);
|
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_X_SERVER_IP_ADDRESS,
|
||||||
g_string_append_printf (str,
|
conn->ip);
|
||||||
"Content-Type: application/x-rtsp-tunnelled\r\n");
|
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_CONTENT_TYPE,
|
||||||
|
"application/x-rtsp-tunnelled");
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
|
||||||
|
/* ERRORS */
|
||||||
|
no_message:
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
g_string_append_printf (str, "\r\n");
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2078,17 +2080,16 @@ gst_rtsp_connection_receive (GstRTSPConnection * conn, GstRTSPMessage * message,
|
||||||
if (message->type == GST_RTSP_MESSAGE_HTTP_REQUEST) {
|
if (message->type == GST_RTSP_MESSAGE_HTTP_REQUEST) {
|
||||||
if (conn->tstate == TUNNEL_STATE_NONE &&
|
if (conn->tstate == TUNNEL_STATE_NONE &&
|
||||||
message->type_data.request.method == GST_RTSP_GET) {
|
message->type_data.request.method == GST_RTSP_GET) {
|
||||||
GString *str;
|
GstRTSPMessage *response;
|
||||||
|
|
||||||
conn->tstate = TUNNEL_STATE_GET;
|
conn->tstate = TUNNEL_STATE_GET;
|
||||||
|
|
||||||
/* tunnel GET request, we can reply now */
|
/* tunnel GET request, we can reply now */
|
||||||
str = gen_tunnel_reply (conn, GST_RTSP_STS_OK);
|
response = gen_tunnel_reply (conn, GST_RTSP_STS_OK, message);
|
||||||
res =
|
res = gst_rtsp_connection_send (conn, response, timeout);
|
||||||
gst_rtsp_connection_write (conn, (guint8 *) str->str, str->len,
|
gst_rtsp_message_free (response);
|
||||||
timeout);
|
if (res == GST_RTSP_OK)
|
||||||
g_string_free (str, TRUE);
|
res = GST_RTSP_ETGET;
|
||||||
res = GST_RTSP_ETGET;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (conn->tstate == TUNNEL_STATE_NONE &&
|
} else if (conn->tstate == TUNNEL_STATE_NONE &&
|
||||||
message->type_data.request.method == GST_RTSP_POST) {
|
message->type_data.request.method == GST_RTSP_POST) {
|
||||||
|
@ -2911,9 +2912,8 @@ gst_rtsp_source_dispatch (GSource * source, GSourceFunc callback G_GNUC_UNUSED,
|
||||||
if (watch->message.type == GST_RTSP_MESSAGE_HTTP_REQUEST) {
|
if (watch->message.type == GST_RTSP_MESSAGE_HTTP_REQUEST) {
|
||||||
if (watch->conn->tstate == TUNNEL_STATE_NONE &&
|
if (watch->conn->tstate == TUNNEL_STATE_NONE &&
|
||||||
watch->message.type_data.request.method == GST_RTSP_GET) {
|
watch->message.type_data.request.method == GST_RTSP_GET) {
|
||||||
GString *str;
|
GstRTSPMessage *response;
|
||||||
GstRTSPStatusCode code;
|
GstRTSPStatusCode code;
|
||||||
guint size;
|
|
||||||
|
|
||||||
watch->conn->tstate = TUNNEL_STATE_GET;
|
watch->conn->tstate = TUNNEL_STATE_GET;
|
||||||
|
|
||||||
|
@ -2922,11 +2922,10 @@ gst_rtsp_source_dispatch (GSource * source, GSourceFunc callback G_GNUC_UNUSED,
|
||||||
else
|
else
|
||||||
code = GST_RTSP_STS_OK;
|
code = GST_RTSP_STS_OK;
|
||||||
|
|
||||||
/* queue the response string */
|
/* queue the response */
|
||||||
str = gen_tunnel_reply (watch->conn, code);
|
response = gen_tunnel_reply (watch->conn, code, &watch->message);
|
||||||
size = str->len;
|
gst_rtsp_watch_queue_message (watch, response);
|
||||||
gst_rtsp_watch_queue_data (watch, (guint8 *) g_string_free (str,
|
gst_rtsp_message_free (response);
|
||||||
FALSE), size);
|
|
||||||
goto read_done;
|
goto read_done;
|
||||||
} else if (watch->conn->tstate == TUNNEL_STATE_NONE &&
|
} else if (watch->conn->tstate == TUNNEL_STATE_NONE &&
|
||||||
watch->message.type_data.request.method == GST_RTSP_POST) {
|
watch->message.type_data.request.method == GST_RTSP_POST) {
|
||||||
|
|
|
@ -191,6 +191,8 @@ static const gchar *rtsp_headers[] = {
|
||||||
|
|
||||||
"Authentication-Info", /* Authentication-Info */
|
"Authentication-Info", /* Authentication-Info */
|
||||||
"Host", /* Host */
|
"Host", /* Host */
|
||||||
|
"Pragma", /* Pragma */
|
||||||
|
"X-Server-IP-Address", /* X-Server-IP-Address */
|
||||||
"X-Sessioncookie", /* X-Sessioncookie */
|
"X-Sessioncookie", /* X-Sessioncookie */
|
||||||
|
|
||||||
NULL
|
NULL
|
||||||
|
|
|
@ -322,6 +322,8 @@ typedef enum {
|
||||||
/* Since 0.10.25 */
|
/* Since 0.10.25 */
|
||||||
GST_RTSP_HDR_AUTHENTICATION_INFO, /* Authentication-Info */
|
GST_RTSP_HDR_AUTHENTICATION_INFO, /* Authentication-Info */
|
||||||
GST_RTSP_HDR_HOST, /* Host */
|
GST_RTSP_HDR_HOST, /* Host */
|
||||||
|
GST_RTSP_HDR_PRAGMA, /* Pragma */
|
||||||
|
GST_RTSP_HDR_X_SERVER_IP_ADDRESS, /* X-Server-IP-Address */
|
||||||
GST_RTSP_HDR_X_SESSIONCOOKIE, /* X-Sessioncookie */
|
GST_RTSP_HDR_X_SESSIONCOOKIE, /* X-Sessioncookie */
|
||||||
|
|
||||||
GST_RTSP_HDR_LAST
|
GST_RTSP_HDR_LAST
|
||||||
|
|
Loading…
Reference in a new issue