mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 10:40:34 +00:00
rtsp-server: Run gst-indent
Since it wasn't using the upstream common previously, there was no indentation check before commiting.
This commit is contained in:
parent
b95165fcff
commit
eb83fc6318
9 changed files with 239 additions and 189 deletions
|
@ -49,7 +49,7 @@ static void gst_rtsp_client_finalize (GObject * obj);
|
|||
static void client_session_finalized (GstRTSPClient * client,
|
||||
GstRTSPSession * session);
|
||||
static void unlink_session_streams (GstRTSPClient * client,
|
||||
GstRTSPSession *session, GstRTSPSessionMedia * media);
|
||||
GstRTSPSession * session, GstRTSPSessionMedia * media);
|
||||
|
||||
G_DEFINE_TYPE (GstRTSPClient, gst_rtsp_client, G_TYPE_OBJECT);
|
||||
|
||||
|
@ -89,18 +89,19 @@ gst_rtsp_client_init (GstRTSPClient * client)
|
|||
}
|
||||
|
||||
static void
|
||||
client_unlink_session (GstRTSPClient *client, GstRTSPSession *session)
|
||||
client_unlink_session (GstRTSPClient * client, GstRTSPSession * session)
|
||||
{
|
||||
GList *medias;
|
||||
|
||||
/* unlink all media managed in this session */
|
||||
for (medias = session->medias; medias; medias = g_list_next (medias)) {
|
||||
unlink_session_streams (client, session, (GstRTSPSessionMedia *) medias->data);
|
||||
unlink_session_streams (client, session,
|
||||
(GstRTSPSessionMedia *) medias->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
client_cleanup_sessions (GstRTSPClient *client)
|
||||
client_cleanup_sessions (GstRTSPClient * client)
|
||||
{
|
||||
GList *sessions;
|
||||
|
||||
|
@ -350,7 +351,8 @@ do_send_data (GstBuffer * buffer, guint8 channel, GstRTSPClient * client)
|
|||
}
|
||||
|
||||
static void
|
||||
link_stream (GstRTSPClient * client, GstRTSPSession *session, GstRTSPSessionStream * stream)
|
||||
link_stream (GstRTSPClient * client, GstRTSPSession * session,
|
||||
GstRTSPSessionStream * stream)
|
||||
{
|
||||
GST_DEBUG ("client %p: linking stream %p", client, stream);
|
||||
gst_rtsp_session_stream_set_callbacks (stream, (GstRTSPSendFunc) do_send_data,
|
||||
|
@ -361,7 +363,8 @@ link_stream (GstRTSPClient * client, GstRTSPSession *session, GstRTSPSessionStre
|
|||
}
|
||||
|
||||
static void
|
||||
unlink_stream (GstRTSPClient * client, GstRTSPSession *session, GstRTSPSessionStream * stream)
|
||||
unlink_stream (GstRTSPClient * client, GstRTSPSession * session,
|
||||
GstRTSPSessionStream * stream)
|
||||
{
|
||||
GST_DEBUG ("client %p: unlinking stream %p", client, stream);
|
||||
gst_rtsp_session_stream_set_callbacks (stream, NULL, NULL, NULL, NULL);
|
||||
|
@ -371,7 +374,8 @@ unlink_stream (GstRTSPClient * client, GstRTSPSession *session, GstRTSPSessionSt
|
|||
}
|
||||
|
||||
static void
|
||||
unlink_session_streams (GstRTSPClient * client, GstRTSPSession *session, GstRTSPSessionMedia * media)
|
||||
unlink_session_streams (GstRTSPClient * client, GstRTSPSession * session,
|
||||
GstRTSPSessionMedia * media)
|
||||
{
|
||||
guint n_streams, i;
|
||||
|
||||
|
@ -396,7 +400,7 @@ unlink_session_streams (GstRTSPClient * client, GstRTSPSession *session, GstRTSP
|
|||
static void
|
||||
close_connection (GstRTSPClient * client)
|
||||
{
|
||||
const gchar * tunnelid;
|
||||
const gchar *tunnelid;
|
||||
|
||||
GST_DEBUG ("client %p: closing connection", client);
|
||||
|
||||
|
@ -1163,7 +1167,8 @@ client_session_finalized (GstRTSPClient * client, GstRTSPSession * session)
|
|||
|
||||
/* remove the session */
|
||||
if (!(client->sessions = g_list_remove (client->sessions, session))) {
|
||||
GST_INFO ("client %p: all sessions finalized, close the connection", client);
|
||||
GST_INFO ("client %p: all sessions finalized, close the connection",
|
||||
client);
|
||||
close_connection (client);
|
||||
}
|
||||
}
|
||||
|
@ -1550,7 +1555,8 @@ no_tunnelid:
|
|||
tunnel_existed:
|
||||
{
|
||||
g_mutex_unlock (tunnels_lock);
|
||||
GST_ERROR ("client %p: tunnel session %s already existed", client, tunnelid);
|
||||
GST_ERROR ("client %p: tunnel session %s already existed", client,
|
||||
tunnelid);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1562,7 +1568,8 @@ tunnel_start (GstRTSPWatch * watch, gpointer user_data)
|
|||
|
||||
client = GST_RTSP_CLIENT (user_data);
|
||||
|
||||
GST_INFO ("client %p: tunnel start (connection %p)", client, client->connection);
|
||||
GST_INFO ("client %p: tunnel start (connection %p)", client,
|
||||
client->connection);
|
||||
|
||||
if (!remember_tunnel (client))
|
||||
goto tunnel_error;
|
||||
|
@ -1584,7 +1591,8 @@ tunnel_lost (GstRTSPWatch * watch, gpointer user_data)
|
|||
|
||||
client = GST_RTSP_CLIENT (user_data);
|
||||
|
||||
GST_INFO ("client %p: tunnel lost (connection %p)", client, client->connection);
|
||||
GST_INFO ("client %p: tunnel lost (connection %p)", client,
|
||||
client->connection);
|
||||
|
||||
/* ignore error, it'll only be a problem when the client does a POST again */
|
||||
remember_tunnel (client);
|
||||
|
|
|
@ -35,17 +35,22 @@ enum
|
|||
GST_DEBUG_CATEGORY (rtsp_media_debug);
|
||||
#define GST_CAT_DEFAULT rtsp_media_debug
|
||||
|
||||
static void gst_rtsp_media_factory_get_property (GObject *object, guint propid,
|
||||
GValue *value, GParamSpec *pspec);
|
||||
static void gst_rtsp_media_factory_set_property (GObject *object, guint propid,
|
||||
const GValue *value, GParamSpec *pspec);
|
||||
static void gst_rtsp_media_factory_get_property (GObject * object, guint propid,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
static void gst_rtsp_media_factory_set_property (GObject * object, guint propid,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_rtsp_media_factory_finalize (GObject * obj);
|
||||
|
||||
static gchar * default_gen_key (GstRTSPMediaFactory *factory, const GstRTSPUrl *url);
|
||||
static GstElement * default_get_element (GstRTSPMediaFactory *factory, const GstRTSPUrl *url);
|
||||
static GstRTSPMedia * default_construct (GstRTSPMediaFactory *factory, const GstRTSPUrl *url);
|
||||
static void default_configure (GstRTSPMediaFactory *factory, GstRTSPMedia *media);
|
||||
static GstElement* default_create_pipeline (GstRTSPMediaFactory *factory, GstRTSPMedia *media);
|
||||
static gchar *default_gen_key (GstRTSPMediaFactory * factory,
|
||||
const GstRTSPUrl * url);
|
||||
static GstElement *default_get_element (GstRTSPMediaFactory * factory,
|
||||
const GstRTSPUrl * url);
|
||||
static GstRTSPMedia *default_construct (GstRTSPMediaFactory * factory,
|
||||
const GstRTSPUrl * url);
|
||||
static void default_configure (GstRTSPMediaFactory * factory,
|
||||
GstRTSPMedia * media);
|
||||
static GstElement *default_create_pipeline (GstRTSPMediaFactory * factory,
|
||||
GstRTSPMedia * media);
|
||||
|
||||
G_DEFINE_TYPE (GstRTSPMediaFactory, gst_rtsp_media_factory, G_TYPE_OBJECT);
|
||||
|
||||
|
@ -77,16 +82,18 @@ gst_rtsp_media_factory_class_init (GstRTSPMediaFactoryClass * klass)
|
|||
* named dynpay0, dynpay1, etc..
|
||||
*/
|
||||
g_object_class_install_property (gobject_class, PROP_LAUNCH,
|
||||
g_param_spec_string ("launch", "Launch", "A launch description of the pipeline",
|
||||
DEFAULT_LAUNCH, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string ("launch", "Launch",
|
||||
"A launch description of the pipeline", DEFAULT_LAUNCH,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_SHARED,
|
||||
g_param_spec_boolean ("shared", "Shared", "If media from this factory is shared",
|
||||
DEFAULT_SHARED, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boolean ("shared", "Shared",
|
||||
"If media from this factory is shared", DEFAULT_SHARED,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_EOS_SHUTDOWN,
|
||||
g_param_spec_boolean ("eos-shutdown", "EOS Shutdown",
|
||||
"Send EOS down the pipeline before shutting down",
|
||||
"Send EOS down the pipeline before shutting down",
|
||||
DEFAULT_EOS_SHUTDOWN, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
klass->gen_key = default_gen_key;
|
||||
|
@ -108,7 +115,7 @@ gst_rtsp_media_factory_init (GstRTSPMediaFactory * factory)
|
|||
factory->lock = g_mutex_new ();
|
||||
factory->medias_lock = g_mutex_new ();
|
||||
factory->medias = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, g_object_unref);
|
||||
g_free, g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -125,8 +132,8 @@ gst_rtsp_media_factory_finalize (GObject * obj)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_rtsp_media_factory_get_property (GObject *object, guint propid,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
gst_rtsp_media_factory_get_property (GObject * object, guint propid,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstRTSPMediaFactory *factory = GST_RTSP_MEDIA_FACTORY (object);
|
||||
|
||||
|
@ -138,7 +145,8 @@ gst_rtsp_media_factory_get_property (GObject *object, guint propid,
|
|||
g_value_set_boolean (value, gst_rtsp_media_factory_is_shared (factory));
|
||||
break;
|
||||
case PROP_EOS_SHUTDOWN:
|
||||
g_value_set_boolean (value, gst_rtsp_media_factory_is_eos_shutdown (factory));
|
||||
g_value_set_boolean (value,
|
||||
gst_rtsp_media_factory_is_eos_shutdown (factory));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
|
||||
|
@ -146,8 +154,8 @@ gst_rtsp_media_factory_get_property (GObject *object, guint propid,
|
|||
}
|
||||
|
||||
static void
|
||||
gst_rtsp_media_factory_set_property (GObject *object, guint propid,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
gst_rtsp_media_factory_set_property (GObject * object, guint propid,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstRTSPMediaFactory *factory = GST_RTSP_MEDIA_FACTORY (object);
|
||||
|
||||
|
@ -159,7 +167,8 @@ gst_rtsp_media_factory_set_property (GObject *object, guint propid,
|
|||
gst_rtsp_media_factory_set_shared (factory, g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_EOS_SHUTDOWN:
|
||||
gst_rtsp_media_factory_set_eos_shutdown (factory, g_value_get_boolean (value));
|
||||
gst_rtsp_media_factory_set_eos_shutdown (factory,
|
||||
g_value_get_boolean (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propid, pspec);
|
||||
|
@ -200,7 +209,8 @@ gst_rtsp_media_factory_new (void)
|
|||
* etc.. Each of the payloaders will result in a stream.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_media_factory_set_launch (GstRTSPMediaFactory *factory, const gchar *launch)
|
||||
gst_rtsp_media_factory_set_launch (GstRTSPMediaFactory * factory,
|
||||
const gchar * launch)
|
||||
{
|
||||
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
||||
g_return_if_fail (launch != NULL);
|
||||
|
@ -221,7 +231,7 @@ gst_rtsp_media_factory_set_launch (GstRTSPMediaFactory *factory, const gchar *la
|
|||
* Returns: the configured launch description. g_free() after usage.
|
||||
*/
|
||||
gchar *
|
||||
gst_rtsp_media_factory_get_launch (GstRTSPMediaFactory *factory)
|
||||
gst_rtsp_media_factory_get_launch (GstRTSPMediaFactory * factory)
|
||||
{
|
||||
gchar *result;
|
||||
|
||||
|
@ -242,7 +252,7 @@ gst_rtsp_media_factory_get_launch (GstRTSPMediaFactory *factory)
|
|||
* Configure if media created from this factory can be shared between clients.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_media_factory_set_shared (GstRTSPMediaFactory *factory,
|
||||
gst_rtsp_media_factory_set_shared (GstRTSPMediaFactory * factory,
|
||||
gboolean shared)
|
||||
{
|
||||
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
||||
|
@ -261,7 +271,7 @@ gst_rtsp_media_factory_set_shared (GstRTSPMediaFactory *factory,
|
|||
* Returns: %TRUE if the media will be shared between clients.
|
||||
*/
|
||||
gboolean
|
||||
gst_rtsp_media_factory_is_shared (GstRTSPMediaFactory *factory)
|
||||
gst_rtsp_media_factory_is_shared (GstRTSPMediaFactory * factory)
|
||||
{
|
||||
gboolean result;
|
||||
|
||||
|
@ -283,7 +293,7 @@ gst_rtsp_media_factory_is_shared (GstRTSPMediaFactory *factory)
|
|||
* pipeline before shutdown.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_media_factory_set_eos_shutdown (GstRTSPMediaFactory *factory,
|
||||
gst_rtsp_media_factory_set_eos_shutdown (GstRTSPMediaFactory * factory,
|
||||
gboolean eos_shutdown)
|
||||
{
|
||||
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
||||
|
@ -303,7 +313,7 @@ gst_rtsp_media_factory_set_eos_shutdown (GstRTSPMediaFactory *factory,
|
|||
* Returns: %TRUE if the media will receive EOS before shutdown.
|
||||
*/
|
||||
gboolean
|
||||
gst_rtsp_media_factory_is_eos_shutdown (GstRTSPMediaFactory *factory)
|
||||
gst_rtsp_media_factory_is_eos_shutdown (GstRTSPMediaFactory * factory)
|
||||
{
|
||||
gboolean result;
|
||||
|
||||
|
@ -317,17 +327,16 @@ gst_rtsp_media_factory_is_eos_shutdown (GstRTSPMediaFactory *factory)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
compare_media (gpointer key, GstRTSPMedia *media1, GstRTSPMedia *media2)
|
||||
compare_media (gpointer key, GstRTSPMedia * media1, GstRTSPMedia * media2)
|
||||
{
|
||||
return (media1 == media2);
|
||||
}
|
||||
|
||||
static void
|
||||
media_unprepared (GstRTSPMedia *media, GstRTSPMediaFactory *factory)
|
||||
media_unprepared (GstRTSPMedia * media, GstRTSPMediaFactory * factory)
|
||||
{
|
||||
g_mutex_lock (factory->medias_lock);
|
||||
g_hash_table_foreach_remove (factory->medias, (GHRFunc) compare_media,
|
||||
media);
|
||||
g_hash_table_foreach_remove (factory->medias, (GHRFunc) compare_media, media);
|
||||
g_mutex_unlock (factory->medias_lock);
|
||||
}
|
||||
|
||||
|
@ -347,7 +356,8 @@ media_unprepared (GstRTSPMedia *media, GstRTSPMediaFactory *factory)
|
|||
* Returns: a new #GstRTSPMedia if the media could be prepared.
|
||||
*/
|
||||
GstRTSPMedia *
|
||||
gst_rtsp_media_factory_construct (GstRTSPMediaFactory *factory, const GstRTSPUrl *url)
|
||||
gst_rtsp_media_factory_construct (GstRTSPMediaFactory * factory,
|
||||
const GstRTSPUrl * url)
|
||||
{
|
||||
gchar *key;
|
||||
GstRTSPMedia *media;
|
||||
|
@ -368,8 +378,7 @@ gst_rtsp_media_factory_construct (GstRTSPMediaFactory *factory, const GstRTSPUrl
|
|||
media = g_hash_table_lookup (factory->medias, key);
|
||||
if (media)
|
||||
g_object_ref (media);
|
||||
}
|
||||
else
|
||||
} else
|
||||
media = NULL;
|
||||
|
||||
if (media == NULL) {
|
||||
|
@ -392,10 +401,10 @@ gst_rtsp_media_factory_construct (GstRTSPMediaFactory *factory, const GstRTSPUrl
|
|||
key = NULL;
|
||||
}
|
||||
if (!gst_rtsp_media_is_reusable (media)) {
|
||||
/* when not reusable, connect to the unprepare signal to remove the item
|
||||
* from our cache when it gets unprepared */
|
||||
g_signal_connect (media, "unprepared", (GCallback) media_unprepared,
|
||||
factory);
|
||||
/* when not reusable, connect to the unprepare signal to remove the item
|
||||
* from our cache when it gets unprepared */
|
||||
g_signal_connect (media, "unprepared", (GCallback) media_unprepared,
|
||||
factory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -410,7 +419,7 @@ gst_rtsp_media_factory_construct (GstRTSPMediaFactory *factory, const GstRTSPUrl
|
|||
}
|
||||
|
||||
static gchar *
|
||||
default_gen_key (GstRTSPMediaFactory *factory, const GstRTSPUrl *url)
|
||||
default_gen_key (GstRTSPMediaFactory * factory, const GstRTSPUrl * url)
|
||||
{
|
||||
gchar *result;
|
||||
const gchar *pre_query;
|
||||
|
@ -419,13 +428,14 @@ default_gen_key (GstRTSPMediaFactory *factory, const GstRTSPUrl *url)
|
|||
pre_query = url->query ? "?" : "";
|
||||
query = url->query ? url->query : "";
|
||||
|
||||
result = g_strdup_printf ("%u%s%s%s", url->port, url->abspath, pre_query, query);
|
||||
result =
|
||||
g_strdup_printf ("%u%s%s%s", url->port, url->abspath, pre_query, query);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static GstElement *
|
||||
default_get_element (GstRTSPMediaFactory *factory, const GstRTSPUrl *url)
|
||||
default_get_element (GstRTSPMediaFactory * factory, const GstRTSPUrl * url)
|
||||
{
|
||||
GstElement *element;
|
||||
GError *error = NULL;
|
||||
|
@ -459,8 +469,8 @@ no_launch:
|
|||
parse_error:
|
||||
{
|
||||
g_mutex_unlock (factory->lock);
|
||||
g_critical ("could not parse launch syntax (%s): %s", factory->launch,
|
||||
(error ? error->message : "unknown reason"));
|
||||
g_critical ("could not parse launch syntax (%s): %s", factory->launch,
|
||||
(error ? error->message : "unknown reason"));
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
return NULL;
|
||||
|
@ -470,11 +480,11 @@ parse_error:
|
|||
/* try to find all the payloader elements, they should be named 'pay%d'. for
|
||||
* each of the payloaders we will create a stream and collect the source pad. */
|
||||
void
|
||||
gst_rtsp_media_factory_collect_streams (GstRTSPMediaFactory *factory, const GstRTSPUrl *url,
|
||||
GstRTSPMedia *media)
|
||||
gst_rtsp_media_factory_collect_streams (GstRTSPMediaFactory * factory,
|
||||
const GstRTSPUrl * url, GstRTSPMedia * media)
|
||||
{
|
||||
GstElement *element, *elem;
|
||||
GstPad * pad;
|
||||
GstPad *pad;
|
||||
gint i;
|
||||
GstRTSPMediaStream *stream;
|
||||
gboolean have_elem;
|
||||
|
@ -482,7 +492,7 @@ gst_rtsp_media_factory_collect_streams (GstRTSPMediaFactory *factory, const GstR
|
|||
element = media->element;
|
||||
|
||||
have_elem = TRUE;
|
||||
for (i = 0; have_elem ; i++) {
|
||||
for (i = 0; have_elem; i++) {
|
||||
gchar *name;
|
||||
|
||||
have_elem = FALSE;
|
||||
|
@ -524,7 +534,7 @@ gst_rtsp_media_factory_collect_streams (GstRTSPMediaFactory *factory, const GstR
|
|||
}
|
||||
|
||||
static GstRTSPMedia *
|
||||
default_construct (GstRTSPMediaFactory *factory, const GstRTSPUrl *url)
|
||||
default_construct (GstRTSPMediaFactory * factory, const GstRTSPUrl * url)
|
||||
{
|
||||
GstRTSPMedia *media;
|
||||
GstElement *element;
|
||||
|
@ -573,8 +583,8 @@ no_pipeline:
|
|||
}
|
||||
}
|
||||
|
||||
static GstElement*
|
||||
default_create_pipeline (GstRTSPMediaFactory *factory, GstRTSPMedia *media)
|
||||
static GstElement *
|
||||
default_create_pipeline (GstRTSPMediaFactory * factory, GstRTSPMedia * media)
|
||||
{
|
||||
GstElement *pipeline;
|
||||
|
||||
|
@ -595,7 +605,7 @@ no_element:
|
|||
}
|
||||
|
||||
static void
|
||||
default_configure (GstRTSPMediaFactory *factory, GstRTSPMedia *media)
|
||||
default_configure (GstRTSPMediaFactory * factory, GstRTSPMedia * media)
|
||||
{
|
||||
gboolean shared, eos_shutdown;
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ GST_DEBUG_CATEGORY_EXTERN (rtsp_media_debug);
|
|||
|
||||
static void gst_rtsp_media_mapping_finalize (GObject * obj);
|
||||
|
||||
static GstRTSPMediaFactory * find_media (GstRTSPMediaMapping *mapping, const GstRTSPUrl *url);
|
||||
static GstRTSPMediaFactory *find_media (GstRTSPMediaMapping * mapping,
|
||||
const GstRTSPUrl * url);
|
||||
|
||||
static void
|
||||
gst_rtsp_media_mapping_class_init (GstRTSPMediaMappingClass * klass)
|
||||
|
@ -44,7 +45,7 @@ static void
|
|||
gst_rtsp_media_mapping_init (GstRTSPMediaMapping * mapping)
|
||||
{
|
||||
mapping->mappings = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, g_object_unref);
|
||||
g_free, g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -68,7 +69,7 @@ gst_rtsp_media_mapping_new (void)
|
|||
}
|
||||
|
||||
static GstRTSPMediaFactory *
|
||||
find_media (GstRTSPMediaMapping *mapping, const GstRTSPUrl *url)
|
||||
find_media (GstRTSPMediaMapping * mapping, const GstRTSPUrl * url)
|
||||
{
|
||||
GstRTSPMediaFactory *result;
|
||||
|
||||
|
@ -76,7 +77,7 @@ find_media (GstRTSPMediaMapping *mapping, const GstRTSPUrl *url)
|
|||
* path of the uri to find a mapping. If the mapping depends on other
|
||||
* properties found in the url, this method should be overridden. */
|
||||
result = g_hash_table_lookup (mapping->mappings, url->abspath);
|
||||
if (result)
|
||||
if (result)
|
||||
g_object_ref (result);
|
||||
|
||||
GST_INFO ("found media %p for url abspath %s", result, url->abspath);
|
||||
|
@ -95,7 +96,8 @@ find_media (GstRTSPMediaMapping *mapping, const GstRTSPUrl *url)
|
|||
* Returns: the #GstRTSPMediaFactory for @url. g_object_unref() after usage.
|
||||
*/
|
||||
GstRTSPMediaFactory *
|
||||
gst_rtsp_media_mapping_find_factory (GstRTSPMediaMapping *mapping, const GstRTSPUrl *url)
|
||||
gst_rtsp_media_mapping_find_factory (GstRTSPMediaMapping * mapping,
|
||||
const GstRTSPUrl * url)
|
||||
{
|
||||
GstRTSPMediaFactory *result;
|
||||
GstRTSPMediaMappingClass *klass;
|
||||
|
@ -124,8 +126,8 @@ gst_rtsp_media_mapping_find_factory (GstRTSPMediaMapping *mapping, const GstRTSP
|
|||
* used after calling this function.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_media_mapping_add_factory (GstRTSPMediaMapping *mapping, const gchar *path,
|
||||
GstRTSPMediaFactory *factory)
|
||||
gst_rtsp_media_mapping_add_factory (GstRTSPMediaMapping * mapping,
|
||||
const gchar * path, GstRTSPMediaFactory * factory)
|
||||
{
|
||||
g_return_if_fail (GST_IS_RTSP_MEDIA_MAPPING (mapping));
|
||||
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
|
||||
|
@ -142,11 +144,11 @@ gst_rtsp_media_mapping_add_factory (GstRTSPMediaMapping *mapping, const gchar *p
|
|||
* Remove the #GstRTSPMediaFactory associated with @path in @mapping.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_media_mapping_remove_factory (GstRTSPMediaMapping *mapping, const gchar *path)
|
||||
gst_rtsp_media_mapping_remove_factory (GstRTSPMediaMapping * mapping,
|
||||
const gchar * path)
|
||||
{
|
||||
g_return_if_fail (GST_IS_RTSP_MEDIA_MAPPING (mapping));
|
||||
g_return_if_fail (path != NULL);
|
||||
|
||||
g_hash_table_remove (mapping->mappings, path);
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,8 @@ gst_rtsp_media_init (GstRTSPMedia * media)
|
|||
}
|
||||
|
||||
/* FIXME. this should be done in multiudpsink */
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
gint count;
|
||||
gchar *dest;
|
||||
gint min, max;
|
||||
|
@ -144,14 +145,15 @@ typedef struct {
|
|||
static gint
|
||||
dest_compare (RTSPDestination * a, RTSPDestination * b)
|
||||
{
|
||||
if ((a->min == b->min) && (a->max == b->max) && (strcmp (a->dest, b->dest) == 0))
|
||||
if ((a->min == b->min) && (a->max == b->max)
|
||||
&& (strcmp (a->dest, b->dest) == 0))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static RTSPDestination *
|
||||
create_destination (const gchar *dest, gint min, gint max)
|
||||
create_destination (const gchar * dest, gint min, gint max)
|
||||
{
|
||||
RTSPDestination *res;
|
||||
|
||||
|
@ -165,14 +167,14 @@ create_destination (const gchar *dest, gint min, gint max)
|
|||
}
|
||||
|
||||
static void
|
||||
free_destination (RTSPDestination *dest)
|
||||
free_destination (RTSPDestination * dest)
|
||||
{
|
||||
g_free (dest->dest);
|
||||
g_slice_free (RTSPDestination, dest);
|
||||
}
|
||||
|
||||
void
|
||||
gst_rtsp_media_trans_cleanup (GstRTSPMediaTrans *trans)
|
||||
gst_rtsp_media_trans_cleanup (GstRTSPMediaTrans * trans)
|
||||
{
|
||||
if (trans->transport) {
|
||||
gst_rtsp_transport_free (trans->transport);
|
||||
|
@ -466,7 +468,8 @@ gst_rtsp_media_set_protocols (GstRTSPMedia * media, GstRTSPLowerTrans protocols)
|
|||
GstRTSPLowerTrans
|
||||
gst_rtsp_media_get_protocols (GstRTSPMedia * media)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), GST_RTSP_LOWER_TRANS_UNKNOWN);
|
||||
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media),
|
||||
GST_RTSP_LOWER_TRANS_UNKNOWN);
|
||||
|
||||
return media->protocols;
|
||||
}
|
||||
|
@ -480,7 +483,7 @@ gst_rtsp_media_get_protocols (GstRTSPMedia * media)
|
|||
* it is unprepared.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_media_set_eos_shutdown (GstRTSPMedia *media, gboolean eos_shutdown)
|
||||
gst_rtsp_media_set_eos_shutdown (GstRTSPMedia * media, gboolean eos_shutdown)
|
||||
{
|
||||
g_return_if_fail (GST_IS_RTSP_MEDIA (media));
|
||||
|
||||
|
@ -497,7 +500,7 @@ gst_rtsp_media_set_eos_shutdown (GstRTSPMedia *media, gboolean eos_shutdown)
|
|||
* Returns: %TRUE if the media will send EOS before unpreparing.
|
||||
*/
|
||||
gboolean
|
||||
gst_rtsp_media_is_eos_shutdown (GstRTSPMedia *media)
|
||||
gst_rtsp_media_is_eos_shutdown (GstRTSPMedia * media)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), FALSE);
|
||||
|
||||
|
@ -797,12 +800,12 @@ again:
|
|||
if (!udpsink1)
|
||||
goto no_udp_protocol;
|
||||
|
||||
if (g_object_class_find_property (G_OBJECT_GET_CLASS (udpsink0), "send-duplicates")) {
|
||||
if (g_object_class_find_property (G_OBJECT_GET_CLASS (udpsink0),
|
||||
"send-duplicates")) {
|
||||
g_object_set (G_OBJECT (udpsink0), "send-duplicates", FALSE, NULL);
|
||||
g_object_set (G_OBJECT (udpsink1), "send-duplicates", FALSE, NULL);
|
||||
stream->filter_duplicates = FALSE;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
GST_WARNING ("multiudpsink version found without send-duplicates property");
|
||||
stream->filter_duplicates = TRUE;
|
||||
}
|
||||
|
@ -1269,7 +1272,7 @@ unlock_streams (GstRTSPMedia * media)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_rtsp_media_set_status (GstRTSPMedia *media, GstRTSPMediaStatus status)
|
||||
gst_rtsp_media_set_status (GstRTSPMedia * media, GstRTSPMediaStatus status)
|
||||
{
|
||||
g_mutex_lock (media->lock);
|
||||
/* never overwrite the error status */
|
||||
|
@ -1281,7 +1284,7 @@ gst_rtsp_media_set_status (GstRTSPMedia *media, GstRTSPMediaStatus status)
|
|||
}
|
||||
|
||||
static GstRTSPMediaStatus
|
||||
gst_rtsp_media_get_status (GstRTSPMedia *media)
|
||||
gst_rtsp_media_get_status (GstRTSPMedia * media)
|
||||
{
|
||||
GstRTSPMediaStatus result;
|
||||
GTimeVal timeout;
|
||||
|
@ -1648,7 +1651,7 @@ default_unprepare (GstRTSPMedia * media)
|
|||
/* ref so that we don't disappear */
|
||||
g_object_ref (media);
|
||||
media->eos_pending = TRUE;
|
||||
gst_element_send_event (media->pipeline, gst_event_new_eos());
|
||||
gst_element_send_event (media->pipeline, gst_event_new_eos ());
|
||||
/* we need to go to playing again for the EOS to propagate, normally in this
|
||||
* state, nothing is receiving data from us anymore so this is ok. */
|
||||
gst_element_set_state (media->pipeline, GST_STATE_PLAYING);
|
||||
|
@ -1660,8 +1663,8 @@ default_unprepare (GstRTSPMedia * media)
|
|||
}
|
||||
|
||||
static void
|
||||
add_udp_destination (GstRTSPMedia *media, GstRTSPMediaStream *stream,
|
||||
gchar *dest, gint min, gint max)
|
||||
add_udp_destination (GstRTSPMedia * media, GstRTSPMediaStream * stream,
|
||||
gchar * dest, gint min, gint max)
|
||||
{
|
||||
gboolean do_add = TRUE;
|
||||
RTSPDestination *ndest;
|
||||
|
@ -1675,11 +1678,14 @@ add_udp_destination (GstRTSPMedia *media, GstRTSPMediaStream *stream,
|
|||
fdest.max = max;
|
||||
|
||||
/* first see if we already added this destination */
|
||||
find = g_list_find_custom (stream->destinations, &fdest, (GCompareFunc) dest_compare);
|
||||
find =
|
||||
g_list_find_custom (stream->destinations, &fdest,
|
||||
(GCompareFunc) dest_compare);
|
||||
if (find) {
|
||||
ndest = (RTSPDestination *) find->data;
|
||||
|
||||
GST_INFO ("already streaming to %s:%d-%d with %d clients", dest, min, max, ndest->count);
|
||||
GST_INFO ("already streaming to %s:%d-%d with %d clients", dest, min, max,
|
||||
ndest->count);
|
||||
ndest->count++;
|
||||
do_add = FALSE;
|
||||
}
|
||||
|
@ -1698,8 +1704,8 @@ add_udp_destination (GstRTSPMedia *media, GstRTSPMediaStream *stream,
|
|||
}
|
||||
|
||||
static void
|
||||
remove_udp_destination (GstRTSPMedia *media, GstRTSPMediaStream *stream,
|
||||
gchar *dest, gint min, gint max)
|
||||
remove_udp_destination (GstRTSPMedia * media, GstRTSPMediaStream * stream,
|
||||
gchar * dest, gint min, gint max)
|
||||
{
|
||||
gboolean do_remove = TRUE;
|
||||
RTSPDestination *ndest = NULL;
|
||||
|
@ -1713,14 +1719,17 @@ remove_udp_destination (GstRTSPMedia *media, GstRTSPMediaStream *stream,
|
|||
fdest.max = max;
|
||||
|
||||
/* first see if we already added this destination */
|
||||
find = g_list_find_custom (stream->destinations, &fdest, (GCompareFunc) dest_compare);
|
||||
find =
|
||||
g_list_find_custom (stream->destinations, &fdest,
|
||||
(GCompareFunc) dest_compare);
|
||||
if (!find)
|
||||
return;
|
||||
|
||||
ndest = (RTSPDestination *) find->data;
|
||||
if (--ndest->count > 0) {
|
||||
do_remove = FALSE;
|
||||
GST_INFO ("still streaming to %s:%d-%d with %d clients", dest, min, max, ndest->count);
|
||||
GST_INFO ("still streaming to %s:%d-%d with %d clients", dest, min, max,
|
||||
ndest->count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ gst_rtsp_params_set (GstRTSPClient * client, GstRTSPUrl * uri,
|
|||
code = GST_RTSP_STS_PARAMETER_NOT_UNDERSTOOD;
|
||||
|
||||
gst_rtsp_message_init_response (response, code,
|
||||
gst_rtsp_status_as_text (code), request);
|
||||
gst_rtsp_status_as_text (code), request);
|
||||
|
||||
return GST_RTSP_OK;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ gst_rtsp_params_get (GstRTSPClient * client, GstRTSPUrl * uri,
|
|||
code = GST_RTSP_STS_PARAMETER_NOT_UNDERSTOOD;
|
||||
|
||||
gst_rtsp_message_init_response (response, code,
|
||||
gst_rtsp_status_as_text (code), request);
|
||||
gst_rtsp_status_as_text (code), request);
|
||||
|
||||
return GST_RTSP_OK;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
* Returns: TRUE on success.
|
||||
*/
|
||||
gboolean
|
||||
gst_rtsp_sdp_from_media (GstSDPMessage *sdp, GstSDPInfo *info, GstRTSPMedia * media)
|
||||
gst_rtsp_sdp_from_media (GstSDPMessage * sdp, GstSDPInfo * info,
|
||||
GstRTSPMedia * media)
|
||||
{
|
||||
guint i, n_streams;
|
||||
gchar *rangestr;
|
||||
|
@ -85,7 +86,8 @@ gst_rtsp_sdp_from_media (GstSDPMessage *sdp, GstSDPInfo *info, GstRTSPMedia * me
|
|||
gst_sdp_media_set_proto (smedia, "RTP/AVP");
|
||||
|
||||
/* for the c= line */
|
||||
gst_sdp_media_add_connection (smedia, "IN", info->server_proto, info->server_ip, 16, 0);
|
||||
gst_sdp_media_add_connection (smedia, "IN", info->server_proto,
|
||||
info->server_ip, 16, 0);
|
||||
|
||||
/* get clock-rate, media type and params for the rtpmap attribute */
|
||||
gst_structure_get_int (s, "clock-rate", &caps_rate);
|
||||
|
|
|
@ -49,14 +49,14 @@ G_DEFINE_TYPE (GstRTSPServer, gst_rtsp_server, G_TYPE_OBJECT);
|
|||
GST_DEBUG_CATEGORY_STATIC (rtsp_server_debug);
|
||||
#define GST_CAT_DEFAULT rtsp_server_debug
|
||||
|
||||
static void gst_rtsp_server_get_property (GObject *object, guint propid,
|
||||
GValue *value, GParamSpec *pspec);
|
||||
static void gst_rtsp_server_set_property (GObject *object, guint propid,
|
||||
const GValue *value, GParamSpec *pspec);
|
||||
static void gst_rtsp_server_finalize (GObject *object);
|
||||
static void gst_rtsp_server_get_property (GObject * object, guint propid,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
static void gst_rtsp_server_set_property (GObject * object, guint propid,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_rtsp_server_finalize (GObject * object);
|
||||
|
||||
static GstRTSPClient * default_accept_client (GstRTSPServer *server,
|
||||
GIOChannel *channel);
|
||||
static GstRTSPClient *default_accept_client (GstRTSPServer * server,
|
||||
GIOChannel * channel);
|
||||
|
||||
static void
|
||||
gst_rtsp_server_class_init (GstRTSPServerClass * klass)
|
||||
|
@ -76,8 +76,9 @@ gst_rtsp_server_class_init (GstRTSPServerClass * klass)
|
|||
* listen on.
|
||||
*/
|
||||
g_object_class_install_property (gobject_class, PROP_ADDRESS,
|
||||
g_param_spec_string ("address", "Address", "The address the server uses to listen on",
|
||||
DEFAULT_ADDRESS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string ("address", "Address",
|
||||
"The address the server uses to listen on", DEFAULT_ADDRESS,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
/**
|
||||
* GstRTSPServer::service
|
||||
*
|
||||
|
@ -85,7 +86,8 @@ gst_rtsp_server_class_init (GstRTSPServerClass * klass)
|
|||
* a port number (as a string) the server will listen on.
|
||||
*/
|
||||
g_object_class_install_property (gobject_class, PROP_SERVICE,
|
||||
g_param_spec_string ("service", "Service", "The service or port number the server uses to listen on",
|
||||
g_param_spec_string ("service", "Service",
|
||||
"The service or port number the server uses to listen on",
|
||||
DEFAULT_SERVICE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
/**
|
||||
* GstRTSPServer::backlog
|
||||
|
@ -97,9 +99,10 @@ gst_rtsp_server_class_init (GstRTSPServerClass * klass)
|
|||
* request may be ignored so that a later reattempt at connection succeeds.
|
||||
*/
|
||||
g_object_class_install_property (gobject_class, PROP_BACKLOG,
|
||||
g_param_spec_int ("backlog", "Backlog", "The maximum length to which the queue "
|
||||
"of pending connections may grow",
|
||||
0, G_MAXINT, DEFAULT_BACKLOG, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_int ("backlog", "Backlog",
|
||||
"The maximum length to which the queue "
|
||||
"of pending connections may grow", 0, G_MAXINT, DEFAULT_BACKLOG,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
/**
|
||||
* GstRTSPServer::session-pool
|
||||
*
|
||||
|
@ -110,7 +113,8 @@ gst_rtsp_server_class_init (GstRTSPServerClass * klass)
|
|||
g_object_class_install_property (gobject_class, PROP_SESSION_POOL,
|
||||
g_param_spec_object ("session-pool", "Session Pool",
|
||||
"The session pool to use for client session",
|
||||
GST_TYPE_RTSP_SESSION_POOL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
GST_TYPE_RTSP_SESSION_POOL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
/**
|
||||
* GstRTSPServer::media-mapping
|
||||
*
|
||||
|
@ -120,7 +124,8 @@ gst_rtsp_server_class_init (GstRTSPServerClass * klass)
|
|||
g_object_class_install_property (gobject_class, PROP_MEDIA_MAPPING,
|
||||
g_param_spec_object ("media-mapping", "Media Mapping",
|
||||
"The media mapping to use for client session",
|
||||
GST_TYPE_RTSP_MEDIA_MAPPING, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
GST_TYPE_RTSP_MEDIA_MAPPING,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
klass->accept_client = default_accept_client;
|
||||
|
||||
|
@ -138,7 +143,7 @@ gst_rtsp_server_init (GstRTSPServer * server)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_rtsp_server_finalize (GObject *object)
|
||||
gst_rtsp_server_finalize (GObject * object)
|
||||
{
|
||||
GstRTSPServer *server = GST_RTSP_SERVER (object);
|
||||
|
||||
|
@ -174,7 +179,7 @@ gst_rtsp_server_new (void)
|
|||
* This function must be called before the server is bound.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_server_set_address (GstRTSPServer *server, const gchar *address)
|
||||
gst_rtsp_server_set_address (GstRTSPServer * server, const gchar * address)
|
||||
{
|
||||
g_return_if_fail (GST_IS_RTSP_SERVER (server));
|
||||
g_return_if_fail (address != NULL);
|
||||
|
@ -192,7 +197,7 @@ gst_rtsp_server_set_address (GstRTSPServer *server, const gchar *address)
|
|||
* Returns: the server address. g_free() after usage.
|
||||
*/
|
||||
gchar *
|
||||
gst_rtsp_server_get_address (GstRTSPServer *server)
|
||||
gst_rtsp_server_get_address (GstRTSPServer * server)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_RTSP_SERVER (server), NULL);
|
||||
|
||||
|
@ -211,7 +216,7 @@ gst_rtsp_server_get_address (GstRTSPServer *server)
|
|||
* This function must be called before the server is bound.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_server_set_service (GstRTSPServer *server, const gchar *service)
|
||||
gst_rtsp_server_set_service (GstRTSPServer * server, const gchar * service)
|
||||
{
|
||||
g_return_if_fail (GST_IS_RTSP_SERVER (server));
|
||||
g_return_if_fail (service != NULL);
|
||||
|
@ -229,7 +234,7 @@ gst_rtsp_server_set_service (GstRTSPServer *server, const gchar *service)
|
|||
* Returns: the service. use g_free() after usage.
|
||||
*/
|
||||
gchar *
|
||||
gst_rtsp_server_get_service (GstRTSPServer *server)
|
||||
gst_rtsp_server_get_service (GstRTSPServer * server)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_RTSP_SERVER (server), NULL);
|
||||
|
||||
|
@ -247,7 +252,7 @@ gst_rtsp_server_get_service (GstRTSPServer *server)
|
|||
* This function must be called before the server is bound.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_server_set_backlog (GstRTSPServer *server, gint backlog)
|
||||
gst_rtsp_server_set_backlog (GstRTSPServer * server, gint backlog)
|
||||
{
|
||||
g_return_if_fail (GST_IS_RTSP_SERVER (server));
|
||||
|
||||
|
@ -263,7 +268,7 @@ gst_rtsp_server_set_backlog (GstRTSPServer *server, gint backlog)
|
|||
* Returns: the server backlog.
|
||||
*/
|
||||
gint
|
||||
gst_rtsp_server_get_backlog (GstRTSPServer *server)
|
||||
gst_rtsp_server_get_backlog (GstRTSPServer * server)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_RTSP_SERVER (server), -1);
|
||||
|
||||
|
@ -278,7 +283,8 @@ gst_rtsp_server_get_backlog (GstRTSPServer *server)
|
|||
* configure @pool to be used as the session pool of @server.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_server_set_session_pool (GstRTSPServer *server, GstRTSPSessionPool *pool)
|
||||
gst_rtsp_server_set_session_pool (GstRTSPServer * server,
|
||||
GstRTSPSessionPool * pool)
|
||||
{
|
||||
GstRTSPSessionPool *old;
|
||||
|
||||
|
@ -305,7 +311,7 @@ gst_rtsp_server_set_session_pool (GstRTSPServer *server, GstRTSPSessionPool *poo
|
|||
* usage.
|
||||
*/
|
||||
GstRTSPSessionPool *
|
||||
gst_rtsp_server_get_session_pool (GstRTSPServer *server)
|
||||
gst_rtsp_server_get_session_pool (GstRTSPServer * server)
|
||||
{
|
||||
GstRTSPSessionPool *result;
|
||||
|
||||
|
@ -325,7 +331,8 @@ gst_rtsp_server_get_session_pool (GstRTSPServer *server)
|
|||
* configure @mapping to be used as the media mapping of @server.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_server_set_media_mapping (GstRTSPServer *server, GstRTSPMediaMapping *mapping)
|
||||
gst_rtsp_server_set_media_mapping (GstRTSPServer * server,
|
||||
GstRTSPMediaMapping * mapping)
|
||||
{
|
||||
GstRTSPMediaMapping *old;
|
||||
|
||||
|
@ -353,7 +360,7 @@ gst_rtsp_server_set_media_mapping (GstRTSPServer *server, GstRTSPMediaMapping *m
|
|||
* usage.
|
||||
*/
|
||||
GstRTSPMediaMapping *
|
||||
gst_rtsp_server_get_media_mapping (GstRTSPServer *server)
|
||||
gst_rtsp_server_get_media_mapping (GstRTSPServer * server)
|
||||
{
|
||||
GstRTSPMediaMapping *result;
|
||||
|
||||
|
@ -366,8 +373,8 @@ gst_rtsp_server_get_media_mapping (GstRTSPServer *server)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_rtsp_server_get_property (GObject *object, guint propid,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
gst_rtsp_server_get_property (GObject * object, guint propid,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstRTSPServer *server = GST_RTSP_SERVER (object);
|
||||
|
||||
|
@ -393,8 +400,8 @@ gst_rtsp_server_get_property (GObject *object, guint propid,
|
|||
}
|
||||
|
||||
static void
|
||||
gst_rtsp_server_set_property (GObject *object, guint propid,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
gst_rtsp_server_set_property (GObject * object, guint propid,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstRTSPServer *server = GST_RTSP_SERVER (object);
|
||||
|
||||
|
@ -430,19 +437,21 @@ gst_rtsp_server_sink_init_send (GstRTSPServer * server)
|
|||
struct linger linger;
|
||||
#endif
|
||||
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
|
||||
hints.ai_socktype = SOCK_STREAM; /* stream socket */
|
||||
hints.ai_flags = AI_PASSIVE | AI_CANONNAME; /* For wildcard IP address */
|
||||
hints.ai_protocol = 0; /* Any protocol */
|
||||
memset (&hints, 0, sizeof (struct addrinfo));
|
||||
hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
|
||||
hints.ai_socktype = SOCK_STREAM; /* stream socket */
|
||||
hints.ai_flags = AI_PASSIVE | AI_CANONNAME; /* For wildcard IP address */
|
||||
hints.ai_protocol = 0; /* Any protocol */
|
||||
hints.ai_canonname = NULL;
|
||||
hints.ai_addr = NULL;
|
||||
hints.ai_next = NULL;
|
||||
|
||||
GST_DEBUG_OBJECT (server, "getting address info of %s/%s", server->address, server->service);
|
||||
GST_DEBUG_OBJECT (server, "getting address info of %s/%s", server->address,
|
||||
server->service);
|
||||
|
||||
/* resolve the server IP address */
|
||||
if ((ret = getaddrinfo (server->address, server->service, &hints, &result)) != 0)
|
||||
if ((ret =
|
||||
getaddrinfo (server->address, server->service, &hints, &result)) != 0)
|
||||
goto no_address;
|
||||
|
||||
/* create server socket, we loop through all the addresses until we manage to
|
||||
|
@ -450,7 +459,8 @@ gst_rtsp_server_sink_init_send (GstRTSPServer * server)
|
|||
for (rp = result; rp; rp = rp->ai_next) {
|
||||
sockfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
|
||||
if (sockfd == -1) {
|
||||
GST_DEBUG_OBJECT (server, "failed to make socket (%s), try next", g_strerror (errno));
|
||||
GST_DEBUG_OBJECT (server, "failed to make socket (%s), try next",
|
||||
g_strerror (errno));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -459,7 +469,8 @@ gst_rtsp_server_sink_init_send (GstRTSPServer * server)
|
|||
break;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (server, "failed to bind socket (%s), try next", g_strerror (errno));
|
||||
GST_DEBUG_OBJECT (server, "failed to bind socket (%s), try next",
|
||||
g_strerror (errno));
|
||||
close (sockfd);
|
||||
}
|
||||
freeaddrinfo (result);
|
||||
|
@ -514,12 +525,14 @@ gst_rtsp_server_sink_init_send (GstRTSPServer * server)
|
|||
/* ERRORS */
|
||||
no_address:
|
||||
{
|
||||
GST_ERROR_OBJECT (server, "failed to resolve address: %s", gai_strerror(ret));
|
||||
GST_ERROR_OBJECT (server, "failed to resolve address: %s",
|
||||
gai_strerror (ret));
|
||||
return FALSE;
|
||||
}
|
||||
no_socket:
|
||||
{
|
||||
GST_ERROR_OBJECT (server, "failed to create socket: %s", g_strerror (errno));
|
||||
GST_ERROR_OBJECT (server, "failed to create socket: %s",
|
||||
g_strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
reuse_failed:
|
||||
|
@ -529,19 +542,22 @@ reuse_failed:
|
|||
}
|
||||
keepalive_failed:
|
||||
{
|
||||
GST_ERROR_OBJECT (server, "failed to configure keepalive socket: %s", g_strerror (errno));
|
||||
GST_ERROR_OBJECT (server, "failed to configure keepalive socket: %s",
|
||||
g_strerror (errno));
|
||||
goto close_error;
|
||||
}
|
||||
#ifdef USE_SOLINGER
|
||||
linger_failed:
|
||||
{
|
||||
GST_ERROR_OBJECT (server, "failed to no linger socket: %s", g_strerror (errno));
|
||||
GST_ERROR_OBJECT (server, "failed to no linger socket: %s",
|
||||
g_strerror (errno));
|
||||
goto close_error;
|
||||
}
|
||||
#endif
|
||||
listen_failed:
|
||||
{
|
||||
GST_ERROR_OBJECT (server, "failed to listen on socket: %s", g_strerror (errno));
|
||||
GST_ERROR_OBJECT (server, "failed to listen on socket: %s",
|
||||
g_strerror (errno));
|
||||
goto close_error;
|
||||
}
|
||||
close_error:
|
||||
|
@ -557,7 +573,7 @@ close_error:
|
|||
/* default method for creating a new client object in the server to accept and
|
||||
* handle a client connection on this server */
|
||||
static GstRTSPClient *
|
||||
default_accept_client (GstRTSPServer *server, GIOChannel *channel)
|
||||
default_accept_client (GstRTSPServer * server, GIOChannel * channel)
|
||||
{
|
||||
GstRTSPClient *client;
|
||||
|
||||
|
@ -580,8 +596,9 @@ default_accept_client (GstRTSPServer *server, GIOChannel *channel)
|
|||
/* ERRORS */
|
||||
accept_failed:
|
||||
{
|
||||
GST_ERROR_OBJECT (server, "Could not accept client on server socket %d: %s (%d)",
|
||||
server->server_sock.fd, g_strerror (errno), errno);
|
||||
GST_ERROR_OBJECT (server,
|
||||
"Could not accept client on server socket %d: %s (%d)",
|
||||
server->server_sock.fd, g_strerror (errno), errno);
|
||||
gst_object_unref (client);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -598,7 +615,8 @@ accept_failed:
|
|||
* Returns: TRUE if the source could be connected, FALSE if an error occured.
|
||||
*/
|
||||
gboolean
|
||||
gst_rtsp_server_io_func (GIOChannel *channel, GIOCondition condition, GstRTSPServer *server)
|
||||
gst_rtsp_server_io_func (GIOChannel * channel, GIOCondition condition,
|
||||
GstRTSPServer * server)
|
||||
{
|
||||
GstRTSPClient *client = NULL;
|
||||
GstRTSPServerClass *klass;
|
||||
|
@ -615,8 +633,7 @@ gst_rtsp_server_io_func (GIOChannel *channel, GIOCondition condition, GstRTSPSer
|
|||
/* can unref the client now, when the request is finished, it will be
|
||||
* unreffed async. */
|
||||
gst_object_unref (client);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
GST_WARNING_OBJECT (server, "received unknown event %08x", condition);
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -638,7 +655,7 @@ client_failed:
|
|||
* Returns: the GIOChannel for @server or NULL when an error occured.
|
||||
*/
|
||||
GIOChannel *
|
||||
gst_rtsp_server_get_io_channel (GstRTSPServer *server)
|
||||
gst_rtsp_server_get_io_channel (GstRTSPServer * server)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_RTSP_SERVER (server), NULL);
|
||||
|
||||
|
@ -668,7 +685,7 @@ init_failed:
|
|||
* Returns: the #GSource for @server or NULL when an error occured.
|
||||
*/
|
||||
GSource *
|
||||
gst_rtsp_server_create_watch (GstRTSPServer *server)
|
||||
gst_rtsp_server_create_watch (GstRTSPServer * server)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_RTSP_SERVER (server), NULL);
|
||||
|
||||
|
@ -681,10 +698,11 @@ gst_rtsp_server_create_watch (GstRTSPServer *server)
|
|||
|
||||
/* create a watch for reads (new connections) and possible errors */
|
||||
server->io_watch = g_io_create_watch (channel, G_IO_IN |
|
||||
G_IO_ERR | G_IO_HUP | G_IO_NVAL);
|
||||
G_IO_ERR | G_IO_HUP | G_IO_NVAL);
|
||||
|
||||
/* configure the callback */
|
||||
g_source_set_callback (server->io_watch, (GSourceFunc) gst_rtsp_server_io_func, server, NULL);
|
||||
g_source_set_callback (server->io_watch,
|
||||
(GSourceFunc) gst_rtsp_server_io_func, server, NULL);
|
||||
}
|
||||
return server->io_watch;
|
||||
|
||||
|
@ -709,7 +727,7 @@ no_channel:
|
|||
* Returns: the ID (greater than 0) for the source within the GMainContext.
|
||||
*/
|
||||
guint
|
||||
gst_rtsp_server_attach (GstRTSPServer *server, GMainContext *context)
|
||||
gst_rtsp_server_attach (GstRTSPServer * server, GMainContext * context)
|
||||
{
|
||||
guint res;
|
||||
GSource *source;
|
||||
|
|
|
@ -33,13 +33,13 @@ enum
|
|||
GST_DEBUG_CATEGORY (rtsp_session_debug);
|
||||
#define GST_CAT_DEFAULT rtsp_session_debug
|
||||
|
||||
static void gst_rtsp_session_pool_get_property (GObject *object, guint propid,
|
||||
GValue *value, GParamSpec *pspec);
|
||||
static void gst_rtsp_session_pool_set_property (GObject *object, guint propid,
|
||||
const GValue *value, GParamSpec *pspec);
|
||||
static void gst_rtsp_session_pool_get_property (GObject * object, guint propid,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
static void gst_rtsp_session_pool_set_property (GObject * object, guint propid,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_rtsp_session_pool_finalize (GObject * object);
|
||||
|
||||
static gchar * create_session_id (GstRTSPSessionPool *pool);
|
||||
static gchar *create_session_id (GstRTSPSessionPool * pool);
|
||||
|
||||
G_DEFINE_TYPE (GstRTSPSessionPool, gst_rtsp_session_pool, G_TYPE_OBJECT);
|
||||
|
||||
|
@ -62,7 +62,8 @@ gst_rtsp_session_pool_class_init (GstRTSPSessionPoolClass * klass)
|
|||
|
||||
klass->create_session_id = create_session_id;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (rtsp_session_debug, "rtspsession", 0, "GstRTSPSession");
|
||||
GST_DEBUG_CATEGORY_INIT (rtsp_session_debug, "rtspsession", 0,
|
||||
"GstRTSPSession");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -70,24 +71,24 @@ gst_rtsp_session_pool_init (GstRTSPSessionPool * pool)
|
|||
{
|
||||
pool->lock = g_mutex_new ();
|
||||
pool->sessions = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
NULL, g_object_unref);
|
||||
NULL, g_object_unref);
|
||||
pool->max_sessions = DEFAULT_MAX_SESSIONS;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtsp_session_pool_finalize (GObject * object)
|
||||
{
|
||||
GstRTSPSessionPool * pool = GST_RTSP_SESSION_POOL (object);
|
||||
GstRTSPSessionPool *pool = GST_RTSP_SESSION_POOL (object);
|
||||
|
||||
g_mutex_free (pool->lock);
|
||||
g_hash_table_unref (pool->sessions);
|
||||
|
||||
|
||||
G_OBJECT_CLASS (gst_rtsp_session_pool_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtsp_session_pool_get_property (GObject *object, guint propid,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
gst_rtsp_session_pool_get_property (GObject * object, guint propid,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstRTSPSessionPool *pool = GST_RTSP_SESSION_POOL (object);
|
||||
|
||||
|
@ -102,8 +103,8 @@ gst_rtsp_session_pool_get_property (GObject *object, guint propid,
|
|||
}
|
||||
|
||||
static void
|
||||
gst_rtsp_session_pool_set_property (GObject *object, guint propid,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
gst_rtsp_session_pool_set_property (GObject * object, guint propid,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstRTSPSessionPool *pool = GST_RTSP_SESSION_POOL (object);
|
||||
|
||||
|
@ -143,7 +144,7 @@ gst_rtsp_session_pool_new (void)
|
|||
* A value of 0 means an unlimited amount of sessions.
|
||||
*/
|
||||
void
|
||||
gst_rtsp_session_pool_set_max_sessions (GstRTSPSessionPool *pool, guint max)
|
||||
gst_rtsp_session_pool_set_max_sessions (GstRTSPSessionPool * pool, guint max)
|
||||
{
|
||||
g_return_if_fail (GST_IS_RTSP_SESSION_POOL (pool));
|
||||
|
||||
|
@ -162,7 +163,7 @@ gst_rtsp_session_pool_set_max_sessions (GstRTSPSessionPool *pool, guint max)
|
|||
* Returns: the maximum allowed number of sessions.
|
||||
*/
|
||||
guint
|
||||
gst_rtsp_session_pool_get_max_sessions (GstRTSPSessionPool *pool)
|
||||
gst_rtsp_session_pool_get_max_sessions (GstRTSPSessionPool * pool)
|
||||
{
|
||||
guint result;
|
||||
|
||||
|
@ -184,7 +185,7 @@ gst_rtsp_session_pool_get_max_sessions (GstRTSPSessionPool *pool)
|
|||
* Returns: the amount of active sessions in @pool.
|
||||
*/
|
||||
guint
|
||||
gst_rtsp_session_pool_get_n_sessions (GstRTSPSessionPool *pool)
|
||||
gst_rtsp_session_pool_get_n_sessions (GstRTSPSessionPool * pool)
|
||||
{
|
||||
guint result;
|
||||
|
||||
|
@ -209,7 +210,7 @@ gst_rtsp_session_pool_get_n_sessions (GstRTSPSessionPool *pool)
|
|||
* not exist. g_object_unref() after usage.
|
||||
*/
|
||||
GstRTSPSession *
|
||||
gst_rtsp_session_pool_find (GstRTSPSessionPool *pool, const gchar *sessionid)
|
||||
gst_rtsp_session_pool_find (GstRTSPSessionPool * pool, const gchar * sessionid)
|
||||
{
|
||||
GstRTSPSession *result;
|
||||
|
||||
|
@ -228,7 +229,7 @@ gst_rtsp_session_pool_find (GstRTSPSessionPool *pool, const gchar *sessionid)
|
|||
}
|
||||
|
||||
static gchar *
|
||||
create_session_id (GstRTSPSessionPool *pool)
|
||||
create_session_id (GstRTSPSessionPool * pool)
|
||||
{
|
||||
gchar id[16];
|
||||
gint i;
|
||||
|
@ -249,7 +250,7 @@ create_session_id (GstRTSPSessionPool *pool)
|
|||
* Returns: a new #GstRTSPSession.
|
||||
*/
|
||||
GstRTSPSession *
|
||||
gst_rtsp_session_pool_create (GstRTSPSessionPool *pool)
|
||||
gst_rtsp_session_pool_create (GstRTSPSessionPool * pool)
|
||||
{
|
||||
GstRTSPSession *result = NULL;
|
||||
GstRTSPSessionPoolClass *klass;
|
||||
|
@ -276,7 +277,7 @@ gst_rtsp_session_pool_create (GstRTSPSessionPool *pool)
|
|||
/* check session limit */
|
||||
if (pool->max_sessions > 0) {
|
||||
if (g_hash_table_size (pool->sessions) >= pool->max_sessions)
|
||||
goto too_many_sessions;
|
||||
goto too_many_sessions;
|
||||
}
|
||||
/* check if the sessionid existed */
|
||||
result = g_hash_table_lookup (pool->sessions, id);
|
||||
|
@ -285,11 +286,10 @@ gst_rtsp_session_pool_create (GstRTSPSessionPool *pool)
|
|||
result = NULL;
|
||||
retry++;
|
||||
if (retry > 100)
|
||||
goto collision;
|
||||
}
|
||||
else {
|
||||
goto collision;
|
||||
} else {
|
||||
/* not found, create session and insert it in the pool */
|
||||
result = gst_rtsp_session_new (id);
|
||||
result = gst_rtsp_session_new (id);
|
||||
/* take additional ref for the pool */
|
||||
g_object_ref (result);
|
||||
g_hash_table_insert (pool->sessions, result->sessionid, result);
|
||||
|
@ -338,7 +338,7 @@ too_many_sessions:
|
|||
* Returns: %TRUE if the session was found and removed.
|
||||
*/
|
||||
gboolean
|
||||
gst_rtsp_session_pool_remove (GstRTSPSessionPool *pool, GstRTSPSession *sess)
|
||||
gst_rtsp_session_pool_remove (GstRTSPSessionPool * pool, GstRTSPSession * sess)
|
||||
{
|
||||
gboolean found;
|
||||
|
||||
|
@ -353,7 +353,7 @@ gst_rtsp_session_pool_remove (GstRTSPSessionPool *pool, GstRTSPSession *sess)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
cleanup_func (gchar *sessionid, GstRTSPSession *sess, GTimeVal *now)
|
||||
cleanup_func (gchar * sessionid, GstRTSPSession * sess, GTimeVal * now)
|
||||
{
|
||||
return gst_rtsp_session_is_expired (sess, now);
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ cleanup_func (gchar *sessionid, GstRTSPSession *sess, GTimeVal *now)
|
|||
* Returns: the amount of sessions that got removed.
|
||||
*/
|
||||
guint
|
||||
gst_rtsp_session_pool_cleanup (GstRTSPSessionPool *pool)
|
||||
gst_rtsp_session_pool_cleanup (GstRTSPSessionPool * pool)
|
||||
{
|
||||
guint result;
|
||||
GTimeVal now;
|
||||
|
@ -378,7 +378,9 @@ gst_rtsp_session_pool_cleanup (GstRTSPSessionPool *pool)
|
|||
g_get_current_time (&now);
|
||||
|
||||
g_mutex_lock (pool->lock);
|
||||
result = g_hash_table_foreach_remove (pool->sessions, (GHRFunc) cleanup_func, &now);
|
||||
result =
|
||||
g_hash_table_foreach_remove (pool->sessions, (GHRFunc) cleanup_func,
|
||||
&now);
|
||||
g_mutex_unlock (pool->lock);
|
||||
|
||||
return result;
|
||||
|
@ -393,7 +395,7 @@ typedef struct
|
|||
} FilterData;
|
||||
|
||||
static gboolean
|
||||
filter_func (gchar *sessionid, GstRTSPSession *sess, FilterData *data)
|
||||
filter_func (gchar * sessionid, GstRTSPSession * sess, FilterData * data)
|
||||
{
|
||||
switch (data->func (data->pool, sess, data->user_data)) {
|
||||
case GST_RTSP_FILTER_REMOVE:
|
||||
|
@ -432,7 +434,7 @@ filter_func (gchar *sessionid, GstRTSPSession *sess, FilterData *data)
|
|||
* before the list is freed.
|
||||
*/
|
||||
GList *
|
||||
gst_rtsp_session_pool_filter (GstRTSPSessionPool *pool,
|
||||
gst_rtsp_session_pool_filter (GstRTSPSessionPool * pool,
|
||||
GstRTSPSessionFilterFunc func, gpointer user_data)
|
||||
{
|
||||
FilterData data;
|
||||
|
@ -460,12 +462,12 @@ typedef struct
|
|||
} GstPoolSource;
|
||||
|
||||
static void
|
||||
collect_timeout (gchar *sessionid, GstRTSPSession *sess, GstPoolSource *psrc)
|
||||
collect_timeout (gchar * sessionid, GstRTSPSession * sess, GstPoolSource * psrc)
|
||||
{
|
||||
gint timeout;
|
||||
GTimeVal now;
|
||||
|
||||
g_source_get_current_time ((GSource*)psrc, &now);
|
||||
g_source_get_current_time ((GSource *) psrc, &now);
|
||||
|
||||
timeout = gst_rtsp_session_next_timeout (sess, &now);
|
||||
GST_INFO ("%p: next timeout: %d", sess, timeout);
|
||||
|
@ -547,7 +549,7 @@ static GSourceFuncs gst_pool_source_funcs = {
|
|||
* A GSource that will be dispatched when the session should be cleaned up.
|
||||
*/
|
||||
GSource *
|
||||
gst_rtsp_session_pool_create_watch (GstRTSPSessionPool *pool)
|
||||
gst_rtsp_session_pool_create_watch (GstRTSPSessionPool * pool)
|
||||
{
|
||||
GstPoolSource *source;
|
||||
|
||||
|
@ -559,4 +561,3 @@ gst_rtsp_session_pool_create_watch (GstRTSPSessionPool *pool)
|
|||
|
||||
return (GSource *) source;
|
||||
}
|
||||
|
||||
|
|
|
@ -421,7 +421,7 @@ gst_rtsp_session_touch (GstRTSPSession * session)
|
|||
}
|
||||
|
||||
void
|
||||
gst_rtsp_session_prevent_expire (GstRTSPSession *session)
|
||||
gst_rtsp_session_prevent_expire (GstRTSPSession * session)
|
||||
{
|
||||
g_return_if_fail (GST_IS_RTSP_SESSION (session));
|
||||
|
||||
|
@ -429,7 +429,7 @@ gst_rtsp_session_prevent_expire (GstRTSPSession *session)
|
|||
}
|
||||
|
||||
void
|
||||
gst_rtsp_session_allow_expire (GstRTSPSession *session)
|
||||
gst_rtsp_session_allow_expire (GstRTSPSession * session)
|
||||
{
|
||||
g_atomic_int_add (&session->expire_count, -1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue