Commit ad00c5e7 authored by Wim Taymans's avatar Wim Taymans

rtsp: make object details private

Make all object details private
Add methods to access private bits
parent 8665c3b4
......@@ -313,6 +313,7 @@ gst_rtsp_stream_set_mtu
gst_rtsp_stream_join_bin
gst_rtsp_stream_leave_bin
gst_rtsp_stream_get_rtpinfo
gst_rtsp_stream_get_caps
gst_rtsp_stream_recv_rtcp
gst_rtsp_stream_recv_rtp
gst_rtsp_stream_add_transport
......
......@@ -35,8 +35,8 @@ remove_sessions (GstRTSPServer * server)
g_print ("removing all sessions\n");
pool = gst_rtsp_server_get_session_pool (server);
gst_rtsp_session_pool_filter (pool, (GstRTSPSessionFilterFunc) remove_func,
server);
gst_rtsp_session_pool_filter (pool,
(GstRTSPSessionPoolFilterFunc) remove_func, server);
g_object_unref (pool);
return FALSE;
......
......@@ -21,6 +21,16 @@
#include "rtsp-auth.h"
#define GST_RTSP_AUTH_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_RTSP_AUTH, GstRTSPAuthPrivate))
struct _GstRTSPAuthPrivate
{
GMutex lock;
gchar *basic;
GstRTSPMethod methods;
};
enum
{
PROP_0,
......@@ -48,6 +58,8 @@ gst_rtsp_auth_class_init (GstRTSPAuthClass * klass)
{
GObjectClass *gobject_class;
g_type_class_add_private (klass, sizeof (GstRTSPAuthPrivate));
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->get_property = gst_rtsp_auth_get_property;
......@@ -63,9 +75,11 @@ gst_rtsp_auth_class_init (GstRTSPAuthClass * klass)
static void
gst_rtsp_auth_init (GstRTSPAuth * auth)
{
g_mutex_init (&auth->lock);
auth->priv = GST_RTSP_AUTH_GET_PRIVATE (auth);
g_mutex_init (&auth->priv->lock);
/* bitwise or of all methods that need authentication */
auth->methods = GST_RTSP_DESCRIBE |
auth->priv->methods = GST_RTSP_DESCRIBE |
GST_RTSP_ANNOUNCE |
GST_RTSP_GET_PARAMETER |
GST_RTSP_SET_PARAMETER |
......@@ -77,10 +91,11 @@ static void
gst_rtsp_auth_finalize (GObject * obj)
{
GstRTSPAuth *auth = GST_RTSP_AUTH (obj);
GstRTSPAuthPrivate *priv = auth->priv;
GST_INFO ("finalize auth %p", auth);
g_free (auth->basic);
g_mutex_clear (&auth->lock);
g_free (priv->basic);
g_mutex_clear (&priv->lock);
G_OBJECT_CLASS (gst_rtsp_auth_parent_class)->finalize (obj);
}
......@@ -132,12 +147,16 @@ gst_rtsp_auth_new (void)
void
gst_rtsp_auth_set_basic (GstRTSPAuth * auth, const gchar * basic)
{
GstRTSPAuthPrivate *priv;
g_return_if_fail (GST_IS_RTSP_AUTH (auth));
g_mutex_lock (&auth->lock);
g_free (auth->basic);
auth->basic = g_strdup (basic);
g_mutex_unlock (&auth->lock);
priv = auth->priv;
g_mutex_lock (&priv->lock);
g_free (priv->basic);
priv->basic = g_strdup (basic);
g_mutex_unlock (&priv->lock);
}
static gboolean
......@@ -190,10 +209,11 @@ static gboolean
default_check_method (GstRTSPAuth * auth, GstRTSPClient * client,
GQuark hint, GstRTSPClientState * state)
{
GstRTSPAuthPrivate *priv = auth->priv;
gboolean result = TRUE;
GstRTSPResult res;
if ((state->method & auth->methods) != 0) {
if ((state->method & priv->methods) != 0) {
gchar *authorization;
result = FALSE;
......@@ -207,10 +227,10 @@ default_check_method (GstRTSPAuth * auth, GstRTSPClient * client,
/* parse type */
if (g_ascii_strncasecmp (authorization, "basic ", 6) == 0) {
GST_DEBUG_OBJECT (auth, "check Basic auth");
g_mutex_lock (&auth->lock);
if (auth->basic && strcmp (&authorization[6], auth->basic) == 0)
g_mutex_lock (&priv->lock);
if (priv->basic && strcmp (&authorization[6], priv->basic) == 0)
result = TRUE;
g_mutex_unlock (&auth->lock);
g_mutex_unlock (&priv->lock);
} else if (g_ascii_strncasecmp (authorization, "digest ", 7) == 0) {
GST_DEBUG_OBJECT (auth, "check Digest auth");
/* not implemented yet */
......
......@@ -24,6 +24,7 @@
typedef struct _GstRTSPAuth GstRTSPAuth;
typedef struct _GstRTSPAuthClass GstRTSPAuthClass;
typedef struct _GstRTSPAuthPrivate GstRTSPAuthPrivate;
#include "rtsp-client.h"
......@@ -46,10 +47,7 @@ G_BEGIN_DECLS
struct _GstRTSPAuth {
GObject parent;
/*< private >*/
GMutex lock;
gchar *basic;
GstRTSPMethod methods;
GstRTSPAuthPrivate *priv;
};
struct _GstRTSPAuthClass {
......
This diff is collapsed.
......@@ -28,6 +28,7 @@ G_BEGIN_DECLS
typedef struct _GstRTSPClient GstRTSPClient;
typedef struct _GstRTSPClientClass GstRTSPClientClass;
typedef struct _GstRTSPClientState GstRTSPClientState;
typedef struct _GstRTSPClientPrivate GstRTSPClientPrivate;
#include "rtsp-media.h"
#include "rtsp-mount-points.h"
......@@ -90,51 +91,13 @@ typedef gboolean (*GstRTSPClientSendFunc) (GstRTSPClient *client,
/**
* GstRTSPClient:
* @lock: lock protecting the client object
* @connection: the connection object handling the client request.
* @watch: watch for the connection
* @close_seq: sequence number of message with close header
* @server_ip: ip address of the server
* @is_ipv6: if we are IPv6
* @use_client_settings: whether to allow client transport settings for multicast
* @send_func: a #GstRTSPClientSendFunc called when an RTSP message needs to be
* sent to the client.
* @send_data: user data passed to @send_func
* @send_notify: notify called when @send_data is no longer used.
* @session_pool: handle to the session pool used by the client.
* @mount_points: handle to the mount points used by the client.
* @auth: authorization object
* @uri: cached uri
* @media: cached media
* @transports: a list of #GstRTSPStreamTransport using @connection.
* @sessions: a list of sessions managed by @connection.
*
* The client structure.
*/
struct _GstRTSPClient {
GObject parent;
GMutex lock;
GstRTSPConnection *connection;
GstRTSPWatch *watch;
guint close_seq;
gchar *server_ip;
gboolean is_ipv6;
gboolean use_client_settings;
GstRTSPClientSendFunc send_func;
gpointer send_data;
GDestroyNotify send_notify;
GstRTSPSessionPool *session_pool;
GstRTSPMountPoints *mount_points;
GstRTSPAuth *auth;
GstRTSPUrl *uri;
GstRTSPMedia *media;
GList *transports;
GList *sessions;
GstRTSPClientPrivate *priv;
};
struct _GstRTSPClientClass {
......
......@@ -21,6 +21,22 @@
#include "rtsp-media-factory-uri.h"
#define GST_RTSP_MEDIA_FACTORY_URI_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_RTSP_MEDIA_FACTORY_URI, GstRTSPMediaFactoryURIPrivate))
struct _GstRTSPMediaFactoryURIPrivate
{
GMutex lock;
gchar *uri;
gboolean use_gstpay;
GstCaps *raw_vcaps;
GstCaps *raw_acaps;
GList *demuxers;
GList *payloaders;
GList *decoders;
};
#define DEFAULT_URI NULL
#define DEFAULT_USE_GSTPAY FALSE
......@@ -156,41 +172,48 @@ payloader_filter (GstPluginFeature * feature, FilterData * data)
static void
gst_rtsp_media_factory_uri_init (GstRTSPMediaFactoryURI * factory)
{
GstRTSPMediaFactoryURIPrivate *priv =
GST_RTSP_MEDIA_FACTORY_URI_GET_PRIVATE (factory);
FilterData data = { NULL, NULL, NULL };
GST_DEBUG_OBJECT (factory, "new");
factory->uri = g_strdup (DEFAULT_URI);
factory->use_gstpay = DEFAULT_USE_GSTPAY;
factory->priv = priv;
priv->uri = g_strdup (DEFAULT_URI);
priv->use_gstpay = DEFAULT_USE_GSTPAY;
g_mutex_init (&priv->lock);
/* get the feature list using the filter */
gst_registry_feature_filter (gst_registry_get (), (GstPluginFeatureFilter)
payloader_filter, FALSE, &data);
/* sort */
factory->demuxers =
priv->demuxers =
g_list_sort (data.demux, gst_plugin_feature_rank_compare_func);
factory->payloaders =
priv->payloaders =
g_list_sort (data.payload, gst_plugin_feature_rank_compare_func);
factory->decoders =
priv->decoders =
g_list_sort (data.decode, gst_plugin_feature_rank_compare_func);
factory->raw_vcaps = gst_static_caps_get (&raw_video_caps);
factory->raw_acaps = gst_static_caps_get (&raw_audio_caps);
priv->raw_vcaps = gst_static_caps_get (&raw_video_caps);
priv->raw_acaps = gst_static_caps_get (&raw_audio_caps);
}
static void
gst_rtsp_media_factory_uri_finalize (GObject * obj)
{
GstRTSPMediaFactoryURI *factory = GST_RTSP_MEDIA_FACTORY_URI (obj);
GstRTSPMediaFactoryURIPrivate *priv = factory->priv;
GST_DEBUG_OBJECT (factory, "finalize");
g_free (factory->uri);
gst_plugin_feature_list_free (factory->demuxers);
gst_plugin_feature_list_free (factory->payloaders);
gst_plugin_feature_list_free (factory->decoders);
gst_caps_unref (factory->raw_vcaps);
gst_caps_unref (factory->raw_acaps);
g_free (priv->uri);
gst_plugin_feature_list_free (priv->demuxers);
gst_plugin_feature_list_free (priv->payloaders);
gst_plugin_feature_list_free (priv->decoders);
gst_caps_unref (priv->raw_vcaps);
gst_caps_unref (priv->raw_acaps);
g_mutex_clear (&priv->lock);
G_OBJECT_CLASS (gst_rtsp_media_factory_uri_parent_class)->finalize (obj);
}
......@@ -200,13 +223,14 @@ gst_rtsp_media_factory_uri_get_property (GObject * object, guint propid,
GValue * value, GParamSpec * pspec)
{
GstRTSPMediaFactoryURI *factory = GST_RTSP_MEDIA_FACTORY_URI (object);
GstRTSPMediaFactoryURIPrivate *priv = factory->priv;
switch (propid) {
case PROP_URI:
g_value_take_string (value, gst_rtsp_media_factory_uri_get_uri (factory));
break;
case PROP_USE_GSTPAY:
g_value_set_boolean (value, factory->use_gstpay);
g_value_set_boolean (value, priv->use_gstpay);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
......@@ -218,13 +242,14 @@ gst_rtsp_media_factory_uri_set_property (GObject * object, guint propid,
const GValue * value, GParamSpec * pspec)
{
GstRTSPMediaFactoryURI *factory = GST_RTSP_MEDIA_FACTORY_URI (object);
GstRTSPMediaFactoryURIPrivate *priv = factory->priv;
switch (propid) {
case PROP_URI:
gst_rtsp_media_factory_uri_set_uri (factory, g_value_get_string (value));
break;
case PROP_USE_GSTPAY:
factory->use_gstpay = g_value_get_boolean (value);
priv->use_gstpay = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
......@@ -259,13 +284,17 @@ void
gst_rtsp_media_factory_uri_set_uri (GstRTSPMediaFactoryURI * factory,
const gchar * uri)
{
GstRTSPMediaFactoryURIPrivate *priv;
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY_URI (factory));
g_return_if_fail (uri != NULL);
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
g_free (factory->uri);
factory->uri = g_strdup (uri);
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
priv = factory->priv;
g_mutex_lock (&priv->lock);
g_free (priv->uri);
priv->uri = g_strdup (uri);
g_mutex_unlock (&priv->lock);
}
/**
......@@ -279,13 +308,16 @@ gst_rtsp_media_factory_uri_set_uri (GstRTSPMediaFactoryURI * factory,
gchar *
gst_rtsp_media_factory_uri_get_uri (GstRTSPMediaFactoryURI * factory)
{
GstRTSPMediaFactoryURIPrivate *priv;
gchar *result;
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY_URI (factory), NULL);
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
result = g_strdup (factory->uri);
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
priv = factory->priv;
g_mutex_lock (&priv->lock);
result = g_strdup (priv->uri);
g_mutex_unlock (&priv->lock);
return result;
}
......@@ -293,12 +325,13 @@ gst_rtsp_media_factory_uri_get_uri (GstRTSPMediaFactoryURI * factory)
static GstElementFactory *
find_payloader (GstRTSPMediaFactoryURI * urifact, GstCaps * caps)
{
GstRTSPMediaFactoryURIPrivate *priv = urifact->priv;
GList *list;
GstElementFactory *factory = NULL;
gboolean autoplug_more = FALSE;
/* first find a demuxer that can link */
list = gst_element_factory_list_filter (urifact->demuxers, caps,
list = gst_element_factory_list_filter (priv->demuxers, caps,
GST_PAD_SINK, FALSE);
if (list) {
......@@ -340,17 +373,17 @@ find_payloader (GstRTSPMediaFactoryURI * urifact, GstCaps * caps)
return NULL;
/* no demuxer try a depayloader */
list = gst_element_factory_list_filter (urifact->payloaders, caps,
list = gst_element_factory_list_filter (priv->payloaders, caps,
GST_PAD_SINK, FALSE);
if (list == NULL) {
if (urifact->use_gstpay) {
if (priv->use_gstpay) {
/* no depayloader or parser/demuxer, use gstpay when allowed */
factory = gst_element_factory_find ("rtpgstpay");
} else {
/* no depayloader, try a decoder, we'll get to a payloader for a decoded
* video or audio format, worst case. */
list = gst_element_factory_list_filter (urifact->decoders, caps,
list = gst_element_factory_list_filter (priv->decoders, caps,
GST_PAD_SINK, FALSE);
if (list != NULL) {
......@@ -405,6 +438,7 @@ static void
pad_added_cb (GstElement * uribin, GstPad * pad, GstElement * element)
{
GstRTSPMediaFactoryURI *urifact;
GstRTSPMediaFactoryURIPrivate *priv;
FactoryData *data;
GstElementFactory *factory;
GstElement *payloader;
......@@ -418,6 +452,7 @@ pad_added_cb (GstElement * uribin, GstPad * pad, GstElement * element)
/* link the element now and expose the pad */
data = g_object_get_data (G_OBJECT (element), factory_key);
urifact = data->factory;
priv = urifact->priv;
/* ref to make refcounting easier later */
gst_object_ref (pad);
......@@ -429,10 +464,10 @@ pad_added_cb (GstElement * uribin, GstPad * pad, GstElement * element)
goto no_caps;
/* check for raw caps */
if (gst_caps_can_intersect (caps, urifact->raw_vcaps)) {
if (gst_caps_can_intersect (caps, priv->raw_vcaps)) {
/* we have raw video caps, insert converter */
convert = gst_element_factory_make ("videoconvert", NULL);
} else if (gst_caps_can_intersect (caps, urifact->raw_acaps)) {
} else if (gst_caps_can_intersect (caps, priv->raw_acaps)) {
/* we have raw audio caps, insert converter */
convert = gst_element_factory_make ("audioconvert", NULL);
} else {
......@@ -536,11 +571,13 @@ static GstElement *
rtsp_media_factory_uri_create_element (GstRTSPMediaFactory * factory,
const GstRTSPUrl * url)
{
GstRTSPMediaFactoryURIPrivate *priv;
GstElement *topbin, *element, *uribin;
GstRTSPMediaFactoryURI *urifact;
FactoryData *data;
urifact = GST_RTSP_MEDIA_FACTORY_URI_CAST (factory);
priv = urifact->priv;
GST_LOG ("creating element");
......@@ -555,7 +592,7 @@ rtsp_media_factory_uri_create_element (GstRTSPMediaFactory * factory,
if (uribin == NULL)
goto no_uridecodebin;
g_object_set (uribin, "uri", urifact->uri, NULL);
g_object_set (uribin, "uri", priv->uri, NULL);
/* keep factory data around */
data = g_new0 (FactoryData, 1);
......
......@@ -38,24 +38,17 @@ G_BEGIN_DECLS
typedef struct _GstRTSPMediaFactoryURI GstRTSPMediaFactoryURI;
typedef struct _GstRTSPMediaFactoryURIClass GstRTSPMediaFactoryURIClass;
typedef struct _GstRTSPMediaFactoryURIPrivate GstRTSPMediaFactoryURIPrivate;
/**
* GstRTSPMediaFactoryURI:
* @uri: the uri
*
* A media factory that creates a pipeline to play and uri.
*/
struct _GstRTSPMediaFactoryURI {
GstRTSPMediaFactory parent;
gchar *uri;
gboolean use_gstpay;
GstCaps *raw_vcaps;
GstCaps *raw_acaps;
GList *demuxers;
GList *payloaders;
GList *decoders;
GstRTSPMediaFactoryURIPrivate *priv;
};
/**
......
This diff is collapsed.
......@@ -41,24 +41,11 @@ G_BEGIN_DECLS
typedef struct _GstRTSPMediaFactory GstRTSPMediaFactory;
typedef struct _GstRTSPMediaFactoryClass GstRTSPMediaFactoryClass;
#define GST_RTSP_MEDIA_FACTORY_GET_LOCK(f) (&(GST_RTSP_MEDIA_FACTORY_CAST(f)->lock))
#define GST_RTSP_MEDIA_FACTORY_LOCK(f) (g_mutex_lock(GST_RTSP_MEDIA_FACTORY_GET_LOCK(f)))
#define GST_RTSP_MEDIA_FACTORY_UNLOCK(f) (g_mutex_unlock(GST_RTSP_MEDIA_FACTORY_GET_LOCK(f)))
typedef struct _GstRTSPMediaFactoryPrivate GstRTSPMediaFactoryPrivate;
/**
* GstRTSPMediaFactory:
* @parent: the parent GObject
* @lock: mutex protecting the datastructure.
* @launch: the launch description
* @shared: if media from this factory can be shared between clients
* @eos_shutdown: if shutdown should first send EOS to the pipeline
* @protocols: allowed transport protocols
* @auth: the authentication manager
* @buffer_size: the kernel udp buffer size
* @pool: the multicast address pool to use
* @medias_lock: mutex protecting the medias.
* @medias: hashtable of shared media
*
* The definition and logic for constructing the pipeline for a media. The media
* can contain multiple streams like audio and video.
......@@ -66,17 +53,7 @@ typedef struct _GstRTSPMediaFactoryClass GstRTSPMediaFactoryClass;
struct _GstRTSPMediaFactory {
GObject parent;
GMutex lock;
gchar *launch;
gboolean shared;
gboolean eos_shutdown;
GstRTSPLowerTrans protocols;
GstRTSPAuth *auth;
guint buffer_size;
GstRTSPAddressPool *pool;
GMutex medias_lock;
GHashTable *medias;
GstRTSPMediaFactoryPrivate *priv;
};
/**
......
This diff is collapsed.
......@@ -38,6 +38,7 @@ G_BEGIN_DECLS
typedef struct _GstRTSPMedia GstRTSPMedia;
typedef struct _GstRTSPMediaClass GstRTSPMediaClass;
typedef struct _GstRTSPMediaPrivate GstRTSPMediaPrivate;
#include "rtsp-stream.h"
#include "rtsp-auth.h"
......@@ -64,36 +65,6 @@ typedef enum {
/**
* GstRTSPMedia:
* @parent: parent GObject
* @lock: for protecting the object
* @cond: for signaling the object
* @shared: if this media can be shared between clients
* @reusable: if this media can be reused after an unprepare
* @protocols: the allowed lower transport for this stream
* @reused: if this media has been reused
* @is_ipv6: if this media is using ipv6
* @eos_shutdown: if EOS should be sent on shutdown
* @buffer_size: The UDP buffer size
* @auth: the authentication service in use
* @multicast_group: the multicast group to use
* @element: the data providing element, owned by @pipeline
* @streams: the different #GstRTSPStream provided by @element
* @dynamic: list of dynamic elements managed by @element
* @status: the status of the media pipeline
* @n_active: the number of active connections
* @adding: when elements are added to the pipeline
* @pipeline: the toplevel pipeline
* @fakesink: for making state changes async
* @source: the bus watch for pipeline messages.
* @id: the id of the watch
* @is_live: if the pipeline is live
* @seekable: if the pipeline can perform a seek
* @buffering: if the pipeline is buffering
* @target_state: the desired target state of the pipeline
* @rtpbin: the rtpbin
* @range: the range of the media being streamed
* @range_start: range start in #GstClockTime
* @range_stop: range stop in #GstClockTime
*
* A class that contains the GStreamer element along with a list of
* #GstRTSPStream objects that can produce data.
......@@ -103,45 +74,7 @@ typedef enum {
struct _GstRTSPMedia {
GObject parent;
GMutex lock;
GCond cond;
gboolean shared;
gboolean reusable;
GstRTSPLowerTrans protocols;
gboolean reused;
gboolean is_ipv6;
gboolean eos_shutdown;
guint buffer_size;
GstRTSPAuth *auth;
GstRTSPAddressPool*pool;
GstElement *element;
GRecMutex state_lock;
GPtrArray *streams;
GList *dynamic;
GstRTSPMediaStatus status;
gint n_active;
gboolean adding;
/* the pipeline for the media */
GstElement *pipeline;
GstElement *fakesink;
GSource *source;
guint id;
gboolean is_live;
gboolean seekable;
gboolean buffering;
GstState target_state;
/* RTP session manager */
GstElement *rtpbin;
/* the range of media */
GstRTSPTimeRange range;
GstClockTime range_start;
GstClockTime range_stop;
GstRTSPMediaPrivate *priv;
};
/**
......@@ -179,7 +112,11 @@ struct _GstRTSPMediaClass {
GType gst_rtsp_media_get_type (void);
/* creating the media */
GstRTSPMedia * gst_rtsp_media_new (void);
GstRTSPMedia * gst_rtsp_media_new (GstElement *element);
void gst_rtsp_media_take_pipeline (GstRTSPMedia *media, GstPipeline *pipeline);
GstRTSPMediaStatus gst_rtsp_media_get_status (GstRTSPMedia *media);
void gst_rtsp_media_set_shared (GstRTSPMedia *media, gboolean shared);
gboolean gst_rtsp_media_is_shared (GstRTSPMedia *media);
......
......@@ -19,6 +19,15 @@
#include "rtsp-mount-points.h"
#define GST_RTSP_MOUNT_POINTS_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_RTSP_MOUNT_POINTS, GstRTSPMountPointsPrivate))
struct _GstRTSPMountPointsPrivate
{
GMutex lock;
GHashTable *mounts;
};
G_DEFINE_TYPE (GstRTSPMountPoints, gst_rtsp_mount_points, G_TYPE_OBJECT);
GST_DEBUG_CATEGORY_STATIC (rtsp_media_debug);
......@@ -34,6 +43,8 @@ gst_rtsp_mount_points_class_init (GstRTSPMountPointsClass * klass)
{
GObjectClass *gobject_class;
g_type_class_add_private (klass, sizeof (GstRTSPMountPointsPrivate));
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = gst_rtsp_mount_points_finalize;
......@@ -47,10 +58,14 @@ gst_rtsp_mount_points_class_init (GstRTSPMountPointsClass * klass)
static void
gst_rtsp_mount_points_init (GstRTSPMountPoints * mounts)
{
GstRTSPMountPointsPrivate *priv = GST_RTSP_MOUNT_POINTS_GET_PRIVATE (mounts);
GST_DEBUG_OBJECT (mounts, "created");
g_mutex_init (&mounts->lock);
mounts->mounts = g_hash_table_new_full (g_str_hash, g_str_equal,
mounts->priv = priv;
g_mutex_init (&priv->lock);
priv->mounts = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_object_unref);
}
......@@ -58,11 +73,12 @@ static void
gst_rtsp_mount_points_finalize (GObject * obj)
{
GstRTSPMountPoints *mounts = GST_RTSP_MOUNT_POINTS (obj);
GstRTSPMountPointsPrivate *priv = mounts->priv;
GST_DEBUG_OBJECT (mounts, "finalized");
g_hash_table_unref (mounts->mounts);
g_mutex_clear (&mounts->lock);
g_hash_table_unref (priv->mounts);
g_mutex_clear (&priv->lock);
G_OBJECT_CLASS (gst_rtsp_mount_points_parent_class)->finalize (obj);
}
......@@ -87,16 +103,17 @@ gst_rtsp_mount_points_new (void)
static GstRTSPMediaFactory *
find_factory (GstRTSPMountPoints * mounts, const GstRTSPUrl * url)
{
GstRTSPMountPointsPrivate *priv = mounts->priv;
GstRTSPMediaFactory *result;
g_mutex_lock (&mounts->lock);
g_mutex_lock (&priv->lock);
/* find the location of the media in the hashtable we only use the absolute
* path of the uri to find a media factory. If the factory depends on other
* properties found in the url, this method should be overridden. */
result = g_hash_table_lookup (mounts->mounts, url->abspath);
result = g_hash_table_lookup (priv->mounts, url->abspath);
if (result)
g_object_ref (result);
g_mutex_unlock (&mounts->lock);
g_mutex_unlock (&priv->lock);
GST_INFO ("found media factory %p for url abspath %s", result, url->abspath);
......@@ -150,13 +167,17 @@ void
gst_rtsp_mount_points_add_factory (GstRTSPMountPoints * mounts,
const gchar * path, GstRTSPMediaFactory * factory)
{
GstRTSPMountPointsPrivate *priv;
g_return_if_fail (GST_IS_RTSP_MOUNT_POINTS (mounts));
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
g_return_if_fail (path != NULL);
g_mutex_lock (&mounts->lock);
g_hash_table_insert (mounts->mounts, g_strdup (path), factory);
g_mutex_unlock (&mounts->lock);
priv = mounts->priv;
g_mutex_lock (&priv->lock);
g_hash_table_insert (priv->mounts, g_strdup (path), factory);
g_mutex_unlock (&priv->lock);
}
/**
......@@ -170,10 +191,14 @@ void
gst_rtsp_mount_points_remove_factory (GstRTSPMountPoints * mounts,
const gchar * path)
{
GstRTSPMountPointsPrivate *priv;
g_return_if_fail (GST_IS_RTSP_MOUNT_POINTS (mounts));
g_return_if_fail (path != NULL);
g_mutex_lock (&mounts->lock);
g_hash_table_remove (mounts->mounts, path);
g_mutex_unlock (&mounts->lock);
priv = mounts->priv;