mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
rtsp: Start implementing support for RTSP 2.0
Properly handle protocol version in the connection Add the following headers types: * Pipelined-Request * Media-Properties * Seek-Style * Accept-Ranges https://bugzilla.gnome.org/show_bug.cgi?id=781446
This commit is contained in:
parent
43985b363d
commit
20fae3f1e0
4 changed files with 43 additions and 11 deletions
|
@ -109,6 +109,7 @@ struct _GstRTSPConnection
|
||||||
/*< private > */
|
/*< private > */
|
||||||
/* URL for the remote connection */
|
/* URL for the remote connection */
|
||||||
GstRTSPUrl *url;
|
GstRTSPUrl *url;
|
||||||
|
GstRTSPVersion version;
|
||||||
|
|
||||||
gboolean server;
|
gboolean server;
|
||||||
GSocketClient *client;
|
GSocketClient *client;
|
||||||
|
@ -314,6 +315,7 @@ gst_rtsp_connection_create (const GstRTSPUrl * url, GstRTSPConnection ** conn)
|
||||||
newconn->username = NULL;
|
newconn->username = NULL;
|
||||||
newconn->passwd = NULL;
|
newconn->passwd = NULL;
|
||||||
newconn->auth_params = NULL;
|
newconn->auth_params = NULL;
|
||||||
|
newconn->version = 0;
|
||||||
|
|
||||||
*conn = newconn;
|
*conn = newconn;
|
||||||
|
|
||||||
|
@ -1454,10 +1456,12 @@ message_to_string (GstRTSPConnection * conn, GstRTSPMessage * message)
|
||||||
switch (message->type) {
|
switch (message->type) {
|
||||||
case GST_RTSP_MESSAGE_REQUEST:
|
case GST_RTSP_MESSAGE_REQUEST:
|
||||||
/* create request string, add CSeq */
|
/* create request string, add CSeq */
|
||||||
g_string_append_printf (str, "%s %s RTSP/1.0\r\n"
|
g_string_append_printf (str, "%s %s RTSP/%s\r\n"
|
||||||
"CSeq: %d\r\n",
|
"CSeq: %d\r\n",
|
||||||
gst_rtsp_method_as_text (message->type_data.request.method),
|
gst_rtsp_method_as_text (message->type_data.request.method),
|
||||||
message->type_data.request.uri, conn->cseq++);
|
message->type_data.request.uri,
|
||||||
|
gst_rtsp_version_as_text (message->type_data.request.version),
|
||||||
|
conn->cseq++);
|
||||||
/* add session id if we have one */
|
/* add session id if we have one */
|
||||||
if (conn->session_id[0] != '\0') {
|
if (conn->session_id[0] != '\0') {
|
||||||
gst_rtsp_message_remove_header (message, GST_RTSP_HDR_SESSION, -1);
|
gst_rtsp_message_remove_header (message, GST_RTSP_HDR_SESSION, -1);
|
||||||
|
@ -1469,7 +1473,8 @@ message_to_string (GstRTSPConnection * conn, GstRTSPMessage * message)
|
||||||
break;
|
break;
|
||||||
case GST_RTSP_MESSAGE_RESPONSE:
|
case GST_RTSP_MESSAGE_RESPONSE:
|
||||||
/* create response string */
|
/* create response string */
|
||||||
g_string_append_printf (str, "RTSP/1.0 %d %s\r\n",
|
g_string_append_printf (str, "RTSP/%s %d %s\r\n",
|
||||||
|
gst_rtsp_version_as_text (message->type_data.response.version),
|
||||||
message->type_data.response.code, message->type_data.response.reason);
|
message->type_data.response.code, message->type_data.response.reason);
|
||||||
break;
|
break;
|
||||||
case GST_RTSP_MESSAGE_HTTP_REQUEST:
|
case GST_RTSP_MESSAGE_HTTP_REQUEST:
|
||||||
|
@ -1626,6 +1631,7 @@ static GstRTSPResult
|
||||||
parse_protocol_version (gchar * protocol, GstRTSPMsgType * type,
|
parse_protocol_version (gchar * protocol, GstRTSPMsgType * type,
|
||||||
GstRTSPVersion * version)
|
GstRTSPVersion * version)
|
||||||
{
|
{
|
||||||
|
GstRTSPVersion rversion;
|
||||||
GstRTSPResult res = GST_RTSP_OK;
|
GstRTSPResult res = GST_RTSP_OK;
|
||||||
gchar *ver;
|
gchar *ver;
|
||||||
|
|
||||||
|
@ -1640,8 +1646,10 @@ parse_protocol_version (gchar * protocol, GstRTSPMsgType * type,
|
||||||
if (sscanf (ver, "%u.%u%c", &major, &minor, &dummychar) != 2)
|
if (sscanf (ver, "%u.%u%c", &major, &minor, &dummychar) != 2)
|
||||||
res = GST_RTSP_EPARSE;
|
res = GST_RTSP_EPARSE;
|
||||||
|
|
||||||
|
rversion = major * 0x10 + minor;
|
||||||
if (g_ascii_strcasecmp (protocol, "RTSP") == 0) {
|
if (g_ascii_strcasecmp (protocol, "RTSP") == 0) {
|
||||||
if (major != 1 || minor != 0) {
|
|
||||||
|
if (rversion != GST_RTSP_VERSION_1_0 && rversion != GST_RTSP_VERSION_2_0) {
|
||||||
*version = GST_RTSP_VERSION_INVALID;
|
*version = GST_RTSP_VERSION_INVALID;
|
||||||
res = GST_RTSP_ERROR;
|
res = GST_RTSP_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1651,17 +1659,17 @@ parse_protocol_version (gchar * protocol, GstRTSPMsgType * type,
|
||||||
else if (*type == GST_RTSP_MESSAGE_RESPONSE)
|
else if (*type == GST_RTSP_MESSAGE_RESPONSE)
|
||||||
*type = GST_RTSP_MESSAGE_HTTP_RESPONSE;
|
*type = GST_RTSP_MESSAGE_HTTP_RESPONSE;
|
||||||
|
|
||||||
if (major == 1 && minor == 1) {
|
if (rversion != GST_RTSP_VERSION_1_0 &&
|
||||||
*version = GST_RTSP_VERSION_1_1;
|
rversion != GST_RTSP_VERSION_1_1 && rversion != GST_RTSP_VERSION_2_0)
|
||||||
} else if (major != 1 || minor != 0) {
|
|
||||||
*version = GST_RTSP_VERSION_INVALID;
|
|
||||||
res = GST_RTSP_ERROR;
|
res = GST_RTSP_ERROR;
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
res = GST_RTSP_EPARSE;
|
res = GST_RTSP_EPARSE;
|
||||||
} else
|
} else
|
||||||
res = GST_RTSP_EPARSE;
|
res = GST_RTSP_EPARSE;
|
||||||
|
|
||||||
|
if (res == GST_RTSP_OK)
|
||||||
|
*version = rversion;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "gstrtspdefs.h"
|
#include "gstrtspdefs.h"
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
struct rtsp_header
|
struct rtsp_header
|
||||||
{
|
{
|
||||||
|
@ -176,6 +177,12 @@ static struct rtsp_header rtsp_headers[] = {
|
||||||
/* Since 1.4 */
|
/* Since 1.4 */
|
||||||
{"KeyMgmt", FALSE},
|
{"KeyMgmt", FALSE},
|
||||||
|
|
||||||
|
/* Since 1.XX */
|
||||||
|
{"Pipelined-Requests", FALSE},
|
||||||
|
{"Media-Properties", FALSE},
|
||||||
|
{"Seek-Style", FALSE},
|
||||||
|
{"Accept-Ranges", FALSE},
|
||||||
|
|
||||||
{NULL, FALSE}
|
{NULL, FALSE}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -338,6 +345,10 @@ gst_rtsp_version_as_text (GstRTSPVersion version)
|
||||||
case GST_RTSP_VERSION_1_1:
|
case GST_RTSP_VERSION_1_1:
|
||||||
return "1.1";
|
return "1.1";
|
||||||
|
|
||||||
|
case GST_RTSP_VERSION_2_0:
|
||||||
|
return "2.0";
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "0.0";
|
return "0.0";
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ G_STMT_START { \
|
||||||
* @GST_RTSP_ERESOLV: a host resolve error occured
|
* @GST_RTSP_ERESOLV: a host resolve error occured
|
||||||
* @GST_RTSP_ENOTIMPL: function not implemented
|
* @GST_RTSP_ENOTIMPL: function not implemented
|
||||||
* @GST_RTSP_ESYS: a system error occured, errno contains more details
|
* @GST_RTSP_ESYS: a system error occured, errno contains more details
|
||||||
* @GST_RTSP_EPARSE: a persing error occured
|
* @GST_RTSP_EPARSE: a parsing error occured
|
||||||
* @GST_RTSP_EWSASTART: windows networking could not start
|
* @GST_RTSP_EWSASTART: windows networking could not start
|
||||||
* @GST_RTSP_EWSAVERSION: windows networking stack has wrong version
|
* @GST_RTSP_EWSAVERSION: windows networking stack has wrong version
|
||||||
* @GST_RTSP_EEOF: end-of-file was reached
|
* @GST_RTSP_EEOF: end-of-file was reached
|
||||||
|
@ -158,13 +158,15 @@ typedef enum {
|
||||||
* @GST_RTSP_VERSION_INVALID: unknown/invalid version
|
* @GST_RTSP_VERSION_INVALID: unknown/invalid version
|
||||||
* @GST_RTSP_VERSION_1_0: version 1.0
|
* @GST_RTSP_VERSION_1_0: version 1.0
|
||||||
* @GST_RTSP_VERSION_1_1: version 1.1.
|
* @GST_RTSP_VERSION_1_1: version 1.1.
|
||||||
|
* @GST_RTSP_VERSION_2_0: version 2.0.
|
||||||
*
|
*
|
||||||
* The supported RTSP versions.
|
* The supported RTSP versions.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GST_RTSP_VERSION_INVALID = 0x00,
|
GST_RTSP_VERSION_INVALID = 0x00,
|
||||||
GST_RTSP_VERSION_1_0 = 0x10,
|
GST_RTSP_VERSION_1_0 = 0x10,
|
||||||
GST_RTSP_VERSION_1_1 = 0x11
|
GST_RTSP_VERSION_1_1 = 0x11,
|
||||||
|
GST_RTSP_VERSION_2_0 = 0x20
|
||||||
} GstRTSPVersion;
|
} GstRTSPVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -332,6 +334,12 @@ typedef enum {
|
||||||
/* Since 1.4 */
|
/* Since 1.4 */
|
||||||
GST_RTSP_HDR_KEYMGMT, /* KeyMgmt */
|
GST_RTSP_HDR_KEYMGMT, /* KeyMgmt */
|
||||||
|
|
||||||
|
/* Since 1.X */
|
||||||
|
GST_RTSP_HDR_PIPELINED_REQUESTS, /* Pipelined-Requests Rr opt. SETUP */
|
||||||
|
GST_RTSP_HDR_MEDIA_PROPERTIES, /* Media-Properties Rr opt. SETUP */
|
||||||
|
GST_RTSP_HDR_SEEK_STYLE, /* Seek-Type Rr opt. PLAY */
|
||||||
|
GST_RTSP_HDR_ACCEPT_RANGES, /* Accept-Ranges Rr opt. SETUP, GET_PARAMETER */
|
||||||
|
|
||||||
GST_RTSP_HDR_LAST
|
GST_RTSP_HDR_LAST
|
||||||
} GstRTSPHeaderField;
|
} GstRTSPHeaderField;
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,11 @@ G_BEGIN_DECLS
|
||||||
#define GST_RTSP_EXTENSION_GET_INTERFACE(inst) \
|
#define GST_RTSP_EXTENSION_GET_INTERFACE(inst) \
|
||||||
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_RTSP_EXTENSION, GstRTSPExtensionInterface))
|
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_RTSP_EXTENSION, GstRTSPExtensionInterface))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstRTSPExtension:
|
||||||
|
*
|
||||||
|
* An interface representing RTSP extensions.
|
||||||
|
*/
|
||||||
typedef struct _GstRTSPExtension GstRTSPExtension;
|
typedef struct _GstRTSPExtension GstRTSPExtension;
|
||||||
typedef struct _GstRTSPExtensionInterface GstRTSPExtensionInterface;
|
typedef struct _GstRTSPExtensionInterface GstRTSPExtensionInterface;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue