...
 
Commits (38)
This diff is collapsed.
This diff is collapsed.
This is GStreamer gst-rtsp-server 1.14.0.
This is GStreamer gst-rtsp-server 1.14.5.
The GStreamer team is thrilled to announce a new major feature release in the
The GStreamer team is pleased to announce another bug-fix release in the
stable 1.x API series of your favourite cross-platform multimedia framework!
As always, this release is again packed with new features, bug fixes and
other improvements.
The 1.14 release series adds new features on top of the 1.12 series and is
part of the API and ABI-stable 1.x release series of the GStreamer multimedia
framework.
The 1.14 release series has now been superseded by the stable 1.16 series
which was released on 19 April 2019 and should be backwards compatible. We
recommend you upgrade to 1.16 at your earliest convenience.
Full release notes can be found at:
https://gstreamer.freedesktop.org/releases/1.14/
......@@ -57,10 +58,10 @@ with other GStreamer modules for a complete multimedia experience.
==== Download ====
You can find source releases of gstreamer in the download
directory: https://gstreamer.freedesktop.org/src/gstreamer/
directory: https://gstreamer.freedesktop.org/src/
The git repository and details how to clone it can be found at
http://cgit.freedesktop.org/gstreamer/gstreamer/
https://gitlab.freedesktop.org/gstreamer/
==== Homepage ====
......@@ -68,10 +69,16 @@ The project's website is https://gstreamer.freedesktop.org/
==== Support and Bugs ====
We use GNOME's bugzilla for bug reports and feature requests:
http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer
We have recently moved from GNOME Bugzilla to GitLab on freedesktop.org
for bug reports and feature requests:
https://gitlab.freedesktop.org/gstreamer
Please submit patches via GitLab as well, in form of Merge Requests. See
https://gstreamer.freedesktop.org/documentation/contribute/
Please submit patches via bugzilla as well.
for more details.
For help and support, please subscribe to and send questions to the
gstreamer-devel mailing list (see below for details).
......
......@@ -2,7 +2,7 @@ AC_PREREQ(2.69)
dnl initialize autoconf
dnl when going to/from release please set the nano (fourth number) right !
dnl releases only do Wall, cvs and prerelease does Werror too
AC_INIT([GStreamer RTSP Server Library], [1.14.0],
AC_INIT([GStreamer RTSP Server Library], [1.14.5],
[http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer],
[gst-rtsp-server])
AG_GST_INIT
......@@ -53,13 +53,13 @@ dnl 1.2.5 => 205
dnl 1.10.9 (who knows) => 1009
dnl
dnl sets GST_LT_LDFLAGS
AS_LIBTOOL(GST, 1400, 0, 1400)
AS_LIBTOOL(GST, 1405, 0, 1405)
dnl *** required versions of GStreamer stuff ***
GST_REQ=1.14.0
GSTPB_REQ=1.14.0
GSTPG_REQ=1.14.0
GSTPD_REQ=1.14.0
GST_REQ=1.14.5
GSTPB_REQ=1.14.5
GSTPG_REQ=1.14.5
GSTPD_REQ=1.14.5
dnl *** autotools stuff ****
......
......@@ -216,6 +216,7 @@ gst_rtsp_media_set_pipeline_state
<SUBSECTION MediaClocks>
gst_rtsp_media_get_clock
gst_rtsp_media_set_clock
gst_rtsp_media_get_base_time
gst_rtsp_media_use_time_provider
gst_rtsp_media_is_time_provider
......@@ -250,6 +251,9 @@ gst_rtsp_media_factory_set_permissions
gst_rtsp_media_factory_add_role
gst_rtsp_media_factory_add_role_from_structure
gst_rtsp_media_factory_get_clock
gst_rtsp_media_factory_set_clock
gst_rtsp_media_factory_set_shared
gst_rtsp_media_factory_is_shared
......
......@@ -30,6 +30,56 @@ RTSP server library based on GStreamer
</GitRepository>
</repository>
<release>
<Version>
<revision>1.14.5</revision>
<branch>1.14</branch>
<name></name>
<created>2019-05-29</created>
<file-release rdf:resource="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-1.14.5.tar.xz" />
</Version>
</release>
<release>
<Version>
<revision>1.14.4</revision>
<branch>1.14</branch>
<name></name>
<created>2018-10-02</created>
<file-release rdf:resource="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-1.14.4.tar.xz" />
</Version>
</release>
<release>
<Version>
<revision>1.14.3</revision>
<branch>1.14</branch>
<name></name>
<created>2018-09-16</created>
<file-release rdf:resource="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-1.14.3.tar.xz" />
</Version>
</release>
<release>
<Version>
<revision>1.14.2</revision>
<branch>1.14</branch>
<name></name>
<created>2018-07-20</created>
<file-release rdf:resource="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-1.14.2.tar.xz" />
</Version>
</release>
<release>
<Version>
<revision>1.14.1</revision>
<branch>1.14</branch>
<name></name>
<created>2018-05-17</created>
<file-release rdf:resource="https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-1.14.1.tar.xz" />
</Version>
</release>
<release>
<Version>
<revision>1.14.0</revision>
......
......@@ -18,6 +18,7 @@ public_headers = \
rtsp-token.h \
rtsp-client.h \
rtsp-server.h \
rtsp-server-object.h \
rtsp-server-prelude.h \
rtsp-onvif-server.h \
rtsp-onvif-client.h \
......
......@@ -18,6 +18,10 @@ rtsp_server_sources = [
'rtsp-stream-transport.c',
'rtsp-thread-pool.c',
'rtsp-token.c',
'rtsp-onvif-server.c',
'rtsp-onvif-client.c',
'rtsp-onvif-media-factory.c',
'rtsp-onvif-media.c',
]
rtsp_server_headers = [
......@@ -40,8 +44,14 @@ rtsp_server_headers = [
'rtsp-token.h',
'rtsp-client.h',
'rtsp-server.h',
'rtsp-server-object.h',
'rtsp-server-prelude.h',
'rtsp-onvif-server.h',
'rtsp-onvif-client.h',
'rtsp-onvif-media-factory.h',
'rtsp-onvif-media.h',
]
install_headers(rtsp_server_headers, subdir : 'gstreamer-1.0/gst/rtsp-server')
gst_rtsp_server_deps = [gstrtsp_dep, gstrtp_dep, gstsdp_dep, gstnet_dep, gstapp_dep]
......
......@@ -320,7 +320,7 @@ gst_rtsp_auth_get_tls_certificate (GstRTSPAuth * auth)
* If set to %NULL (the default), then peer certificate validation will always
* set the %G_TLS_CERTIFICATE_UNKNOWN_CA error.
*
* Since 1.6
* Since: 1.6
*/
void
gst_rtsp_auth_set_tls_database (GstRTSPAuth * auth, GTlsDatabase * database)
......
......@@ -164,6 +164,8 @@ static void gst_rtsp_client_set_property (GObject * object, guint propid,
const GValue * value, GParamSpec * pspec);
static void gst_rtsp_client_finalize (GObject * obj);
static void rtsp_ctrl_timeout_remove (GstRTSPClientPrivate * priv);
static GstSDPMessage *create_sdp (GstRTSPClient * client, GstRTSPMedia * media);
static gboolean handle_sdp (GstRTSPClient * client, GstRTSPContext * ctx,
GstRTSPMedia * media, GstSDPMessage * sdp);
......@@ -767,6 +769,14 @@ gst_rtsp_client_finalize (GObject * obj)
clean_cached_media (client, TRUE);
if (priv->rtsp_ctrl_timeout_id != 0) {
GST_DEBUG ("Killing leftover timeout GSource for client %p", client);
g_source_destroy (g_main_context_find_source_by_id (priv->watch_context,
priv->rtsp_ctrl_timeout_id));
priv->rtsp_ctrl_timeout_id = 0;
priv->rtsp_ctrl_timeout_cnt = 0;
}
g_free (priv->server_ip);
g_mutex_clear (&priv->lock);
g_mutex_clear (&priv->send_lock);
......@@ -1056,7 +1066,7 @@ do_send_data (GstBuffer * buffer, guint8 channel, GstRTSPClient * client)
{
GstRTSPClientPrivate *priv = client->priv;
GstRTSPMessage message = { 0 };
GstRTSPResult res = GST_RTSP_OK;
gboolean ret = TRUE;
GstMapInfo map_info;
guint8 *data;
guint usize;
......@@ -1071,7 +1081,7 @@ do_send_data (GstBuffer * buffer, guint8 channel, GstRTSPClient * client)
g_mutex_lock (&priv->send_lock);
if (priv->send_func)
res = priv->send_func (client, &message, FALSE, priv->send_data);
ret = priv->send_func (client, &message, FALSE, priv->send_data);
g_mutex_unlock (&priv->send_lock);
gst_rtsp_message_steal_body (&message, &data, &usize);
......@@ -1079,7 +1089,7 @@ do_send_data (GstBuffer * buffer, guint8 channel, GstRTSPClient * client)
gst_rtsp_message_unset (&message);
return res == GST_RTSP_OK;
return ret;
}
/**
......@@ -1115,6 +1125,7 @@ gst_rtsp_client_close (GstRTSPClient * client)
g_source_destroy ((GSource *) priv->watch);
priv->watch = NULL;
gst_rtsp_client_set_send_func (client, NULL, NULL, NULL);
rtsp_ctrl_timeout_remove (priv);
g_main_context_unref (priv->watch_context);
priv->watch_context = NULL;
}
......@@ -1784,6 +1795,7 @@ parse_transport (const char *transport, GstRTSPStream * stream,
/* loop through the transports, try to parse */
for (i = 0; transports[i]; i++) {
g_strstrip (transports[i]);
res = gst_rtsp_transport_parse (transports[i], tr);
if (res != GST_RTSP_OK) {
/* no valid transport, search some more */
......
......@@ -87,7 +87,7 @@ struct _GstRTSPClient {
* @params_get: get parameters. This function should also initialize the
* RTSP response(ctx->response) via a call to gst_rtsp_message_init_response()
* @tunnel_http_response: called when a response to the GET request is about to
* be sent for a tunneled connection. The response can be modified. Since 1.4
* be sent for a tunneled connection. The response can be modified. Since: 1.4
*
* The client class structure.
*/
......
......@@ -30,7 +30,7 @@ G_BEGIN_DECLS
typedef struct _GstRTSPContext GstRTSPContext;
#include "rtsp-server-prelude.h"
#include "rtsp-server.h"
#include "rtsp-server-object.h"
#include "rtsp-media.h"
#include "rtsp-media-factory.h"
#include "rtsp-session-media.h"
......
......@@ -618,7 +618,7 @@ rtsp_media_factory_uri_create_element (GstRTSPMediaFactory * factory,
/* keep factory data around */
data = g_new0 (FactoryData, 1);
data->factory = g_object_ref (factory);
data->factory = g_object_ref (urifact);
data->pt = 96;
g_object_set_data_full (G_OBJECT (element), factory_key,
......
......@@ -278,6 +278,8 @@ gst_rtsp_media_factory_finalize (GObject * obj)
GstRTSPMediaFactory *factory = GST_RTSP_MEDIA_FACTORY (obj);
GstRTSPMediaFactoryPrivate *priv = factory->priv;
if (priv->clock)
gst_object_unref (priv->clock);
if (priv->permissions)
gst_rtsp_permissions_unref (priv->permissions);
g_hash_table_unref (priv->medias);
......@@ -1330,13 +1332,14 @@ void
gst_rtsp_media_factory_set_clock (GstRTSPMediaFactory * factory,
GstClock * clock)
{
GstRTSPMediaFactoryPrivate *priv;
GstClock **clock_p;
g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
g_return_if_fail (GST_IS_CLOCK (clock) || clock == NULL);
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
priv = factory->priv;
priv->clock = clock ? gst_object_ref (clock) : NULL;
clock_p = &factory->priv->clock;
gst_object_replace ((GstObject **) clock_p, (GstObject *) clock);
GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
}
......@@ -1357,6 +1360,8 @@ gst_rtsp_media_factory_get_clock (GstRTSPMediaFactory * factory)
GstRTSPMediaFactoryPrivate *priv;
GstClock *ret;
g_return_val_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory), NULL);
GST_RTSP_MEDIA_FACTORY_LOCK (factory);
priv = factory->priv;
ret = priv->clock ? gst_object_ref (priv->clock) : NULL;
......
......@@ -113,6 +113,7 @@ struct _GstRTSPMediaPrivate
gint prepare_count;
gint n_active;
gboolean complete;
gboolean finishing_unprepare;
/* the pipeline for the media */
GstElement *pipeline;
......@@ -474,6 +475,8 @@ gst_rtsp_media_finalize (GObject * obj)
g_object_unref (priv->pool);
if (priv->payloads)
g_list_free (priv->payloads);
if (priv->clock)
gst_object_unref (priv->clock);
g_free (priv->multicast_iface);
g_mutex_clear (&priv->lock);
g_cond_clear (&priv->cond);
......@@ -2395,6 +2398,8 @@ gst_rtsp_media_get_status (GstRTSPMedia * media)
* gst_rtsp_media_prepare().
*
* Returns: %TRUE on success.
*
* Since: 1.14
*/
gboolean
gst_rtsp_media_seek_full (GstRTSPMedia * media, GstRTSPTimeRange * range,
......@@ -3304,6 +3309,10 @@ finish_unprepare (GstRTSPMedia * media)
gint i;
GList *walk;
if (priv->finishing_unprepare)
return;
priv->finishing_unprepare = TRUE;
GST_DEBUG ("shutting down");
/* release the lock on shutdown, otherwise pad_added_cb might try to
......@@ -3314,9 +3323,6 @@ finish_unprepare (GstRTSPMedia * media)
media_streams_set_blocked (media, FALSE);
if (priv->status != GST_RTSP_MEDIA_STATUS_UNPREPARING)
return;
for (i = 0; i < priv->streams->len; i++) {
GstRTSPStream *stream;
......@@ -3369,6 +3375,8 @@ finish_unprepare (GstRTSPMedia * media)
GST_DEBUG ("stop thread");
gst_rtsp_thread_stop (priv->thread);
}
priv->finishing_unprepare = FALSE;
}
/* called with state-lock */
......@@ -4051,6 +4059,13 @@ gst_rtsp_media_set_state (GstRTSPMedia * media, GstState state,
priv = media->priv;
g_rec_mutex_lock (&priv->state_lock);
if (priv->status == GST_RTSP_MEDIA_STATUS_PREPARING
&& gst_rtsp_media_is_shared (media)) {
g_rec_mutex_unlock (&priv->state_lock);
gst_rtsp_media_get_status (media);
g_rec_mutex_lock (&priv->state_lock);
}
if (priv->status == GST_RTSP_MEDIA_STATUS_ERROR)
goto error_status;
if (priv->status != GST_RTSP_MEDIA_STATUS_PREPARED &&
......@@ -4212,7 +4227,7 @@ gst_rtsp_media_get_transport_mode (GstRTSPMedia * media)
}
/**
* gst_rtsp_media_get_seekable:
* gst_rtsp_media_seekable:
* @media: a #GstRTSPMedia
*
* Check if the pipeline for @media seek and up to what point in time,
......@@ -4221,6 +4236,8 @@ gst_rtsp_media_get_transport_mode (GstRTSPMedia * media)
* Returns: -1 if the stream is not seekable, 0 if seekable only to the beginning
* and > 0 to indicate the longest duration between any two random access points.
* %G_MAXINT64 means any value is possible.
*
* Since: 1.14
*/
GstClockTimeDiff
gst_rtsp_media_seekable (GstRTSPMedia * media)
......@@ -4250,6 +4267,8 @@ gst_rtsp_media_seekable (GstRTSPMedia * media)
* SETUP.
*
* Returns: %TRUE if the media pipeline has been sucessfully updated.
*
* Since: 1.14
*/
gboolean
gst_rtsp_media_complete_pipeline (GstRTSPMedia * media, GPtrArray * transports)
......
......@@ -35,6 +35,11 @@
typedef struct GstRTSPOnvifClientClass GstRTSPOnvifClientClass;
typedef struct GstRTSPOnvifClient GstRTSPOnvifClient;
/**
* GstRTSPOnvifClient:
*
* Since: 1.14
*/
struct GstRTSPOnvifClientClass
{
GstRTSPClientClass parent;
......
......@@ -36,6 +36,11 @@ typedef struct GstRTSPOnvifMediaFactoryClass GstRTSPOnvifMediaFactoryClass;
typedef struct GstRTSPOnvifMediaFactory GstRTSPOnvifMediaFactory;
typedef struct GstRTSPOnvifMediaFactoryPrivate GstRTSPOnvifMediaFactoryPrivate;
/**
* GstRTSPOnvifMediaFactory:
*
* Since: 1.14
*/
struct GstRTSPOnvifMediaFactoryClass
{
GstRTSPMediaFactoryClass parent;
......@@ -74,6 +79,7 @@ void gst_rtsp_onvif_media_factory_set_backchannel_bandwidth (GstRTSPOnvifMediaFa
GST_RTSP_SERVER_API
guint gst_rtsp_onvif_media_factory_get_backchannel_bandwidth (GstRTSPOnvifMediaFactory * factory);
GST_RTSP_SERVER_API
gboolean gst_rtsp_onvif_media_factory_requires_backchannel (GstRTSPMediaFactory * factory, GstRTSPContext * ctx);
#endif /* __GST_RTSP_ONVIF_MEDIA_FACTORY_H__ */
......@@ -134,12 +134,12 @@ gst_rtsp_onvif_media_setup_sdp (GstRTSPMedia * media, GstSDPMessage * sdp,
if (sinkpad) {
GstRTSPOnvifMedia *onvif_media = GST_RTSP_ONVIF_MEDIA (media);
gst_sdp_media_add_attribute (smedia, "recvonly", "");
gst_sdp_media_add_attribute (smedia, "sendonly", "");
if (onvif_media->priv->backchannel_bandwidth > 0)
gst_sdp_media_add_bandwidth (smedia, GST_SDP_BWTYPE_AS,
onvif_media->priv->backchannel_bandwidth);
} else {
gst_sdp_media_add_attribute (smedia, "sendonly", "");
gst_sdp_media_add_attribute (smedia, "recvonly", "");
}
}
}
......@@ -284,7 +284,7 @@ out:
/**
* gst_rtsp_onvif_media_set_backchannel_bandwidth:
* @factory: a #GstRTSPMedia
* @media: a #GstRTSPMedia
* @bandwidth: the bandwidth in bits per second
*
* Set the configured/supported bandwidth of the ONVIF backchannel pipeline in
......@@ -305,7 +305,7 @@ gst_rtsp_onvif_media_set_backchannel_bandwidth (GstRTSPOnvifMedia * media,
/**
* gst_rtsp_onvif_media_get_backchannel_bandwidth:
* @factory: a #GstRTSPMedia
* @media: a #GstRTSPMedia
*
* Get the configured/supported bandwidth of the ONVIF backchannel pipeline in
* bits per second.
......
......@@ -36,6 +36,11 @@ typedef struct GstRTSPOnvifMediaClass GstRTSPOnvifMediaClass;
typedef struct GstRTSPOnvifMedia GstRTSPOnvifMedia;
typedef struct GstRTSPOnvifMediaPrivate GstRTSPOnvifMediaPrivate;
/**
* GstRTSPOnvifMedia:
*
* Since: 1.14
*/
struct GstRTSPOnvifMediaClass
{
GstRTSPMediaClass parent;
......
......@@ -35,6 +35,7 @@
#include "config.h"
#endif
#include "rtsp-context.h"
#include "rtsp-onvif-server.h"
#include "rtsp-onvif-client.h"
......
......@@ -21,7 +21,7 @@
#define __GST_RTSP_ONVIF_SERVER_H__
#include <gst/gst.h>
#include "rtsp-server.h"
#include "rtsp-server-object.h"
#define GST_TYPE_RTSP_ONVIF_SERVER (gst_rtsp_onvif_server_get_type ())
#define GST_IS_RTSP_ONVIF_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_ONVIF_SERVER))
......@@ -35,6 +35,11 @@
typedef struct GstRTSPOnvifServerClass GstRTSPOnvifServerClass;
typedef struct GstRTSPOnvifServer GstRTSPOnvifServer;
/**
* GstRTSPOnvifServer:
*
* Since: 1.14
*/
struct GstRTSPOnvifServerClass
{
GstRTSPServerClass parent;
......
......@@ -181,6 +181,20 @@ cleanup:
}
}
/**
* gst_rtsp_sdp_make_media:
* @sdp: a #GstRTSPMessage
* @info: a #GstSDPInfo
* @stream: a #GstRTSPStream
* @caps: a #GstCaps
* @profile: a #GstRTSPProfile
*
* Creates a #GstSDPMedia from the parameters and stores it in @sdp.
*
* Returns: %TRUE on success
*
* Since: 1.14
*/
gboolean
gst_rtsp_sdp_make_media (GstSDPMessage * sdp, GstSDPInfo * info,
GstRTSPStream * stream, GstCaps * caps, GstRTSPProfile profile)
......
/* GStreamer
* Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_RTSP_SERVER_OBJECT_H__
#define __GST_RTSP_SERVER_OBJECT_H__
#include <gst/gst.h>
G_BEGIN_DECLS
typedef struct _GstRTSPServer GstRTSPServer;
typedef struct _GstRTSPServerClass GstRTSPServerClass;
typedef struct _GstRTSPServerPrivate GstRTSPServerPrivate;
#include "rtsp-server-prelude.h"
#include "rtsp-session-pool.h"
#include "rtsp-session.h"
#include "rtsp-media.h"
#include "rtsp-stream.h"
#include "rtsp-stream-transport.h"
#include "rtsp-address-pool.h"
#include "rtsp-thread-pool.h"
#include "rtsp-client.h"
#include "rtsp-context.h"
#include "rtsp-mount-points.h"
#include "rtsp-media-factory.h"
#include "rtsp-permissions.h"
#include "rtsp-auth.h"
#include "rtsp-token.h"
#include "rtsp-session-media.h"
#include "rtsp-sdp.h"
#include "rtsp-media-factory-uri.h"
#include "rtsp-params.h"
#define GST_TYPE_RTSP_SERVER (gst_rtsp_server_get_type ())
#define GST_IS_RTSP_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SERVER))
#define GST_IS_RTSP_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SERVER))
#define GST_RTSP_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SERVER, GstRTSPServerClass))
#define GST_RTSP_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SERVER, GstRTSPServer))
#define GST_RTSP_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SERVER, GstRTSPServerClass))
#define GST_RTSP_SERVER_CAST(obj) ((GstRTSPServer*)(obj))
#define GST_RTSP_SERVER_CLASS_CAST(klass) ((GstRTSPServerClass*)(klass))
/**
* GstRTSPServer:
*
* This object listens on a port, creates and manages the clients connected to
* it.
*/
struct _GstRTSPServer {
GObject parent;
/*< private >*/
GstRTSPServerPrivate *priv;
gpointer _gst_reserved[GST_PADDING];
};
/**
* GstRTSPServerClass:
* @create_client: Create, configure a new GstRTSPClient
* object that handles the new connection on @socket. The default
* implementation will create a GstRTSPClient and will configure the
* mount-points, auth, session-pool and thread-pool on the client.
* @client_connected: emitted when a new client connected.
*
* The RTSP server class structure
*/
struct _GstRTSPServerClass {
GObjectClass parent_class;
GstRTSPClient * (*create_client) (GstRTSPServer *server);
/* signals */
void (*client_connected) (GstRTSPServer *server, GstRTSPClient *client);
/*< private >*/
gpointer _gst_reserved[GST_PADDING_LARGE];
};
GST_RTSP_SERVER_API
GType gst_rtsp_server_get_type (void);
GST_RTSP_SERVER_API
GstRTSPServer * gst_rtsp_server_new (void);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_address (GstRTSPServer *server, const gchar *address);
GST_RTSP_SERVER_API
gchar * gst_rtsp_server_get_address (GstRTSPServer *server);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_service (GstRTSPServer *server, const gchar *service);
GST_RTSP_SERVER_API
gchar * gst_rtsp_server_get_service (GstRTSPServer *server);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_backlog (GstRTSPServer *server, gint backlog);
GST_RTSP_SERVER_API
gint gst_rtsp_server_get_backlog (GstRTSPServer *server);
GST_RTSP_SERVER_API
int gst_rtsp_server_get_bound_port (GstRTSPServer *server);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_session_pool (GstRTSPServer *server, GstRTSPSessionPool *pool);
GST_RTSP_SERVER_API
GstRTSPSessionPool * gst_rtsp_server_get_session_pool (GstRTSPServer *server);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_mount_points (GstRTSPServer *server, GstRTSPMountPoints *mounts);
GST_RTSP_SERVER_API
GstRTSPMountPoints * gst_rtsp_server_get_mount_points (GstRTSPServer *server);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_auth (GstRTSPServer *server, GstRTSPAuth *auth);
GST_RTSP_SERVER_API
GstRTSPAuth * gst_rtsp_server_get_auth (GstRTSPServer *server);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_thread_pool (GstRTSPServer *server, GstRTSPThreadPool *pool);
GST_RTSP_SERVER_API
GstRTSPThreadPool * gst_rtsp_server_get_thread_pool (GstRTSPServer *server);
GST_RTSP_SERVER_API
gboolean gst_rtsp_server_transfer_connection (GstRTSPServer * server, GSocket *socket,
const gchar * ip, gint port,
const gchar *initial_buffer);
GST_RTSP_SERVER_API
gboolean gst_rtsp_server_io_func (GSocket *socket, GIOCondition condition,
GstRTSPServer *server);
GST_RTSP_SERVER_API
GSocket * gst_rtsp_server_create_socket (GstRTSPServer *server,
GCancellable *cancellable,
GError **error);
GST_RTSP_SERVER_API
GSource * gst_rtsp_server_create_source (GstRTSPServer *server,
GCancellable * cancellable,
GError **error);
GST_RTSP_SERVER_API
guint gst_rtsp_server_attach (GstRTSPServer *server,
GMainContext *context);
/**
* GstRTSPServerClientFilterFunc:
* @server: a #GstRTSPServer object
* @client: a #GstRTSPClient in @server
* @user_data: user data that has been given to gst_rtsp_server_client_filter()
*
* This function will be called by the gst_rtsp_server_client_filter(). An
* implementation should return a value of #GstRTSPFilterResult.
*
* When this function returns #GST_RTSP_FILTER_REMOVE, @client will be removed
* from @server.
*
* A return value of #GST_RTSP_FILTER_KEEP will leave @client untouched in
* @server.
*
* A value of #GST_RTSP_FILTER_REF will add @client to the result #GList of
* gst_rtsp_server_client_filter().
*
* Returns: a #GstRTSPFilterResult.
*/
typedef GstRTSPFilterResult (*GstRTSPServerClientFilterFunc) (GstRTSPServer *server,
GstRTSPClient *client,
gpointer user_data);
GST_RTSP_SERVER_API
GList * gst_rtsp_server_client_filter (GstRTSPServer *server,
GstRTSPServerClientFilterFunc func,
gpointer user_data);
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPServer, gst_object_unref)
#endif
G_END_DECLS
#endif /* __GST_RTSP_SERVER_OBJECT_H__ */
......@@ -28,4 +28,13 @@
#define GST_RTSP_SERVER_API GST_EXPORT
#endif
/* Do *not* use these defines outside of rtsp-server. Use G_DEPRECATED instead. */
#ifdef GST_DISABLE_DEPRECATED
#define GST_RTSP_SERVER_DEPRECATED GST_RTSP_SERVER_API
#define GST_RTSP_SERVER_DEPRECATED_FOR(f) GST_RTSP_SERVER_API
#else
#define GST_RTSP_SERVER_DEPRECATED G_DEPRECATED GST_RTSP_SERVER_API
#define GST_RTSP_SERVER_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) GST_RTSP_SERVER_API
#endif
#endif /* __GST_RTSP_SERVER_PRELUDE_H__ */
......@@ -55,7 +55,8 @@
#include <stdlib.h>
#include <string.h>
#include "rtsp-server.h"
#include "rtsp-context.h"
#include "rtsp-server-object.h"
#include "rtsp-client.h"
#define GST_RTSP_SERVER_GET_PRIVATE(obj) \
......
......@@ -24,20 +24,8 @@
G_BEGIN_DECLS
/* Do *not* use these defines outside of rtsp-server. Use G_DEPRECATED instead. */
#ifdef GST_DISABLE_DEPRECATED
#define GST_RTSP_SERVER_DEPRECATED GST_RTSP_SERVER_API
#define GST_RTSP_SERVER_DEPRECATED_FOR(f) GST_RTSP_SERVER_API
#else
#define GST_RTSP_SERVER_DEPRECATED G_DEPRECATED GST_RTSP_SERVER_API
#define GST_RTSP_SERVER_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) GST_RTSP_SERVER_API
#endif
typedef struct _GstRTSPServer GstRTSPServer;
typedef struct _GstRTSPServerClass GstRTSPServerClass;
typedef struct _GstRTSPServerPrivate GstRTSPServerPrivate;
#include "rtsp-server-prelude.h"
#include "rtsp-server-object.h"
#include "rtsp-session-pool.h"
#include "rtsp-session.h"
#include "rtsp-media.h"
......@@ -58,157 +46,10 @@ typedef struct _GstRTSPServerPrivate GstRTSPServerPrivate;
#include "rtsp-media-factory-uri.h"
#include "rtsp-params.h"
#define GST_TYPE_RTSP_SERVER (gst_rtsp_server_get_type ())
#define GST_IS_RTSP_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SERVER))
#define GST_IS_RTSP_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SERVER))
#define GST_RTSP_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SERVER, GstRTSPServerClass))
#define GST_RTSP_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SERVER, GstRTSPServer))
#define GST_RTSP_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SERVER, GstRTSPServerClass))
#define GST_RTSP_SERVER_CAST(obj) ((GstRTSPServer*)(obj))
#define GST_RTSP_SERVER_CLASS_CAST(klass) ((GstRTSPServerClass*)(klass))
/**
* GstRTSPServer:
*
* This object listens on a port, creates and manages the clients connected to
* it.
*/
struct _GstRTSPServer {
GObject parent;
/*< private >*/
GstRTSPServerPrivate *priv;
gpointer _gst_reserved[GST_PADDING];
};
/**
* GstRTSPServerClass:
* @create_client: Create, configure a new GstRTSPClient
* object that handles the new connection on @socket. The default
* implementation will create a GstRTSPClient and will configure the
* mount-points, auth, session-pool and thread-pool on the client.
* @client_connected: emitted when a new client connected.
*
* The RTSP server class structure
*/
struct _GstRTSPServerClass {
GObjectClass parent_class;
GstRTSPClient * (*create_client) (GstRTSPServer *server);
/* signals */
void (*client_connected) (GstRTSPServer *server, GstRTSPClient *client);
/*< private >*/
gpointer _gst_reserved[GST_PADDING_LARGE];
};
GST_RTSP_SERVER_API
GType gst_rtsp_server_get_type (void);
GST_RTSP_SERVER_API
GstRTSPServer * gst_rtsp_server_new (void);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_address (GstRTSPServer *server, const gchar *address);
GST_RTSP_SERVER_API
gchar * gst_rtsp_server_get_address (GstRTSPServer *server);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_service (GstRTSPServer *server, const gchar *service);
GST_RTSP_SERVER_API
gchar * gst_rtsp_server_get_service (GstRTSPServer *server);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_backlog (GstRTSPServer *server, gint backlog);
GST_RTSP_SERVER_API
gint gst_rtsp_server_get_backlog (GstRTSPServer *server);
GST_RTSP_SERVER_API
int gst_rtsp_server_get_bound_port (GstRTSPServer *server);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_session_pool (GstRTSPServer *server, GstRTSPSessionPool *pool);
GST_RTSP_SERVER_API
GstRTSPSessionPool * gst_rtsp_server_get_session_pool (GstRTSPServer *server);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_mount_points (GstRTSPServer *server, GstRTSPMountPoints *mounts);
GST_RTSP_SERVER_API
GstRTSPMountPoints * gst_rtsp_server_get_mount_points (GstRTSPServer *server);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_auth (GstRTSPServer *server, GstRTSPAuth *auth);
GST_RTSP_SERVER_API
GstRTSPAuth * gst_rtsp_server_get_auth (GstRTSPServer *server);
GST_RTSP_SERVER_API
void gst_rtsp_server_set_thread_pool (GstRTSPServer *server, GstRTSPThreadPool *pool);
GST_RTSP_SERVER_API
GstRTSPThreadPool * gst_rtsp_server_get_thread_pool (GstRTSPServer *server);
GST_RTSP_SERVER_API
gboolean gst_rtsp_server_transfer_connection (GstRTSPServer * server, GSocket *socket,
const gchar * ip, gint port,
const gchar *initial_buffer);
GST_RTSP_SERVER_API
gboolean gst_rtsp_server_io_func (GSocket *socket, GIOCondition condition,
GstRTSPServer *server);
GST_RTSP_SERVER_API
GSocket * gst_rtsp_server_create_socket (GstRTSPServer *server,
GCancellable *cancellable,
GError **error);
GST_RTSP_SERVER_API
GSource * gst_rtsp_server_create_source (GstRTSPServer *server,
GCancellable * cancellable,
GError **error);
GST_RTSP_SERVER_API
guint gst_rtsp_server_attach (GstRTSPServer *server,
GMainContext *context);
/**
* GstRTSPServerClientFilterFunc:
* @server: a #GstRTSPServer object
* @client: a #GstRTSPClient in @server
* @user_data: user data that has been given to gst_rtsp_server_client_filter()
*
* This function will be called by the gst_rtsp_server_client_filter(). An
* implementation should return a value of #GstRTSPFilterResult.
*
* When this function returns #GST_RTSP_FILTER_REMOVE, @client will be removed
* from @server.
*
* A return value of #GST_RTSP_FILTER_KEEP will leave @client untouched in
* @server.
*
* A value of #GST_RTSP_FILTER_REF will add @client to the result #GList of
* gst_rtsp_server_client_filter().
*
* Returns: a #GstRTSPFilterResult.
*/
typedef GstRTSPFilterResult (*GstRTSPServerClientFilterFunc) (GstRTSPServer *server,
GstRTSPClient *client,
gpointer user_data);
GST_RTSP_SERVER_API
GList * gst_rtsp_server_client_filter (GstRTSPServer *server,
GstRTSPServerClientFilterFunc func,
gpointer user_data);
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPServer, gst_object_unref)
#endif
#include "rtsp-onvif-client.h"
#include "rtsp-onvif-media-factory.h"
#include "rtsp-onvif-media.h"
#include "rtsp-onvif-server.h"
G_END_DECLS
......
......@@ -415,6 +415,8 @@ gst_rtsp_session_media_get_transport (GstRTSPSessionMedia * media, guint idx)
*
* Returns: (transfer full) (element-type GstRTSPStreamTransport): a
* list of #GstRTSPStreamTransport, g_ptr_array_unref () after usage.
*
* Since: 1.14
*/
GPtrArray *
gst_rtsp_session_media_get_transports (GstRTSPSessionMedia * media)
......
......@@ -387,7 +387,7 @@ gst_rtsp_session_pool_create (GstRTSPSessionPool * pool)
} else {
/* not found, create session and insert it in the pool */
if (klass->create_session)
result = create_session (pool, id);
result = klass->create_session (pool, id);
if (result == NULL)
goto too_many_sessions;
/* take additional ref for the pool */
......
......@@ -20,7 +20,7 @@
#include <gst/gst.h>
#include <gst/rtsp/gstrtsptransport.h>
#include "rtsp-server.h" /* for GST_RTSP_SERVER_DEPRECATED_FOR */
#include "rtsp-server-prelude.h" /* for GST_RTSP_SERVER_DEPRECATED_FOR */
#ifndef __GST_RTSP_SESSION_H__
#define __GST_RTSP_SESSION_H__
......
......@@ -1359,7 +1359,10 @@ again:
else
flags |= GST_RTSP_ADDRESS_FLAG_IPV4;
addr = gst_rtsp_address_pool_acquire_address (pool, flags, 2);
if (*server_addr_out)
addr = *server_addr_out;
else
addr = gst_rtsp_address_pool_acquire_address (pool, flags, 2);
if (addr == NULL)
goto no_address;
......@@ -2885,23 +2888,29 @@ plug_src (GstRTSPStream * stream, GstBin * bin, GstElement * src,
{
GstRTSPStreamPrivate *priv;
GstPad *pad, *selpad;
gulong id = 0;
priv = stream->priv;
/* add src */
gst_bin_add (bin, src);
pad = gst_element_get_static_pad (src, "src");
if (priv->srcpad) {
/* block pad so src can't push data while it's not yet linked */
id = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BLOCK |
GST_PAD_PROBE_TYPE_BUFFER, NULL, NULL, NULL);
/* we set and keep these to playing so that they don't cause NO_PREROLL return
* values. This is only relevant for PLAY pipelines */
gst_element_set_state (src, GST_STATE_PLAYING);
gst_element_set_locked_state (src, TRUE);
}
/* add src */
gst_bin_add (bin, src);
/* and link to the funnel */
selpad = gst_element_get_request_pad (funnel, "sink_%u");
pad = gst_element_get_static_pad (src, "src");
gst_pad_link (pad, selpad);
if (id != 0)
gst_pad_remove_probe (pad, id);
gst_object_unref (pad);
gst_object_unref (selpad);
}
......@@ -3489,7 +3498,7 @@ stats:
goto no_stats;
if (seq)
gst_structure_get_uint (stats, "seqnum", seq);
gst_structure_get_uint (stats, "seqnum-offset", seq);
if (rtptime)
gst_structure_get_uint (stats, "timestamp", rtptime);
......@@ -3965,6 +3974,7 @@ gst_rtsp_stream_get_rtcp_socket (GstRTSPStream * stream, GSocketFamily family)
* Get the multicast RTP socket from @stream for a @family.
*
* Returns: (transfer full) (nullable): the multicast RTP socket or %NULL if no
*
* socket could be allocated for @family. Unref after usage
*/
GSocket *
......@@ -3999,6 +4009,8 @@ gst_rtsp_stream_get_rtp_multicast_socket (GstRTSPStream * stream,
*
* Returns: (transfer full) (nullable): the multicast RTCP socket or %NULL if no
* socket could be allocated for @family. Unref after usage
*
* Since: 1.14
*/
GSocket *
gst_rtsp_stream_get_rtcp_multicast_socket (GstRTSPStream * stream,
......@@ -4256,6 +4268,8 @@ gst_rtsp_stream_set_blocked (GstRTSPStream * stream, gboolean blocked)
* Unblocks the dataflow on @stream if it is linked.
*
* Returns: %TRUE on success
*
* Since: 1.14
*/
gboolean
gst_rtsp_stream_unblock_linked (GstRTSPStream * stream)
......@@ -4472,6 +4486,8 @@ gst_rtsp_stream_query_stop (GstRTSPStream * stream, gint64 * stop)
* Checks whether the individual @stream is seekable.
*
* Returns: %TRUE if @stream is seekable, else %FALSE.
*
* Since: 1.14
*/
gboolean
gst_rtsp_stream_seekable (GstRTSPStream * stream)
......@@ -4526,6 +4542,8 @@ beach:
* SETUP.
*
* Returns: %TRUE if the stream has been sucessfully updated.
*
* Since: 1.14
*/
gboolean
gst_rtsp_stream_complete_stream (GstRTSPStream * stream,
......@@ -4574,6 +4592,8 @@ unallowed_transport:
* seek operations on it.
*
* Returns: %TRUE if the stream contains at least one sink element.
*
* Since: 1.14
*/
gboolean
gst_rtsp_stream_is_complete (GstRTSPStream * stream)
......@@ -4598,6 +4618,8 @@ gst_rtsp_stream_is_complete (GstRTSPStream * stream)
* Checks whether the stream is a sender.
*
* Returns: %TRUE if the stream is a sender and %FALSE otherwise.
*
* Since: 1.14
*/
gboolean
gst_rtsp_stream_is_sender (GstRTSPStream * stream)
......@@ -4622,6 +4644,8 @@ gst_rtsp_stream_is_sender (GstRTSPStream * stream)
* Checks whether the stream is a receiver.
*
* Returns: %TRUE if the stream is a receiver and %FALSE otherwise.
*
* Since: 1.14
*/
gboolean
gst_rtsp_stream_is_receiver (GstRTSPStream * stream)
......
......@@ -1404,6 +1404,9 @@ gst_rtsp_client_sink_release_pad (GstElement * element, GstPad * pad)
context = gst_pad_get_element_private (pad);
/* FIXME: we may need to change our blocking state waiting for
* GstRTSPStreamBlocking messages */
GST_RTSP_STATE_LOCK (sink);
sink->contexts = g_list_remove (sink->contexts, context);
GST_RTSP_STATE_UNLOCK (sink);
......@@ -2006,7 +2009,10 @@ gst_rtsp_conninfo_close (GstRTSPClientSink * sink, GstRTSPConnInfo * info,
/* free connection */
GST_DEBUG_OBJECT (sink, "freeing connection...");
gst_rtsp_connection_free (info->connection);
g_mutex_lock (&sink->preroll_lock);
info->connection = NULL;
g_cond_broadcast (&sink->preroll_cond);
g_mutex_unlock (&sink->preroll_lock);
}
GST_RTSP_STATE_UNLOCK (sink);
return GST_RTSP_OK;
......@@ -3585,7 +3591,8 @@ gst_rtsp_client_sink_collect_streams (GstRTSPClientSink * sink)
/* Now wait for the preroll of the rtp bin */
g_mutex_lock (&sink->preroll_lock);
while (!sink->prerolled && !sink->conninfo.flushing) {
while (!sink->prerolled && sink->conninfo.connection
&& !sink->conninfo.flushing) {
GST_LOG_OBJECT (sink, "Waiting for preroll before continuing");
g_cond_wait (&sink->preroll_cond, &sink->preroll_lock);
}
......@@ -3909,9 +3916,6 @@ gst_rtsp_client_sink_setup_streams (GstRTSPClientSink * sink, gboolean async)
goto create_request_failed;
}
/* select transport */
gst_rtsp_message_take_header (&request, GST_RTSP_HDR_TRANSPORT, transports);
/* set up keys */
if (cur_profile == GST_RTSP_PROFILE_SAVP ||
cur_profile == GST_RTSP_PROFILE_SAVPF) {
......@@ -3952,6 +3956,29 @@ gst_rtsp_client_sink_setup_streams (GstRTSPClientSink * sink, gboolean async)
gst_rtsp_stream_set_blocked (stream, FALSE);
}
/* FIXME:
* the creation of the transports string depends on
* calling stream_get_server_port, which only starts returning
* something meaningful after a call to stream_allocate_udp_sockets
* has been made, this function expects a transport that we parse
* from the transport string ...
*
* Significant refactoring is in order, but does not look entirely
* trivial, for now we put a band aid on and create a second transport
* string after the stream has been completed, to pass it in
* the request headers instead of the previous, incomplete one.
*/
g_free (transports);
transports = NULL;
res = gst_rtsp_client_sink_create_transports_string (sink, context, family,
protocols & protocol_masks[mask], cur_profile, &transports);
if (res < 0 || transports == NULL)
goto setup_transport_failed;
/* select transport */
gst_rtsp_message_take_header (&request, GST_RTSP_HDR_TRANSPORT, transports);
/* handle the code ourselves */
res = gst_rtsp_client_sink_send (sink, info, &request, &response, &code);
if (res < 0)
......@@ -4241,7 +4268,7 @@ gst_rtsp_client_sink_record (GstRTSPClientSink * sink, gboolean async)
g_mutex_lock (&sink->block_streams_lock);
/* Wait for streams to be blocked */
while (!sink->streams_blocked) {
while (sink->n_streams_blocked < g_list_length (sink->contexts)) {
GST_DEBUG_OBJECT (sink, "waiting for streams to be blocked");
g_cond_wait (&sink->block_streams_cond, &sink->block_streams_lock);
}
......@@ -4571,7 +4598,7 @@ gst_rtsp_client_sink_handle_message (GstBin * bin, GstMessage * message)
/* An RTSPStream has prerolled */
GST_DEBUG_OBJECT (rtsp_client_sink, "received GstRTSPStreamBlocking");
g_mutex_lock (&rtsp_client_sink->block_streams_lock);
rtsp_client_sink->streams_blocked = TRUE;
rtsp_client_sink->n_streams_blocked++;
g_cond_broadcast (&rtsp_client_sink->block_streams_cond);
g_mutex_unlock (&rtsp_client_sink->block_streams_lock);
}
......
......@@ -218,7 +218,7 @@ struct _GstRTSPClientSink {
gboolean streams_collected;
/* TRUE when streams have been blocked */
gboolean streams_blocked;
guint n_streams_blocked;
GMutex block_streams_lock;
GCond block_streams_cond;
......
project('gst-rtsp-server', 'c',
version : '1.14.0',
meson_version : '>= 0.33.0',
version : '1.14.5',
meson_version : '>= 0.40.1',
default_options : ['warning_level=1', 'buildtype=debugoptimized'])
gst_version = meson.project_version()
......
......@@ -393,6 +393,173 @@ GST_START_TEST (test_media_prepare)
GST_END_TEST;
enum _SyncState
{
SYNC_STATE_INIT,
SYNC_STATE_1,
SYNC_STATE_2,
SYNC_STATE_RACE
};
typedef enum _SyncState SyncState;
struct _help_thread_data
{
GstRTSPThreadPool *pool;
GstRTSPMedia *media;
GstRTSPTransport *transport;
GstRTSPStream *stream;
SyncState *state;
GMutex *sync_mutex;
GCond *sync_cond;
};
typedef struct _help_thread_data help_thread_data;
static gpointer
help_thread_main (gpointer user_data)
{
help_thread_data *data;
GstRTSPThread *thread;
GPtrArray *transports;
GstRTSPStreamTransport *stream_transport;
data = (help_thread_data *) user_data;
GST_INFO ("Another thread sharing media");
/* wait SYNC_STATE_1 */
g_mutex_lock (data->sync_mutex);
while (*data->state < SYNC_STATE_1)
g_cond_wait (data->sync_cond, data->sync_mutex);
g_mutex_unlock (data->sync_mutex);
/* prepare */
thread = gst_rtsp_thread_pool_get_thread (data->pool,
GST_RTSP_THREAD_TYPE_MEDIA, NULL);
fail_unless (gst_rtsp_media_prepare (data->media, thread));
/* set SYNC_STATE_2 */
g_mutex_lock (data->sync_mutex);
*data->state = SYNC_STATE_2;
g_cond_signal (data->sync_cond);
g_mutex_unlock (data->sync_mutex);
/* wait SYNC_STATE_RACE */
g_mutex_lock (data->sync_mutex);
while (*data->state < SYNC_STATE_RACE)
g_cond_wait (data->sync_cond, data->sync_mutex);
g_mutex_unlock (data->sync_mutex);
/* set state */
transports = g_ptr_array_new_with_free_func (g_object_unref);
fail_unless (transports != NULL);
stream_transport =
gst_rtsp_stream_transport_new (data->stream, data->transport);
fail_unless (stream_transport != NULL);
g_ptr_array_add (transports, stream_transport);
fail_unless (gst_rtsp_media_set_state (data->media, GST_STATE_NULL,
transports));
/* clean up */
GST_INFO ("Thread exit");
fail_unless (gst_rtsp_media_unprepare (data->media));
g_ptr_array_unref (transports);
return NULL;
}
GST_START_TEST (test_media_shared_race_test_unsuspend_vs_set_state_null)
{
help_thread_data data;
GstRTSPMediaFactory *factory;
GstRTSPMedia *media;
GstRTSPUrl *url;
GstRTSPThreadPool *pool;
GstRTSPThread *thread;
GThread *sharing_media_thread;
GstRTSPTransport *transport;
GstRTSPStream *stream;
SyncState state = SYNC_STATE_INIT;
GMutex sync_mutex;
GCond sync_cond;
g_mutex_init (&sync_mutex);
g_cond_init (&sync_cond);
pool = gst_rtsp_thread_pool_new ();
/* test non-reusable media first */
factory = gst_rtsp_media_factory_new ();
gst_rtsp_media_factory_set_shared (factory, TRUE);
fail_unless (gst_rtsp_url_parse ("rtsp://localhost:8554/test",
&url) == GST_RTSP_OK);
gst_rtsp_media_factory_set_launch (factory,
"( videotestsrc ! rtpvrawpay pt=96 name=pay0 )");
media = gst_rtsp_media_factory_construct (factory, url);
fail_unless (GST_IS_RTSP_MEDIA (media));
fail_unless (gst_rtsp_media_n_streams (media) == 1);
gst_rtsp_media_set_suspend_mode (media, GST_RTSP_SUSPEND_MODE_RESET);
stream = gst_rtsp_media_get_stream (media, 0);
fail_unless (stream != NULL);
thread = gst_rtsp_thread_pool_get_thread (pool,
GST_RTSP_THREAD_TYPE_MEDIA, NULL);
fail_unless (gst_rtsp_media_prepare (media, thread));
/* help thread */
data.pool = pool;
data.media = media;
data.stream = stream;
data.state = &state;
data.sync_mutex = &sync_mutex;
data.sync_cond = &sync_cond;
sharing_media_thread = g_thread_new ("new thread", help_thread_main, &data);
fail_unless (sharing_media_thread != NULL);
/* set state SYNC_STATE_1 */
g_mutex_lock (&sync_mutex);
state = SYNC_STATE_1;
g_cond_signal (&sync_cond);
g_mutex_unlock (&sync_mutex);
/* wait SYNC_STATE_2 */
g_mutex_lock (&sync_mutex);
while (state < SYNC_STATE_2)
g_cond_wait (&sync_cond, &sync_mutex);
g_mutex_unlock (&sync_mutex);
gst_rtsp_media_suspend (media);
fail_unless (gst_rtsp_transport_new (&transport) == GST_RTSP_OK);
transport->lower_transport = GST_RTSP_LOWER_TRANS_TCP;
fail_unless (gst_rtsp_stream_complete_stream (stream, transport));
data.transport = transport;
/* set state SYNC_STATE_RACE let the race begin unsuspend <-> set state GST_STATE_NULL */
g_mutex_lock (&sync_mutex);
state = SYNC_STATE_RACE;
g_cond_signal (&sync_cond);
g_mutex_unlock (&sync_mutex);
fail_unless (gst_rtsp_media_unsuspend (media));
/* sync end of other thread */
g_thread_join (sharing_media_thread);
/* clean up */
g_cond_clear (&sync_cond);
g_mutex_clear (&sync_mutex);
fail_unless (gst_rtsp_media_unprepare (media));
g_object_unref (media);
gst_rtsp_url_free (url);
g_object_unref (factory);
g_object_unref (pool);
gst_rtsp_thread_pool_cleanup ();
}
GST_END_TEST;
#define FLAG_HAVE_CAPS GST_ELEMENT_FLAG_LAST
static void
on_notify_caps (GstPad * pad, GParamSpec * pspec, GstElement * pay)
......@@ -654,6 +821,7 @@ rtspmedia_suite (void)
tcase_add_test (tc, test_media_seek_one_active_stream);
tcase_add_test (tc, test_media);
tcase_add_test (tc, test_media_prepare);
tcase_add_test (tc, test_media_shared_race_test_unsuspend_vs_set_state_null);
tcase_add_test (tc, test_media_reusable);
tcase_add_test (tc, test_media_dyn_prepare);
tcase_add_test (tc, test_media_take_pipeline);
......
......@@ -38,6 +38,7 @@ static GstRTSPServer *server = NULL;
/* tcp port that the test server listens for rtsp requests on */
static gint test_port = 0;
static gint server_send_rtcp_port;
/* id of the server's source within the GMainContext */
static guint source_id;
......@@ -132,6 +133,26 @@ get_server_uri (gint port, const gchar * mount_point)
return uri_string;
}
static GstRTSPFilterResult
check_transport (GstRTSPStream *stream, GstRTSPStreamTransport *strans, gpointer user_data)
{
const GstRTSPTransport *trans = gst_rtsp_stream_transport_get_transport (strans);
server_send_rtcp_port = trans->client_port.max;
return GST_RTSP_FILTER_KEEP;
}
static void
new_state_cb (GstRTSPMedia * media, gint state, gpointer user_data)
{
if (state == GST_STATE_PLAYING) {
GstRTSPStream *stream = gst_rtsp_media_get_stream (media, 0);
gst_rtsp_stream_transport_filter (stream, (GstRTSPStreamTransportFilterFunc) check_transport, user_data);
}
}
static void
media_constructed_cb (GstRTSPMediaFactory * mfactory, GstRTSPMedia * media,
gpointer user_data)
......@@ -139,6 +160,9 @@ media_constructed_cb (GstRTSPMediaFactory * mfactory, GstRTSPMedia * media,
GstElement **p_sink = user_data;
GstElement *bin;
g_signal_connect (media, "new-state",
G_CALLBACK (new_state_cb), user_data);
bin = gst_rtsp_media_get_element (media);
*p_sink = gst_bin_get_by_name (GST_BIN (bin), "sink");
GST_INFO ("media constructed!: %" GST_PTR_FORMAT, *p_sink);
......@@ -193,6 +217,8 @@ GST_START_TEST (test_record)
iterate ();