summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2013-07-26 08:16:48 +0200
committerSebastian Dröge <slomo@circular-chaos.org>2013-07-26 08:16:48 +0200
commit7b63d2226b71142e3c63f1a5d0cfda37f94f450a (patch)
tree2e6b401d43da45e0580f005f2c550c8a8e272316
parent8445a500e4c5040439a05ca5e171cddd2870bd07 (diff)
parentd423c25a3feeb88f25d5ec52363f990d4fc22c71 (diff)
Merge remote-tracking branch 'origin/master' into 1.01.0
-rw-r--r--examples/test-auth.c38
-rw-r--r--examples/test-cgroups.c31
-rw-r--r--gst/rtsp-server/Makefile.am2
-rw-r--r--gst/rtsp-server/rtsp-address-pool.c19
-rw-r--r--gst/rtsp-server/rtsp-auth.c163
-rw-r--r--gst/rtsp-server/rtsp-auth.h9
-rw-r--r--gst/rtsp-server/rtsp-client.c411
-rw-r--r--gst/rtsp-server/rtsp-client.h77
-rw-r--r--gst/rtsp-server/rtsp-context.c90
-rw-r--r--gst/rtsp-server/rtsp-context.h81
-rw-r--r--gst/rtsp-server/rtsp-params.c16
-rw-r--r--gst/rtsp-server/rtsp-params.h4
-rw-r--r--gst/rtsp-server/rtsp-permissions.c2
-rw-r--r--gst/rtsp-server/rtsp-server.c38
-rw-r--r--gst/rtsp-server/rtsp-thread-pool.c20
-rw-r--r--gst/rtsp-server/rtsp-thread-pool.h6
-rw-r--r--tests/check/gst/client.c32
17 files changed, 601 insertions, 438 deletions
diff --git a/examples/test-auth.c b/examples/test-auth.c
index 27eca57..eff3c74 100644
--- a/examples/test-auth.c
+++ b/examples/test-auth.c
@@ -92,16 +92,16 @@ main (int argc, char *argv[])
/* allow user and admin to access this resource */
gst_rtsp_media_factory_add_role (factory, "user",
- "media.factory.access", G_TYPE_BOOLEAN, TRUE,
- "media.factory.construct", G_TYPE_BOOLEAN, TRUE, NULL);
+ GST_RTSP_PERM_MEDIA_FACTORY_ACCESS, G_TYPE_BOOLEAN, TRUE,
+ GST_RTSP_PERM_MEDIA_FACTORY_CONSTRUCT, G_TYPE_BOOLEAN, TRUE, NULL);
gst_rtsp_media_factory_add_role (factory, "admin",
- "media.factory.access", G_TYPE_BOOLEAN, TRUE,
- "media.factory.construct", G_TYPE_BOOLEAN, TRUE, NULL);
+ GST_RTSP_PERM_MEDIA_FACTORY_ACCESS, G_TYPE_BOOLEAN, TRUE,
+ GST_RTSP_PERM_MEDIA_FACTORY_CONSTRUCT, G_TYPE_BOOLEAN, TRUE, NULL);
/* admin2 can look at the media but not construct so he gets a
* 401 Unauthorized */
gst_rtsp_media_factory_add_role (factory, "admin2",
- "media.factory.access", G_TYPE_BOOLEAN, TRUE,
- "media.factory.construct", G_TYPE_BOOLEAN, FALSE, NULL);
+ GST_RTSP_PERM_MEDIA_FACTORY_ACCESS, G_TYPE_BOOLEAN, TRUE,
+ GST_RTSP_PERM_MEDIA_FACTORY_CONSTRUCT, G_TYPE_BOOLEAN, FALSE, NULL);
/* make another factory */
factory = gst_rtsp_media_factory_new ();
@@ -115,8 +115,8 @@ main (int argc, char *argv[])
/* user and admin have no permissions so they can't even see the
* media and get a 404 Not Found */
gst_rtsp_media_factory_add_role (factory, "admin2",
- "media.factory.access", G_TYPE_BOOLEAN, TRUE,
- "media.factory.construct", G_TYPE_BOOLEAN, TRUE, NULL);
+ GST_RTSP_PERM_MEDIA_FACTORY_ACCESS, G_TYPE_BOOLEAN, TRUE,
+ GST_RTSP_PERM_MEDIA_FACTORY_CONSTRUCT, G_TYPE_BOOLEAN, TRUE, NULL);
/* don't need the ref to the mapper anymore */
g_object_unref (mounts);
@@ -124,25 +124,35 @@ main (int argc, char *argv[])
/* make a new authentication manager */
auth = gst_rtsp_auth_new ();
+ /* make default token, it has the same permissions as admin2 */
+ token =
+ gst_rtsp_token_new (GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE, G_TYPE_STRING,
+ "admin2", NULL);
+ gst_rtsp_auth_set_default_token (auth, token);
+ gst_rtsp_token_unref (token);
+
/* make user token */
- token = gst_rtsp_token_new ("resources.class", G_TYPE_STRING, "user",
- "media.factory.role", G_TYPE_STRING, "user", NULL);
+ token =
+ gst_rtsp_token_new (GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE, G_TYPE_STRING,
+ "user", NULL);
basic = gst_rtsp_auth_make_basic ("user", "password");
gst_rtsp_auth_add_basic (auth, basic, token);
g_free (basic);
gst_rtsp_token_unref (token);
/* make admin token */
- token = gst_rtsp_token_new ("resources.class", G_TYPE_STRING, "admin",
- "media.factory.role", G_TYPE_STRING, "admin", NULL);
+ token =
+ gst_rtsp_token_new (GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE, G_TYPE_STRING,
+ "admin", NULL);
basic = gst_rtsp_auth_make_basic ("admin", "power");
gst_rtsp_auth_add_basic (auth, basic, token);
g_free (basic);
gst_rtsp_token_unref (token);
/* make admin2 token */
- token = gst_rtsp_token_new ("resources.class", G_TYPE_STRING, "admin",
- "media.factory.role", G_TYPE_STRING, "admin2", NULL);
+ token =
+ gst_rtsp_token_new (GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE, G_TYPE_STRING,
+ "admin2", NULL);
basic = gst_rtsp_auth_make_basic ("admin2", "power2");
gst_rtsp_auth_add_basic (auth, basic, token);
g_free (basic);
diff --git a/examples/test-cgroups.c b/examples/test-cgroups.c
index 8188588..0a38916 100644
--- a/examples/test-cgroups.c
+++ b/examples/test-cgroups.c
@@ -17,6 +17,29 @@
* Boston, MA 02110-1301, USA.
*/
+/* Runs a pipeline and clasifies the media pipelines based on the
+ * authenticated user.
+ *
+ * This test requires 2 cpu cgroups to exist named 'user' and 'admin'.
+ * The rtsp server should have permission to add its threads to the
+ * cgroups.
+ *
+ * sudo cgcreate -t uid:gid -g cpu:/user
+ * sudo cgcreate -t uid:gid -g cpu:/admin
+ *
+ * With -t you can give the user and group access to the task file to
+ * write the thread ids. The user running the server can be used.
+ *
+ * Then you would want to change the cpu shares assigned to each group:
+ *
+ * sudo cgset -r cpu.shares=100 user
+ * sudo cgset -r cpu.shares=1024 admin
+ *
+ * Then start clients for 'user' until the stream is degraded because of
+ * lack of CPU. Then start a client for 'admin' and check that the stream
+ * is not degraded.
+ */
+
#include <libcgroup.h>
#include <gst/gst.h>
@@ -54,7 +77,7 @@ static void gst_rtsp_cgroup_pool_finalize (GObject * obj);
static void default_thread_enter (GstRTSPThreadPool * pool,
GstRTSPThread * thread);
static void default_configure_thread (GstRTSPThreadPool * pool,
- GstRTSPThread * thread, GstRTSPClientState * state);
+ GstRTSPThread * thread, GstRTSPContext * ctx);
G_DEFINE_TYPE (GstRTSPCGroupPool, gst_rtsp_cgroup_pool,
GST_TYPE_RTSP_THREAD_POOL);
@@ -118,14 +141,14 @@ default_thread_enter (GstRTSPThreadPool * pool, GstRTSPThread * thread)
static void
default_configure_thread (GstRTSPThreadPool * pool,
- GstRTSPThread * thread, GstRTSPClientState * state)
+ GstRTSPThread * thread, GstRTSPContext * ctx)
{
GstRTSPCGroupPool *cpool = GST_RTSP_CGROUP_POOL (pool);
const gchar *cls;
struct cgroup *cgroup;
- if (state->token)
- cls = gst_rtsp_token_get_string (state->token, "cgroup.pool.media.class");
+ if (ctx->token)
+ cls = gst_rtsp_token_get_string (ctx->token, "cgroup.pool.media.class");
else
cls = NULL;
diff --git a/gst/rtsp-server/Makefile.am b/gst/rtsp-server/Makefile.am
index 725537e..638b2c6 100644
--- a/gst/rtsp-server/Makefile.am
+++ b/gst/rtsp-server/Makefile.am
@@ -1,6 +1,7 @@
public_headers = \
rtsp-auth.h \
rtsp-address-pool.h \
+ rtsp-context.h \
rtsp-params.h \
rtsp-sdp.h \
rtsp-thread-pool.h \
@@ -21,6 +22,7 @@ public_headers = \
c_sources = \
rtsp-auth.c \
rtsp-address-pool.c \
+ rtsp-context.c \
rtsp-params.c \
rtsp-sdp.c \
rtsp-thread-pool.c \
diff --git a/gst/rtsp-server/rtsp-address-pool.c b/gst/rtsp-server/rtsp-address-pool.c
index 2407444..6bb0956 100644
--- a/gst/rtsp-server/rtsp-address-pool.c
+++ b/gst/rtsp-server/rtsp-address-pool.c
@@ -21,7 +21,20 @@
* @short_description: A pool of network addresses
* @see_also: #GstRTSPStream, #GstRTSPStreamTransport
*
- * Last reviewed on 2013-07-11 (1.0.0)
+ * The #GstRTSPAddressPool is an object that maintains a collection of network
+ * addresses. It is used to allocate server ports and server multicast addresses
+ * but also to reserve client provided destination addresses.
+ *
+ * A range of addresses can be added with gst_rtsp_address_pool_add_range().
+ * Both multicast and unicast addresses can be added.
+ *
+ * With gst_rtsp_address_pool_acquire_address() an unused address and port range
+ * can be acquired from the pool. With gst_rtsp_address_pool_reserve_address() a
+ * specific address can be retrieved. Both methods return a boxed
+ * #GstRTSPAddress that should be freed with gst_rtsp_address_free() after
+ * usage, which brings the address back into the pool.
+ *
+ * Last reviewed on 2013-07-16 (1.0.0)
*/
#include <string.h>
@@ -412,8 +425,6 @@ split_range (GstRTSPAddressPool * pool, AddrRange * range, guint skip_addr,
* allocation. @n_ports consecutive ports will be allocated of which the first
* one can be found in @port.
*
- * This function should only be used internally.
- *
* Returns: a #GstRTSPAddress that should be freed with gst_rtsp_address_free
* after use or %NULL when no address could be acquired.
*/
@@ -589,8 +600,6 @@ gst_rtsp_address_pool_dump (GstRTSPAddressPool * pool)
* If @ttl is 0, @address should be a unicast address. If @ttl > 0, @address
* should be a valid multicast address.
*
- * This function should only be used internally.
- *
* Returns: a #GstRTSPAddress that should be freed with gst_rtsp_address_free
* after use or %NULL when no address could be acquired.
*/
diff --git a/gst/rtsp-server/rtsp-auth.c b/gst/rtsp-server/rtsp-auth.c
index da575ee..7264128 100644
--- a/gst/rtsp-server/rtsp-auth.c
+++ b/gst/rtsp-server/rtsp-auth.c
@@ -31,7 +31,7 @@
* The RTSP server will call gst_rtsp_auth_check() with a string describing the
* check to perform. The possible checks are prefixed with
* #GST_RTSP_AUTH_CHECK_*. Depending on the check, the default implementation
- * will use the current #GstRTSPToken, #GstRTSPClientState and
+ * will use the current #GstRTSPToken, #GstRTSPContext and
* #GstRTSPPermissions on the object to check if an operation is allowed.
*
* The default #GstRTSPAuth object has support for basic authentication. With
@@ -60,6 +60,7 @@ struct _GstRTSPAuthPrivate
/* the TLS certificate */
GTlsCertificate *certificate;
GHashTable *basic; /* protected by lock */
+ GstRTSPToken *default_token;
GstRTSPMethod methods;
};
@@ -78,9 +79,8 @@ static void gst_rtsp_auth_set_property (GObject * object, guint propid,
const GValue * value, GParamSpec * pspec);
static void gst_rtsp_auth_finalize (GObject * obj);
-static gboolean default_authenticate (GstRTSPAuth * auth,
- GstRTSPClientState * state);
-static gboolean default_check (GstRTSPAuth * auth, GstRTSPClientState * state,
+static gboolean default_authenticate (GstRTSPAuth * auth, GstRTSPContext * ctx);
+static gboolean default_check (GstRTSPAuth * auth, GstRTSPContext * ctx,
const gchar * check);
G_DEFINE_TYPE (GstRTSPAuth, gst_rtsp_auth, G_TYPE_OBJECT);
@@ -230,6 +230,63 @@ gst_rtsp_auth_get_tls_certificate (GstRTSPAuth * auth)
return result;
}
+/**
+ * gst_rtsp_auth_set_default_token:
+ * @auth: a #GstRTSPAuth
+ * @token: (allow none): a #GstRTSPToken
+ *
+ * Set the default #GstRTSPToken to @token in @auth. The default token will
+ * be used for unauthenticated users.
+ */
+void
+gst_rtsp_auth_set_default_token (GstRTSPAuth * auth, GstRTSPToken * token)
+{
+ GstRTSPAuthPrivate *priv;
+ GstRTSPToken *old;
+
+ g_return_if_fail (GST_IS_RTSP_AUTH (auth));
+
+ priv = auth->priv;
+
+ if (token)
+ gst_rtsp_token_ref (token);
+
+ g_mutex_lock (&priv->lock);
+ old = priv->default_token;
+ priv->default_token = token;
+ g_mutex_unlock (&priv->lock);
+
+ if (old)
+ gst_rtsp_token_unref (old);
+}
+
+/**
+ * gst_rtsp_auth_get_default_token:
+ * @auth: a #GstRTSPAuth
+ *
+ * Get the default token for @auth. This token will be used for unauthorized
+ * users.
+ *
+ * Returns: (transfer full): the #GstRTSPToken of @auth. gst_rtsp_token_unref() after
+ * usage.
+ */
+GstRTSPToken *
+gst_rtsp_auth_get_default_token (GstRTSPAuth * auth)
+{
+ GstRTSPAuthPrivate *priv;
+ GstRTSPToken *result;
+
+ g_return_val_if_fail (GST_IS_RTSP_AUTH (auth), NULL);
+
+ priv = auth->priv;
+
+ g_mutex_lock (&priv->lock);
+ if ((result = priv->default_token))
+ gst_rtsp_token_ref (result);
+ g_mutex_unlock (&priv->lock);
+
+ return result;
+}
/**
* gst_rtsp_auth_add_basic:
@@ -282,7 +339,7 @@ gst_rtsp_auth_remove_basic (GstRTSPAuth * auth, const gchar * basic)
}
static gboolean
-default_authenticate (GstRTSPAuth * auth, GstRTSPClientState * state)
+default_authenticate (GstRTSPAuth * auth, GstRTSPContext * ctx)
{
GstRTSPAuthPrivate *priv = auth->priv;
GstRTSPResult res;
@@ -290,8 +347,14 @@ default_authenticate (GstRTSPAuth * auth, GstRTSPClientState * state)
GST_DEBUG_OBJECT (auth, "authenticate");
+ g_mutex_lock (&priv->lock);
+ /* FIXME, need to ref but we have no way to unref when the ctx is
+ * popped */
+ ctx->token = priv->default_token;
+ g_mutex_unlock (&priv->lock);
+
res =
- gst_rtsp_message_get_header (state->request, GST_RTSP_HDR_AUTHORIZATION,
+ gst_rtsp_message_get_header (ctx->request, GST_RTSP_HDR_AUTHORIZATION,
&authorization, 0);
if (res < 0)
goto no_auth;
@@ -304,7 +367,7 @@ default_authenticate (GstRTSPAuth * auth, GstRTSPClientState * state)
g_mutex_lock (&priv->lock);
if ((token = g_hash_table_lookup (priv->basic, &authorization[6]))) {
GST_DEBUG_OBJECT (auth, "setting token %p", token);
- state->token = token;
+ ctx->token = token;
}
g_mutex_unlock (&priv->lock);
} else if (g_ascii_strncasecmp (authorization, "digest ", 7) == 0) {
@@ -321,35 +384,34 @@ no_auth:
}
static void
-send_response (GstRTSPAuth * auth, GstRTSPStatusCode code,
- GstRTSPClientState * state)
+send_response (GstRTSPAuth * auth, GstRTSPStatusCode code, GstRTSPContext * ctx)
{
- gst_rtsp_message_init_response (state->response, code,
- gst_rtsp_status_as_text (code), state->request);
+ gst_rtsp_message_init_response (ctx->response, code,
+ gst_rtsp_status_as_text (code), ctx->request);
if (code == GST_RTSP_STS_UNAUTHORIZED) {
/* we only have Basic for now */
- gst_rtsp_message_add_header (state->response, GST_RTSP_HDR_WWW_AUTHENTICATE,
+ gst_rtsp_message_add_header (ctx->response, GST_RTSP_HDR_WWW_AUTHENTICATE,
"Basic realm=\"GStreamer RTSP Server\"");
}
- gst_rtsp_client_send_message (state->client, state->session, state->response);
+ gst_rtsp_client_send_message (ctx->client, ctx->session, ctx->response);
}
static gboolean
-ensure_authenticated (GstRTSPAuth * auth, GstRTSPClientState * state)
+ensure_authenticated (GstRTSPAuth * auth, GstRTSPContext * ctx)
{
GstRTSPAuthClass *klass;
klass = GST_RTSP_AUTH_GET_CLASS (auth);
/* we need a token to check */
- if (state->token == NULL) {
+ if (ctx->token == NULL) {
if (klass->authenticate) {
- if (!klass->authenticate (auth, state))
+ if (!klass->authenticate (auth, ctx))
goto authenticate_failed;
}
}
- if (state->token == NULL)
+ if (ctx->token == NULL)
goto no_auth;
return TRUE;
@@ -358,21 +420,20 @@ ensure_authenticated (GstRTSPAuth * auth, GstRTSPClientState * state)
authenticate_failed:
{
GST_DEBUG_OBJECT (auth, "authenticate failed");
- send_response (auth, GST_RTSP_STS_UNAUTHORIZED, state);
+ send_response (auth, GST_RTSP_STS_UNAUTHORIZED, ctx);
return FALSE;
}
no_auth:
{
GST_DEBUG_OBJECT (auth, "no authorization token found");
- send_response (auth, GST_RTSP_STS_UNAUTHORIZED, state);
+ send_response (auth, GST_RTSP_STS_UNAUTHORIZED, ctx);
return FALSE;
}
}
/* new connection */
static gboolean
-check_connect (GstRTSPAuth * auth, GstRTSPClientState * state,
- const gchar * check)
+check_connect (GstRTSPAuth * auth, GstRTSPContext * ctx, const gchar * check)
{
GstRTSPAuthPrivate *priv = auth->priv;
@@ -380,7 +441,7 @@ check_connect (GstRTSPAuth * auth, GstRTSPClientState * state,
GTlsConnection *tls;
/* configure the connection */
- tls = gst_rtsp_connection_get_tls (state->conn, NULL);
+ tls = gst_rtsp_connection_get_tls (ctx->conn, NULL);
g_tls_connection_set_certificate (tls, priv->certificate);
}
return TRUE;
@@ -388,12 +449,12 @@ check_connect (GstRTSPAuth * auth, GstRTSPClientState * state,
/* check url and methods */
static gboolean
-check_url (GstRTSPAuth * auth, GstRTSPClientState * state, const gchar * check)
+check_url (GstRTSPAuth * auth, GstRTSPContext * ctx, const gchar * check)
{
GstRTSPAuthPrivate *priv = auth->priv;
- if ((state->method & priv->methods) != 0)
- if (!ensure_authenticated (auth, state))
+ if ((ctx->method & priv->methods) != 0)
+ if (!ensure_authenticated (auth, ctx))
goto not_authenticated;
return TRUE;
@@ -407,26 +468,25 @@ not_authenticated:
/* check access to media factory */
static gboolean
-check_factory (GstRTSPAuth * auth, GstRTSPClientState * state,
- const gchar * check)
+check_factory (GstRTSPAuth * auth, GstRTSPContext * ctx, const gchar * check)
{
const gchar *role;
GstRTSPPermissions *perms;
- if (!ensure_authenticated (auth, state))
+ if (!ensure_authenticated (auth, ctx))
return FALSE;
- if (!(role = gst_rtsp_token_get_string (state->token,
+ if (!(role = gst_rtsp_token_get_string (ctx->token,
GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE)))
goto no_media_role;
- if (!(perms = gst_rtsp_media_factory_get_permissions (state->factory)))
+ if (!(perms = gst_rtsp_media_factory_get_permissions (ctx->factory)))
goto no_permissions;
- if (g_str_equal (check, "auth.check.media.factory.access")) {
+ if (g_str_equal (check, GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_ACCESS)) {
if (!gst_rtsp_permissions_is_allowed (perms, role,
GST_RTSP_PERM_MEDIA_FACTORY_ACCESS))
goto no_access;
- } else if (g_str_equal (check, "auth.check.media.factory.construct")) {
+ } else if (g_str_equal (check, GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_CONSTRUCT)) {
if (!gst_rtsp_permissions_is_allowed (perms, role,
GST_RTSP_PERM_MEDIA_FACTORY_CONSTRUCT))
goto no_construct;
@@ -437,55 +497,54 @@ check_factory (GstRTSPAuth * auth, GstRTSPClientState * state,
no_media_role:
{
GST_DEBUG_OBJECT (auth, "no media factory role found");
- send_response (auth, GST_RTSP_STS_UNAUTHORIZED, state);
+ send_response (auth, GST_RTSP_STS_UNAUTHORIZED, ctx);
return FALSE;
}
no_permissions:
{
GST_DEBUG_OBJECT (auth, "no permissions on media factory found");
- send_response (auth, GST_RTSP_STS_UNAUTHORIZED, state);
+ send_response (auth, GST_RTSP_STS_UNAUTHORIZED, ctx);
return FALSE;
}
no_access:
{
GST_DEBUG_OBJECT (auth, "no permissions to access media factory");
- send_response (auth, GST_RTSP_STS_NOT_FOUND, state);
+ send_response (auth, GST_RTSP_STS_NOT_FOUND, ctx);
return FALSE;
}
no_construct:
{
GST_DEBUG_OBJECT (auth, "no permissions to construct media factory");
- send_response (auth, GST_RTSP_STS_UNAUTHORIZED, state);
+ send_response (auth, GST_RTSP_STS_UNAUTHORIZED, ctx);
return FALSE;
}
}
static gboolean
-check_client_settings (GstRTSPAuth * auth, GstRTSPClientState * state,
+check_client_settings (GstRTSPAuth * auth, GstRTSPContext * ctx,
const gchar * check)
{
- if (!ensure_authenticated (auth, state))
+ if (!ensure_authenticated (auth, ctx))
return FALSE;
- return gst_rtsp_token_is_allowed (state->token,
+ return gst_rtsp_token_is_allowed (ctx->token,
GST_RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS);
}
static gboolean
-default_check (GstRTSPAuth * auth, GstRTSPClientState * state,
- const gchar * check)
+default_check (GstRTSPAuth * auth, GstRTSPContext * ctx, const gchar * check)
{
gboolean res = FALSE;
/* FIXME, use hastable or so */
if (g_str_equal (check, GST_RTSP_AUTH_CHECK_CONNECT)) {
- res = check_connect (auth, state, check);
+ res = check_connect (auth, ctx, check);
} else if (g_str_equal (check, GST_RTSP_AUTH_CHECK_URL)) {
- res = check_url (auth, state, check);
+ res = check_url (auth, ctx, check);
} else if (g_str_has_prefix (check, "auth.check.media.factory.")) {
- res = check_factory (auth, state, check);
+ res = check_factory (auth, ctx, check);
} else if (g_str_equal (check, GST_RTSP_AUTH_CHECK_TRANSPORT_CLIENT_SETTINGS)) {
- res = check_client_settings (auth, state, check);
+ res = check_client_settings (auth, ctx, check);
}
return res;
}
@@ -516,16 +575,16 @@ gst_rtsp_auth_check (const gchar * check)
{
gboolean result = FALSE;
GstRTSPAuthClass *klass;
- GstRTSPClientState *state;
+ GstRTSPContext *ctx;
GstRTSPAuth *auth;
g_return_val_if_fail (check != NULL, FALSE);
- if (!(state = gst_rtsp_client_state_get_current ()))
- goto no_state;
+ if (!(ctx = gst_rtsp_context_get_current ()))
+ goto no_context;
/* no auth, we don't need to check */
- if (!(auth = state->auth))
+ if (!(auth = ctx->auth))
return no_auth_check (check);
klass = GST_RTSP_AUTH_GET_CLASS (auth);
@@ -533,14 +592,14 @@ gst_rtsp_auth_check (const gchar * check)
GST_DEBUG_OBJECT (auth, "check authorization '%s'", check);
if (klass->check)
- result = klass->check (auth, state, check);
+ result = klass->check (auth, ctx, check);
return result;
/* ERRORS */
-no_state:
+no_context:
{
- GST_ERROR ("no clientstate found");
+ GST_ERROR ("no context found");
return FALSE;
}
}
diff --git a/gst/rtsp-server/rtsp-auth.h b/gst/rtsp-server/rtsp-auth.h
index 54c268f..c2dd971 100644
--- a/gst/rtsp-server/rtsp-auth.h
+++ b/gst/rtsp-server/rtsp-auth.h
@@ -56,7 +56,7 @@ struct _GstRTSPAuth {
* @authenticate: check the authentication of a client. The default implementation
* checks if the authentication in the header matches one of the basic
* authentication tokens. This function should set the authgroup field
- * in the state.
+ * in the context.
* @check: check if a resource can be accessed. this function should
* call authenticate to authenticate the client when needed. The method
* should also construct and send an appropriate response message on
@@ -67,8 +67,8 @@ struct _GstRTSPAuth {
struct _GstRTSPAuthClass {
GObjectClass parent_class;
- gboolean (*authenticate) (GstRTSPAuth *auth, GstRTSPClientState *state);
- gboolean (*check) (GstRTSPAuth *auth, GstRTSPClientState *state,
+ gboolean (*authenticate) (GstRTSPAuth *auth, GstRTSPContext *ctx);
+ gboolean (*check) (GstRTSPAuth *auth, GstRTSPContext *ctx,
const gchar *check);
};
@@ -79,6 +79,9 @@ GstRTSPAuth * gst_rtsp_auth_new (void);
void gst_rtsp_auth_set_tls_certificate (GstRTSPAuth *auth, GTlsCertificate *cert);
GTlsCertificate * gst_rtsp_auth_get_tls_certificate (GstRTSPAuth *auth);
+void gst_rtsp_auth_set_default_token (GstRTSPAuth *auth, GstRTSPToken *token);
+GstRTSPToken * gst_rtsp_auth_get_default_token (GstRTSPAuth *auth);
+
void gst_rtsp_auth_add_basic (GstRTSPAuth *auth, const gchar * basic,
GstRTSPToken *token);
void gst_rtsp_auth_remove_basic (GstRTSPAuth *auth, const gchar * basic);
diff --git a/gst/rtsp-server/rtsp-client.c b/gst/rtsp-server/rtsp-client.c
index e67386a..dcaffaa 100644
--- a/gst/rtsp-server/rtsp-client.c
+++ b/gst/rtsp-server/rtsp-client.c
@@ -127,11 +127,11 @@ static void client_session_finalized (GstRTSPClient * client,
static void unlink_session_transports (GstRTSPClient * client,
GstRTSPSession * session, GstRTSPSessionMedia * sessmedia);
static gboolean default_configure_client_transport (GstRTSPClient * client,
- GstRTSPClientState * state, GstRTSPTransport * ct);
+ GstRTSPContext * ctx, GstRTSPTransport * ct);
static GstRTSPResult default_params_set (GstRTSPClient * client,
- GstRTSPClientState * state);
+ GstRTSPContext * ctx);
static GstRTSPResult default_params_get (GstRTSPClient * client,
- GstRTSPClientState * state);
+ GstRTSPContext * ctx);
G_DEFINE_TYPE (GstRTSPClient, gst_rtsp_client, G_TYPE_OBJECT);
@@ -444,12 +444,12 @@ send_message (GstRTSPClient * client, GstRTSPSession * session,
static void
send_generic_response (GstRTSPClient * client, GstRTSPStatusCode code,
- GstRTSPClientState * state)
+ GstRTSPContext * ctx)
{
- gst_rtsp_message_init_response (state->response, code,
- gst_rtsp_status_as_text (code), state->request);
+ gst_rtsp_message_init_response (ctx->response, code,
+ gst_rtsp_status_as_text (code), ctx->request);
- send_message (client, NULL, state->response, FALSE);
+ send_message (client, NULL, ctx->response, FALSE);
}
static gboolean
@@ -471,7 +471,7 @@ paths_are_equal (const gchar * path1, const gchar * path2, gint len2)
* but is cached for when the same client (without breaking the connection) is
* doing a setup for the exact same url. */
static GstRTSPMedia *
-find_media (GstRTSPClient * client, GstRTSPClientState * state, gint * matched)
+find_media (GstRTSPClient * client, GstRTSPContext * ctx, gint * matched)
{
GstRTSPClientPrivate *priv = client->priv;
GstRTSPMediaFactory *factory;
@@ -482,14 +482,14 @@ find_media (GstRTSPClient * client, GstRTSPClientState * state, gint * matched)
if (!priv->mount_points)
goto no_mount_points;
- path = state->uri->abspath;
+ path = ctx->uri->abspath;
/* find the longest matching factory for the uri first */
if (!(factory = gst_rtsp_mount_points_match (priv->mount_points,
path, matched)))
goto no_factory;
- state->factory = factory;
+ ctx->factory = factory;
if (!gst_rtsp_auth_check (GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_ACCESS))
goto no_factory_access;
@@ -517,13 +517,13 @@ find_media (GstRTSPClient * client, GstRTSPClientState * state, gint * matched)
priv->media = NULL;
/* prepare the media and add it to the pipeline */
- if (!(media = gst_rtsp_media_factory_construct (factory, state->uri)))
+ if (!(media = gst_rtsp_media_factory_construct (factory, ctx->uri)))
goto no_media;
- state->media = media;
+ ctx->media = media;
thread = gst_rtsp_thread_pool_get_thread (priv->thread_pool,
- GST_RTSP_THREAD_TYPE_MEDIA, state);
+ GST_RTSP_THREAD_TYPE_MEDIA, ctx);
if (thread == NULL)
goto no_thread;
@@ -537,12 +537,12 @@ find_media (GstRTSPClient * client, GstRTSPClientState * state, gint * matched)
} else {
/* we have seen this path before, used cached media */
media = priv->media;
- state->media = media;
+ ctx->media = media;
GST_INFO ("reusing cached media %p for path %s", media, priv->path);
}
g_object_unref (factory);
- state->factory = NULL;
+ ctx->factory = NULL;
if (media)
g_object_ref (media);
@@ -553,13 +553,13 @@ find_media (GstRTSPClient * client, GstRTSPClientState * state, gint * matched)
no_mount_points:
{
GST_ERROR ("client %p: no mount points configured", client);
- send_generic_response (client, GST_RTSP_STS_NOT_FOUND, state);
+ send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
return NULL;
}
no_factory:
{
GST_ERROR ("client %p: no factory for uri %s", client, path);
- send_generic_response (client, GST_RTSP_STS_NOT_FOUND, state);
+ send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
return NULL;
}
no_factory_access:
@@ -575,29 +575,29 @@ not_authorized:
no_media:
{
GST_ERROR ("client %p: can't create media", client);
- send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, state);
+ send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, ctx);
g_object_unref (factory);
- state->factory = NULL;
+ ctx->factory = NULL;
return NULL;
}
no_thread:
{
GST_ERROR ("client %p: can't create thread", client);
- send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, state);
+ send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, ctx);
g_object_unref (media);
- state->media = NULL;
+ ctx->media = NULL;
g_object_unref (factory);
- state->factory = NULL;
+ ctx->factory = NULL;
return NULL;
}
no_prepare:
{
GST_ERROR ("client %p: can't prepare media", client);
- send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, state);
+ send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, ctx);
g_object_unref (media);
- state->media = NULL;
+ ctx->media = NULL;
g_object_unref (factory);
- state->factory = NULL;
+ ctx->factory = NULL;
return NULL;
}
}
@@ -711,7 +711,7 @@ close_connection (GstRTSPClient * client)
}
static gboolean
-handle_teardown_request (GstRTSPClient * client, GstRTSPClientState * state)
+handle_teardown_request (GstRTSPClient * client, GstRTSPContext * ctx)
{
GstRTSPClientPrivate *priv = client->priv;
GstRTSPSession *session;
@@ -720,15 +720,15 @@ handle_teardown_request (GstRTSPClient * client, GstRTSPClientState * state)
const gchar *path;
gint matched;
- if (!state->session)
+ if (!ctx->session)
goto no_session;
- session = state->session;
+ session = ctx->session;
- if (!state->uri)
+ if (!ctx->uri)
goto no_uri;
- path = state->uri->abspath;
+ path = ctx->uri->abspath;
/* get a handle to the configuration of the media in the session */
sessmedia = gst_rtsp_session_get_media (session, path, &matched);
@@ -739,11 +739,11 @@ handle_teardown_request (GstRTSPClient * client, GstRTSPClientState * state)
if (path[matched] != '\0')
goto no_aggregate;
- state->sessmedia = sessmedia;
+ ctx->sessmedia = sessmedia;
/* we emit the signal before closing the connection */
g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_TEARDOWN_REQUEST],
- 0, state);
+ 0, ctx);
/* unlink the all TCP callbacks */
unlink_session_transports (client, session, sessmedia);
@@ -761,10 +761,10 @@ handle_teardown_request (GstRTSPClient * client, GstRTSPClientState * state)
}
/* construct the response now */
code = GST_RTSP_STS_OK;
- gst_rtsp_message_init_response (state->response, code,
- gst_rtsp_status_as_text (code), state->request);
+ gst_rtsp_message_init_response (ctx->response, code,
+ gst_rtsp_status_as_text (code), ctx->request);
- send_message (client, session, state->response, TRUE);
+ send_message (client, session, ctx->response, TRUE);
return TRUE;
@@ -772,75 +772,75 @@ handle_teardown_request (GstRTSPClient * client, GstRTSPClientState * state)
no_session:
{
GST_ERROR ("client %p: no session", client);
- send_generic_response (client, GST_RTSP_STS_SESSION_NOT_FOUND, state);
+ send_generic_response (client, GST_RTSP_STS_SESSION_NOT_FOUND, ctx);
return FALSE;
}
no_uri:
{
GST_ERROR ("client %p: no uri supplied", client);
- send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, state);
+ send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, ctx);
return FALSE;
}
not_found:
{
GST_ERROR ("client %p: no media for uri", client);
- send_generic_response (client, GST_RTSP_STS_NOT_FOUND, state);
+ send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
return FALSE;
}
no_aggregate:
{
GST_ERROR ("client %p: no aggregate path %s", client, path);
send_generic_response (client,
- GST_RTSP_STS_ONLY_AGGREGATE_OPERATION_ALLOWED, state);
+ GST_RTSP_STS_ONLY_AGGREGATE_OPERATION_ALLOWED, ctx);
return FALSE;
}
}
static GstRTSPResult
-default_params_set (GstRTSPClient * client, GstRTSPClientState * state)
+default_params_set (GstRTSPClient * client, GstRTSPContext * ctx)
{
GstRTSPResult res;
- res = gst_rtsp_params_set (client, state);
+ res = gst_rtsp_params_set (client, ctx);
return res;
}
static GstRTSPResult
-default_params_get (GstRTSPClient * client, GstRTSPClientState * state)
+default_params_get (GstRTSPClient * client, GstRTSPContext * ctx)
{
GstRTSPResult res;
- res = gst_rtsp_params_get (client, state);
+ res = gst_rtsp_params_get (client, ctx);
return res;
}
static gboolean
-handle_get_param_request (GstRTSPClient * client, GstRTSPClientState * state)
+handle_get_param_request (GstRTSPClient * client, GstRTSPContext * ctx)
{
GstRTSPResult res;
guint8 *data;
guint size;
- res = gst_rtsp_message_get_body (state->request, &data, &size);
+ res = gst_rtsp_message_get_body (ctx->request, &data, &size);
if (res != GST_RTSP_OK)
goto bad_request;
if (size == 0) {
/* no body, keep-alive request */
- send_generic_response (client, GST_RTSP_STS_OK, state);
+ send_generic_response (client, GST_RTSP_STS_OK, ctx);
} else {
/* there is a body, handle the params */
- res = GST_RTSP_CLIENT_GET_CLASS (client)->params_get (client, state);
+ res = GST_RTSP_CLIENT_GET_CLASS (client)->params_get (client, ctx);
if (res != GST_RTSP_OK)
goto bad_request;
- send_message (client, state->session, state->response, FALSE);
+ send_message (client, ctx->session, ctx->response, FALSE);
}
g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_GET_PARAMETER_REQUEST],
- 0, state);
+ 0, ctx);
return TRUE;
@@ -848,36 +848,36 @@ handle_get_param_request (GstRTSPClient * client, GstRTSPClientState * state)
bad_request:
{
GST_ERROR ("client %p: bad request", client);
- send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, state);
+ send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, ctx);
return FALSE;
}
}
static gboolean
-handle_set_param_request (GstRTSPClient * client, GstRTSPClientState * state)
+handle_set_param_request (GstRTSPClient * client, GstRTSPContext * ctx)
{
GstRTSPResult res;
guint8 *data;
guint size;
- res = gst_rtsp_message_get_body (state->request, &data, &size);
+ res = gst_rtsp_message_get_body (ctx->request, &data, &size);
if (res != GST_RTSP_OK)
goto bad_request;
if (size == 0) {
/* no body, keep-alive request */
- send_generic_response (client, GST_RTSP_STS_OK, state);
+ send_generic_response (client, GST_RTSP_STS_OK, ctx);
} else {
/* there is a body, handle the params */
- res = GST_RTSP_CLIENT_GET_CLASS (client)->params_set (client, state);
+ res = GST_RTSP_CLIENT_GET_CLASS (client)->params_set (client, ctx);
if (res != GST_RTSP_OK)
goto bad_request;
- send_message (client, state->session, state->response, FALSE);
+ send_message (client, ctx->session, ctx->response, FALSE);
}
g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_SET_PARAMETER_REQUEST],
- 0, state);
+ 0, ctx);
return TRUE;
@@ -885,13 +885,13 @@ handle_set_param_request (GstRTSPClient * client, GstRTSPClientState * state)
bad_request:
{
GST_ERROR ("client %p: bad request", client);
- send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, state);
+ send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, ctx);
return FALSE;
}
}
static gboolean
-handle_pause_request (GstRTSPClient * client, GstRTSPClientState * state)
+handle_pause_request (GstRTSPClient * client, GstRTSPContext * ctx)
{
GstRTSPSession *session;
GstRTSPSessionMedia *sessmedia;
@@ -900,13 +900,13 @@ handle_pause_request (GstRTSPClient * client, GstRTSPClientState * state)
const gchar *path;
gint matched;
- if (!(session = state->session))
+ if (!(session = ctx->session))
goto no_session;
- if (!state->uri)
+ if (!ctx->uri)
goto no_uri;
- path = state->uri->abspath;
+ path = ctx->uri->abspath;
/* get a handle to the configuration of the media in the session */
sessmedia = gst_rtsp_session_get_media (session, path, &matched);
@@ -916,7 +916,7 @@ handle_pause_request (GstRTSPClient * client, GstRTSPClientState * state)
if (path[matched] != '\0')
goto no_aggregate;
- state->sessmedia = sessmedia;
+ ctx->sessmedia = sessmedia;
rtspstate = gst_rtsp_session_media_get_rtsp_state (sessmedia);
/* the session state must be playing or recording */
@@ -932,16 +932,15 @@ handle_pause_request (GstRTSPClient * client, GstRTSPClientState * state)
/* construct the response now */
code = GST_RTSP_STS_OK;
- gst_rtsp_message_init_response (state->response, code,
- gst_rtsp_status_as_text (code), state->request);
+ gst_rtsp_message_init_response (ctx->response, code,
+ gst_rtsp_status_as_text (code), ctx->request);
- send_message (client, session, state->response, FALSE);
+ send_message (client, session, ctx->response, FALSE);
/* the state is now READY */
gst_rtsp_session_media_set_rtsp_state (sessmedia, GST_RTSP_STATE_READY);
- g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_PAUSE_REQUEST],
- 0, state);
+ g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_PAUSE_REQUEST], 0, ctx);
return TRUE;
@@ -949,39 +948,39 @@ handle_pause_request (GstRTSPClient * client, GstRTSPClientState * state)
no_session:
{
GST_ERROR ("client %p: no seesion", client);
- send_generic_response (client, GST_RTSP_STS_SESSION_NOT_FOUND, state);
+ send_generic_response (client, GST_RTSP_STS_SESSION_NOT_FOUND, ctx);
return FALSE;
}
no_uri:
{
GST_ERROR ("client %p: no uri supplied", client);
- send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, state);
+ send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, ctx);
return FALSE;
}
not_found:
{
GST_ERROR ("client %p: no media for uri", client);
- send_generic_response (client, GST_RTSP_STS_NOT_FOUND, state);
+ send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
return FALSE;
}
no_aggregate:
{
GST_ERROR ("client %p: no aggregate path %s", client, path);
send_generic_response (client,
- GST_RTSP_STS_ONLY_AGGREGATE_OPERATION_ALLOWED, state);
+ GST_RTSP_STS_ONLY_AGGREGATE_OPERATION_ALLOWED, ctx);
return FALSE;
}
invalid_state:
{
GST_ERROR ("client %p: not PLAYING or RECORDING", client);
send_generic_response (client, GST_RTSP_STS_METHOD_NOT_VALID_IN_THIS_STATE,
- state);
+ ctx);
return FALSE;
}
}
static gboolean
-handle_play_request (GstRTSPClient * client, GstRTSPClientState * state)
+handle_play_request (GstRTSPClient * client, GstRTSPContext * ctx)
{
GstRTSPSession *session;
GstRTSPSessionMedia *sessmedia;
@@ -997,13 +996,13 @@ handle_play_request (GstRTSPClient * client, GstRTSPClientState * state)
const gchar *path;
gint matched;
- if (!(session = state->session))
+ if (!(session = ctx->session))
goto no_session;
- if (!state->uri)
+ if (!ctx->uri)
goto no_uri;
- path = state->uri->abspath;
+ path = ctx->uri->abspath;
/* get a handle to the configuration of the media in the session */
sessmedia = gst_rtsp_session_get_media (session, path, &matched);
@@ -1013,8 +1012,8 @@ handle_play_request (GstRTSPClient * client, GstRTSPClientState * state)
if (path[matched] != '\0')
goto no_aggregate;
- state->sessmedia = sessmedia;
- state->media = media = gst_rtsp_session_media_get_media (sessmedia);
+ ctx->sessmedia = sessmedia;
+ ctx->media = media = gst_rtsp_session_media_get_media (sessmedia);
/* the session state must be playing or ready */
rtspstate = gst_rtsp_session_media_get_rtsp_state (sessmedia);
@@ -1022,8 +1021,7 @@ handle_play_request (GstRTSPClient * client, GstRTSPClientState * state)
goto invalid_state;
/* parse the range header if we have one */
- res =
- gst_rtsp_message_get_header (state->request, GST_RTSP_HDR_RANGE, &str, 0);
+ res = gst_rtsp_message_get_header (ctx->request, GST_RTSP_HDR_RANGE, &str, 0);
if (res == GST_RTSP_OK) {
if (gst_rtsp_range_parse (str, &range) == GST_RTSP_OK) {
/* we have a range, seek to the position */
@@ -1062,7 +1060,7 @@ handle_play_request (GstRTSPClient * client, GstRTSPClientState * state)
if (infocount > 0)
g_string_append (rtpinfo, ", ");
- uristr = gst_rtsp_url_get_request_uri (state->uri);
+ uristr = gst_rtsp_url_get_request_uri (ctx->uri);
g_string_append_printf (rtpinfo, "url=%s/stream=%d;seq=%u;rtptime=%u",
uristr, i, seq, rtptime);
g_free (uristr);
@@ -1075,30 +1073,29 @@ handle_play_request (GstRTSPClient * client, GstRTSPClientState * state)
/* construct the response now */
code = GST_RTSP_STS_OK;
- gst_rtsp_message_init_response (state->response, code,
- gst_rtsp_status_as_text (code), state->request);
+ gst_rtsp_message_init_response (ctx->response, code,
+ gst_rtsp_status_as_text (code), ctx->request);
/* add the RTP-Info header */
if (infocount > 0) {
str = g_string_free (rtpinfo, FALSE);
- gst_rtsp_message_take_header (state->response, GST_RTSP_HDR_RTP_INFO, str);
+ gst_rtsp_message_take_header (ctx->response, GST_RTSP_HDR_RTP_INFO, str);
} else {
g_string_free (rtpinfo, TRUE);
}
/* add the range */
str = gst_rtsp_media_get_range_string (media, TRUE, unit);
- gst_rtsp_message_take_header (state->response, GST_RTSP_HDR_RANGE, str);
+ gst_rtsp_message_take_header (ctx->response, GST_RTSP_HDR_RANGE, str);
- send_message (client, session, state->response, FALSE);
+ send_message (client, session, ctx->response, FALSE);
/* start playing after sending the request */
gst_rtsp_session_media_set_state (sessmedia, GST_STATE_PLAYING);
gst_rtsp_session_media_set_rtsp_state (sessmedia, GST_RTSP_STATE_PLAYING);
- g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_PLAY_REQUEST],
- 0, state);
+ g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_PLAY_REQUEST], 0, ctx);
return TRUE;
@@ -1106,33 +1103,33 @@ handle_play_request (GstRTSPClient * client, GstRTSPClientState * state)
no_session:
{
GST_ERROR ("client %p: no session", client);
- send_generic_response (client, GST_RTSP_STS_SESSION_NOT_FOUND, state);
+ send_generic_response (client, GST_RTSP_STS_SESSION_NOT_FOUND, ctx);
return FALSE;
}
no_uri:
{
GST_ERROR ("client %p: no uri supplied", client);
- send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, state);
+ send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, ctx);
return FALSE;
}
not_found:
{
GST_ERROR ("client %p: media not found", client);
- send_generic_response (client, GST_RTSP_STS_NOT_FOUND, state);
+ send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
return FALSE;
}
no_aggregate:
{
GST_ERROR ("client %p: no aggregate path %s", client, path);
send_generic_response (client,
- GST_RTSP_STS_ONLY_AGGREGATE_OPERATION_ALLOWED, state);
+ GST_RTSP_STS_ONLY_AGGREGATE_OPERATION_ALLOWED, ctx);
return FALSE;
}
invalid_state:
{
GST_ERROR ("client %p: not PLAYING or READY", client);
send_generic_response (client, GST_RTSP_STS_METHOD_NOT_VALID_IN_THIS_STATE,
- state);
+ ctx);
return FALSE;
}
}
@@ -1227,7 +1224,7 @@ handle_blocksize (GstRTSPMedia * media, GstRTSPStream * stream,
static gboolean
default_configure_client_transport (GstRTSPClient * client,
- GstRTSPClientState * state, GstRTSPTransport * ct)
+ GstRTSPContext * ctx, GstRTSPTransport * ct)
{
GstRTSPClientPrivate *priv = client->priv;
@@ -1241,7 +1238,7 @@ default_configure_client_transport (GstRTSPClient * client,
if (ct->destination && use_client_settings) {
GstRTSPAddress *addr;
- addr = gst_rtsp_stream_reserve_address (state->stream, ct->destination,
+ addr = gst_rtsp_stream_reserve_address (ctx->stream, ct->destination,
ct->port.min, ct->port.max - ct->port.min + 1, ct->ttl);
if (addr == NULL)
@@ -1254,7 +1251,7 @@ default_configure_client_transport (GstRTSPClient * client,
family = priv->is_ipv6 ? G_SOCKET_FAMILY_IPV6 : G_SOCKET_FAMILY_IPV4;
- addr = gst_rtsp_stream_get_multicast_address (state->stream, family);
+ addr = gst_rtsp_stream_get_multicast_address (ctx->stream, family);
if (addr == NULL)
goto no_address;
@@ -1276,7 +1273,7 @@ default_configure_client_transport (GstRTSPClient * client,
if (ct->lower_transport & GST_RTSP_LOWER_TRANS_TCP) {
/* check if the client selected channels for TCP */
if (ct->interleaved.min == -1 || ct->interleaved.max == -1) {
- gst_rtsp_session_media_alloc_channels (state->sessmedia,
+ gst_rtsp_session_media_alloc_channels (ctx->sessmedia,
&ct->interleaved);
}
}
@@ -1292,7 +1289,7 @@ no_address:
}
static GstRTSPTransport *
-make_server_transport (GstRTSPClient * client, GstRTSPClientState * state,
+make_server_transport (GstRTSPClient * client, GstRTSPContext * ctx,
GstRTSPTransport * ct)
{
GstRTSPTransport *st;
@@ -1320,7 +1317,7 @@ make_server_transport (GstRTSPClient * client, GstRTSPClientState * state,
switch (st->lower_transport) {
case GST_RTSP_LOWER_TRANS_UDP:
st->client_port = ct->client_port;
- gst_rtsp_stream_get_server_port (state->stream, &st->server_port, family);
+ gst_rtsp_stream_get_server_port (ctx->stream, &st->server_port, family);
break;
case GST_RTSP_LOWER_TRANS_UDP_MCAST:
st->port = ct->port;
@@ -1333,13 +1330,13 @@ make_server_transport (GstRTSPClient * client, GstRTSPClientState * state,
break;
}
- gst_rtsp_stream_get_ssrc (state->stream, &st->ssrc);
+ gst_rtsp_stream_get_ssrc (ctx->stream, &st->ssrc);
return st;
}
static gboolean
-handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
+handle_setup_request (GstRTSPClient * client, GstRTSPContext * ctx)
{
GstRTSPClientPrivate *priv = client->priv;
GstRTSPResult res;
@@ -1359,15 +1356,15 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
gchar *path, *control;
gint matched;
- if (!state->uri)
+ if (!ctx->uri)
goto no_uri;
- uri = state->uri;
+ uri = ctx->uri;
path = uri->abspath;
/* parse the transport */
res =
- gst_rtsp_message_get_header (state->request, GST_RTSP_HDR_TRANSPORT,
+ gst_rtsp_message_get_header (ctx->request, GST_RTSP_HDR_TRANSPORT,
&transport, 0);
if (res != GST_RTSP_OK)
goto no_transport;
@@ -1377,7 +1374,7 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
if (priv->session_pool == NULL)
goto no_pool;
- session = state->session;
+ session = ctx->session;
if (session) {
g_object_ref (session);
@@ -1392,7 +1389,7 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
/* we have no session media, find one and manage it */
if (sessmedia == NULL) {
/* get a handle to the configuration of the media in the session */
- media = find_media (client, state, &matched);
+ media = find_media (client, ctx, &matched);
} else {
if ((media = gst_rtsp_session_media_get_media (sessmedia)))
g_object_ref (media);
@@ -1412,8 +1409,8 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
goto stream_not_found;
/* now we have a uri identifying a valid media and stream */
- state->stream = stream;
- state->media = media;
+ ctx->stream = stream;
+ ctx->media = media;
if (session == NULL) {
/* create a session if this fails we probably reached our session limit or
@@ -1428,7 +1425,7 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_NEW_SESSION], 0,
session);
- state->session = session;
+ ctx->session = session;
}
if (sessmedia == NULL) {
@@ -1441,10 +1438,10 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
g_object_unref (media);
}
- state->sessmedia = sessmedia;
+ ctx->sessmedia = sessmedia;
/* set blocksize on this stream */
- if (!handle_blocksize (media, stream, state->request))
+ if (!handle_blocksize (media, stream, ctx->request))
goto invalid_blocksize;
gst_rtsp_transport_new (&ct);
@@ -1459,7 +1456,7 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
/* update the client transport */
klass = GST_RTSP_CLIENT_GET_CLASS (client);
- if (!klass->configure_client_transport (client, state, ct))
+ if (!klass->configure_client_transport (client, ctx, ct))
goto unsupported_client_transport;
/* set in the session media transport */
@@ -1470,20 +1467,20 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
(GstRTSPKeepAliveFunc) do_keepalive, session, NULL);
/* create and serialize the server transport */
- st = make_server_transport (client, state, ct);
+ st = make_server_transport (client, ctx, ct);
trans_str = gst_rtsp_transport_as_text (st);
gst_rtsp_transport_free (st);
/* construct the response now */
code = GST_RTSP_STS_OK;
- gst_rtsp_message_init_response (state->response, code,
- gst_rtsp_status_as_text (code), state->request);
+ gst_rtsp_message_init_response (ctx->response, code,
+ gst_rtsp_status_as_text (code), ctx->request);
- gst_rtsp_message_add_header (state->response, GST_RTSP_HDR_TRANSPORT,
+ gst_rtsp_message_add_header (ctx->response, GST_RTSP_HDR_TRANSPORT,
trans_str);
g_free (trans_str);
- send_message (client, session, state->response, FALSE);
+ send_message (client, session, ctx->response, FALSE);
/* update the state */
rtspstate = gst_rtsp_session_media_get_rtsp_state (sessmedia);
@@ -1499,8 +1496,7 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
}
g_object_unref (session);
- g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_SETUP_REQUEST],
- 0, state);
+ g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_SETUP_REQUEST], 0, ctx);
return TRUE;
@@ -1508,45 +1504,45 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
no_uri:
{
GST_ERROR ("client %p: no uri", client);
- send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, state);
+ send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, ctx);
return FALSE;
}
no_transport:
{
GST_ERROR ("client %p: no transport", client);
- send_generic_response (client, GST_RTSP_STS_UNSUPPORTED_TRANSPORT, state);
+ send_generic_response (client, GST_RTSP_STS_UNSUPPORTED_TRANSPORT, ctx);
return FALSE;
}
no_pool:
{
GST_ERROR ("client %p: no session pool configured", client);
- send_generic_response (client, GST_RTSP_STS_SESSION_NOT_FOUND, state);
+ 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);
- send_generic_response (client, GST_RTSP_STS_NOT_FOUND, state);
+ 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);
- send_generic_response (client, GST_RTSP_STS_NOT_FOUND, state);
+ send_generic_response (client, GST_RTSP_STS_NOT_FOUND, ctx);
g_object_unref (media);
return FALSE;
}
service_unavailable:
{
GST_ERROR ("client %p: can't create session", client);
- send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, state);
+ send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, ctx);
g_object_unref (media);
return FALSE;
}
sessmedia_unavailable:
{
GST_ERROR ("client %p: can't create session media", client);
- send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, state);
+ send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, ctx);
g_object_unref (media);
g_object_unref (session);
return FALSE;
@@ -1554,14 +1550,14 @@ sessmedia_unavailable:
invalid_blocksize:
{
GST_ERROR ("client %p: invalid blocksize", client);
- send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, state);
+ send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, ctx);
g_object_unref (session);
return FALSE;
}
unsupported_transports:
{
GST_ERROR ("client %p: unsupported transports", client);
- send_generic_response (client, GST_RTSP_STS_UNSUPPORTED_TRANSPORT, state);
+ send_generic_response (client, GST_RTSP_STS_UNSUPPORTED_TRANSPORT, ctx);
gst_rtsp_transport_free (ct);
g_object_unref (session);
return FALSE;
@@ -1569,7 +1565,7 @@ unsupported_transports:
unsupported_client_transport:
{
GST_ERROR ("client %p: unsupported client transport", client);
- send_generic_response (client, GST_RTSP_STS_UNSUPPORTED_TRANSPORT, state);
+ send_generic_response (client, GST_RTSP_STS_UNSUPPORTED_TRANSPORT, ctx);
gst_rtsp_transport_free (ct);
g_object_unref (session);
return FALSE;
@@ -1624,7 +1620,7 @@ no_sdp:
/* for the describe we must generate an SDP */
static gboolean
-handle_describe_request (GstRTSPClient * client, GstRTSPClientState * state)
+handle_describe_request (GstRTSPClient * client, GstRTSPContext * ctx)
{
GstRTSPResult res;
GstSDPMessage *sdp;
@@ -1635,7 +1631,7 @@ handle_describe_request (GstRTSPClient * client, GstRTSPClientState * state)
klass = GST_RTSP_CLIENT_GET_CLASS (client);
- if (!state->uri)
+ if (!ctx->uri)
goto no_uri;
/* check what kind of format is accepted, we don't really do anything with it
@@ -1644,7 +1640,7 @@ handle_describe_request (GstRTSPClient * client, GstRTSPClientState * state)
gchar *accept;
res =
- gst_rtsp_message_get_header (state->request, GST_RTSP_HDR_ACCEPT,
+ gst_rtsp_message_get_header (ctx->request, GST_RTSP_HDR_ACCEPT,
&accept, i);
if (res == GST_RTSP_ENOTIMPL)
break;
@@ -1654,7 +1650,7 @@ handle_describe_request (GstRTSPClient * client, GstRTSPClientState * state)
}
/* find the media object for the uri */
- if (!(media = find_media (client, state, NULL)))
+ if (!(media = find_media (client, ctx, NULL)))
goto no_media;
/* create an SDP for the media object on this client */
@@ -1663,14 +1659,14 @@ handle_describe_request (GstRTSPClient * client, GstRTSPClientState * state)
g_object_unref (media);
- gst_rtsp_message_init_response (state->response, GST_RTSP_STS_OK,
- gst_rtsp_status_as_text (GST_RTSP_STS_OK), state->request);
+ gst_rtsp_message_init_response (ctx->response, GST_RTSP_STS_OK,
+ gst_rtsp_status_as_text (GST_RTSP_STS_OK), ctx->request);
- gst_rtsp_message_add_header (state->response, GST_RTSP_HDR_CONTENT_TYPE,
+ gst_rtsp_message_add_header (ctx->response, GST_RTSP_HDR_CONTENT_TYPE,
"application/sdp");
/* content base for some clients that might screw up creating the setup uri */
- str = gst_rtsp_url_get_request_uri (state->uri);
+ str = gst_rtsp_url_get_request_uri (ctx->uri);
str_len = strlen (str);
/* check for trailing '/' and append one */
@@ -1686,19 +1682,19 @@ handle_describe_request (GstRTSPClient * client, GstRTSPClientState * state)
GST_INFO ("adding content-base: %s", content_base);
- gst_rtsp_message_add_header (state->response, GST_RTSP_HDR_CONTENT_BASE,
+ gst_rtsp_message_add_header (ctx->response, GST_RTSP_HDR_CONTENT_BASE,
content_base);
g_free (content_base);
/* add SDP to the response body */
str = gst_sdp_message_as_text (sdp);
- gst_rtsp_message_take_body (state->response, (guint8 *) str, strlen (str));
+ gst_rtsp_message_take_body (ctx->response, (guint8 *) str, strlen (str));
gst_sdp_message_free (sdp);
- send_message (client, state->session, state->response, FALSE);
+ send_message (client, ctx->session, ctx->response, FALSE);
g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_DESCRIBE_REQUEST],
- 0, state);
+ 0, ctx);
return TRUE;
@@ -1706,7 +1702,7 @@ handle_describe_request (GstRTSPClient * client, GstRTSPClientState * state)
no_uri:
{
GST_ERROR ("client %p: no uri", client);
- send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, state);
+ send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, ctx);
return FALSE;
}
no_media:
@@ -1718,14 +1714,14 @@ no_media:
no_sdp:
{
GST_ERROR ("client %p: can't create SDP", client);
- send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, state);
+ send_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, ctx);
g_object_unref (media);
return FALSE;
}
}
static gboolean
-handle_options_request (GstRTSPClient * client, GstRTSPClientState * state)
+handle_options_request (GstRTSPClient * client, GstRTSPContext * ctx)
{
GstRTSPMethod options;
gchar *str;
@@ -1739,16 +1735,16 @@ handle_options_request (GstRTSPClient * client, GstRTSPClientState * state)
str = gst_rtsp_options_as_text (options);
- gst_rtsp_message_init_response (state->response, GST_RTSP_STS_OK,
- gst_rtsp_status_as_text (GST_RTSP_STS_OK), state->request);
+ gst_rtsp_message_init_response (ctx->response, GST_RTSP_STS_OK,
+ gst_rtsp_status_as_text (GST_RTSP_STS_OK), ctx->request);
- gst_rtsp_message_add_header (state->response, GST_RTSP_HDR_PUBLIC, str);
+ gst_rtsp_message_add_header (ctx->response, GST_RTSP_HDR_PUBLIC, str);
g_free (str);
- send_message (client, state->session, state->response, FALSE);
+ send_message (client, ctx->session, ctx->response, FALSE);
g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_OPTIONS_REQUEST],
- 0, state);
+ 0, ctx);
return TRUE;
}
@@ -1798,69 +1794,6 @@ client_session_finalized (GstRTSPClient * client, GstRTSPSession * session)
}
}
-static GPrivate current_state;
-
-/**
- * gst_rtsp_client_state_get_current:
- *
- * Get the current #GstRTSPClientState. This object is retrieved from the
- * current thread that is handling the request for a client.
- *
- * Returns: a #GstRTSPClientState
- */
-GstRTSPClientState *
-gst_rtsp_client_state_get_current (void)
-{
- GSList *l;
-
- l = g_private_get (&current_state);
- if (l == NULL)
- return NULL;
-
- return (GstRTSPClientState *) (l->data);
-
-}
-
-/**
- * gst_rtsp_client_state_push_current:
- * @state: a ##GstRTSPClientState
- *
- * Pushes @state onto the state stack. The current
- * state can then be received using gst_rtsp_client_state_get_current().
- **/
-void
-gst_rtsp_client_state_push_current (GstRTSPClientState * state)
-{
- GSList *l;
-
- g_return_if_fail (state != NULL);
-
- l = g_private_get (&current_state);
- l = g_slist_prepend (l, state);
- g_private_set (&current_state, l);
-}
-
-/**
- * gst_rtsp_client_state_pop_current:
- * @state: a #GstRTSPClientState
- *
- * Pops @state off the state stack (verifying that @state
- * is on the top of the stack).
- **/
-void
-gst_rtsp_client_state_pop_current (GstRTSPClientState * state)
-{
- GSList *l;
-
- l = g_private_get (&current_state);
-
- g_return_if_fail (l != NULL);
- g_return_if_fail (l->data == state);
-
- l = g_slist_delete_link (l, l);
- g_private_set (&current_state, l);
-}
-
static void
handle_request (GstRTSPClient * client, GstRTSPMessage * request)
{
@@ -1871,20 +1804,20 @@ handle_request (GstRTSPClient * client, GstRTSPMessage * request)
GstRTSPVersion version;
GstRTSPResult res;
GstRTSPSession *session = NULL;
- GstRTSPClientState sstate = { NULL }, *state;
+ GstRTSPContext sctx = { NULL }, *ctx;
GstRTSPMessage response = { 0 };
gchar *sessid;
- if (!(state = gst_rtsp_client_state_get_current ())) {
- state = &sstate;
- state->auth = priv->auth;
- gst_rtsp_client_state_push_current (state);
+ if (!(ctx = gst_rtsp_context_get_current ())) {
+ ctx = &sctx;
+ ctx->auth = priv->auth;
+ gst_rtsp_context_push_current (ctx);
}
- state->conn = priv->connection;
- state->client = client;
- state->request = request;
- state->response = &response;
+ ctx->conn = priv->connection;
+ ctx->client = client;
+ ctx->request = request;
+ ctx->response = &response;
if (gst_debug_category_get_threshold (rtsp_client_debug) >= GST_LEVEL_LOG) {
gst_rtsp_message_dump (request);
@@ -1898,7 +1831,7 @@ handle_request (GstRTSPClient * client, GstRTSPMessage * request)
if (version != GST_RTSP_VERSION_1_0)
goto not_supported;
- state->method = method;
+ ctx->method = method;
/* we always try to parse the url first */
if (strcmp (uristr, "*") == 0) {
@@ -1925,8 +1858,8 @@ handle_request (GstRTSPClient * client, GstRTSPMessage * request)
/* sanitize the uri */
if (uri)
sanitize_uri (uri);
- state->uri = uri;
- state->session = session;
+ ctx->uri = uri;
+ ctx->session = session;
if (!gst_rtsp_auth_check (GST_RTSP_AUTH_CHECK_URL))
goto not_authorized;
@@ -1934,28 +1867,28 @@ handle_request (GstRTSPClient * client, GstRTSPMessage * request)
/* now see what is asked and dispatch to a dedicated handler */
switch (method) {
case GST_RTSP_OPTIONS:
- handle_options_request (client, state);
+ handle_options_request (client, ctx);
break;
case GST_RTSP_DESCRIBE:
- handle_describe_request (client, state);
+ handle_describe_request (client, ctx);
break;
case GST_RTSP_SETUP:
- handle_setup_request (client, state);
+ handle_setup_request (client, ctx);
break;
case GST_RTSP_PLAY:
- handle_play_request (client, state);
+ handle_play_request (client, ctx);
break;
case GST_RTSP_PAUSE:
- handle_pause_request (client, state);
+ handle_pause_request (client, ctx);
break;
case GST_RTSP_TEARDOWN:
- handle_teardown_request (client, state);
+ handle_teardown_request (client, ctx);
break;
case GST_RTSP_SET_PARAMETER:
- handle_set_param_request (client, state);
+ handle_set_param_request (client, ctx);
break;
case GST_RTSP_GET_PARAMETER:
- handle_get_param_request (client, state);
+ handle_get_param_request (client, ctx);
break;
case GST_RTSP_ANNOUNCE:
case GST_RTSP_RECORD:
@@ -1967,8 +1900,8 @@ handle_request (GstRTSPClient * client, GstRTSPMessage * request)
}
done:
- if (state == &sstate)
- gst_rtsp_client_state_pop_current (state);
+ if (ctx == &sctx)
+ gst_rtsp_context_pop_current (ctx);
if (session)
g_object_unref (session);
if (uri)
@@ -1980,25 +1913,25 @@ not_supported:
{
GST_ERROR ("client %p: version %d not supported", client, version);
send_generic_response (client, GST_RTSP_STS_RTSP_VERSION_NOT_SUPPORTED,
- state);
+ ctx);
goto done;
}
bad_request:
{
GST_ERROR ("client %p: bad request", client);
- send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, state);
+ send_generic_response (client, GST_RTSP_STS_BAD_REQUEST, ctx);
goto done;
}
no_pool:
{
GST_ERROR ("client %p: no pool configured", client);
- send_generic_response (client, GST_RTSP_STS_SESSION_NOT_FOUND, state);
+ send_generic_response (client, GST_RTSP_STS_SESSION_NOT_FOUND, ctx);
goto done;
}
session_not_found:
{
GST_ERROR ("client %p: session not found", client);
- send_generic_response (client, GST_RTSP_STS_SESSION_NOT_FOUND, state);
+ send_generic_response (client, GST_RTSP_STS_SESSION_NOT_FOUND, ctx);
goto done;
}
not_authorized:
@@ -2009,7 +1942,7 @@ not_authorized:
not_implemented:
{
GST_ERROR ("client %p: method %d not implemented", client, method);
- send_generic_response (client, GST_RTSP_STS_NOT_IMPLEMENTED, state);
+ send_generic_response (client, GST_RTSP_STS_NOT_IMPLEMENTED, ctx);
goto done;
}
}
diff --git a/gst/rtsp-server/rtsp-client.h b/gst/rtsp-server/rtsp-client.h
index 5ea6071..72c5187 100644
--- a/gst/rtsp-server/rtsp-client.h
+++ b/gst/rtsp-server/rtsp-client.h
@@ -27,18 +27,12 @@ G_BEGIN_DECLS
typedef struct _GstRTSPClient GstRTSPClient;
typedef struct _GstRTSPClientClass GstRTSPClientClass;
-typedef struct _GstRTSPClientState GstRTSPClientState;
typedef struct _GstRTSPClientPrivate GstRTSPClientPrivate;
-#include "rtsp-server.h"
-#include "rtsp-media.h"
+#include "rtsp-context.h"
#include "rtsp-mount-points.h"
-#include "rtsp-session-pool.h"
-#include "rtsp-session-media.h"
-#include "rtsp-auth.h"
-#include "rtsp-thread-pool.h"
-#include "rtsp-token.h"
#include "rtsp-sdp.h"
+#include "rtsp-auth.h"
#define GST_TYPE_RTSP_CLIENT (gst_rtsp_client_get_type ())
#define GST_IS_RTSP_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_CLIENT))
@@ -50,47 +44,6 @@ typedef struct _GstRTSPClientPrivate GstRTSPClientPrivate;
#define GST_RTSP_CLIENT_CLASS_CAST(klass) ((GstRTSPClientClass*)(klass))
/**
- * GstRTSPClientState:
- * @server: the server
- * @conn: the connection
- * @client: the client
- * @request: the complete request
- * @uri: the complete url parsed from @request
- * @method: the parsed method of @uri
- * @auth: the current auth object or NULL
- * @token: authorisation token
- * @session: the session, can be NULL
- * @sessmedia: the session media for the url can be NULL
- * @factory: the media factory for the url, can be NULL.
- * @media: the media for the url can be NULL
- * @stream: the stream for the url can be NULL
- * @response: the response
- *
- * Information passed around containing the client state of a request.
- */
-struct _GstRTSPClientState {
- GstRTSPServer *server;
- GstRTSPConnection *conn;
- GstRTSPClient *client;
- GstRTSPMessage *request;
- GstRTSPUrl *uri;
- GstRTSPMethod method;
- GstRTSPAuth *auth;
- GstRTSPToken *token;
- GstRTSPSession *session;
- GstRTSPSessionMedia *sessmedia;
- GstRTSPMediaFactory *factory;
- GstRTSPMedia *media;
- GstRTSPStream *stream;
- GstRTSPMessage *response;
-};
-
-GstRTSPClientState * gst_rtsp_client_state_get_current (void);
-void gst_rtsp_client_state_push_current (GstRTSPClientState * state);
-void gst_rtsp_client_state_pop_current (GstRTSPClientState * state);
-
-
-/**
* GstRTSPClientSendFunc:
* @client: a #GstRTSPClient
* @message: a #GstRTSPMessage
@@ -124,9 +77,9 @@ struct _GstRTSPClient {
* @configure_client_transport: called when the client transport needs to be
* configured.
* @params_set: set parameters. This function should also initialize the
- * RTSP response(state->response) via a call to gst_rtsp_message_init_response()
+ * RTSP response(ctx->response) via a call to gst_rtsp_message_init_response()
* @params_get: get parameters. This function should also initialize the
- * RTSP response(state->response) via a call to gst_rtsp_message_init_response()
+ * RTSP response(ctx->response) via a call to gst_rtsp_message_init_response()
*
* The client class structure.
*/
@@ -135,22 +88,22 @@ struct _GstRTSPClientClass {
GstSDPMessage * (*create_sdp) (GstRTSPClient *client, GstRTSPMedia *media);
gboolean (*configure_client_transport) (GstRTSPClient * client,
- GstRTSPClientState * state,
+ GstRTSPContext * ctx,
GstRTSPTransport * ct);
- GstRTSPResult (*params_set) (GstRTSPClient *client, GstRTSPClientState *state);
- GstRTSPResult (*params_get) (GstRTSPClient *client, GstRTSPClientState *state);
+ GstRTSPResult (*params_set) (GstRTSPClient *client, GstRTSPContext *ctx);
+ GstRTSPResult (*params_get) (GstRTSPClient *client, GstRTSPContext *ctx);
/* signals */
void (*closed) (GstRTSPClient *client);
void (*new_session) (GstRTSPClient *client, GstRTSPSession *session);
- void (*options_request) (GstRTSPClient *client, GstRTSPClientState *state);
- void (*describe_request) (GstRTSPClient *client, GstRTSPClientState *state);
- void (*setup_request) (GstRTSPClient *client, GstRTSPClientState *state);
- void (*play_request) (GstRTSPClient *client, GstRTSPClientState *state);
- void (*pause_request) (GstRTSPClient *client, GstRTSPClientState *state);
- void (*teardown_request) (GstRTSPClient *client, GstRTSPClientState *state);
- void (*set_parameter_request) (GstRTSPClient *client, GstRTSPClientState *state);
- void (*get_parameter_request) (GstRTSPClient *client, GstRTSPClientState *state);
+ void (*options_request) (GstRTSPClient *client, GstRTSPContext *ctx);
+ void (*describe_request) (GstRTSPClient *client, GstRTSPContext *ctx);
+ void (*setup_request) (GstRTSPClient *client, GstRTSPContext *ctx);
+ void (*play_request) (GstRTSPClient *client, GstRTSPContext *ctx);
+ void (*pause_request) (GstRTSPClient *client, GstRTSPContext *ctx);
+ void (*teardown_request) (GstRTSPClient *client, GstRTSPContext *ctx);
+ void (*set_parameter_request) (GstRTSPClient *client, GstRTSPContext *ctx);
+ void (*get_parameter_request) (GstRTSPClient *client, GstRTSPContext *ctx);
};
GType gst_rtsp_client_get_type (void);
diff --git a/gst/rtsp-server/rtsp-context.c b/gst/rtsp-server/rtsp-context.c
new file mode 100644
index 0000000..3b8c0a1
--- /dev/null
+++ b/gst/rtsp-server/rtsp-context.c
@@ -0,0 +1,90 @@
+/* GStreamer
+ * Copyright (C) 2013 Wim Taymans <wim.taymans at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+/**
+ * SECTION:rtsp-context
+ * @short_description: A client request context
+ * @see_also: #GstRTSPServer, #GstRTSPClient
+ *
+ * Last reviewed on 2013-07-11 (1.0.0)
+ */
+
+#include "rtsp-context.h"
+
+static GPrivate current_context;
+
+/**
+ * gst_rtsp_context_get_current:
+ *
+ * Get the current #GstRTSPContext. This object is retrieved from the
+ * current thread that is handling the request for a client.
+ *
+ * Returns: a #GstRTSPContext
+ */
+GstRTSPContext *
+gst_rtsp_context_get_current (void)
+{
+ GSList *l;
+
+ l = g_private_get (&current_context);
+ if (l == NULL)
+ return NULL;
+
+ return (GstRTSPContext *) (l->data);
+
+}
+
+/**
+ * gst_rtsp_context_push_current:
+ * @ctx: a ##GstRTSPContext
+ *
+ * Pushes @ctx onto the context stack. The current
+ * context can then be received using gst_rtsp_context_get_current().
+ **/
+void
+gst_rtsp_context_push_current (GstRTSPContext * ctx)
+{
+ GSList *l;
+
+ g_return_if_fail (ctx != NULL);
+
+ l = g_private_get (&current_context);
+ l = g_slist_prepend (l, ctx);
+ g_private_set (&current_context, l);
+}
+
+/**
+ * gst_rtsp_context_pop_current:
+ * @ctx: a #GstRTSPContext
+ *
+ * Pops @ctx off the context stack (verifying that @ctx
+ * is on the top of the stack).
+ **/
+void
+gst_rtsp_context_pop_current (GstRTSPContext * ctx)
+{
+ GSList *l;
+
+ l = g_private_get (&current_context);
+
+ g_return_if_fail (l != NULL);
+ g_return_if_fail (l->data == ctx);
+
+ l = g_slist_delete_link (l, l);
+ g_private_set (&current_context, l);
+}
diff --git a/gst/rtsp-server/rtsp-context.h b/gst/rtsp-server/rtsp-context.h
new file mode 100644
index 0000000..60ff030
--- /dev/null
+++ b/gst/rtsp-server/rtsp-context.h
@@ -0,0 +1,81 @@
+/* GStreamer
+ * Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <gst/gst.h>
+#include <gst/rtsp/gstrtspconnection.h>
+
+#ifndef __GST_RTSP_CONTEXT_H__
+#define __GST_RTSP_CONTEXT_H__
+
+G_BEGIN_DECLS
+
+typedef struct _GstRTSPContext GstRTSPContext;
+
+#include "rtsp-server.h"
+#include "rtsp-media.h"
+#include "rtsp-media-factory.h"
+#include "rtsp-session-media.h"
+#include "rtsp-auth.h"
+#include "rtsp-thread-pool.h"
+#include "rtsp-token.h"
+
+/**
+ * GstRTSPContext:
+ * @server: the server
+ * @conn: the connection
+ * @client: the client
+ * @request: the complete request
+ * @uri: the complete url parsed from @request
+ * @method: the parsed method of @uri
+ * @auth: the current auth object or NULL
+ * @token: authorisation token
+ * @session: the session, can be NULL
+ * @sessmedia: the session media for the url can be NULL
+ * @factory: the media factory for the url, can be NULL.
+ * @media: the media for the url can be NULL
+ * @stream: the stream for the url can be NULL
+ * @response: the response
+ *
+ * Information passed around containing the context of a request.
+ */
+struct _GstRTSPContext {
+ GstRTSPServer *server;
+ GstRTSPConnection *conn;
+ GstRTSPClient *client;
+ GstRTSPMessage *request;
+ GstRTSPUrl *uri;
+ GstRTSPMethod method;
+ GstRTSPAuth *auth;
+ GstRTSPToken *token;
+ GstRTSPSession *session;
+ GstRTSPSessionMedia *sessmedia;
+ GstRTSPMediaFactory *factory;
+ GstRTSPMedia *media;
+ GstRTSPStream *stream;
+ GstRTSPMessage *response;
+};
+
+GstRTSPContext * gst_rtsp_context_get_current (void);
+void gst_rtsp_context_push_current (GstRTSPContext * ctx);
+void gst_rtsp_context_pop_current (GstRTSPContext * ctx);
+
+
+G_END_DECLS
+
+#endif /* __GST_RTSP_CONTEXT_H__ */
diff --git a/gst/rtsp-server/rtsp-params.c b/gst/rtsp-server/rtsp-params.c
index d1f9b69..ce18eaa 100644
--- a/gst/rtsp-server/rtsp-params.c
+++ b/gst/rtsp-server/rtsp-params.c
@@ -31,14 +31,14 @@
/**
* gst_rtsp_params_set:
* @client: a #GstRTSPClient
- * @state: a #GstRTSPClientState
+ * @ctx: a #GstRTSPContext
*
* Set parameters (not implemented yet)
*
* Returns: a #GstRTSPResult
*/
GstRTSPResult
-gst_rtsp_params_set (GstRTSPClient * client, GstRTSPClientState * state)
+gst_rtsp_params_set (GstRTSPClient * client, GstRTSPContext * ctx)
{
GstRTSPStatusCode code;
@@ -46,8 +46,8 @@ gst_rtsp_params_set (GstRTSPClient * client, GstRTSPClientState * state)
* with a list of the parameters */
code = GST_RTSP_STS_PARAMETER_NOT_UNDERSTOOD;
- gst_rtsp_message_init_response (state->response, code,
- gst_rtsp_status_as_text (code), state->request);
+ gst_rtsp_message_init_response (ctx->response, code,
+ gst_rtsp_status_as_text (code), ctx->request);
return GST_RTSP_OK;
}
@@ -55,14 +55,14 @@ gst_rtsp_params_set (GstRTSPClient * client, GstRTSPClientState * state)
/**
* gst_rtsp_params_get:
* @client: a #GstRTSPClient
- * @state: a #GstRTSPClientState
+ * @ctx: a #GstRTSPContext
*
* Get parameters (not implemented yet)
*
* Returns: a #GstRTSPResult
*/
GstRTSPResult
-gst_rtsp_params_get (GstRTSPClient * client, GstRTSPClientState * state)
+gst_rtsp_params_get (GstRTSPClient * client, GstRTSPContext * ctx)
{
GstRTSPStatusCode code;
@@ -70,8 +70,8 @@ gst_rtsp_params_get (GstRTSPClient * client, GstRTSPClientState * state)
* with a list of the parameters */
code = GST_RTSP_STS_PARAMETER_NOT_UNDERSTOOD;
- gst_rtsp_message_init_response (state->response, code,
- gst_rtsp_status_as_text (code), state->request);
+ gst_rtsp_message_init_response (ctx->response, code,
+ gst_rtsp_status_as_text (code), ctx->request);
return GST_RTSP_OK;
}
diff --git a/gst/rtsp-server/rtsp-params.h b/gst/rtsp-server/rtsp-params.h
index 93fb959..563757d 100644
--- a/gst/rtsp-server/rtsp-params.h
+++ b/gst/rtsp-server/rtsp-params.h
@@ -30,8 +30,8 @@
G_BEGIN_DECLS
-GstRTSPResult gst_rtsp_params_set (GstRTSPClient * client, GstRTSPClientState * state);
-GstRTSPResult gst_rtsp_params_get (GstRTSPClient * client, GstRTSPClientState * state);
+GstRTSPResult gst_rtsp_params_set (GstRTSPClient * client, GstRTSPContext * ctx);
+GstRTSPResult gst_rtsp_params_get (GstRTSPClient * client, GstRTSPContext * ctx);
G_END_DECLS
diff --git a/gst/rtsp-server/rtsp-permissions.c b/gst/rtsp-server/rtsp-permissions.c
index 077ae5b..25872c6 100644
--- a/gst/rtsp-server/rtsp-permissions.c
+++ b/gst/rtsp-server/rtsp-permissions.c
@@ -87,7 +87,7 @@ _gst_rtsp_permissions_copy (GstRTSPPermissionsImpl * permissions)
gst_structure_set_parent_refcount (entry_copy,
&copy->permissions.mini_object.refcount);
- g_ptr_array_add (permissions->roles, entry_copy);
+ g_ptr_array_add (copy->roles, entry_copy);
}
return GST_RTSP_PERMISSIONS (copy);
diff --git a/gst/rtsp-server/rtsp-server.c b/gst/rtsp-server/rtsp-server.c
index cd61614..538a2d2 100644
--- a/gst/rtsp-server/rtsp-server.c
+++ b/gst/rtsp-server/rtsp-server.c
@@ -991,26 +991,26 @@ unmanage_client (GstRTSPClient * client, ClientContext * ctx)
static void
manage_client (GstRTSPServer * server, GstRTSPClient * client)
{
- ClientContext *ctx;
+ ClientContext *cctx;
GstRTSPServerPrivate *priv = server->priv;
GMainContext *mainctx = NULL;
- GstRTSPClientState state = { NULL };
+ GstRTSPContext ctx = { NULL };
GST_DEBUG_OBJECT (server, "manage client %p", client);
- ctx = g_slice_new0 (ClientContext);
- ctx->server = g_object_ref (server);
- ctx->client = client;
+ cctx = g_slice_new0 (ClientContext);
+ cctx->server = g_object_ref (server);
+ cctx->client = client;
GST_RTSP_SERVER_LOCK (server);
- state.server = server;
- state.client = client;
+ ctx.server = server;
+ ctx.client = client;
- ctx->thread = gst_rtsp_thread_pool_get_thread (priv->thread_pool,
- GST_RTSP_THREAD_TYPE_CLIENT, &state);
- if (ctx->thread)
- mainctx = ctx->thread->context;
+ cctx->thread = gst_rtsp_thread_pool_get_thread (priv->thread_pool,
+ GST_RTSP_THREAD_TYPE_CLIENT, &ctx);
+ if (cctx->thread)
+ mainctx = cctx->thread->context;
else {
GSource *source;
/* find the context to add the watch */
@@ -1018,8 +1018,8 @@ manage_client (GstRTSPServer * server, GstRTSPClient * client)
mainctx = g_source_get_context (source);
}
- g_signal_connect (client, "closed", (GCallback) unmanage_client, ctx);
- priv->clients = g_list_prepend (priv->clients, ctx);
+ g_signal_connect (client, "closed", (GCallback) unmanage_client, cctx);
+ priv->clients = g_list_prepend (priv->clients, cctx);
gst_rtsp_client_attach (client, mainctx);
@@ -1129,17 +1129,17 @@ gst_rtsp_server_io_func (GSocket * socket, GIOCondition condition,
GstRTSPServerClass *klass;
GstRTSPResult res;
GstRTSPConnection *conn = NULL;
- GstRTSPClientState state = { NULL };
+ GstRTSPContext ctx = { NULL };
if (condition & G_IO_IN) {
/* a new client connected. */
GST_RTSP_CHECK (gst_rtsp_connection_accept (socket, &conn, NULL),
accept_failed);
- state.server = server;
- state.conn = conn;
- state.auth = priv->auth;
- gst_rtsp_client_state_push_current (&state);
+ ctx.server = server;
+ ctx.conn = conn;
+ ctx.auth = priv->auth;
+ gst_rtsp_context_push_current (&ctx);
if (!gst_rtsp_auth_check (GST_RTSP_AUTH_CHECK_CONNECT))
goto connection_refused;
@@ -1163,7 +1163,7 @@ gst_rtsp_server_io_func (GSocket * socket, GIOCondition condition,
GST_WARNING_OBJECT (server, "received unknown event %08x", condition);
}
exit:
- gst_rtsp_client_state_pop_current (&state);
+ gst_rtsp_context_pop_current (&ctx);
return G_SOURCE_CONTINUE;
diff --git a/gst/rtsp-server/rtsp-thread-pool.c b/gst/rtsp-server/rtsp-thread-pool.c
index b29f20e..87a035f 100644
--- a/gst/rtsp-server/rtsp-thread-pool.c
+++ b/gst/rtsp-server/rtsp-thread-pool.c
@@ -197,7 +197,7 @@ static void gst_rtsp_thread_pool_finalize (GObject * obj);
static gpointer do_loop (GstRTSPThread * thread);
static GstRTSPThread *default_get_thread (GstRTSPThreadPool * pool,
- GstRTSPThreadType type, GstRTSPClientState * state);
+ GstRTSPThreadType type, GstRTSPContext * ctx);
G_DEFINE_TYPE (GstRTSPThreadPool, gst_rtsp_thread_pool, G_TYPE_OBJECT);
@@ -393,7 +393,7 @@ gst_rtsp_thread_pool_get_max_threads (GstRTSPThreadPool * pool)
static GstRTSPThread *
make_thread (GstRTSPThreadPool * pool, GstRTSPThreadType type,
- GstRTSPClientState * state)
+ GstRTSPContext * ctx)
{
GstRTSPThreadPoolClass *klass;
GstRTSPThread *thread;
@@ -407,14 +407,14 @@ make_thread (GstRTSPThreadPool * pool, GstRTSPThreadType type,
GST_DEBUG_OBJECT (pool, "new thread %p", thread);
if (klass->configure_thread)
- klass->configure_thread (pool, thread, state);
+ klass->configure_thread (pool, thread, ctx);
return thread;
}
static GstRTSPThread *
default_get_thread (GstRTSPThreadPool * pool,
- GstRTSPThreadType type, GstRTSPClientState * state)
+ GstRTSPThreadType type, GstRTSPContext * ctx)
{
GstRTSPThreadPoolPrivate *priv = pool->priv;
GstRTSPThreadPoolClass *klass;
@@ -450,7 +450,7 @@ default_get_thread (GstRTSPThreadPool * pool,
} else {
/* make more threads */
GST_DEBUG_OBJECT (pool, "make new client thread");
- thread = make_thread (pool, type, state);
+ thread = make_thread (pool, type, ctx);
if (!g_thread_pool_push (klass->pool, thread, &error))
goto thread_error;
@@ -461,7 +461,7 @@ default_get_thread (GstRTSPThreadPool * pool,
break;
case GST_RTSP_THREAD_TYPE_MEDIA:
GST_DEBUG_OBJECT (pool, "make new media thread");
- thread = make_thread (pool, type, state);
+ thread = make_thread (pool, type, ctx);
if (!g_thread_pool_push (klass->pool, thread, &error))
goto thread_error;
@@ -486,15 +486,15 @@ thread_error:
* gst_rtsp_thread_pool_get_thread:
* @pool: a #GstRTSPThreadPool
* @type: the #GstRTSPThreadType
- * @state: a #GstRTSPClientState
+ * @ctx: a #GstRTSPContext
*
- * Get a new #GstRTSPThread for @type and @state.
+ * Get a new #GstRTSPThread for @type and @ctx.
*
* Returns: a new #GstRTSPThread, gst_rtsp_thread_stop() after usage
*/
GstRTSPThread *
gst_rtsp_thread_pool_get_thread (GstRTSPThreadPool * pool,
- GstRTSPThreadType type, GstRTSPClientState * state)
+ GstRTSPThreadType type, GstRTSPContext * ctx)
{
GstRTSPThreadPoolClass *klass;
GstRTSPThread *result = NULL;
@@ -504,7 +504,7 @@ gst_rtsp_thread_pool_get_thread (GstRTSPThreadPool * pool,
klass = GST_RTSP_THREAD_POOL_GET_CLASS (pool);
if (klass->get_thread)
- result = klass->get_thread (pool, type, state);
+ result = klass->get_thread (pool, type, ctx);
return result;
}
diff --git a/gst/rtsp-server/rtsp-thread-pool.h b/gst/rtsp-server/rtsp-thread-pool.h
index 74f9e07..148e73f 100644
--- a/gst/rtsp-server/rtsp-thread-pool.h
+++ b/gst/rtsp-server/rtsp-thread-pool.h
@@ -148,10 +148,10 @@ struct _GstRTSPThreadPoolClass {
GstRTSPThread * (*get_thread) (GstRTSPThreadPool *pool,
GstRTSPThreadType type,
- GstRTSPClientState *state);
+ GstRTSPContext *ctx);
void (*configure_thread) (GstRTSPThreadPool *pool,
GstRTSPThread * thread,
- GstRTSPClientState *state);
+ GstRTSPContext *ctx);
void (*thread_enter) (GstRTSPThreadPool *pool,
GstRTSPThread *thread);
@@ -168,7 +168,7 @@ gint gst_rtsp_thread_pool_get_max_threads (GstRTSPThreadPool * po
GstRTSPThread * gst_rtsp_thread_pool_get_thread (GstRTSPThreadPool *pool,
GstRTSPThreadType type,
- GstRTSPClientState *state);
+ GstRTSPContext *ctx);
G_END_DECLS
#endif /* __GST_RTSP_THREAD_POOL_H__ */
diff --git a/tests/check/gst/client.c b/tests/check/gst/client.c
index 8a442bc..58d5d83 100644
--- a/tests/check/gst/client.c
+++ b/tests/check/gst/client.c
@@ -529,17 +529,17 @@ GST_START_TEST (test_client_multicast_invalid_transport_specific)
GstRTSPMessage request = { 0, };
gchar *str;
GstRTSPSessionPool *session_pool;
- GstRTSPClientState state = { NULL };
+ GstRTSPContext ctx = { NULL };
client = setup_multicast_client ();
- state.client = client;
- state.auth = gst_rtsp_auth_new ();
- state.token =
+ ctx.client = client;
+ ctx.auth = gst_rtsp_auth_new ();
+ ctx.token =
gst_rtsp_token_new (GST_RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS,
G_TYPE_BOOLEAN, TRUE, GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE, G_TYPE_STRING,
"user", NULL);
- gst_rtsp_client_state_push_current (&state);
+ gst_rtsp_context_push_current (&ctx);
/* simple SETUP with a valid URI and multicast, but an invalid ip */
fail_unless (gst_rtsp_message_init_request (&request, GST_RTSP_SETUP,
@@ -604,9 +604,9 @@ GST_START_TEST (test_client_multicast_invalid_transport_specific)
g_object_unref (client);
- g_object_unref (state.auth);
- gst_rtsp_token_unref (state.token);
- gst_rtsp_client_state_pop_current (&state);
+ g_object_unref (ctx.auth);
+ gst_rtsp_token_unref (ctx.token);
+ gst_rtsp_context_pop_current (&ctx);
}
GST_END_TEST;
@@ -617,17 +617,17 @@ GST_START_TEST (test_client_multicast_transport_specific)
GstRTSPMessage request = { 0, };
gchar *str;
GstRTSPSessionPool *session_pool;
- GstRTSPClientState state = { NULL };
+ GstRTSPContext ctx = { NULL };
client = setup_multicast_client ();
- state.client = client;
- state.auth = gst_rtsp_auth_new ();
- state.token =
+ ctx.client = client;
+ ctx.auth = gst_rtsp_auth_new ();
+ ctx.token =
gst_rtsp_token_new (GST_RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS,
G_TYPE_BOOLEAN, TRUE, GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE, G_TYPE_STRING,
"user", NULL);
- gst_rtsp_client_state_push_current (&state);
+ gst_rtsp_context_push_current (&ctx);
expected_transport = "RTP/AVP;multicast;destination=233.252.0.1;"
"ttl=1;port=5000-5001;mode=\"PLAY\"";
@@ -655,9 +655,9 @@ GST_START_TEST (test_client_multicast_transport_specific)
g_object_unref (session_pool);
g_object_unref (client);
- g_object_unref (state.auth);
- gst_rtsp_token_unref (state.token);
- gst_rtsp_client_state_pop_current (&state);
+ g_object_unref (ctx.auth);
+ gst_rtsp_token_unref (ctx.token);
+ gst_rtsp_context_pop_current (&ctx);
}
GST_END_TEST;