mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
client: map URL to path in requests
This commit is contained in:
parent
952aa309dc
commit
e3fded2cec
1 changed files with 95 additions and 13 deletions
|
@ -740,18 +740,20 @@ handle_teardown_request (GstRTSPClient * client, GstRTSPContext * ctx)
|
|||
GstRTSPSession *session;
|
||||
GstRTSPSessionMedia *sessmedia;
|
||||
GstRTSPStatusCode code;
|
||||
const gchar *path;
|
||||
gchar *path;
|
||||
gint matched;
|
||||
|
||||
if (!ctx->session)
|
||||
if (!(session = ctx->session))
|
||||
goto no_session;
|
||||
|
||||
session = ctx->session;
|
||||
|
||||
if (!ctx->uri)
|
||||
goto no_uri;
|
||||
|
||||
path = ctx->uri->abspath;
|
||||
if (!priv->mount_points)
|
||||
goto no_mount_points;
|
||||
|
||||
if (!(path = gst_rtsp_mount_points_make_path (priv->mount_points, ctx->uri)))
|
||||
goto no_path;
|
||||
|
||||
/* get a handle to the configuration of the media in the session */
|
||||
sessmedia = gst_rtsp_session_get_media (session, path, &matched);
|
||||
|
@ -762,6 +764,8 @@ handle_teardown_request (GstRTSPClient * client, GstRTSPContext * ctx)
|
|||
if (path[matched] != '\0')
|
||||
goto no_aggregate;
|
||||
|
||||
g_free (path);
|
||||
|
||||
ctx->sessmedia = sessmedia;
|
||||
|
||||
/* we emit the signal before closing the connection */
|
||||
|
@ -804,15 +808,29 @@ no_uri:
|
|||
send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
no_mount_points:
|
||||
{
|
||||
GST_ERROR ("client %p: no mount points configured", client);
|
||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
no_path:
|
||||
{
|
||||
GST_ERROR ("client %p: can't find path for url", client);
|
||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
not_found:
|
||||
{
|
||||
GST_ERROR ("client %p: no media for uri", client);
|
||||
g_free (path);
|
||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
no_aggregate:
|
||||
{
|
||||
GST_ERROR ("client %p: no aggregate path %s", client, path);
|
||||
g_free (path);
|
||||
send_generic_response (client,
|
||||
GST_RTSP_STS_ONLY_AGGREGATE_OPERATION_ALLOWED, ctx);
|
||||
return FALSE;
|
||||
|
@ -916,11 +934,12 @@ bad_request:
|
|||
static gboolean
|
||||
handle_pause_request (GstRTSPClient * client, GstRTSPContext * ctx)
|
||||
{
|
||||
GstRTSPClientPrivate *priv = client->priv;
|
||||
GstRTSPSession *session;
|
||||
GstRTSPSessionMedia *sessmedia;
|
||||
GstRTSPStatusCode code;
|
||||
GstRTSPState rtspstate;
|
||||
const gchar *path;
|
||||
gchar *path;
|
||||
gint matched;
|
||||
|
||||
if (!(session = ctx->session))
|
||||
|
@ -929,7 +948,11 @@ handle_pause_request (GstRTSPClient * client, GstRTSPContext * ctx)
|
|||
if (!ctx->uri)
|
||||
goto no_uri;
|
||||
|
||||
path = ctx->uri->abspath;
|
||||
if (!priv->mount_points)
|
||||
goto no_mount_points;
|
||||
|
||||
if (!(path = gst_rtsp_mount_points_make_path (priv->mount_points, ctx->uri)))
|
||||
goto no_path;
|
||||
|
||||
/* get a handle to the configuration of the media in the session */
|
||||
sessmedia = gst_rtsp_session_get_media (session, path, &matched);
|
||||
|
@ -939,6 +962,8 @@ handle_pause_request (GstRTSPClient * client, GstRTSPContext * ctx)
|
|||
if (path[matched] != '\0')
|
||||
goto no_aggregate;
|
||||
|
||||
g_free (path);
|
||||
|
||||
ctx->sessmedia = sessmedia;
|
||||
|
||||
rtspstate = gst_rtsp_session_media_get_rtsp_state (sessmedia);
|
||||
|
@ -980,15 +1005,29 @@ no_uri:
|
|||
send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
no_mount_points:
|
||||
{
|
||||
GST_ERROR ("client %p: no mount points configured", client);
|
||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
no_path:
|
||||
{
|
||||
GST_ERROR ("client %p: can't find path for url", client);
|
||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
not_found:
|
||||
{
|
||||
GST_ERROR ("client %p: no media for uri", client);
|
||||
g_free (path);
|
||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
no_aggregate:
|
||||
{
|
||||
GST_ERROR ("client %p: no aggregate path %s", client, path);
|
||||
g_free (path);
|
||||
send_generic_response (client,
|
||||
GST_RTSP_STS_ONLY_AGGREGATE_OPERATION_ALLOWED, ctx);
|
||||
return FALSE;
|
||||
|
@ -1005,6 +1044,7 @@ invalid_state:
|
|||
static gboolean
|
||||
handle_play_request (GstRTSPClient * client, GstRTSPContext * ctx)
|
||||
{
|
||||
GstRTSPClientPrivate *priv = client->priv;
|
||||
GstRTSPSession *session;
|
||||
GstRTSPSessionMedia *sessmedia;
|
||||
GstRTSPMedia *media;
|
||||
|
@ -1016,7 +1056,7 @@ handle_play_request (GstRTSPClient * client, GstRTSPContext * ctx)
|
|||
GstRTSPResult res;
|
||||
GstRTSPState rtspstate;
|
||||
GstRTSPRangeUnit unit = GST_RTSP_RANGE_NPT;
|
||||
const gchar *path;
|
||||
gchar *path;
|
||||
gint matched;
|
||||
|
||||
if (!(session = ctx->session))
|
||||
|
@ -1025,7 +1065,11 @@ handle_play_request (GstRTSPClient * client, GstRTSPContext * ctx)
|
|||
if (!ctx->uri)
|
||||
goto no_uri;
|
||||
|
||||
path = ctx->uri->abspath;
|
||||
if (!priv->mount_points)
|
||||
goto no_mount_points;
|
||||
|
||||
if (!(path = gst_rtsp_mount_points_make_path (priv->mount_points, ctx->uri)))
|
||||
goto no_path;
|
||||
|
||||
/* get a handle to the configuration of the media in the session */
|
||||
sessmedia = gst_rtsp_session_get_media (session, path, &matched);
|
||||
|
@ -1035,6 +1079,8 @@ handle_play_request (GstRTSPClient * client, GstRTSPContext * ctx)
|
|||
if (path[matched] != '\0')
|
||||
goto no_aggregate;
|
||||
|
||||
g_free (path);
|
||||
|
||||
ctx->sessmedia = sessmedia;
|
||||
ctx->media = media = gst_rtsp_session_media_get_media (sessmedia);
|
||||
|
||||
|
@ -1136,15 +1182,29 @@ no_uri:
|
|||
send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
no_mount_points:
|
||||
{
|
||||
GST_ERROR ("client %p: no mount points configured", client);
|
||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
no_path:
|
||||
{
|
||||
GST_ERROR ("client %p: can't find path for url", client);
|
||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
not_found:
|
||||
{
|
||||
GST_ERROR ("client %p: media not found", client);
|
||||
g_free (path);
|
||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
no_aggregate:
|
||||
{
|
||||
GST_ERROR ("client %p: no aggregate path %s", client, path);
|
||||
g_free (path);
|
||||
send_generic_response (client,
|
||||
GST_RTSP_STS_ONLY_AGGREGATE_OPERATION_ALLOWED, ctx);
|
||||
return FALSE;
|
||||
|
@ -1380,11 +1440,14 @@ handle_setup_request (GstRTSPClient * client, GstRTSPContext * ctx)
|
|||
gchar *path, *control;
|
||||
gint matched;
|
||||
|
||||
if (!ctx->uri)
|
||||
if (!(uri = ctx->uri))
|
||||
goto no_uri;
|
||||
|
||||
uri = ctx->uri;
|
||||
path = uri->abspath;
|
||||
if (!priv->mount_points)
|
||||
goto no_mount_points;
|
||||
|
||||
if (!(path = gst_rtsp_mount_points_make_path (priv->mount_points, uri)))
|
||||
goto no_path;
|
||||
|
||||
/* parse the transport */
|
||||
res =
|
||||
|
@ -1422,7 +1485,7 @@ handle_setup_request (GstRTSPClient * client, GstRTSPContext * ctx)
|
|||
if (media == NULL)
|
||||
goto media_not_found;
|
||||
|
||||
/* path is what matched. We can modify the parsed uri in place */
|
||||
/* path is what matched */
|
||||
path[matched] = '\0';
|
||||
/* control is remainder */
|
||||
control = &path[matched + 1];
|
||||
|
@ -1461,6 +1524,7 @@ handle_setup_request (GstRTSPClient * client, GstRTSPContext * ctx)
|
|||
} else {
|
||||
g_object_unref (media);
|
||||
}
|
||||
g_free (path);
|
||||
|
||||
ctx->sessmedia = sessmedia;
|
||||
|
||||
|
@ -1530,27 +1594,43 @@ no_uri:
|
|||
send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
no_mount_points:
|
||||
{
|
||||
GST_ERROR ("client %p: no mount points configured", client);
|
||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
no_path:
|
||||
{
|
||||
GST_ERROR ("client %p: can't find path for url", client);
|
||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
no_transport:
|
||||
{
|
||||
GST_ERROR ("client %p: no transport", client);
|
||||
g_free (path);
|
||||
send_generic_response (client, GST_RTSP_STS_UNSUPPORTED_TRANSPORT, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
no_pool:
|
||||
{
|
||||
GST_ERROR ("client %p: no session pool configured", client);
|
||||
g_free (path);
|
||||
send_generic_response (client, GST_RTSP_STS_SESSION_NOT_FOUND, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
media_not_found:
|
||||
{
|
||||
GST_ERROR ("client %p: media '%s' not found", client, path);
|
||||
g_free (path);
|
||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||
return FALSE;
|
||||
}
|
||||
stream_not_found:
|
||||
{
|
||||
GST_ERROR ("client %p: stream '%s' not found", client, control);
|
||||
g_free (path);
|
||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||
g_object_unref (media);
|
||||
return FALSE;
|
||||
|
@ -1558,6 +1638,7 @@ stream_not_found:
|
|||
service_unavailable:
|
||||
{
|
||||
GST_ERROR ("client %p: can't create session", client);
|
||||
g_free (path);
|
||||
send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, ctx);
|
||||
g_object_unref (media);
|
||||
return FALSE;
|
||||
|
@ -1566,6 +1647,7 @@ sessmedia_unavailable:
|
|||
{
|
||||
GST_ERROR ("client %p: can't create session media", client);
|
||||
send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, ctx);
|
||||
g_free (path);
|
||||
g_object_unref (media);
|
||||
g_object_unref (session);
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in a new issue