static void
gst_rtsp_session_init (GstRTSPSession * session)
{
+ g_mutex_init (&session->lock);
session->timeout = DEFAULT_TIMEOUT;
g_get_current_time (&session->create_time);
gst_rtsp_session_touch (session);
/* free session id */
g_free (session->sessionid);
+ g_mutex_clear (&session->lock);
G_OBJECT_CLASS (gst_rtsp_session_parent_class)->finalize (obj);
}
result = gst_rtsp_session_media_new (uri, media);
+ g_mutex_lock (&sess->lock);
sess->medias = g_list_prepend (sess->medias, result);
+ g_mutex_unlock (&sess->lock);
GST_INFO ("manage new media %p in session %p", media, result);
GstRTSPSessionMedia * media)
{
GList *find;
+ gboolean more;
g_return_val_if_fail (GST_IS_RTSP_SESSION (sess), FALSE);
g_return_val_if_fail (media != NULL, FALSE);
+ g_mutex_lock (&sess->lock);
find = g_list_find (sess->medias, media);
- if (find) {
- g_object_unref (find->data);
+ if (find)
sess->medias = g_list_delete_link (sess->medias, find);
- }
- return (sess->medias != NULL);
+ more = (sess->medias != NULL);
+ g_mutex_unlock (&sess->lock);
+
+ if (find)
+ g_object_unref (media);
+
+ return more;
}
/**
result = NULL;
+ g_mutex_lock (&sess->lock);
for (walk = sess->medias; walk; walk = g_list_next (walk)) {
result = (GstRTSPSessionMedia *) walk->data;
result = NULL;
}
+ g_mutex_unlock (&sess->lock);
+
return result;
}
g_return_val_if_fail (GST_IS_RTSP_SESSION (session), NULL);
+ g_mutex_lock (&session->lock);
if (session->timeout != 60)
result = g_strdup_printf ("%s; timeout=%d", session->sessionid,
session->timeout);
else
result = g_strdup (session->sessionid);
+ g_mutex_unlock (&session->lock);
return result;
}
{
g_return_if_fail (GST_IS_RTSP_SESSION (session));
+ g_mutex_lock (&session->lock);
session->timeout = timeout;
+ g_mutex_unlock (&session->lock);
}
/**
guint
gst_rtsp_session_get_timeout (GstRTSPSession * session)
{
+ guint res;
+
g_return_val_if_fail (GST_IS_RTSP_SESSION (session), 0);
- return session->timeout;
+ g_mutex_lock (&session->lock);
+ res = session->timeout;
+ g_mutex_unlock (&session->lock);
+
+ return res;
}
/**
{
g_return_if_fail (GST_IS_RTSP_SESSION (session));
+ g_mutex_lock (&session->lock);
g_get_current_time (&session->last_access);
+ g_mutex_unlock (&session->lock);
}
/**
g_return_val_if_fail (GST_IS_RTSP_SESSION (session), -1);
g_return_val_if_fail (now != NULL, -1);
+ g_mutex_lock (&session->lock);
if (g_atomic_int_get (&session->expire_count) != 0) {
/* touch session when the expire count is not 0 */
g_get_current_time (&session->last_access);
last_access = GST_TIMEVAL_TO_TIME (session->last_access);
/* add timeout allow for 5 seconds of extra time */
last_access += session->timeout * GST_SECOND + (5 * GST_SECOND);
+ g_mutex_unlock (&session->lock);
now_ns = GST_TIMEVAL_TO_TIME (*now);