mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
mount-points: make vmethod to make path from uri
Make a vmethod to transform an url into a path. The path is then used to lookup the factory. This makes it possible to also use other bits of the url, such as the query parameters, to locate the factory.
This commit is contained in:
parent
258f63b8ac
commit
952aa309dc
3 changed files with 60 additions and 1 deletions
|
@ -491,7 +491,8 @@ find_media (GstRTSPClient * client, GstRTSPContext * ctx, gint * matched)
|
||||||
if (!priv->mount_points)
|
if (!priv->mount_points)
|
||||||
goto no_mount_points;
|
goto no_mount_points;
|
||||||
|
|
||||||
path = ctx->uri->abspath;
|
if (!(path = gst_rtsp_mount_points_make_path (priv->mount_points, ctx->uri)))
|
||||||
|
goto no_path;
|
||||||
|
|
||||||
/* find the longest matching factory for the uri first */
|
/* find the longest matching factory for the uri first */
|
||||||
if (!(factory = gst_rtsp_mount_points_match (priv->mount_points,
|
if (!(factory = gst_rtsp_mount_points_match (priv->mount_points,
|
||||||
|
@ -552,6 +553,7 @@ find_media (GstRTSPClient * client, GstRTSPContext * ctx, gint * matched)
|
||||||
|
|
||||||
g_object_unref (factory);
|
g_object_unref (factory);
|
||||||
ctx->factory = NULL;
|
ctx->factory = NULL;
|
||||||
|
g_free (path);
|
||||||
|
|
||||||
if (media)
|
if (media)
|
||||||
g_object_ref (media);
|
g_object_ref (media);
|
||||||
|
@ -565,20 +567,29 @@ no_mount_points:
|
||||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
no_path:
|
||||||
|
{
|
||||||
|
GST_ERROR ("client %p: can't find path for url", client);
|
||||||
|
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
no_factory:
|
no_factory:
|
||||||
{
|
{
|
||||||
GST_ERROR ("client %p: no factory for uri %s", client, path);
|
GST_ERROR ("client %p: no factory for uri %s", client, path);
|
||||||
|
g_free (path);
|
||||||
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
no_factory_access:
|
no_factory_access:
|
||||||
{
|
{
|
||||||
GST_ERROR ("client %p: not authorized to see factory uri %s", client, path);
|
GST_ERROR ("client %p: not authorized to see factory uri %s", client, path);
|
||||||
|
g_free (path);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
not_authorized:
|
not_authorized:
|
||||||
{
|
{
|
||||||
GST_ERROR ("client %p: not authorized for factory uri %s", client, path);
|
GST_ERROR ("client %p: not authorized for factory uri %s", client, path);
|
||||||
|
g_free (path);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
no_media:
|
no_media:
|
||||||
|
@ -587,6 +598,7 @@ no_media:
|
||||||
send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, ctx);
|
send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, ctx);
|
||||||
g_object_unref (factory);
|
g_object_unref (factory);
|
||||||
ctx->factory = NULL;
|
ctx->factory = NULL;
|
||||||
|
g_free (path);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
no_thread:
|
no_thread:
|
||||||
|
@ -597,6 +609,7 @@ no_thread:
|
||||||
ctx->media = NULL;
|
ctx->media = NULL;
|
||||||
g_object_unref (factory);
|
g_object_unref (factory);
|
||||||
ctx->factory = NULL;
|
ctx->factory = NULL;
|
||||||
|
g_free (path);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
no_prepare:
|
no_prepare:
|
||||||
|
@ -607,6 +620,7 @@ no_prepare:
|
||||||
ctx->media = NULL;
|
ctx->media = NULL;
|
||||||
g_object_unref (factory);
|
g_object_unref (factory);
|
||||||
ctx->factory = NULL;
|
ctx->factory = NULL;
|
||||||
|
g_free (path);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,8 @@ G_DEFINE_TYPE (GstRTSPMountPoints, gst_rtsp_mount_points, G_TYPE_OBJECT);
|
||||||
GST_DEBUG_CATEGORY_STATIC (rtsp_media_debug);
|
GST_DEBUG_CATEGORY_STATIC (rtsp_media_debug);
|
||||||
#define GST_CAT_DEFAULT rtsp_media_debug
|
#define GST_CAT_DEFAULT rtsp_media_debug
|
||||||
|
|
||||||
|
static gchar *default_make_path (GstRTSPMountPoints * mounts,
|
||||||
|
const GstRTSPUrl * url);
|
||||||
static void gst_rtsp_mount_points_finalize (GObject * obj);
|
static void gst_rtsp_mount_points_finalize (GObject * obj);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -115,6 +117,8 @@ gst_rtsp_mount_points_class_init (GstRTSPMountPointsClass * klass)
|
||||||
|
|
||||||
gobject_class->finalize = gst_rtsp_mount_points_finalize;
|
gobject_class->finalize = gst_rtsp_mount_points_finalize;
|
||||||
|
|
||||||
|
klass->make_path = default_make_path;
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (rtsp_media_debug, "rtspmountpoints", 0,
|
GST_DEBUG_CATEGORY_INIT (rtsp_media_debug, "rtspmountpoints", 0,
|
||||||
"GstRTSPMountPoints");
|
"GstRTSPMountPoints");
|
||||||
}
|
}
|
||||||
|
@ -164,6 +168,41 @@ gst_rtsp_mount_points_new (void)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
default_make_path (GstRTSPMountPoints * mounts, const GstRTSPUrl * url)
|
||||||
|
{
|
||||||
|
return g_strdup (url->abspath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_rtsp_mount_points_make_path:
|
||||||
|
* @mounts: a #GstRTSPMountPoints
|
||||||
|
* @url: a #GstRTSPUrl
|
||||||
|
*
|
||||||
|
* Make a path string from @url.
|
||||||
|
*
|
||||||
|
* Returns: a path string for @url, g_free() after usage.
|
||||||
|
*/
|
||||||
|
gchar *
|
||||||
|
gst_rtsp_mount_points_make_path (GstRTSPMountPoints * mounts,
|
||||||
|
const GstRTSPUrl * url)
|
||||||
|
{
|
||||||
|
GstRTSPMountPointsClass *klass;
|
||||||
|
gchar *result;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_RTSP_MOUNT_POINTS (mounts), NULL);
|
||||||
|
g_return_val_if_fail (url != NULL, NULL);
|
||||||
|
|
||||||
|
klass = GST_RTSP_MOUNT_POINTS_GET_CLASS (mounts);
|
||||||
|
|
||||||
|
if (klass->make_path)
|
||||||
|
result = klass->make_path (mounts, url);
|
||||||
|
else
|
||||||
|
result = NULL;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
has_prefix (DataItem * str, DataItem * prefix)
|
has_prefix (DataItem * str, DataItem * prefix)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,11 +53,15 @@ struct _GstRTSPMountPoints {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstRTSPMountPointsClass:
|
* GstRTSPMountPointsClass:
|
||||||
|
* @make_path: make a path from the given url.
|
||||||
*
|
*
|
||||||
* The class for the media mounts object.
|
* The class for the media mounts object.
|
||||||
*/
|
*/
|
||||||
struct _GstRTSPMountPointsClass {
|
struct _GstRTSPMountPointsClass {
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
gchar * (*make_path) (GstRTSPMountPoints *mounts,
|
||||||
|
const GstRTSPUrl *url);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_rtsp_mount_points_get_type (void);
|
GType gst_rtsp_mount_points_get_type (void);
|
||||||
|
@ -65,6 +69,8 @@ GType gst_rtsp_mount_points_get_type (void);
|
||||||
/* creating a mount points */
|
/* creating a mount points */
|
||||||
GstRTSPMountPoints * gst_rtsp_mount_points_new (void);
|
GstRTSPMountPoints * gst_rtsp_mount_points_new (void);
|
||||||
|
|
||||||
|
gchar * gst_rtsp_mount_points_make_path (GstRTSPMountPoints *mounts,
|
||||||
|
const GstRTSPUrl * url);
|
||||||
/* finding a media factory */
|
/* finding a media factory */
|
||||||
GstRTSPMediaFactory * gst_rtsp_mount_points_match (GstRTSPMountPoints *mounts,
|
GstRTSPMediaFactory * gst_rtsp_mount_points_match (GstRTSPMountPoints *mounts,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
|
|
Loading…
Reference in a new issue