2008-10-09 12:29:12 +00:00
|
|
|
/* 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., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2009-01-29 12:31:27 +00:00
|
|
|
#include <string.h>
|
2008-10-09 12:29:12 +00:00
|
|
|
|
|
|
|
#include "rtsp-session.h"
|
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
|
2009-02-04 18:52:50 +00:00
|
|
|
#define DEFAULT_TIMEOUT 60
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_SESSIONID,
|
|
|
|
PROP_TIMEOUT,
|
|
|
|
PROP_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
static void gst_rtsp_session_get_property (GObject *object, guint propid,
|
|
|
|
GValue *value, GParamSpec *pspec);
|
|
|
|
static void gst_rtsp_session_set_property (GObject *object, guint propid,
|
|
|
|
const GValue *value, GParamSpec *pspec);
|
2008-10-09 12:29:12 +00:00
|
|
|
static void gst_rtsp_session_finalize (GObject * obj);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GstRTSPSession, gst_rtsp_session, G_TYPE_OBJECT);
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_rtsp_session_class_init (GstRTSPSessionClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2009-02-04 18:52:50 +00:00
|
|
|
gobject_class->get_property = gst_rtsp_session_get_property;
|
|
|
|
gobject_class->set_property = gst_rtsp_session_set_property;
|
2008-10-09 12:29:12 +00:00
|
|
|
gobject_class->finalize = gst_rtsp_session_finalize;
|
2009-02-04 18:52:50 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_SESSIONID,
|
|
|
|
g_param_spec_string ("sessionid", "Sessionid", "the session id",
|
|
|
|
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, PROP_TIMEOUT,
|
|
|
|
g_param_spec_uint ("timeout", "timeout", "the timeout of the session (0 = never)",
|
|
|
|
0, G_MAXUINT, DEFAULT_TIMEOUT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2008-10-09 12:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_rtsp_session_init (GstRTSPSession * session)
|
|
|
|
{
|
2009-02-04 18:52:50 +00:00
|
|
|
session->timeout = DEFAULT_TIMEOUT;
|
|
|
|
g_get_current_time (&session->create_time);
|
|
|
|
gst_rtsp_session_touch (session);
|
2008-10-09 12:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-02-03 18:32:38 +00:00
|
|
|
gst_rtsp_session_free_stream (GstRTSPSessionStream *stream)
|
2008-10-09 12:29:12 +00:00
|
|
|
{
|
2009-02-04 16:00:42 +00:00
|
|
|
g_message ("free session stream %p", stream);
|
|
|
|
|
2009-02-03 18:32:38 +00:00
|
|
|
if (stream->trans.transport)
|
|
|
|
gst_rtsp_transport_free (stream->trans.transport);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
|
|
|
g_free (stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-01-29 17:55:22 +00:00
|
|
|
gst_rtsp_session_free_media (GstRTSPSessionMedia *media, GstRTSPSession *session)
|
2008-10-09 12:29:12 +00:00
|
|
|
{
|
2009-02-03 18:32:38 +00:00
|
|
|
guint size, i;
|
|
|
|
|
|
|
|
size = media->streams->len;
|
|
|
|
|
2009-02-04 16:00:42 +00:00
|
|
|
g_message ("free session media %p", media);
|
|
|
|
|
2009-02-13 11:57:45 +00:00
|
|
|
gst_rtsp_session_media_stop (media);
|
|
|
|
|
2009-02-03 18:32:38 +00:00
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
GstRTSPSessionStream *stream;
|
|
|
|
|
|
|
|
stream = g_array_index (media->streams, GstRTSPSessionStream *, i);
|
|
|
|
|
|
|
|
if (stream)
|
|
|
|
gst_rtsp_session_free_stream (stream);
|
|
|
|
}
|
|
|
|
g_array_free (media->streams, TRUE);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-01-29 17:55:22 +00:00
|
|
|
if (media->url)
|
|
|
|
gst_rtsp_url_free (media->url);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-01-29 17:55:22 +00:00
|
|
|
if (media->media)
|
|
|
|
g_object_unref (media->media);
|
|
|
|
|
|
|
|
g_free (media);
|
2008-10-09 12:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_rtsp_session_finalize (GObject * obj)
|
|
|
|
{
|
|
|
|
GstRTSPSession *session;
|
|
|
|
|
|
|
|
session = GST_RTSP_SESSION (obj);
|
|
|
|
|
2009-02-04 16:00:42 +00:00
|
|
|
g_message ("finalize session %p", session);
|
|
|
|
|
2009-01-29 17:55:22 +00:00
|
|
|
/* free all media */
|
|
|
|
g_list_foreach (session->medias, (GFunc) gst_rtsp_session_free_media,
|
|
|
|
session);
|
2008-10-09 12:29:12 +00:00
|
|
|
g_list_free (session->medias);
|
|
|
|
|
2009-01-29 17:55:22 +00:00
|
|
|
/* free session id */
|
|
|
|
g_free (session->sessionid);
|
|
|
|
|
2008-10-09 12:29:12 +00:00
|
|
|
G_OBJECT_CLASS (gst_rtsp_session_parent_class)->finalize (obj);
|
|
|
|
}
|
|
|
|
|
2009-02-04 18:52:50 +00:00
|
|
|
static void
|
|
|
|
gst_rtsp_session_get_property (GObject *object, guint propid,
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GstRTSPSession *session = GST_RTSP_SESSION (object);
|
|
|
|
|
|
|
|
switch (propid) {
|
|
|
|
case PROP_SESSIONID:
|
|
|
|
g_value_set_string (value, session->sessionid);
|
|
|
|
break;
|
|
|
|
case PROP_TIMEOUT:
|
|
|
|
g_value_set_uint (value, gst_rtsp_session_get_timeout (session));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_rtsp_session_set_property (GObject *object, guint propid,
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GstRTSPSession *session = GST_RTSP_SESSION (object);
|
|
|
|
|
|
|
|
switch (propid) {
|
|
|
|
case PROP_SESSIONID:
|
|
|
|
g_free (session->sessionid);
|
|
|
|
session->sessionid = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_TIMEOUT:
|
|
|
|
gst_rtsp_session_set_timeout (session, g_value_get_uint (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-29 12:31:27 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_session_manage_media:
|
|
|
|
* @sess: a #GstRTSPSession
|
|
|
|
* @url: the url for the media
|
2009-02-04 16:00:42 +00:00
|
|
|
* @media: a #GstRTSPMediaObject
|
2009-01-29 12:31:27 +00:00
|
|
|
*
|
|
|
|
* Manage the media object @obj in @sess. @url will be used to retrieve this
|
2009-02-04 16:00:42 +00:00
|
|
|
* media from the session with gst_rtsp_session_get_media().
|
|
|
|
*
|
|
|
|
* Ownership is taken from @media.
|
2009-01-29 12:31:27 +00:00
|
|
|
*
|
|
|
|
* Returns: a new @GstRTSPSessionMedia object.
|
|
|
|
*/
|
|
|
|
GstRTSPSessionMedia *
|
|
|
|
gst_rtsp_session_manage_media (GstRTSPSession *sess, const GstRTSPUrl *uri,
|
|
|
|
GstRTSPMedia *media)
|
|
|
|
{
|
|
|
|
GstRTSPSessionMedia *result;
|
2009-02-03 18:32:38 +00:00
|
|
|
guint n_streams;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_SESSION (sess), NULL);
|
|
|
|
g_return_val_if_fail (uri != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), NULL);
|
|
|
|
g_return_val_if_fail (media->prepared, NULL);
|
2009-01-29 12:31:27 +00:00
|
|
|
|
|
|
|
result = g_new0 (GstRTSPSessionMedia, 1);
|
|
|
|
result->media = media;
|
|
|
|
result->url = gst_rtsp_url_copy ((GstRTSPUrl *)uri);
|
2009-02-03 18:32:38 +00:00
|
|
|
result->state = GST_RTSP_STATE_INIT;
|
|
|
|
|
|
|
|
/* prealloc the streams now, filled with NULL */
|
|
|
|
n_streams = gst_rtsp_media_n_streams (media);
|
|
|
|
result->streams = g_array_sized_new (FALSE, TRUE, sizeof (GstRTSPSessionStream *), n_streams);
|
|
|
|
g_array_set_size (result->streams, n_streams);
|
2009-01-29 12:31:27 +00:00
|
|
|
|
|
|
|
sess->medias = g_list_prepend (sess->medias, result);
|
|
|
|
|
2009-02-04 16:00:42 +00:00
|
|
|
g_message ("manage new media %p in session %p", media, result);
|
2009-01-29 12:31:27 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-02-04 16:00:42 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_session_release_media:
|
|
|
|
* @sess: a #GstRTSPSession
|
|
|
|
* @media: a #GstRTSPMediaObject
|
|
|
|
*
|
|
|
|
* Release the managed @media in @sess, freeing the memory allocated by it.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if there are more media session left in @sess.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_rtsp_session_release_media (GstRTSPSession *sess,
|
|
|
|
GstRTSPSessionMedia *media)
|
|
|
|
{
|
|
|
|
GList *walk, *next;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_SESSION (sess), FALSE);
|
|
|
|
g_return_val_if_fail (media != NULL, FALSE);
|
|
|
|
|
|
|
|
for (walk = sess->medias; walk;) {
|
|
|
|
GstRTSPSessionMedia *find;
|
|
|
|
|
|
|
|
find = (GstRTSPSessionMedia *) walk->data;
|
|
|
|
next = g_list_next (walk);
|
|
|
|
|
|
|
|
if (find == media) {
|
|
|
|
sess->medias = g_list_delete_link (sess->medias, walk);
|
|
|
|
|
|
|
|
gst_rtsp_session_free_media (find, sess);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
walk = next;
|
|
|
|
}
|
|
|
|
return (sess->medias != NULL);
|
|
|
|
}
|
|
|
|
|
2008-10-09 12:29:12 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_session_get_media:
|
|
|
|
* @sess: a #GstRTSPSession
|
2009-01-22 16:58:19 +00:00
|
|
|
* @url: the url for the media
|
2008-10-09 12:29:12 +00:00
|
|
|
*
|
2009-01-29 12:31:27 +00:00
|
|
|
* Get the session media of the @url.
|
2008-10-09 12:29:12 +00:00
|
|
|
*
|
2009-02-04 16:00:42 +00:00
|
|
|
* Returns: the configuration for @url in @sess.
|
2008-10-09 12:29:12 +00:00
|
|
|
*/
|
|
|
|
GstRTSPSessionMedia *
|
2009-01-29 12:31:27 +00:00
|
|
|
gst_rtsp_session_get_media (GstRTSPSession *sess, const GstRTSPUrl *url)
|
2008-10-09 12:29:12 +00:00
|
|
|
{
|
|
|
|
GstRTSPSessionMedia *result;
|
|
|
|
GList *walk;
|
|
|
|
|
2009-01-29 12:31:27 +00:00
|
|
|
g_return_val_if_fail (GST_IS_RTSP_SESSION (sess), NULL);
|
|
|
|
g_return_val_if_fail (url != NULL, NULL);
|
|
|
|
|
2008-10-23 10:14:55 +00:00
|
|
|
result = NULL;
|
|
|
|
|
2008-10-09 12:29:12 +00:00
|
|
|
for (walk = sess->medias; walk; walk = g_list_next (walk)) {
|
|
|
|
result = (GstRTSPSessionMedia *) walk->data;
|
|
|
|
|
2009-01-29 12:31:27 +00:00
|
|
|
if (strcmp (result->url->abspath, url->abspath) == 0)
|
2008-10-09 12:29:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
result = NULL;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-01-22 14:33:29 +00:00
|
|
|
* gst_rtsp_session_media_get_stream:
|
2008-10-09 12:29:12 +00:00
|
|
|
* @media: a #GstRTSPSessionMedia
|
|
|
|
* @idx: the stream index
|
|
|
|
*
|
|
|
|
* Get a previously created or create a new #GstRTSPSessionStream at @idx.
|
|
|
|
*
|
|
|
|
* Returns: a #GstRTSPSessionStream that is valid until the session of @media
|
|
|
|
* is unreffed.
|
|
|
|
*/
|
|
|
|
GstRTSPSessionStream *
|
2009-01-22 14:33:29 +00:00
|
|
|
gst_rtsp_session_media_get_stream (GstRTSPSessionMedia *media, guint idx)
|
2008-10-09 12:29:12 +00:00
|
|
|
{
|
|
|
|
GstRTSPSessionStream *result;
|
2009-01-29 17:55:22 +00:00
|
|
|
GstRTSPMediaStream *media_stream;
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-01-29 17:55:22 +00:00
|
|
|
g_return_val_if_fail (media != NULL, NULL);
|
|
|
|
g_return_val_if_fail (media->media != NULL, NULL);
|
|
|
|
|
2009-02-03 18:32:38 +00:00
|
|
|
if (idx >= media->streams->len)
|
|
|
|
return NULL;
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-02-03 18:32:38 +00:00
|
|
|
result = g_array_index (media->streams, GstRTSPSessionStream *, idx);
|
2008-10-09 12:29:12 +00:00
|
|
|
if (result == NULL) {
|
2009-02-03 18:32:38 +00:00
|
|
|
media_stream = gst_rtsp_media_get_stream (media->media, idx);
|
|
|
|
if (media_stream == NULL)
|
|
|
|
goto no_media;
|
|
|
|
|
2008-10-09 12:29:12 +00:00
|
|
|
result = g_new0 (GstRTSPSessionStream, 1);
|
2009-02-03 18:32:38 +00:00
|
|
|
result->trans.idx = idx;
|
|
|
|
result->trans.transport = NULL;
|
2009-01-29 17:55:22 +00:00
|
|
|
result->media_stream = media_stream;
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-02-03 18:32:38 +00:00
|
|
|
g_array_insert_val (media->streams, idx, result);
|
2008-10-09 12:29:12 +00:00
|
|
|
}
|
|
|
|
return result;
|
2009-01-29 17:55:22 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
no_media:
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-10-09 12:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_session_new:
|
|
|
|
*
|
|
|
|
* Create a new #GstRTSPSession instance.
|
|
|
|
*/
|
|
|
|
GstRTSPSession *
|
|
|
|
gst_rtsp_session_new (const gchar *sessionid)
|
|
|
|
{
|
|
|
|
GstRTSPSession *result;
|
|
|
|
|
2009-02-04 18:52:50 +00:00
|
|
|
g_return_val_if_fail (sessionid != NULL, NULL);
|
|
|
|
|
|
|
|
result = g_object_new (GST_TYPE_RTSP_SESSION, "sessionid", sessionid, NULL);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-02-04 18:52:50 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_session_get_sessionid:
|
|
|
|
* @session: a #GstRTSPSession
|
|
|
|
*
|
|
|
|
* Get the sessionid of @session.
|
|
|
|
*
|
|
|
|
* Returns: the sessionid of @session. The value remains valid as long as
|
|
|
|
* @session is alive.
|
|
|
|
*/
|
|
|
|
const gchar *
|
|
|
|
gst_rtsp_session_get_sessionid (GstRTSPSession *session)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_SESSION (session), NULL);
|
|
|
|
|
|
|
|
return session->sessionid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_session_set_timeout:
|
|
|
|
* @session: a #GstRTSPSession
|
|
|
|
* @timeout: the new timeout
|
|
|
|
*
|
|
|
|
* Configure @session for a timeout of @timeout seconds. The session will be
|
|
|
|
* cleaned up when there is no activity for @timeout seconds.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_session_set_timeout (GstRTSPSession *session, guint timeout)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_RTSP_SESSION (session));
|
|
|
|
|
|
|
|
session->timeout = timeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_session_get_timeout:
|
|
|
|
* @session: a #GstRTSPSession
|
|
|
|
*
|
|
|
|
* Get the timeout value of @session.
|
|
|
|
*
|
|
|
|
* Returns: the timeout of @session in seconds.
|
|
|
|
*/
|
|
|
|
guint
|
|
|
|
gst_rtsp_session_get_timeout (GstRTSPSession *session)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_SESSION (session), 0);
|
|
|
|
|
|
|
|
return session->timeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_session_touch:
|
|
|
|
* @session: a #GstRTSPSession
|
|
|
|
*
|
|
|
|
* Update the last_access time of the session to the current time.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_rtsp_session_touch (GstRTSPSession *session)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_RTSP_SESSION (session));
|
|
|
|
|
|
|
|
g_get_current_time (&session->last_access);
|
|
|
|
}
|
|
|
|
|
2009-02-04 19:10:39 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_session_is_expired:
|
|
|
|
* @session: a #GstRTSPSession
|
|
|
|
*
|
|
|
|
* Check if @session timeout out.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @session timed out
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_rtsp_session_is_expired (GstRTSPSession *session)
|
|
|
|
{
|
|
|
|
gboolean res;
|
|
|
|
GstClockTime last_access, now_ns;
|
|
|
|
GTimeVal now;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_RTSP_SESSION (session), FALSE);
|
|
|
|
|
|
|
|
last_access = GST_TIMEVAL_TO_TIME (session->last_access);
|
|
|
|
/* add timeout */
|
|
|
|
last_access += session->timeout * GST_SECOND;
|
|
|
|
|
|
|
|
g_get_current_time (&now);
|
|
|
|
now_ns = GST_TIMEVAL_TO_TIME (now);
|
|
|
|
|
|
|
|
res = now_ns > last_access;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2008-10-09 12:29:12 +00:00
|
|
|
/**
|
|
|
|
* gst_rtsp_session_stream_init_udp:
|
|
|
|
* @stream: a #GstRTSPSessionStream
|
|
|
|
* @ct: a client #GstRTSPTransport
|
|
|
|
*
|
|
|
|
* Set @ct as the client transport and create and return a matching server
|
2009-01-29 12:31:27 +00:00
|
|
|
* transport.
|
2008-10-09 12:29:12 +00:00
|
|
|
*
|
|
|
|
* Returns: a server transport or NULL if something went wrong.
|
|
|
|
*/
|
|
|
|
GstRTSPTransport *
|
|
|
|
gst_rtsp_session_stream_set_transport (GstRTSPSessionStream *stream,
|
2009-01-29 12:31:27 +00:00
|
|
|
GstRTSPTransport *ct)
|
2008-10-09 12:29:12 +00:00
|
|
|
{
|
|
|
|
GstRTSPTransport *st;
|
|
|
|
|
2009-02-04 18:52:50 +00:00
|
|
|
g_return_val_if_fail (stream != NULL, NULL);
|
|
|
|
g_return_val_if_fail (ct != NULL, NULL);
|
|
|
|
|
2008-10-09 12:29:12 +00:00
|
|
|
/* prepare the server transport */
|
|
|
|
gst_rtsp_transport_new (&st);
|
|
|
|
|
|
|
|
st->trans = ct->trans;
|
|
|
|
st->profile = ct->profile;
|
|
|
|
st->lower_transport = ct->lower_transport;
|
|
|
|
st->client_port = ct->client_port;
|
|
|
|
|
|
|
|
/* keep track of the transports */
|
2009-02-03 18:32:38 +00:00
|
|
|
if (stream->trans.transport)
|
|
|
|
gst_rtsp_transport_free (stream->trans.transport);
|
|
|
|
stream->trans.transport = ct;
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-01-29 12:31:27 +00:00
|
|
|
st->server_port.min = stream->media_stream->server_port.min;
|
|
|
|
st->server_port.max = stream->media_stream->server_port.max;
|
2008-10-09 12:29:12 +00:00
|
|
|
|
|
|
|
return st;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_session_media_play:
|
|
|
|
* @media: a #GstRTSPSessionMedia
|
|
|
|
*
|
|
|
|
* Tell the media object @media to start playing and streaming to the client.
|
|
|
|
*
|
2009-02-03 18:32:38 +00:00
|
|
|
* Returns: %TRUE on success.
|
2008-10-09 12:29:12 +00:00
|
|
|
*/
|
2009-02-03 18:32:38 +00:00
|
|
|
gboolean
|
2008-10-09 12:29:12 +00:00
|
|
|
gst_rtsp_session_media_play (GstRTSPSessionMedia *media)
|
|
|
|
{
|
2009-02-03 18:32:38 +00:00
|
|
|
gboolean ret;
|
2009-01-29 12:31:27 +00:00
|
|
|
|
2009-02-04 18:52:50 +00:00
|
|
|
g_return_val_if_fail (media != NULL, FALSE);
|
|
|
|
|
2009-02-03 18:32:38 +00:00
|
|
|
ret = gst_rtsp_media_play (media->media, media->streams);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_session_media_pause:
|
|
|
|
* @media: a #GstRTSPSessionMedia
|
|
|
|
*
|
|
|
|
* Tell the media object @media to pause.
|
|
|
|
*
|
2009-02-03 18:32:38 +00:00
|
|
|
* Returns: %TRUE on success.
|
2008-10-09 12:29:12 +00:00
|
|
|
*/
|
2009-02-03 18:32:38 +00:00
|
|
|
gboolean
|
2008-10-09 12:29:12 +00:00
|
|
|
gst_rtsp_session_media_pause (GstRTSPSessionMedia *media)
|
|
|
|
{
|
2009-02-03 18:32:38 +00:00
|
|
|
gboolean ret;
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-02-04 18:52:50 +00:00
|
|
|
g_return_val_if_fail (media != NULL, FALSE);
|
|
|
|
|
2009-02-03 18:32:38 +00:00
|
|
|
ret = gst_rtsp_media_pause (media->media, media->streams);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_rtsp_session_media_stop:
|
|
|
|
* @media: a #GstRTSPSessionMedia
|
|
|
|
*
|
|
|
|
* Tell the media object @media to stop playing. After this call the media
|
|
|
|
* cannot be played or paused anymore
|
|
|
|
*
|
2009-02-03 18:32:38 +00:00
|
|
|
* Returns: %TRUE on success.
|
2008-10-09 12:29:12 +00:00
|
|
|
*/
|
2009-02-03 18:32:38 +00:00
|
|
|
gboolean
|
2008-10-09 12:29:12 +00:00
|
|
|
gst_rtsp_session_media_stop (GstRTSPSessionMedia *media)
|
|
|
|
{
|
2009-02-03 18:32:38 +00:00
|
|
|
gboolean ret;
|
2008-10-09 12:29:12 +00:00
|
|
|
|
2009-02-04 18:52:50 +00:00
|
|
|
g_return_val_if_fail (media != NULL, FALSE);
|
|
|
|
|
2009-02-03 18:32:38 +00:00
|
|
|
ret = gst_rtsp_media_stop (media->media, media->streams);
|
2008-10-09 12:29:12 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|