diff options
Diffstat (limited to 'include/gst/rtsp-server')
25 files changed, 3997 insertions, 0 deletions
diff --git a/include/gst/rtsp-server/rtsp-address-pool.h b/include/gst/rtsp-server/rtsp-address-pool.h new file mode 100644 index 0000000000..997cfd1d77 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-address-pool.h @@ -0,0 +1,205 @@ +/* GStreamer + * Copyright (C) 2012 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_ADDRESS_POOL_H__ +#define __GST_RTSP_ADDRESS_POOL_H__ + +#include <gst/gst.h> +#include "rtsp-server-prelude.h" + +G_BEGIN_DECLS + +#define GST_TYPE_RTSP_ADDRESS_POOL (gst_rtsp_address_pool_get_type ()) +#define GST_IS_RTSP_ADDRESS_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_ADDRESS_POOL)) +#define GST_IS_RTSP_ADDRESS_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_ADDRESS_POOL)) +#define GST_RTSP_ADDRESS_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_ADDRESS_POOL, GstRTSPAddressPoolClass)) +#define GST_RTSP_ADDRESS_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_ADDRESS_POOL, GstRTSPAddressPool)) +#define GST_RTSP_ADDRESS_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_ADDRESS_POOL, GstRTSPAddressPoolClass)) +#define GST_RTSP_ADDRESS_POOL_CAST(obj) ((GstRTSPAddressPool*)(obj)) +#define GST_RTSP_ADDRESS_POOL_CLASS_CAST(klass) ((GstRTSPAddressPoolClass*)(klass)) + +/** + * GstRTSPAddressPoolResult: + * @GST_RTSP_ADDRESS_POOL_OK: no error + * @GST_RTSP_ADDRESS_POOL_EINVAL:invalid arguments were provided to a function + * @GST_RTSP_ADDRESS_POOL_ERESERVED: the addres has already been reserved + * @GST_RTSP_ADDRESS_POOL_ERANGE: the address is not in the pool + * @GST_RTSP_ADDRESS_POOL_ELAST: last error + * + * Result codes from RTSP address pool functions. + */ +typedef enum { + GST_RTSP_ADDRESS_POOL_OK = 0, + /* errors */ + GST_RTSP_ADDRESS_POOL_EINVAL = -1, + GST_RTSP_ADDRESS_POOL_ERESERVED = -2, + GST_RTSP_ADDRESS_POOL_ERANGE = -3, + + GST_RTSP_ADDRESS_POOL_ELAST = -4, +} GstRTSPAddressPoolResult; + + +typedef struct _GstRTSPAddress GstRTSPAddress; + +typedef struct _GstRTSPAddressPool GstRTSPAddressPool; +typedef struct _GstRTSPAddressPoolClass GstRTSPAddressPoolClass; +typedef struct _GstRTSPAddressPoolPrivate GstRTSPAddressPoolPrivate; + +/** + * GstRTSPAddress: + * @pool: the #GstRTSPAddressPool owner of this address + * @address: the address + * @port: the port number + * @n_ports: number of ports + * @ttl: TTL or 0 for unicast addresses + * + * An address + */ +struct _GstRTSPAddress { + GstRTSPAddressPool *pool; + + gchar *address; + guint16 port; + gint n_ports; + guint8 ttl; + + /*<private >*/ + gpointer priv; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_address_get_type (void); + +GST_RTSP_SERVER_API +GstRTSPAddress * gst_rtsp_address_copy (GstRTSPAddress *addr); + +GST_RTSP_SERVER_API +void gst_rtsp_address_free (GstRTSPAddress *addr); + +/** + * GstRTSPAddressFlags: + * @GST_RTSP_ADDRESS_FLAG_NONE: no flags + * @GST_RTSP_ADDRESS_FLAG_IPV4: an IPv4 address + * @GST_RTSP_ADDRESS_FLAG_IPV6: and IPv6 address + * @GST_RTSP_ADDRESS_FLAG_EVEN_PORT: address with an even port + * @GST_RTSP_ADDRESS_FLAG_MULTICAST: a multicast address + * @GST_RTSP_ADDRESS_FLAG_UNICAST: a unicast address + * + * Flags used to control allocation of addresses + */ +typedef enum { + GST_RTSP_ADDRESS_FLAG_NONE = 0, + GST_RTSP_ADDRESS_FLAG_IPV4 = (1 << 0), + GST_RTSP_ADDRESS_FLAG_IPV6 = (1 << 1), + GST_RTSP_ADDRESS_FLAG_EVEN_PORT = (1 << 2), + GST_RTSP_ADDRESS_FLAG_MULTICAST = (1 << 3), + GST_RTSP_ADDRESS_FLAG_UNICAST = (1 << 4), +} GstRTSPAddressFlags; + +/** + * GST_RTSP_ADDRESS_POOL_ANY_IPV4: + * + * Used with gst_rtsp_address_pool_add_range() to bind to all + * IPv4 addresses + */ +#define GST_RTSP_ADDRESS_POOL_ANY_IPV4 "0.0.0.0" + +/** + * GST_RTSP_ADDRESS_POOL_ANY_IPV6: + * + * Used with gst_rtsp_address_pool_add_range() to bind to all + * IPv6 addresses + */ +#define GST_RTSP_ADDRESS_POOL_ANY_IPV6 "::" + +/** + * GstRTSPAddressPool: + * @parent: the parent GObject + * + * An address pool, all member are private + */ +struct _GstRTSPAddressPool { + GObject parent; + + /*< private >*/ + GstRTSPAddressPoolPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; +}; + +/** + * GstRTSPAddressPoolClass: + * + * Opaque Address pool class. + */ +struct _GstRTSPAddressPoolClass { + GObjectClass parent_class; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_address_pool_get_type (void); + +/* create a new address pool */ + +GST_RTSP_SERVER_API +GstRTSPAddressPool * gst_rtsp_address_pool_new (void); + +GST_RTSP_SERVER_API +void gst_rtsp_address_pool_clear (GstRTSPAddressPool * pool); + +GST_RTSP_SERVER_API +void gst_rtsp_address_pool_dump (GstRTSPAddressPool * pool); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_address_pool_add_range (GstRTSPAddressPool * pool, + const gchar *min_address, + const gchar *max_address, + guint16 min_port, + guint16 max_port, + guint8 ttl); + +GST_RTSP_SERVER_API +GstRTSPAddress * gst_rtsp_address_pool_acquire_address (GstRTSPAddressPool * pool, + GstRTSPAddressFlags flags, + gint n_ports); + +GST_RTSP_SERVER_API +GstRTSPAddressPoolResult gst_rtsp_address_pool_reserve_address (GstRTSPAddressPool * pool, + const gchar *ip_address, + guint port, + guint n_ports, + guint ttl, + GstRTSPAddress ** address); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_address_pool_has_unicast_addresses (GstRTSPAddressPool * pool); + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPAddress, gst_rtsp_address_free) +#endif + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPAddressPool, gst_object_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_ADDRESS_POOL_H__ */ diff --git a/include/gst/rtsp-server/rtsp-auth.h b/include/gst/rtsp-server/rtsp-auth.h new file mode 100644 index 0000000000..05a3e5a455 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-auth.h @@ -0,0 +1,230 @@ +/* GStreamer + * Copyright (C) 2010 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. + */ + +#include <gst/gst.h> + +#ifndef __GST_RTSP_AUTH_H__ +#define __GST_RTSP_AUTH_H__ + +typedef struct _GstRTSPAuth GstRTSPAuth; +typedef struct _GstRTSPAuthClass GstRTSPAuthClass; +typedef struct _GstRTSPAuthPrivate GstRTSPAuthPrivate; + +#include "rtsp-server-prelude.h" +#include "rtsp-client.h" +#include "rtsp-token.h" + +G_BEGIN_DECLS + +#define GST_TYPE_RTSP_AUTH (gst_rtsp_auth_get_type ()) +#define GST_IS_RTSP_AUTH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_AUTH)) +#define GST_IS_RTSP_AUTH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_AUTH)) +#define GST_RTSP_AUTH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_AUTH, GstRTSPAuthClass)) +#define GST_RTSP_AUTH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_AUTH, GstRTSPAuth)) +#define GST_RTSP_AUTH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_AUTH, GstRTSPAuthClass)) +#define GST_RTSP_AUTH_CAST(obj) ((GstRTSPAuth*)(obj)) +#define GST_RTSP_AUTH_CLASS_CAST(klass) ((GstRTSPAuthClass*)(klass)) + +/** + * GstRTSPAuth: + * + * The authentication structure. + */ +struct _GstRTSPAuth { + GObject parent; + + /*< private >*/ + GstRTSPAuthPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; +}; + +/** + * GstRTSPAuthClass: + * @authenticate: check the authentication of a client. The default implementation + * checks if the authentication in the header matches one of the basic + * authentication tokens. This function should set the authgroup field + * in the context. + * @check: check if a resource can be accessed. this function should + * call authenticate to authenticate the client when needed. The method + * should also construct and send an appropriate response message on + * error. + * + * The authentication class. + */ +struct _GstRTSPAuthClass { + GObjectClass parent_class; + + gboolean (*authenticate) (GstRTSPAuth *auth, GstRTSPContext *ctx); + gboolean (*check) (GstRTSPAuth *auth, GstRTSPContext *ctx, + const gchar *check); + void (*generate_authenticate_header) (GstRTSPAuth *auth, GstRTSPContext *ctx); + gboolean (*accept_certificate) (GstRTSPAuth *auth, + GTlsConnection *connection, + GTlsCertificate *peer_cert, + GTlsCertificateFlags errors); + /*< private >*/ + gpointer _gst_reserved[GST_PADDING - 1]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_auth_get_type (void); + +GST_RTSP_SERVER_API +GstRTSPAuth * gst_rtsp_auth_new (void); + +GST_RTSP_SERVER_API +void gst_rtsp_auth_set_tls_certificate (GstRTSPAuth *auth, GTlsCertificate *cert); + +GST_RTSP_SERVER_API +GTlsCertificate * gst_rtsp_auth_get_tls_certificate (GstRTSPAuth *auth); + +GST_RTSP_SERVER_API +void gst_rtsp_auth_set_tls_database (GstRTSPAuth *auth, GTlsDatabase *database); + +GST_RTSP_SERVER_API +GTlsDatabase * gst_rtsp_auth_get_tls_database (GstRTSPAuth *auth); + +GST_RTSP_SERVER_API +void gst_rtsp_auth_set_tls_authentication_mode (GstRTSPAuth *auth, GTlsAuthenticationMode mode); + +GST_RTSP_SERVER_API +GTlsAuthenticationMode gst_rtsp_auth_get_tls_authentication_mode (GstRTSPAuth *auth); + +GST_RTSP_SERVER_API +void gst_rtsp_auth_set_default_token (GstRTSPAuth *auth, GstRTSPToken *token); + +GST_RTSP_SERVER_API +GstRTSPToken * gst_rtsp_auth_get_default_token (GstRTSPAuth *auth); + +GST_RTSP_SERVER_API +void gst_rtsp_auth_add_basic (GstRTSPAuth *auth, const gchar * basic, + GstRTSPToken *token); + +GST_RTSP_SERVER_API +void gst_rtsp_auth_remove_basic (GstRTSPAuth *auth, const gchar * basic); + +GST_RTSP_SERVER_API +void gst_rtsp_auth_add_digest (GstRTSPAuth *auth, const gchar *user, + const gchar *pass, GstRTSPToken *token); + +GST_RTSP_SERVER_API +void gst_rtsp_auth_remove_digest (GstRTSPAuth *auth, const gchar *user); + +GST_RTSP_SERVER_API +void gst_rtsp_auth_set_supported_methods (GstRTSPAuth *auth, GstRTSPAuthMethod methods); + +GST_RTSP_SERVER_API +GstRTSPAuthMethod gst_rtsp_auth_get_supported_methods (GstRTSPAuth *auth); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_auth_check (const gchar *check); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_auth_parse_htdigest (GstRTSPAuth *auth, const gchar *path, GstRTSPToken *token); + +GST_RTSP_SERVER_API +void gst_rtsp_auth_set_realm (GstRTSPAuth *auth, const gchar *realm); + +GST_RTSP_SERVER_API +gchar * gst_rtsp_auth_get_realm (GstRTSPAuth *auth); + +/* helpers */ + +GST_RTSP_SERVER_API +gchar * gst_rtsp_auth_make_basic (const gchar * user, const gchar * pass); + +/* checks */ +/** + * GST_RTSP_AUTH_CHECK_CONNECT: + * + * Check a new connection + */ +#define GST_RTSP_AUTH_CHECK_CONNECT "auth.check.connect" +/** + * GST_RTSP_AUTH_CHECK_URL: + * + * Check the URL and methods + */ +#define GST_RTSP_AUTH_CHECK_URL "auth.check.url" +/** + * GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_ACCESS: + * + * Check if access is allowed to a factory. + * When access is not allowed an 404 Not Found is sent in the response. + */ +#define GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_ACCESS "auth.check.media.factory.access" +/** + * GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_CONSTRUCT: + * + * Check if media can be constructed from a media factory + * A response should be sent on error. + */ +#define GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_CONSTRUCT "auth.check.media.factory.construct" +/** + * GST_RTSP_AUTH_CHECK_TRANSPORT_CLIENT_SETTINGS: + * + * Check if the client can specify TTL, destination and + * port pair in multicast. No response is sent when the check returns + * %FALSE. + */ +#define GST_RTSP_AUTH_CHECK_TRANSPORT_CLIENT_SETTINGS "auth.check.transport.client-settings" + + +/* tokens */ +/** + * GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE: + * + * G_TYPE_STRING, the role to use when dealing with media factories + * + * The default #GstRTSPAuth object uses this string in the token to find the + * role of the media factory. It will then retrieve the #GstRTSPPermissions of + * the media factory and retrieve the role with the same name. + */ +#define GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE "media.factory.role" +/** + * GST_RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS: + * + * G_TYPE_BOOLEAN, %TRUE if the client can specify TTL, destination and + * port pair in multicast. + */ +#define GST_RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS "transport.client-settings" + +/* permissions */ +/** + * GST_RTSP_PERM_MEDIA_FACTORY_ACCESS: + * + * G_TYPE_BOOLEAN, %TRUE if the media can be accessed, %FALSE will + * return a 404 Not Found error when trying to access the media. + */ +#define GST_RTSP_PERM_MEDIA_FACTORY_ACCESS "media.factory.access" +/** + * GST_RTSP_PERM_MEDIA_FACTORY_CONSTRUCT: + * + * G_TYPE_BOOLEAN, %TRUE if the media can be constructed, %FALSE will + * return a 404 Not Found error when trying to access the media. + */ +#define GST_RTSP_PERM_MEDIA_FACTORY_CONSTRUCT "media.factory.construct" + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPAuth, gst_object_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_AUTH_H__ */ diff --git a/include/gst/rtsp-server/rtsp-client.h b/include/gst/rtsp-server/rtsp-client.h new file mode 100644 index 0000000000..604a042399 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-client.h @@ -0,0 +1,294 @@ +/* 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. + */ + +#include <gst/gst.h> +#include <gst/rtsp/gstrtspconnection.h> + +#ifndef __GST_RTSP_CLIENT_H__ +#define __GST_RTSP_CLIENT_H__ + +G_BEGIN_DECLS + +typedef struct _GstRTSPClient GstRTSPClient; +typedef struct _GstRTSPClientClass GstRTSPClientClass; +typedef struct _GstRTSPClientPrivate GstRTSPClientPrivate; + +#include "rtsp-server-prelude.h" +#include "rtsp-context.h" +#include "rtsp-mount-points.h" +#include "rtsp-sdp.h" +#include "rtsp-auth.h" + +#define GST_TYPE_RTSP_CLIENT (gst_rtsp_client_get_type ()) +#define GST_IS_RTSP_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_CLIENT)) +#define GST_IS_RTSP_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_CLIENT)) +#define GST_RTSP_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_CLIENT, GstRTSPClientClass)) +#define GST_RTSP_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_CLIENT, GstRTSPClient)) +#define GST_RTSP_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_CLIENT, GstRTSPClientClass)) +#define GST_RTSP_CLIENT_CAST(obj) ((GstRTSPClient*)(obj)) +#define GST_RTSP_CLIENT_CLASS_CAST(klass) ((GstRTSPClientClass*)(klass)) + +/** + * GstRTSPClientSendFunc: + * @client: a #GstRTSPClient + * @message: a #GstRTSPMessage + * @close: close the connection + * @user_data: user data when registering the callback + * + * This callback is called when @client wants to send @message. When @close is + * %TRUE, the connection should be closed when the message has been sent. + * + * Returns: %TRUE on success. + */ +typedef gboolean (*GstRTSPClientSendFunc) (GstRTSPClient *client, + GstRTSPMessage *message, + gboolean close, + gpointer user_data); + +/** + * GstRTSPClientSendMessagesFunc: + * @client: a #GstRTSPClient + * @messages: #GstRTSPMessage + * @n_messages: number of messages + * @close: close the connection + * @user_data: user data when registering the callback + * + * This callback is called when @client wants to send @messages. When @close is + * %TRUE, the connection should be closed when the message has been sent. + * + * Returns: %TRUE on success. + * + * Since: 1.16 + */ +typedef gboolean (*GstRTSPClientSendMessagesFunc) (GstRTSPClient *client, + GstRTSPMessage *messages, + guint n_messages, + gboolean close, + gpointer user_data); + +/** + * GstRTSPClient: + * + * The client object represents the connection and its state with a client. + */ +struct _GstRTSPClient { + GObject parent; + + /*< private >*/ + GstRTSPClientPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; +}; + +/** + * GstRTSPClientClass: + * @create_sdp: called when the SDP needs to be created for media. + * @configure_client_media: called when the stream in media needs to be configured. + * The default implementation will configure the blocksize on the payloader when + * spcified in the request headers. + * @configure_client_transport: called when the client transport needs to be + * configured. + * @params_set: set parameters. This function should also initialize the + * RTSP response(ctx->response) via a call to gst_rtsp_message_init_response() + * @params_get: get parameters. This function should also initialize the + * RTSP response(ctx->response) via a call to gst_rtsp_message_init_response() + * @make_path_from_uri: called to create path from uri. + * @adjust_play_mode: called to give the application the possibility to adjust + * the range, seek flags, rate and rate-control. Since 1.18 + * @adjust_play_response: called to give the implementation the possibility to + * adjust the response to a play request, for example if extra headers were + * parsed when #GstRTSPClientClass.adjust_play_mode was called. Since 1.18 + * @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 + * + * The client class structure. + */ +struct _GstRTSPClientClass { + GObjectClass parent_class; + + GstSDPMessage * (*create_sdp) (GstRTSPClient *client, GstRTSPMedia *media); + gboolean (*configure_client_media) (GstRTSPClient * client, + GstRTSPMedia * media, GstRTSPStream * stream, + GstRTSPContext * ctx); + gboolean (*configure_client_transport) (GstRTSPClient * client, + GstRTSPContext * ctx, + GstRTSPTransport * ct); + GstRTSPResult (*params_set) (GstRTSPClient *client, GstRTSPContext *ctx); + GstRTSPResult (*params_get) (GstRTSPClient *client, GstRTSPContext *ctx); + gchar * (*make_path_from_uri) (GstRTSPClient *client, const GstRTSPUrl *uri); + GstRTSPStatusCode (*adjust_play_mode) (GstRTSPClient * client, + GstRTSPContext * context, + GstRTSPTimeRange ** range, + GstSeekFlags * flags, + gdouble * rate, + GstClockTime * trickmode_interval, + gboolean * enable_rate_control); + GstRTSPStatusCode (*adjust_play_response) (GstRTSPClient * client, + GstRTSPContext * context); + + /* signals */ + void (*closed) (GstRTSPClient *client); + void (*new_session) (GstRTSPClient *client, GstRTSPSession *session); + void (*options_request) (GstRTSPClient *client, GstRTSPContext *ctx); + void (*describe_request) (GstRTSPClient *client, GstRTSPContext *ctx); + void (*setup_request) (GstRTSPClient *client, GstRTSPContext *ctx); + void (*play_request) (GstRTSPClient *client, GstRTSPContext *ctx); + void (*pause_request) (GstRTSPClient *client, GstRTSPContext *ctx); + void (*teardown_request) (GstRTSPClient *client, GstRTSPContext *ctx); + void (*set_parameter_request) (GstRTSPClient *client, GstRTSPContext *ctx); + void (*get_parameter_request) (GstRTSPClient *client, GstRTSPContext *ctx); + void (*handle_response) (GstRTSPClient *client, GstRTSPContext *ctx); + + void (*tunnel_http_response) (GstRTSPClient * client, GstRTSPMessage * request, + GstRTSPMessage * response); + void (*send_message) (GstRTSPClient * client, GstRTSPContext *ctx, + GstRTSPMessage * response); + + gboolean (*handle_sdp) (GstRTSPClient *client, GstRTSPContext *ctx, GstRTSPMedia *media, GstSDPMessage *sdp); + + void (*announce_request) (GstRTSPClient *client, GstRTSPContext *ctx); + void (*record_request) (GstRTSPClient *client, GstRTSPContext *ctx); + gchar* (*check_requirements) (GstRTSPClient *client, GstRTSPContext *ctx, gchar ** arr); + + GstRTSPStatusCode (*pre_options_request) (GstRTSPClient *client, GstRTSPContext *ctx); + GstRTSPStatusCode (*pre_describe_request) (GstRTSPClient *client, GstRTSPContext *ctx); + GstRTSPStatusCode (*pre_setup_request) (GstRTSPClient *client, GstRTSPContext *ctx); + GstRTSPStatusCode (*pre_play_request) (GstRTSPClient *client, GstRTSPContext *ctx); + GstRTSPStatusCode (*pre_pause_request) (GstRTSPClient *client, GstRTSPContext *ctx); + GstRTSPStatusCode (*pre_teardown_request) (GstRTSPClient *client, GstRTSPContext *ctx); + GstRTSPStatusCode (*pre_set_parameter_request) (GstRTSPClient *client, GstRTSPContext *ctx); + GstRTSPStatusCode (*pre_get_parameter_request) (GstRTSPClient *client, GstRTSPContext *ctx); + GstRTSPStatusCode (*pre_announce_request) (GstRTSPClient *client, GstRTSPContext *ctx); + GstRTSPStatusCode (*pre_record_request) (GstRTSPClient *client, GstRTSPContext *ctx); + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING_LARGE-18]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_client_get_type (void); + +GST_RTSP_SERVER_API +GstRTSPClient * gst_rtsp_client_new (void); + +GST_RTSP_SERVER_API +void gst_rtsp_client_set_session_pool (GstRTSPClient *client, + GstRTSPSessionPool *pool); + +GST_RTSP_SERVER_API +GstRTSPSessionPool * gst_rtsp_client_get_session_pool (GstRTSPClient *client); + +GST_RTSP_SERVER_API +void gst_rtsp_client_set_mount_points (GstRTSPClient *client, + GstRTSPMountPoints *mounts); + +GST_RTSP_SERVER_API +GstRTSPMountPoints * gst_rtsp_client_get_mount_points (GstRTSPClient *client); + +GST_RTSP_SERVER_API +void gst_rtsp_client_set_content_length_limit (GstRTSPClient *client, guint limit); + +GST_RTSP_SERVER_API +guint gst_rtsp_client_get_content_length_limit (GstRTSPClient *client); + +GST_RTSP_SERVER_API +void gst_rtsp_client_set_auth (GstRTSPClient *client, GstRTSPAuth *auth); + +GST_RTSP_SERVER_API +GstRTSPAuth * gst_rtsp_client_get_auth (GstRTSPClient *client); + +GST_RTSP_SERVER_API +void gst_rtsp_client_set_thread_pool (GstRTSPClient *client, GstRTSPThreadPool *pool); + +GST_RTSP_SERVER_API +GstRTSPThreadPool * gst_rtsp_client_get_thread_pool (GstRTSPClient *client); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_client_set_connection (GstRTSPClient *client, GstRTSPConnection *conn); + +GST_RTSP_SERVER_API +GstRTSPConnection * gst_rtsp_client_get_connection (GstRTSPClient *client); + +GST_RTSP_SERVER_API +guint gst_rtsp_client_attach (GstRTSPClient *client, + GMainContext *context); + +GST_RTSP_SERVER_API +void gst_rtsp_client_close (GstRTSPClient * client); + +GST_RTSP_SERVER_API +void gst_rtsp_client_set_send_func (GstRTSPClient *client, + GstRTSPClientSendFunc func, + gpointer user_data, + GDestroyNotify notify); + +GST_RTSP_SERVER_API +void gst_rtsp_client_set_send_messages_func (GstRTSPClient *client, + GstRTSPClientSendMessagesFunc func, + gpointer user_data, + GDestroyNotify notify); + +GST_RTSP_SERVER_API +GstRTSPResult gst_rtsp_client_handle_message (GstRTSPClient *client, + GstRTSPMessage *message); + +GST_RTSP_SERVER_API +GstRTSPResult gst_rtsp_client_send_message (GstRTSPClient * client, + GstRTSPSession *session, + GstRTSPMessage *message); +/** + * GstRTSPClientSessionFilterFunc: + * @client: a #GstRTSPClient object + * @sess: a #GstRTSPSession in @client + * @user_data: user data that has been given to gst_rtsp_client_session_filter() + * + * This function will be called by the gst_rtsp_client_session_filter(). An + * implementation should return a value of #GstRTSPFilterResult. + * + * When this function returns #GST_RTSP_FILTER_REMOVE, @sess will be removed + * from @client. + * + * A return value of #GST_RTSP_FILTER_KEEP will leave @sess untouched in + * @client. + * + * A value of #GST_RTSP_FILTER_REF will add @sess to the result #GList of + * gst_rtsp_client_session_filter(). + * + * Returns: a #GstRTSPFilterResult. + */ +typedef GstRTSPFilterResult (*GstRTSPClientSessionFilterFunc) (GstRTSPClient *client, + GstRTSPSession *sess, + gpointer user_data); + +GST_RTSP_SERVER_API +GList * gst_rtsp_client_session_filter (GstRTSPClient *client, + GstRTSPClientSessionFilterFunc func, + gpointer user_data); + +GST_RTSP_SERVER_API +GstRTSPStreamTransport * gst_rtsp_client_get_stream_transport (GstRTSPClient *client, + guint8 channel); + + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPClient, gst_object_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_CLIENT_H__ */ diff --git a/include/gst/rtsp-server/rtsp-context.h b/include/gst/rtsp-server/rtsp-context.h new file mode 100644 index 0000000000..c4567f9b09 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-context.h @@ -0,0 +1,97 @@ +/* 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. + */ + +#include <gst/gst.h> +#include <gst/rtsp/gstrtspconnection.h> + +#ifndef __GST_RTSP_CONTEXT_H__ +#define __GST_RTSP_CONTEXT_H__ + +G_BEGIN_DECLS + +#define GST_TYPE_RTSP_CONTEXT (gst_rtsp_context_get_type ()) + +typedef struct _GstRTSPContext GstRTSPContext; + +#include "rtsp-server-prelude.h" +#include "rtsp-server-object.h" +#include "rtsp-media.h" +#include "rtsp-media-factory.h" +#include "rtsp-session-media.h" +#include "rtsp-auth.h" +#include "rtsp-thread-pool.h" +#include "rtsp-token.h" + +/** + * GstRTSPContext: + * @server: the server + * @conn: the connection + * @client: the client + * @request: the complete request + * @uri: the complete url parsed from @request + * @method: the parsed method of @uri + * @auth: the current auth object or %NULL + * @token: authorisation token + * @session: the session, can be %NULL + * @sessmedia: the session media for the url can be %NULL + * @factory: the media factory for the url, can be %NULL + * @media: the media for the url can be %NULL + * @stream: the stream for the url can be %NULL + * @response: the response + * @trans: the stream transport, can be %NULL + * + * Information passed around containing the context of a request. + */ +struct _GstRTSPContext { + GstRTSPServer *server; + GstRTSPConnection *conn; + GstRTSPClient *client; + GstRTSPMessage *request; + GstRTSPUrl *uri; + GstRTSPMethod method; + GstRTSPAuth *auth; + GstRTSPToken *token; + GstRTSPSession *session; + GstRTSPSessionMedia *sessmedia; + GstRTSPMediaFactory *factory; + GstRTSPMedia *media; + GstRTSPStream *stream; + GstRTSPMessage *response; + GstRTSPStreamTransport *trans; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING - 1]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_context_get_type (void); + +GST_RTSP_SERVER_API +GstRTSPContext * gst_rtsp_context_get_current (void); + +GST_RTSP_SERVER_API +void gst_rtsp_context_push_current (GstRTSPContext * ctx); + +GST_RTSP_SERVER_API +void gst_rtsp_context_pop_current (GstRTSPContext * ctx); + + +G_END_DECLS + +#endif /* __GST_RTSP_CONTEXT_H__ */ diff --git a/include/gst/rtsp-server/rtsp-media-factory-uri.h b/include/gst/rtsp-server/rtsp-media-factory-uri.h new file mode 100644 index 0000000000..2980670cd5 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-media-factory-uri.h @@ -0,0 +1,91 @@ +/* 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. + */ + +#include <gst/gst.h> + +#include "rtsp-media-factory.h" + +#ifndef __GST_RTSP_MEDIA_FACTORY_URI_H__ +#define __GST_RTSP_MEDIA_FACTORY_URI_H__ + +G_BEGIN_DECLS + +/* types for the media factory */ +#define GST_TYPE_RTSP_MEDIA_FACTORY_URI (gst_rtsp_media_factory_uri_get_type ()) +#define GST_IS_RTSP_MEDIA_FACTORY_URI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_MEDIA_FACTORY_URI)) +#define GST_IS_RTSP_MEDIA_FACTORY_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_MEDIA_FACTORY_URI)) +#define GST_RTSP_MEDIA_FACTORY_URI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_MEDIA_FACTORY_URI, GstRTSPMediaFactoryURIClass)) +#define GST_RTSP_MEDIA_FACTORY_URI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_MEDIA_FACTORY_URI, GstRTSPMediaFactoryURI)) +#define GST_RTSP_MEDIA_FACTORY_URI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_MEDIA_FACTORY_URI, GstRTSPMediaFactoryURIClass)) +#define GST_RTSP_MEDIA_FACTORY_URI_CAST(obj) ((GstRTSPMediaFactoryURI*)(obj)) +#define GST_RTSP_MEDIA_FACTORY_URI_CLASS_CAST(klass) ((GstRTSPMediaFactoryURIClass*)(klass)) + +typedef struct _GstRTSPMediaFactoryURI GstRTSPMediaFactoryURI; +typedef struct _GstRTSPMediaFactoryURIClass GstRTSPMediaFactoryURIClass; +typedef struct _GstRTSPMediaFactoryURIPrivate GstRTSPMediaFactoryURIPrivate; + +/** + * GstRTSPMediaFactoryURI: + * + * A media factory that creates a pipeline to play any uri. + */ +struct _GstRTSPMediaFactoryURI { + GstRTSPMediaFactory parent; + + /*< private >*/ + GstRTSPMediaFactoryURIPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; +}; + +/** + * GstRTSPMediaFactoryURIClass: + * + * The #GstRTSPMediaFactoryURI class structure. + */ +struct _GstRTSPMediaFactoryURIClass { + GstRTSPMediaFactoryClass parent_class; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_media_factory_uri_get_type (void); + +/* creating the factory */ + +GST_RTSP_SERVER_API +GstRTSPMediaFactoryURI * gst_rtsp_media_factory_uri_new (void); + +/* configuring the factory */ + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_uri_set_uri (GstRTSPMediaFactoryURI *factory, + const gchar *uri); + +GST_RTSP_SERVER_API +gchar * gst_rtsp_media_factory_uri_get_uri (GstRTSPMediaFactoryURI *factory); + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPMediaFactoryURI, gst_object_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_MEDIA_FACTORY_URI_H__ */ diff --git a/include/gst/rtsp-server/rtsp-media-factory.h b/include/gst/rtsp-server/rtsp-media-factory.h new file mode 100644 index 0000000000..8e847fda33 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-media-factory.h @@ -0,0 +1,284 @@ +/* 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. + */ + +#include <gst/gst.h> +#include <gst/rtsp/gstrtspurl.h> + +#include "rtsp-media.h" +#include "rtsp-permissions.h" +#include "rtsp-address-pool.h" + +#ifndef __GST_RTSP_MEDIA_FACTORY_H__ +#define __GST_RTSP_MEDIA_FACTORY_H__ + +G_BEGIN_DECLS + +/* types for the media factory */ +#define GST_TYPE_RTSP_MEDIA_FACTORY (gst_rtsp_media_factory_get_type ()) +#define GST_IS_RTSP_MEDIA_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_MEDIA_FACTORY)) +#define GST_IS_RTSP_MEDIA_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_MEDIA_FACTORY)) +#define GST_RTSP_MEDIA_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_MEDIA_FACTORY, GstRTSPMediaFactoryClass)) +#define GST_RTSP_MEDIA_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_MEDIA_FACTORY, GstRTSPMediaFactory)) +#define GST_RTSP_MEDIA_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_MEDIA_FACTORY, GstRTSPMediaFactoryClass)) +#define GST_RTSP_MEDIA_FACTORY_CAST(obj) ((GstRTSPMediaFactory*)(obj)) +#define GST_RTSP_MEDIA_FACTORY_CLASS_CAST(klass) ((GstRTSPMediaFactoryClass*)(klass)) + +typedef struct _GstRTSPMediaFactory GstRTSPMediaFactory; +typedef struct _GstRTSPMediaFactoryClass GstRTSPMediaFactoryClass; +typedef struct _GstRTSPMediaFactoryPrivate GstRTSPMediaFactoryPrivate; + +/** + * GstRTSPMediaFactory: + * + * The definition and logic for constructing the pipeline for a media. The media + * can contain multiple streams like audio and video. + */ +struct _GstRTSPMediaFactory { + GObject parent; + + /*< private >*/ + GstRTSPMediaFactoryPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; +}; + +/** + * GstRTSPMediaFactoryClass: + * @gen_key: convert @url to a key for caching shared #GstRTSPMedia objects. + * The default implementation of this function will use the complete URL + * including the query parameters to return a key. + * @create_element: Construct and return a #GstElement that is a #GstBin containing + * the elements to use for streaming the media. The bin should contain + * payloaders pay\%d for each stream. The default implementation of this + * function returns the bin created from the launch parameter. + * @construct: the vmethod that will be called when the factory has to create the + * #GstRTSPMedia for @url. The default implementation of this + * function calls create_element to retrieve an element and then looks for + * pay\%d to create the streams. + * @create_pipeline: create a new pipeline or re-use an existing one and + * add the #GstRTSPMedia's element created by @construct to the pipeline. + * @configure: configure the media created with @construct. The default + * implementation will configure the 'shared' property of the media. + * @media_constructed: signal emitted when a media was constructed + * @media_configure: signal emitted when a media should be configured + * + * The #GstRTSPMediaFactory class structure. + */ +struct _GstRTSPMediaFactoryClass { + GObjectClass parent_class; + + gchar * (*gen_key) (GstRTSPMediaFactory *factory, const GstRTSPUrl *url); + + GstElement * (*create_element) (GstRTSPMediaFactory *factory, const GstRTSPUrl *url); + GstRTSPMedia * (*construct) (GstRTSPMediaFactory *factory, const GstRTSPUrl *url); + GstElement * (*create_pipeline) (GstRTSPMediaFactory *factory, GstRTSPMedia *media); + void (*configure) (GstRTSPMediaFactory *factory, GstRTSPMedia *media); + + /* signals */ + void (*media_constructed) (GstRTSPMediaFactory *factory, GstRTSPMedia *media); + void (*media_configure) (GstRTSPMediaFactory *factory, GstRTSPMedia *media); + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING_LARGE]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_media_factory_get_type (void); + +/* creating the factory */ + +GST_RTSP_SERVER_API +GstRTSPMediaFactory * gst_rtsp_media_factory_new (void); + +/* configuring the factory */ + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_launch (GstRTSPMediaFactory *factory, + const gchar *launch); + +GST_RTSP_SERVER_API +gchar * gst_rtsp_media_factory_get_launch (GstRTSPMediaFactory *factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_permissions (GstRTSPMediaFactory *factory, + GstRTSPPermissions *permissions); + +GST_RTSP_SERVER_API +GstRTSPPermissions * gst_rtsp_media_factory_get_permissions (GstRTSPMediaFactory *factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_add_role (GstRTSPMediaFactory *factory, + const gchar *role, + const gchar *fieldname, ...); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_add_role_from_structure (GstRTSPMediaFactory * factory, + GstStructure *structure); +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_shared (GstRTSPMediaFactory *factory, + gboolean shared); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_factory_is_shared (GstRTSPMediaFactory *factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_stop_on_disconnect (GstRTSPMediaFactory *factory, + gboolean stop_on_disconnect); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_factory_is_stop_on_disonnect (GstRTSPMediaFactory *factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_suspend_mode (GstRTSPMediaFactory *factory, + GstRTSPSuspendMode mode); + +GST_RTSP_SERVER_API +GstRTSPSuspendMode gst_rtsp_media_factory_get_suspend_mode (GstRTSPMediaFactory *factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_eos_shutdown (GstRTSPMediaFactory *factory, + gboolean eos_shutdown); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_factory_is_eos_shutdown (GstRTSPMediaFactory *factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_profiles (GstRTSPMediaFactory *factory, + GstRTSPProfile profiles); + +GST_RTSP_SERVER_API +GstRTSPProfile gst_rtsp_media_factory_get_profiles (GstRTSPMediaFactory *factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_protocols (GstRTSPMediaFactory *factory, + GstRTSPLowerTrans protocols); + +GST_RTSP_SERVER_API +GstRTSPLowerTrans gst_rtsp_media_factory_get_protocols (GstRTSPMediaFactory *factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_address_pool (GstRTSPMediaFactory * factory, + GstRTSPAddressPool * pool); + +GST_RTSP_SERVER_API +GstRTSPAddressPool * gst_rtsp_media_factory_get_address_pool (GstRTSPMediaFactory * factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_multicast_iface (GstRTSPMediaFactory *factory, const gchar *multicast_iface); + +GST_RTSP_SERVER_API +gchar * gst_rtsp_media_factory_get_multicast_iface (GstRTSPMediaFactory *factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_buffer_size (GstRTSPMediaFactory * factory, + guint size); + +GST_RTSP_SERVER_API +guint gst_rtsp_media_factory_get_buffer_size (GstRTSPMediaFactory * factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_retransmission_time (GstRTSPMediaFactory * factory, + GstClockTime time); + +GST_RTSP_SERVER_API +GstClockTime gst_rtsp_media_factory_get_retransmission_time (GstRTSPMediaFactory * factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_do_retransmission (GstRTSPMediaFactory * factory, + gboolean do_retransmission); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_factory_get_do_retransmission (GstRTSPMediaFactory * factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_latency (GstRTSPMediaFactory * factory, + guint latency); + +GST_RTSP_SERVER_API +guint gst_rtsp_media_factory_get_latency (GstRTSPMediaFactory * factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_transport_mode (GstRTSPMediaFactory *factory, + GstRTSPTransportMode mode); + +GST_RTSP_SERVER_API +GstRTSPTransportMode gst_rtsp_media_factory_get_transport_mode (GstRTSPMediaFactory *factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_media_gtype (GstRTSPMediaFactory * factory, + GType media_gtype); + +GST_RTSP_SERVER_API +GType gst_rtsp_media_factory_get_media_gtype (GstRTSPMediaFactory * factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_clock (GstRTSPMediaFactory *factory, + GstClock * clock); + +GST_RTSP_SERVER_API +GstClock * gst_rtsp_media_factory_get_clock (GstRTSPMediaFactory *factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_publish_clock_mode (GstRTSPMediaFactory * factory, GstRTSPPublishClockMode mode); + +GST_RTSP_SERVER_API +GstRTSPPublishClockMode gst_rtsp_media_factory_get_publish_clock_mode (GstRTSPMediaFactory * factory); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_factory_set_max_mcast_ttl (GstRTSPMediaFactory * factory, + guint ttl); + +GST_RTSP_SERVER_API +guint gst_rtsp_media_factory_get_max_mcast_ttl (GstRTSPMediaFactory * factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_bind_mcast_address (GstRTSPMediaFactory * factory, + gboolean bind_mcast_addr); +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_factory_is_bind_mcast_address (GstRTSPMediaFactory * factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_dscp_qos (GstRTSPMediaFactory * factory, + gint dscp_qos); +GST_RTSP_SERVER_API +gint gst_rtsp_media_factory_get_dscp_qos (GstRTSPMediaFactory * factory); + +GST_RTSP_SERVER_API +void gst_rtsp_media_factory_set_enable_rtcp (GstRTSPMediaFactory * factory, + gboolean enable); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_factory_is_enable_rtcp (GstRTSPMediaFactory * factory); + +/* creating the media from the factory and a url */ + +GST_RTSP_SERVER_API +GstRTSPMedia * gst_rtsp_media_factory_construct (GstRTSPMediaFactory *factory, + const GstRTSPUrl *url); + +GST_RTSP_SERVER_API +GstElement * gst_rtsp_media_factory_create_element (GstRTSPMediaFactory *factory, + const GstRTSPUrl *url); + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPMediaFactory, gst_object_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_MEDIA_FACTORY_H__ */ diff --git a/include/gst/rtsp-server/rtsp-media.h b/include/gst/rtsp-server/rtsp-media.h new file mode 100644 index 0000000000..9c2494a64e --- /dev/null +++ b/include/gst/rtsp-server/rtsp-media.h @@ -0,0 +1,449 @@ +/* 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. + */ + +#include <gst/gst.h> +#include <gst/rtsp/rtsp.h> +#include <gst/net/gstnet.h> + +#ifndef __GST_RTSP_MEDIA_H__ +#define __GST_RTSP_MEDIA_H__ + +#include "rtsp-server-prelude.h" + +G_BEGIN_DECLS + +/* types for the media */ +#define GST_TYPE_RTSP_MEDIA (gst_rtsp_media_get_type ()) +#define GST_IS_RTSP_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_MEDIA)) +#define GST_IS_RTSP_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_MEDIA)) +#define GST_RTSP_MEDIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_MEDIA, GstRTSPMediaClass)) +#define GST_RTSP_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_MEDIA, GstRTSPMedia)) +#define GST_RTSP_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_MEDIA, GstRTSPMediaClass)) +#define GST_RTSP_MEDIA_CAST(obj) ((GstRTSPMedia*)(obj)) +#define GST_RTSP_MEDIA_CLASS_CAST(klass) ((GstRTSPMediaClass*)(klass)) + +typedef struct _GstRTSPMedia GstRTSPMedia; +typedef struct _GstRTSPMediaClass GstRTSPMediaClass; +typedef struct _GstRTSPMediaPrivate GstRTSPMediaPrivate; + +/** + * GstRTSPMediaStatus: + * @GST_RTSP_MEDIA_STATUS_UNPREPARED: media pipeline not prerolled + * @GST_RTSP_MEDIA_STATUS_UNPREPARING: media pipeline is busy doing a clean + * shutdown. + * @GST_RTSP_MEDIA_STATUS_PREPARING: media pipeline is prerolling + * @GST_RTSP_MEDIA_STATUS_PREPARED: media pipeline is prerolled + * @GST_RTSP_MEDIA_STATUS_SUSPENDED: media is suspended + * @GST_RTSP_MEDIA_STATUS_ERROR: media pipeline is in error + * + * The state of the media pipeline. + */ +typedef enum { + GST_RTSP_MEDIA_STATUS_UNPREPARED = 0, + GST_RTSP_MEDIA_STATUS_UNPREPARING = 1, + GST_RTSP_MEDIA_STATUS_PREPARING = 2, + GST_RTSP_MEDIA_STATUS_PREPARED = 3, + GST_RTSP_MEDIA_STATUS_SUSPENDED = 4, + GST_RTSP_MEDIA_STATUS_ERROR = 5 +} GstRTSPMediaStatus; + +/** + * GstRTSPSuspendMode: + * @GST_RTSP_SUSPEND_MODE_NONE: Media is not suspended + * @GST_RTSP_SUSPEND_MODE_PAUSE: Media is PAUSED in suspend + * @GST_RTSP_SUSPEND_MODE_RESET: The media is set to NULL when suspended + * + * The suspend mode of the media pipeline. A media pipeline is suspended right + * after creating the SDP and when the client performs a PAUSED request. + */ +typedef enum { + GST_RTSP_SUSPEND_MODE_NONE = 0, + GST_RTSP_SUSPEND_MODE_PAUSE = 1, + GST_RTSP_SUSPEND_MODE_RESET = 2 +} GstRTSPSuspendMode; + +/** + * GstRTSPTransportMode: + * @GST_RTSP_TRANSPORT_MODE_PLAY: Transport supports PLAY mode + * @GST_RTSP_TRANSPORT_MODE_RECORD: Transport supports RECORD mode + * + * The supported modes of the media. + */ +typedef enum { + GST_RTSP_TRANSPORT_MODE_PLAY = 1, + GST_RTSP_TRANSPORT_MODE_RECORD = 2, +} GstRTSPTransportMode; + +/** + * GstRTSPPublishClockMode: + * @GST_RTSP_PUBLISH_CLOCK_MODE_NONE: Publish nothing + * @GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK: Publish the clock but not the offset + * @GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK_AND_OFFSET: Publish the clock and offset + * + * Whether the clock and possibly RTP/clock offset should be published according to RFC7273. + */ +typedef enum { + GST_RTSP_PUBLISH_CLOCK_MODE_NONE, + GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK, + GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK_AND_OFFSET +} GstRTSPPublishClockMode; + +#define GST_TYPE_RTSP_TRANSPORT_MODE (gst_rtsp_transport_mode_get_type()) +GST_RTSP_SERVER_API +GType gst_rtsp_transport_mode_get_type (void); + +#define GST_TYPE_RTSP_SUSPEND_MODE (gst_rtsp_suspend_mode_get_type()) +GST_RTSP_SERVER_API +GType gst_rtsp_suspend_mode_get_type (void); + +#define GST_TYPE_RTSP_PUBLISH_CLOCK_MODE (gst_rtsp_publish_clock_mode_get_type()) +GST_RTSP_SERVER_API +GType gst_rtsp_publish_clock_mode_get_type (void); + +#include "rtsp-stream.h" +#include "rtsp-thread-pool.h" +#include "rtsp-permissions.h" +#include "rtsp-address-pool.h" +#include "rtsp-sdp.h" + +/** + * GstRTSPMedia: + * + * A class that contains the GStreamer element along with a list of + * #GstRTSPStream objects that can produce data. + * + * This object is usually created from a #GstRTSPMediaFactory. + */ +struct _GstRTSPMedia { + GObject parent; + + /*< private >*/ + GstRTSPMediaPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; +}; + +/** + * GstRTSPMediaClass: + * @handle_message: handle a message + * @prepare: the default implementation adds all elements and sets the + * pipeline's state to GST_STATE_PAUSED (or GST_STATE_PLAYING + * in case of NO_PREROLL elements). + * @unprepare: the default implementation sets the pipeline's state + * to GST_STATE_NULL and removes all elements. + * @suspend: the default implementation sets the pipeline's state to + * GST_STATE_NULL GST_STATE_PAUSED depending on the selected + * suspend mode. + * @unsuspend: the default implementation reverts the suspend operation. + * The pipeline will be prerolled again if it's state was + * set to GST_STATE_NULL in suspend. + * @convert_range: convert a range to the given unit + * @query_position: query the current position in the pipeline + * @query_stop: query when playback will stop + * + * The RTSP media class + */ +struct _GstRTSPMediaClass { + GObjectClass parent_class; + + /* vmethods */ + gboolean (*handle_message) (GstRTSPMedia *media, GstMessage *message); + gboolean (*prepare) (GstRTSPMedia *media, GstRTSPThread *thread); + gboolean (*unprepare) (GstRTSPMedia *media); + gboolean (*suspend) (GstRTSPMedia *media); + gboolean (*unsuspend) (GstRTSPMedia *media); + gboolean (*convert_range) (GstRTSPMedia *media, GstRTSPTimeRange *range, + GstRTSPRangeUnit unit); + gboolean (*query_position) (GstRTSPMedia *media, gint64 *position); + gboolean (*query_stop) (GstRTSPMedia *media, gint64 *stop); + GstElement * (*create_rtpbin) (GstRTSPMedia *media); + gboolean (*setup_rtpbin) (GstRTSPMedia *media, GstElement *rtpbin); + gboolean (*setup_sdp) (GstRTSPMedia *media, GstSDPMessage *sdp, GstSDPInfo *info); + + /* signals */ + void (*new_stream) (GstRTSPMedia *media, GstRTSPStream * stream); + void (*removed_stream) (GstRTSPMedia *media, GstRTSPStream * stream); + + void (*prepared) (GstRTSPMedia *media); + void (*unprepared) (GstRTSPMedia *media); + + void (*target_state) (GstRTSPMedia *media, GstState state); + void (*new_state) (GstRTSPMedia *media, GstState state); + + gboolean (*handle_sdp) (GstRTSPMedia *media, GstSDPMessage *sdp); + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING_LARGE-1]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_media_get_type (void); + +/* creating the media */ + +GST_RTSP_SERVER_API +GstRTSPMedia * gst_rtsp_media_new (GstElement *element); + +GST_RTSP_SERVER_API +GstElement * gst_rtsp_media_get_element (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_take_pipeline (GstRTSPMedia *media, GstPipeline *pipeline); + +GST_RTSP_SERVER_API +GstRTSPMediaStatus gst_rtsp_media_get_status (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_permissions (GstRTSPMedia *media, + GstRTSPPermissions *permissions); + +GST_RTSP_SERVER_API +GstRTSPPermissions * gst_rtsp_media_get_permissions (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_shared (GstRTSPMedia *media, gboolean shared); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_is_shared (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_stop_on_disconnect (GstRTSPMedia *media, gboolean stop_on_disconnect); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_is_stop_on_disconnect (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_transport_mode (GstRTSPMedia *media, GstRTSPTransportMode mode); + +GST_RTSP_SERVER_API +GstRTSPTransportMode gst_rtsp_media_get_transport_mode (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_reusable (GstRTSPMedia *media, gboolean reusable); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_is_reusable (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_profiles (GstRTSPMedia *media, GstRTSPProfile profiles); + +GST_RTSP_SERVER_API +GstRTSPProfile gst_rtsp_media_get_profiles (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_protocols (GstRTSPMedia *media, GstRTSPLowerTrans protocols); + +GST_RTSP_SERVER_API +GstRTSPLowerTrans gst_rtsp_media_get_protocols (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_eos_shutdown (GstRTSPMedia *media, gboolean eos_shutdown); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_is_eos_shutdown (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_address_pool (GstRTSPMedia *media, GstRTSPAddressPool *pool); + +GST_RTSP_SERVER_API +GstRTSPAddressPool * gst_rtsp_media_get_address_pool (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_multicast_iface (GstRTSPMedia *media, const gchar *multicast_iface); + +GST_RTSP_SERVER_API +gchar * gst_rtsp_media_get_multicast_iface (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_buffer_size (GstRTSPMedia *media, guint size); + +GST_RTSP_SERVER_API +guint gst_rtsp_media_get_buffer_size (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_retransmission_time (GstRTSPMedia *media, GstClockTime time); + +GST_RTSP_SERVER_API +GstClockTime gst_rtsp_media_get_retransmission_time (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_do_retransmission (GstRTSPMedia * media, + gboolean do_retransmission); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_get_do_retransmission (GstRTSPMedia * media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_latency (GstRTSPMedia *media, guint latency); + +GST_RTSP_SERVER_API +guint gst_rtsp_media_get_latency (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_use_time_provider (GstRTSPMedia *media, gboolean time_provider); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_is_time_provider (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +GstNetTimeProvider * gst_rtsp_media_get_time_provider (GstRTSPMedia *media, + const gchar *address, guint16 port); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_clock (GstRTSPMedia *media, GstClock * clock); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_publish_clock_mode (GstRTSPMedia * media, GstRTSPPublishClockMode mode); + +GST_RTSP_SERVER_API +GstRTSPPublishClockMode gst_rtsp_media_get_publish_clock_mode (GstRTSPMedia * media); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_set_max_mcast_ttl (GstRTSPMedia *media, guint ttl); + +GST_RTSP_SERVER_API +guint gst_rtsp_media_get_max_mcast_ttl (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_bind_mcast_address (GstRTSPMedia *media, gboolean bind_mcast_addr); +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_is_bind_mcast_address (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_dscp_qos (GstRTSPMedia * media, gint dscp_qos); +GST_RTSP_SERVER_API +gint gst_rtsp_media_get_dscp_qos (GstRTSPMedia * media); + +/* prepare the media for playback */ + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_prepare (GstRTSPMedia *media, GstRTSPThread *thread); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_unprepare (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_suspend_mode (GstRTSPMedia *media, GstRTSPSuspendMode mode); + +GST_RTSP_SERVER_API +GstRTSPSuspendMode gst_rtsp_media_get_suspend_mode (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_suspend (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_unsuspend (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_setup_sdp (GstRTSPMedia * media, GstSDPMessage * sdp, + GstSDPInfo * info); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_handle_sdp (GstRTSPMedia * media, GstSDPMessage * sdp); + +/* creating streams */ + +GST_RTSP_SERVER_API +void gst_rtsp_media_collect_streams (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +GstRTSPStream * gst_rtsp_media_create_stream (GstRTSPMedia *media, + GstElement *payloader, + GstPad *pad); + +/* dealing with the media */ + +GST_RTSP_SERVER_API +void gst_rtsp_media_lock (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_unlock (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +GstClock * gst_rtsp_media_get_clock (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +GstClockTime gst_rtsp_media_get_base_time (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +guint gst_rtsp_media_n_streams (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +GstRTSPStream * gst_rtsp_media_get_stream (GstRTSPMedia *media, guint idx); + +GST_RTSP_SERVER_API +GstRTSPStream * gst_rtsp_media_find_stream (GstRTSPMedia *media, const gchar * control); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_seek (GstRTSPMedia *media, GstRTSPTimeRange *range); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_seek_full (GstRTSPMedia *media, + GstRTSPTimeRange *range, + GstSeekFlags flags); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_seek_trickmode (GstRTSPMedia *media, + GstRTSPTimeRange *range, + GstSeekFlags flags, + gdouble rate, + GstClockTime trickmode_interval); + +GST_RTSP_SERVER_API +GstClockTimeDiff gst_rtsp_media_seekable (GstRTSPMedia *media); + +GST_RTSP_SERVER_API +gchar * gst_rtsp_media_get_range_string (GstRTSPMedia *media, + gboolean play, + GstRTSPRangeUnit unit); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_get_rates (GstRTSPMedia * media, + gdouble * rate, + gdouble * applied_rate); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_set_state (GstRTSPMedia *media, GstState state, + GPtrArray *transports); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_pipeline_state (GstRTSPMedia * media, + GstState state); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_complete_pipeline (GstRTSPMedia * media, GPtrArray * transports); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_is_receive_only (GstRTSPMedia * media); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_has_completed_sender (GstRTSPMedia * media); + +GST_RTSP_SERVER_API +void gst_rtsp_media_set_rate_control (GstRTSPMedia * media, gboolean enabled); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_media_get_rate_control (GstRTSPMedia * media); + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPMedia, gst_object_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_MEDIA_H__ */ diff --git a/include/gst/rtsp-server/rtsp-mount-points.h b/include/gst/rtsp-server/rtsp-mount-points.h new file mode 100644 index 0000000000..200620dcdd --- /dev/null +++ b/include/gst/rtsp-server/rtsp-mount-points.h @@ -0,0 +1,105 @@ +/* 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. + */ + +#include <gst/gst.h> + +#include "rtsp-media-factory.h" + +#ifndef __GST_RTSP_MOUNT_POINTS_H__ +#define __GST_RTSP_MOUNT_POINTS_H__ + +G_BEGIN_DECLS + +#define GST_TYPE_RTSP_MOUNT_POINTS (gst_rtsp_mount_points_get_type ()) +#define GST_IS_RTSP_MOUNT_POINTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_MOUNT_POINTS)) +#define GST_IS_RTSP_MOUNT_POINTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_MOUNT_POINTS)) +#define GST_RTSP_MOUNT_POINTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_MOUNT_POINTS, GstRTSPMountPointsClass)) +#define GST_RTSP_MOUNT_POINTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_MOUNT_POINTS, GstRTSPMountPoints)) +#define GST_RTSP_MOUNT_POINTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_MOUNT_POINTS, GstRTSPMountPointsClass)) +#define GST_RTSP_MOUNT_POINTS_CAST(obj) ((GstRTSPMountPoints*)(obj)) +#define GST_RTSP_MOUNT_POINTS_CLASS_CAST(klass) ((GstRTSPMountPointsClass*)(klass)) + +typedef struct _GstRTSPMountPoints GstRTSPMountPoints; +typedef struct _GstRTSPMountPointsClass GstRTSPMountPointsClass; +typedef struct _GstRTSPMountPointsPrivate GstRTSPMountPointsPrivate; + +/** + * GstRTSPMountPoints: + * + * Creates a #GstRTSPMediaFactory object for a given url. + */ +struct _GstRTSPMountPoints { + GObject parent; + + /*< private >*/ + GstRTSPMountPointsPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; +}; + +/** + * GstRTSPMountPointsClass: + * @make_path: make a path from the given url. + * + * The class for the media mounts object. + */ +struct _GstRTSPMountPointsClass { + GObjectClass parent_class; + + gchar * (*make_path) (GstRTSPMountPoints *mounts, + const GstRTSPUrl *url); + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_mount_points_get_type (void); + +/* creating a mount points */ + +GST_RTSP_SERVER_API +GstRTSPMountPoints * gst_rtsp_mount_points_new (void); + +GST_RTSP_SERVER_API +gchar * gst_rtsp_mount_points_make_path (GstRTSPMountPoints *mounts, + const GstRTSPUrl * url); +/* finding a media factory */ + +GST_RTSP_SERVER_API +GstRTSPMediaFactory * gst_rtsp_mount_points_match (GstRTSPMountPoints *mounts, + const gchar *path, + gint * matched); +/* managing media to a mount point */ + +GST_RTSP_SERVER_API +void gst_rtsp_mount_points_add_factory (GstRTSPMountPoints *mounts, + const gchar *path, + GstRTSPMediaFactory *factory); + +GST_RTSP_SERVER_API +void gst_rtsp_mount_points_remove_factory (GstRTSPMountPoints *mounts, + const gchar *path); + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPMountPoints, gst_object_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_MOUNT_POINTS_H__ */ diff --git a/include/gst/rtsp-server/rtsp-onvif-client.h b/include/gst/rtsp-server/rtsp-onvif-client.h new file mode 100644 index 0000000000..8230f23c59 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-onvif-client.h @@ -0,0 +1,65 @@ +/* GStreamer + * Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.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_ONVIF_CLIENT_H__ +#define __GST_RTSP_ONVIF_CLIENT_H__ + +#include <gst/gst.h> +#include "rtsp-client.h" + +#define GST_TYPE_RTSP_ONVIF_CLIENT (gst_rtsp_onvif_client_get_type ()) +#define GST_IS_RTSP_ONVIF_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_ONVIF_CLIENT)) +#define GST_IS_RTSP_ONVIF_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_ONVIF_CLIENT)) +#define GST_RTSP_ONVIF_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_ONVIF_CLIENT, GstRTSPOnvifClientClass)) +#define GST_RTSP_ONVIF_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_ONVIF_CLIENT, GstRTSPOnvifClient)) +#define GST_RTSP_ONVIF_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_ONVIF_CLIENT, GstRTSPOnvifClientClass)) +#define GST_RTSP_ONVIF_CLIENT_CAST(obj) ((GstRTSPOnvifClient*)(obj)) +#define GST_RTSP_ONVIF_CLIENT_CLASS_CAST(klass) ((GstRTSPOnvifClientClass*)(klass)) + +typedef struct GstRTSPOnvifClientClass GstRTSPOnvifClientClass; +typedef struct GstRTSPOnvifClient GstRTSPOnvifClient; + +/** + * GstRTSPOnvifClient: + * + * Since: 1.14 + */ +struct GstRTSPOnvifClientClass +{ + GstRTSPClientClass parent; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING_LARGE]; +}; + +struct GstRTSPOnvifClient +{ + GstRTSPClient parent; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_onvif_client_get_type (void); + +GST_RTSP_SERVER_API +GstRTSPClient * gst_rtsp_onvif_client_new (void); + +#endif /* __GST_RTSP_ONVIF_CLIENT_H__ */ diff --git a/include/gst/rtsp-server/rtsp-onvif-media-factory.h b/include/gst/rtsp-server/rtsp-onvif-media-factory.h new file mode 100644 index 0000000000..7ff9dc3469 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-onvif-media-factory.h @@ -0,0 +1,95 @@ +/* GStreamer + * Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.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_ONVIF_MEDIA_FACTORY_H__ +#define __GST_RTSP_ONVIF_MEDIA_FACTORY_H__ + +#include <gst/gst.h> +#include "rtsp-media-factory.h" + +#define GST_TYPE_RTSP_ONVIF_MEDIA_FACTORY (gst_rtsp_onvif_media_factory_get_type ()) +#define GST_IS_RTSP_ONVIF_MEDIA_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_ONVIF_MEDIA_FACTORY)) +#define GST_IS_RTSP_ONVIF_MEDIA_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_ONVIF_MEDIA_FACTORY)) +#define GST_RTSP_ONVIF_MEDIA_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_ONVIF_MEDIA_FACTORY, GstRTSPOnvifMediaFactoryClass)) +#define GST_RTSP_ONVIF_MEDIA_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_ONVIF_MEDIA_FACTORY, GstRTSPOnvifMediaFactory)) +#define GST_RTSP_ONVIF_MEDIA_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_ONVIF_MEDIA_FACTORY, GstRTSPOnvifMediaFactoryClass)) +#define GST_RTSP_ONVIF_MEDIA_FACTORY_CAST(obj) ((GstRTSPOnvifMediaFactory*)(obj)) +#define GST_RTSP_ONVIF_MEDIA_FACTORY_CLASS_CAST(klass) ((GstRTSPOnvifMediaFactoryClass*)(klass)) + +typedef struct GstRTSPOnvifMediaFactoryClass GstRTSPOnvifMediaFactoryClass; +typedef struct GstRTSPOnvifMediaFactory GstRTSPOnvifMediaFactory; +typedef struct GstRTSPOnvifMediaFactoryPrivate GstRTSPOnvifMediaFactoryPrivate; + +/** + * GstRTSPOnvifMediaFactory: + * + * Since: 1.14 + */ +struct GstRTSPOnvifMediaFactoryClass +{ + GstRTSPMediaFactoryClass parent; + gboolean (*has_backchannel_support) (GstRTSPOnvifMediaFactory * factory); + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING_LARGE]; +}; + +struct GstRTSPOnvifMediaFactory +{ + GstRTSPMediaFactory parent; + GstRTSPOnvifMediaFactoryPrivate *priv; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_onvif_media_factory_get_type (void); + +GST_RTSP_SERVER_API +GstRTSPMediaFactory *gst_rtsp_onvif_media_factory_new (void); + +GST_RTSP_SERVER_API +void gst_rtsp_onvif_media_factory_set_backchannel_launch (GstRTSPOnvifMediaFactory * + factory, const gchar * launch); +GST_RTSP_SERVER_API +gchar * gst_rtsp_onvif_media_factory_get_backchannel_launch (GstRTSPOnvifMediaFactory * factory); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_onvif_media_factory_has_backchannel_support (GstRTSPOnvifMediaFactory * factory); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_onvif_media_factory_has_replay_support (GstRTSPOnvifMediaFactory * factory); + +GST_RTSP_SERVER_API +void gst_rtsp_onvif_media_factory_set_replay_support (GstRTSPOnvifMediaFactory * factory, gboolean has_replay_support); + +GST_RTSP_SERVER_API +void gst_rtsp_onvif_media_factory_set_backchannel_bandwidth (GstRTSPOnvifMediaFactory * factory, guint bandwidth); +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); + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPOnvifMediaFactory, gst_object_unref) +#endif + +#endif /* __GST_RTSP_ONVIF_MEDIA_FACTORY_H__ */ diff --git a/include/gst/rtsp-server/rtsp-onvif-media.h b/include/gst/rtsp-server/rtsp-onvif-media.h new file mode 100644 index 0000000000..95418c073a --- /dev/null +++ b/include/gst/rtsp-server/rtsp-onvif-media.h @@ -0,0 +1,71 @@ +/* GStreamer + * Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.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_ONVIF_MEDIA_H__ +#define __GST_RTSP_ONVIF_MEDIA_H__ + +#include <gst/gst.h> +#include "rtsp-media.h" + +#define GST_TYPE_RTSP_ONVIF_MEDIA (gst_rtsp_onvif_media_get_type ()) +#define GST_IS_RTSP_ONVIF_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_ONVIF_MEDIA)) +#define GST_IS_RTSP_ONVIF_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_ONVIF_MEDIA)) +#define GST_RTSP_ONVIF_MEDIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_ONVIF_MEDIA, GstRTSPOnvifMediaClass)) +#define GST_RTSP_ONVIF_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_ONVIF_MEDIA, GstRTSPOnvifMedia)) +#define GST_RTSP_ONVIF_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_ONVIF_MEDIA, GstRTSPOnvifMediaClass)) +#define GST_RTSP_ONVIF_MEDIA_CAST(obj) ((GstRTSPOnvifMedia*)(obj)) +#define GST_RTSP_ONVIF_MEDIA_CLASS_CAST(klass) ((GstRTSPOnvifMediaClass*)(klass)) + +typedef struct GstRTSPOnvifMediaClass GstRTSPOnvifMediaClass; +typedef struct GstRTSPOnvifMedia GstRTSPOnvifMedia; +typedef struct GstRTSPOnvifMediaPrivate GstRTSPOnvifMediaPrivate; + +/** + * GstRTSPOnvifMedia: + * + * Since: 1.14 + */ +struct GstRTSPOnvifMediaClass +{ + GstRTSPMediaClass parent; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING_LARGE]; +}; + +struct GstRTSPOnvifMedia +{ + GstRTSPMedia parent; + GstRTSPOnvifMediaPrivate *priv; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_onvif_media_get_type (void); +GST_RTSP_SERVER_API +gboolean gst_rtsp_onvif_media_collect_backchannel (GstRTSPOnvifMedia * media); + +GST_RTSP_SERVER_API +void gst_rtsp_onvif_media_set_backchannel_bandwidth (GstRTSPOnvifMedia * media, guint bandwidth); +GST_RTSP_SERVER_API +guint gst_rtsp_onvif_media_get_backchannel_bandwidth (GstRTSPOnvifMedia * media); + +#endif /* __GST_RTSP_ONVIF_MEDIA_H__ */ diff --git a/include/gst/rtsp-server/rtsp-onvif-server.h b/include/gst/rtsp-server/rtsp-onvif-server.h new file mode 100644 index 0000000000..b04c9b4d5c --- /dev/null +++ b/include/gst/rtsp-server/rtsp-onvif-server.h @@ -0,0 +1,71 @@ +/* GStreamer + * Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.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_ONVIF_SERVER_H__ +#define __GST_RTSP_ONVIF_SERVER_H__ + +#include <gst/gst.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)) +#define GST_IS_RTSP_ONVIF_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_ONVIF_SERVER)) +#define GST_RTSP_ONVIF_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_ONVIF_SERVER, GstRTSPOnvifServerClass)) +#define GST_RTSP_ONVIF_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_ONVIF_SERVER, GstRTSPOnvifServer)) +#define GST_RTSP_ONVIF_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_ONVIF_SERVER, GstRTSPOnvifServerClass)) +#define GST_RTSP_ONVIF_SERVER_CAST(obj) ((GstRTSPOnvifServer*)(obj)) +#define GST_RTSP_ONVIF_SERVER_CLASS_CAST(klass) ((GstRTSPOnvifServerClass*)(klass)) + +typedef struct GstRTSPOnvifServerClass GstRTSPOnvifServerClass; +typedef struct GstRTSPOnvifServer GstRTSPOnvifServer; + +/** + * GstRTSPOnvifServer: + * + * Since: 1.14 + */ +struct GstRTSPOnvifServerClass +{ + GstRTSPServerClass parent; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING_LARGE]; +}; + +struct GstRTSPOnvifServer +{ + GstRTSPServer parent; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_onvif_server_get_type (void); +GST_RTSP_SERVER_API +GstRTSPServer *gst_rtsp_onvif_server_new (void); + +#define GST_RTSP_ONVIF_BACKCHANNEL_REQUIREMENT "www.onvif.org/ver20/backchannel" +#define GST_RTSP_ONVIF_REPLAY_REQUIREMENT "onvif-replay" + +#include "rtsp-onvif-client.h" +#include "rtsp-onvif-media-factory.h" +#include "rtsp-onvif-media.h" + +#endif /* __GST_RTSP_ONVIF_SERVER_H__ */ diff --git a/include/gst/rtsp-server/rtsp-params.h b/include/gst/rtsp-server/rtsp-params.h new file mode 100644 index 0000000000..f2863169d4 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-params.h @@ -0,0 +1,41 @@ +/* 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. + */ + +#include <gst/gst.h> + +#include <gst/rtsp/gstrtspurl.h> +#include <gst/rtsp/gstrtspmessage.h> + +#ifndef __GST_RTSP_PARAMS_H__ +#define __GST_RTSP_PARAMS_H__ + +#include "rtsp-client.h" +#include "rtsp-session.h" + +G_BEGIN_DECLS + +GST_RTSP_SERVER_API +GstRTSPResult gst_rtsp_params_set (GstRTSPClient * client, GstRTSPContext * ctx); + +GST_RTSP_SERVER_API +GstRTSPResult gst_rtsp_params_get (GstRTSPClient * client, GstRTSPContext * ctx); + +G_END_DECLS + +#endif /* __GST_RTSP_PARAMS_H__ */ diff --git a/include/gst/rtsp-server/rtsp-permissions.h b/include/gst/rtsp-server/rtsp-permissions.h new file mode 100644 index 0000000000..fac55e400d --- /dev/null +++ b/include/gst/rtsp-server/rtsp-permissions.h @@ -0,0 +1,122 @@ +/* GStreamer + * Copyright (C) 2010 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. + */ + +#include <gst/gst.h> + +#ifndef __GST_RTSP_PERMISSIONS_H__ +#define __GST_RTSP_PERMISSIONS_H__ + +#include "rtsp-server-prelude.h" + +typedef struct _GstRTSPPermissions GstRTSPPermissions; + +G_BEGIN_DECLS + +GST_RTSP_SERVER_API +GType gst_rtsp_permissions_get_type (void); + +#define GST_TYPE_RTSP_PERMISSIONS (gst_rtsp_permissions_get_type ()) +#define GST_IS_RTSP_PERMISSIONS(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_RTSP_PERMISSIONS)) +#define GST_RTSP_PERMISSIONS_CAST(obj) ((GstRTSPPermissions*)(obj)) +#define GST_RTSP_PERMISSIONS(obj) (GST_RTSP_PERMISSIONS_CAST(obj)) + +/** + * GstRTSPPermissions: + * + * The opaque permissions structure. It is used to define the permissions + * of objects in different roles. + */ +struct _GstRTSPPermissions { + GstMiniObject mini_object; +}; + +/* refcounting */ +/** + * gst_rtsp_permissions_ref: + * @permissions: The permissions to refcount + * + * Increase the refcount of this permissions. + * + * Returns: (transfer full): @permissions (for convenience when doing assignments) + */ +static inline GstRTSPPermissions * +gst_rtsp_permissions_ref (GstRTSPPermissions * permissions) +{ + return (GstRTSPPermissions *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (permissions)); +} + +/** + * gst_rtsp_permissions_unref: + * @permissions: (transfer full): the permissions to refcount + * + * Decrease the refcount of an permissions, freeing it if the refcount reaches 0. + */ +static inline void +gst_rtsp_permissions_unref (GstRTSPPermissions * permissions) +{ + gst_mini_object_unref (GST_MINI_OBJECT_CAST (permissions)); +} + + +GST_RTSP_SERVER_API +GstRTSPPermissions * gst_rtsp_permissions_new (void); + +GST_RTSP_SERVER_API +void gst_rtsp_permissions_add_role (GstRTSPPermissions *permissions, + const gchar *role, + const gchar *fieldname, ...); + +GST_RTSP_SERVER_API +void gst_rtsp_permissions_add_role_valist (GstRTSPPermissions *permissions, + const gchar *role, + const gchar *fieldname, + va_list var_args); + +GST_RTSP_SERVER_API +void gst_rtsp_permissions_add_role_empty (GstRTSPPermissions * permissions, + const gchar * role); + +GST_RTSP_SERVER_API +void gst_rtsp_permissions_add_role_from_structure (GstRTSPPermissions * permissions, + GstStructure *structure); +GST_RTSP_SERVER_API +void gst_rtsp_permissions_add_permission_for_role (GstRTSPPermissions * permissions, + const gchar * role, + const gchar * permission, + gboolean allowed); + +GST_RTSP_SERVER_API +void gst_rtsp_permissions_remove_role (GstRTSPPermissions *permissions, + const gchar *role); + +GST_RTSP_SERVER_API +const GstStructure * gst_rtsp_permissions_get_role (GstRTSPPermissions *permissions, + const gchar *role); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_permissions_is_allowed (GstRTSPPermissions *permissions, + const gchar *role, const gchar *permission); + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPPermissions, gst_rtsp_permissions_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_PERMISSIONS_H__ */ diff --git a/include/gst/rtsp-server/rtsp-sdp.h b/include/gst/rtsp-server/rtsp-sdp.h new file mode 100644 index 0000000000..20d2ac8c6b --- /dev/null +++ b/include/gst/rtsp-server/rtsp-sdp.h @@ -0,0 +1,49 @@ +/* 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. + */ + +#include <gst/gst.h> +#include <gst/sdp/gstsdpmessage.h> + +#include "rtsp-media.h" + +#ifndef __GST_RTSP_SDP_H__ +#define __GST_RTSP_SDP_H__ + +G_BEGIN_DECLS + +typedef struct { + gboolean is_ipv6; + const gchar *server_ip; +} GstSDPInfo; + +/* creating SDP */ + +GST_RTSP_SERVER_API +gboolean gst_rtsp_sdp_from_media (GstSDPMessage *sdp, GstSDPInfo *info, GstRTSPMedia * media); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_sdp_from_stream (GstSDPMessage * sdp, GstSDPInfo * info, GstRTSPStream *stream); + +GST_RTSP_SERVER_API +gboolean +gst_rtsp_sdp_make_media (GstSDPMessage * sdp, GstSDPInfo * info, GstRTSPStream * stream, GstCaps * caps, GstRTSPProfile profile); + +G_END_DECLS + +#endif /* __GST_RTSP_SDP_H__ */ diff --git a/include/gst/rtsp-server/rtsp-server-object.h b/include/gst/rtsp-server/rtsp-server-object.h new file mode 100644 index 0000000000..4f44f3a500 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-server-object.h @@ -0,0 +1,211 @@ +/* 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_content_length_limit (GstRTSPServer * server, guint limit); + +GST_RTSP_SERVER_API +guint gst_rtsp_server_get_content_length_limit (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__ */ diff --git a/include/gst/rtsp-server/rtsp-server-prelude.h b/include/gst/rtsp-server/rtsp-server-prelude.h new file mode 100644 index 0000000000..8aff8c4934 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-server-prelude.h @@ -0,0 +1,44 @@ +/* GStreamer RtspServer Library + * Copyright (C) 2018 GStreamer developers + * + * rtspserver-prelude.h: prelude include header for gst-rtspserver library + * + * 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_PRELUDE_H__ +#define __GST_RTSP_SERVER_PRELUDE_H__ + +#include <gst/gst.h> + +#ifndef GST_RTSP_SERVER_API +# ifdef BUILDING_GST_RTSP_SERVER +# define GST_RTSP_SERVER_API GST_API_EXPORT /* from config.h */ +# else +# define GST_RTSP_SERVER_API GST_API_IMPORT +# endif +#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__ */ diff --git a/include/gst/rtsp-server/rtsp-server.h b/include/gst/rtsp-server/rtsp-server.h new file mode 100644 index 0000000000..1dd1a23242 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-server.h @@ -0,0 +1,56 @@ +/* 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_H__ +#define __GST_RTSP_SERVER_H__ + +#include <gst/gst.h> + +G_BEGIN_DECLS + +#include "rtsp-server-prelude.h" +#include "rtsp-server-object.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-server.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" + +#include "rtsp-onvif-client.h" +#include "rtsp-onvif-media-factory.h" +#include "rtsp-onvif-media.h" +#include "rtsp-onvif-server.h" + +G_END_DECLS + +#endif /* __GST_RTSP_SERVER_H__ */ diff --git a/include/gst/rtsp-server/rtsp-session-media.h b/include/gst/rtsp-server/rtsp-session-media.h new file mode 100644 index 0000000000..a20946606d --- /dev/null +++ b/include/gst/rtsp-server/rtsp-session-media.h @@ -0,0 +1,123 @@ +/* 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. + */ + +#include <gst/gst.h> + +#include <gst/rtsp/gstrtsptransport.h> + +#ifndef __GST_RTSP_SESSION_MEDIA_H__ +#define __GST_RTSP_SESSION_MEDIA_H__ + +#include "rtsp-server-prelude.h" + +G_BEGIN_DECLS + +#define GST_TYPE_RTSP_SESSION_MEDIA (gst_rtsp_session_media_get_type ()) +#define GST_IS_RTSP_SESSION_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SESSION_MEDIA)) +#define GST_IS_RTSP_SESSION_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SESSION_MEDIA)) +#define GST_RTSP_SESSION_MEDIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SESSION_MEDIA, GstRTSPSessionMediaClass)) +#define GST_RTSP_SESSION_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SESSION_MEDIA, GstRTSPSessionMedia)) +#define GST_RTSP_SESSION_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SESSION_MEDIA, GstRTSPSessionMediaClass)) +#define GST_RTSP_SESSION_MEDIA_CAST(obj) ((GstRTSPSessionMedia*)(obj)) +#define GST_RTSP_SESSION_MEDIA_CLASS_CAST(klass) ((GstRTSPSessionMediaClass*)(klass)) + +typedef struct _GstRTSPSessionMedia GstRTSPSessionMedia; +typedef struct _GstRTSPSessionMediaClass GstRTSPSessionMediaClass; +typedef struct _GstRTSPSessionMediaPrivate GstRTSPSessionMediaPrivate; + +/** + * GstRTSPSessionMedia: + * + * State of a client session regarding a specific media identified by path. + */ +struct _GstRTSPSessionMedia +{ + GObject parent; + + /*< private >*/ + GstRTSPSessionMediaPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; +}; + +struct _GstRTSPSessionMediaClass +{ + GObjectClass parent_class; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_session_media_get_type (void); + +GST_RTSP_SERVER_API +GstRTSPSessionMedia * gst_rtsp_session_media_new (const gchar *path, + GstRTSPMedia *media); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_session_media_matches (GstRTSPSessionMedia *media, + const gchar *path, + gint * matched); + +GST_RTSP_SERVER_API +GstRTSPMedia * gst_rtsp_session_media_get_media (GstRTSPSessionMedia *media); + +GST_RTSP_SERVER_API +GstClockTime gst_rtsp_session_media_get_base_time (GstRTSPSessionMedia *media); +/* control media */ + +GST_RTSP_SERVER_API +gboolean gst_rtsp_session_media_set_state (GstRTSPSessionMedia *media, + GstState state); + +GST_RTSP_SERVER_API +void gst_rtsp_session_media_set_rtsp_state (GstRTSPSessionMedia *media, + GstRTSPState state); + +GST_RTSP_SERVER_API +GstRTSPState gst_rtsp_session_media_get_rtsp_state (GstRTSPSessionMedia *media); + +/* get stream transport config */ + +GST_RTSP_SERVER_API +GstRTSPStreamTransport * gst_rtsp_session_media_set_transport (GstRTSPSessionMedia *media, + GstRTSPStream *stream, + GstRTSPTransport *tr); + +GST_RTSP_SERVER_API +GstRTSPStreamTransport * gst_rtsp_session_media_get_transport (GstRTSPSessionMedia *media, + guint idx); + +GST_RTSP_SERVER_API +GPtrArray * gst_rtsp_session_media_get_transports (GstRTSPSessionMedia *media); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_session_media_alloc_channels (GstRTSPSessionMedia *media, + GstRTSPRange *range); + +GST_RTSP_SERVER_API +gchar * gst_rtsp_session_media_get_rtpinfo (GstRTSPSessionMedia * media); + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPSessionMedia, gst_object_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_SESSION_MEDIA_H__ */ diff --git a/include/gst/rtsp-server/rtsp-session-pool.h b/include/gst/rtsp-server/rtsp-session-pool.h new file mode 100644 index 0000000000..aeb375c3cb --- /dev/null +++ b/include/gst/rtsp-server/rtsp-session-pool.h @@ -0,0 +1,169 @@ +/* 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. + */ + +#include <gst/gst.h> + +#ifndef __GST_RTSP_SESSION_POOL_H__ +#define __GST_RTSP_SESSION_POOL_H__ + +#include "rtsp-server-prelude.h" + +G_BEGIN_DECLS + +typedef struct _GstRTSPSessionPool GstRTSPSessionPool; +typedef struct _GstRTSPSessionPoolClass GstRTSPSessionPoolClass; +typedef struct _GstRTSPSessionPoolPrivate GstRTSPSessionPoolPrivate; + +#include "rtsp-session.h" + +#define GST_TYPE_RTSP_SESSION_POOL (gst_rtsp_session_pool_get_type ()) +#define GST_IS_RTSP_SESSION_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SESSION_POOL)) +#define GST_IS_RTSP_SESSION_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SESSION_POOL)) +#define GST_RTSP_SESSION_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SESSION_POOL, GstRTSPSessionPoolClass)) +#define GST_RTSP_SESSION_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SESSION_POOL, GstRTSPSessionPool)) +#define GST_RTSP_SESSION_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SESSION_POOL, GstRTSPSessionPoolClass)) +#define GST_RTSP_SESSION_POOL_CAST(obj) ((GstRTSPSessionPool*)(obj)) +#define GST_RTSP_SESSION_POOL_CLASS_CAST(klass) ((GstRTSPSessionPoolClass*)(klass)) + +/** + * GstRTSPSessionPool: + * + * An object that keeps track of the active sessions. This object is usually + * attached to a #GstRTSPServer object to manage the sessions in that server. + */ +struct _GstRTSPSessionPool { + GObject parent; + + /*< private >*/ + GstRTSPSessionPoolPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; +}; + +/** + * GstRTSPSessionPoolClass: + * @create_session_id: create a new random session id. Subclasses can create + * custom session ids and should not check if the session exists. + * @create_session: make a new session object. + * @session_removed: a session was removed from the pool + */ +struct _GstRTSPSessionPoolClass { + GObjectClass parent_class; + + gchar * (*create_session_id) (GstRTSPSessionPool *pool); + GstRTSPSession * (*create_session) (GstRTSPSessionPool *pool, const gchar *id); + + /* signals */ + void (*session_removed) (GstRTSPSessionPool *pool, + GstRTSPSession *session); + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING_LARGE - 1]; +}; + +/** + * GstRTSPSessionPoolFunc: + * @pool: a #GstRTSPSessionPool object + * @user_data: user data that has been given when registering the handler + * + * The function that will be called from the GSource watch on the session pool. + * + * The function will be called when the pool must be cleaned up because one or + * more sessions timed out. + * + * Returns: %FALSE if the source should be removed. + */ +typedef gboolean (*GstRTSPSessionPoolFunc) (GstRTSPSessionPool *pool, gpointer user_data); + +/** + * GstRTSPSessionPoolFilterFunc: + * @pool: a #GstRTSPSessionPool object + * @session: a #GstRTSPSession in @pool + * @user_data: user data that has been given to gst_rtsp_session_pool_filter() + * + * This function will be called by the gst_rtsp_session_pool_filter(). An + * implementation should return a value of #GstRTSPFilterResult. + * + * When this function returns #GST_RTSP_FILTER_REMOVE, @session will be removed + * from @pool. + * + * A return value of #GST_RTSP_FILTER_KEEP will leave @session untouched in + * @pool. + * + * A value of GST_RTSP_FILTER_REF will add @session to the result #GList of + * gst_rtsp_session_pool_filter(). + * + * Returns: a #GstRTSPFilterResult. + */ +typedef GstRTSPFilterResult (*GstRTSPSessionPoolFilterFunc) (GstRTSPSessionPool *pool, + GstRTSPSession *session, + gpointer user_data); + + +GST_RTSP_SERVER_API +GType gst_rtsp_session_pool_get_type (void); + +/* creating a session pool */ + +GST_RTSP_SERVER_API +GstRTSPSessionPool * gst_rtsp_session_pool_new (void); + +/* counting sessions */ + +GST_RTSP_SERVER_API +void gst_rtsp_session_pool_set_max_sessions (GstRTSPSessionPool *pool, guint max); + +GST_RTSP_SERVER_API +guint gst_rtsp_session_pool_get_max_sessions (GstRTSPSessionPool *pool); + +GST_RTSP_SERVER_API +guint gst_rtsp_session_pool_get_n_sessions (GstRTSPSessionPool *pool); + +/* managing sessions */ + +GST_RTSP_SERVER_API +GstRTSPSession * gst_rtsp_session_pool_create (GstRTSPSessionPool *pool); + +GST_RTSP_SERVER_API +GstRTSPSession * gst_rtsp_session_pool_find (GstRTSPSessionPool *pool, + const gchar *sessionid); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_session_pool_remove (GstRTSPSessionPool *pool, + GstRTSPSession *sess); + +/* perform session maintenance */ + +GST_RTSP_SERVER_API +GList * gst_rtsp_session_pool_filter (GstRTSPSessionPool *pool, + GstRTSPSessionPoolFilterFunc func, + gpointer user_data); + +GST_RTSP_SERVER_API +guint gst_rtsp_session_pool_cleanup (GstRTSPSessionPool *pool); + +GST_RTSP_SERVER_API +GSource * gst_rtsp_session_pool_create_watch (GstRTSPSessionPool *pool); + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPSessionPool, gst_object_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_SESSION_POOL_H__ */ diff --git a/include/gst/rtsp-server/rtsp-session.h b/include/gst/rtsp-server/rtsp-session.h new file mode 100644 index 0000000000..f0ee128088 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-session.h @@ -0,0 +1,186 @@ +/* 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. + */ + +#include <gst/gst.h> + +#include <gst/rtsp/gstrtsptransport.h> +#include "rtsp-server-prelude.h" /* for GST_RTSP_SERVER_DEPRECATED_FOR */ + +#ifndef __GST_RTSP_SESSION_H__ +#define __GST_RTSP_SESSION_H__ + +G_BEGIN_DECLS + +#define GST_TYPE_RTSP_SESSION (gst_rtsp_session_get_type ()) +#define GST_IS_RTSP_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SESSION)) +#define GST_IS_RTSP_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SESSION)) +#define GST_RTSP_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SESSION, GstRTSPSessionClass)) +#define GST_RTSP_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SESSION, GstRTSPSession)) +#define GST_RTSP_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SESSION, GstRTSPSessionClass)) +#define GST_RTSP_SESSION_CAST(obj) ((GstRTSPSession*)(obj)) +#define GST_RTSP_SESSION_CLASS_CAST(klass) ((GstRTSPSessionClass*)(klass)) + +typedef struct _GstRTSPSession GstRTSPSession; +typedef struct _GstRTSPSessionClass GstRTSPSessionClass; +typedef struct _GstRTSPSessionPrivate GstRTSPSessionPrivate; + +/** + * GstRTSPFilterResult: + * @GST_RTSP_FILTER_REMOVE: Remove session + * @GST_RTSP_FILTER_KEEP: Keep session in the pool + * @GST_RTSP_FILTER_REF: Ref session in the result list + * + * Possible return values for gst_rtsp_session_pool_filter(). + */ +typedef enum +{ + GST_RTSP_FILTER_REMOVE, + GST_RTSP_FILTER_KEEP, + GST_RTSP_FILTER_REF, +} GstRTSPFilterResult; + +#include "rtsp-media.h" +#include "rtsp-session-media.h" + +/** + * GstRTSPSession: + * + * Session information kept by the server for a specific client. + * One client session, identified with a session id, can handle multiple medias + * identified with the url of a media. + */ +struct _GstRTSPSession { + GObject parent; + + /*< private >*/ + GstRTSPSessionPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; +}; + +struct _GstRTSPSessionClass { + GObjectClass parent_class; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_session_get_type (void); + +/* create a new session */ + +GST_RTSP_SERVER_API +GstRTSPSession * gst_rtsp_session_new (const gchar *sessionid); + +GST_RTSP_SERVER_API +const gchar * gst_rtsp_session_get_sessionid (GstRTSPSession *session); + +GST_RTSP_SERVER_API +gchar * gst_rtsp_session_get_header (GstRTSPSession *session); + +GST_RTSP_SERVER_API +void gst_rtsp_session_set_timeout (GstRTSPSession *session, guint timeout); + +GST_RTSP_SERVER_API +guint gst_rtsp_session_get_timeout (GstRTSPSession *session); + +/* session timeout stuff */ + +GST_RTSP_SERVER_API +void gst_rtsp_session_touch (GstRTSPSession *session); + +GST_RTSP_SERVER_API +void gst_rtsp_session_prevent_expire (GstRTSPSession *session); + +GST_RTSP_SERVER_API +void gst_rtsp_session_allow_expire (GstRTSPSession *session); + +GST_RTSP_SERVER_API +gint gst_rtsp_session_next_timeout_usec (GstRTSPSession *session, gint64 now); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_session_is_expired_usec (GstRTSPSession *session, gint64 now); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GST_RTSP_SERVER_DEPRECATED_FOR(gst_rtsp_session_next_timeout_usec) +gint gst_rtsp_session_next_timeout (GstRTSPSession *session, GTimeVal *now); + +GST_RTSP_SERVER_DEPRECATED_FOR(gst_rtsp_session_is_expired_usec) +gboolean gst_rtsp_session_is_expired (GstRTSPSession *session, GTimeVal *now); +G_GNUC_END_IGNORE_DEPRECATIONS + +/* handle media in a session */ + +GST_RTSP_SERVER_API +GstRTSPSessionMedia * gst_rtsp_session_manage_media (GstRTSPSession *sess, + const gchar *path, + GstRTSPMedia *media); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_session_release_media (GstRTSPSession *sess, + GstRTSPSessionMedia *media); +/* get media in a session */ + +GST_RTSP_SERVER_API +GstRTSPSessionMedia * gst_rtsp_session_get_media (GstRTSPSession *sess, + const gchar *path, + gint * matched); +/* get media in a session, increasing its reference count */ + +GST_RTSP_SERVER_API +GstRTSPSessionMedia * gst_rtsp_session_dup_media (GstRTSPSession *sess, + const gchar *path, + gint * matched); +/** + * GstRTSPSessionFilterFunc: + * @sess: a #GstRTSPSession object + * @media: a #GstRTSPSessionMedia in @sess + * @user_data: user data that has been given to gst_rtsp_session_filter() + * + * This function will be called by the gst_rtsp_session_filter(). An + * implementation should return a value of #GstRTSPFilterResult. + * + * When this function returns #GST_RTSP_FILTER_REMOVE, @media will be removed + * from @sess. + * + * A return value of #GST_RTSP_FILTER_KEEP will leave @media untouched in + * @sess. + * + * A value of GST_RTSP_FILTER_REF will add @media to the result #GList of + * gst_rtsp_session_filter(). + * + * Returns: a #GstRTSPFilterResult. + */ +typedef GstRTSPFilterResult (*GstRTSPSessionFilterFunc) (GstRTSPSession *sess, + GstRTSPSessionMedia *media, + gpointer user_data); + +GST_RTSP_SERVER_API +GList * gst_rtsp_session_filter (GstRTSPSession *sess, + GstRTSPSessionFilterFunc func, + gpointer user_data); + + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPSession, gst_object_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_SESSION_H__ */ diff --git a/include/gst/rtsp-server/rtsp-stream-transport.h b/include/gst/rtsp-server/rtsp-stream-transport.h new file mode 100644 index 0000000000..d8516c027e --- /dev/null +++ b/include/gst/rtsp-server/rtsp-stream-transport.h @@ -0,0 +1,229 @@ +/* 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. + */ + +#include <gst/gst.h> +#include <gst/base/base.h> +#include <gst/rtsp/gstrtsprange.h> +#include <gst/rtsp/gstrtspurl.h> + +#ifndef __GST_RTSP_STREAM_TRANSPORT_H__ +#define __GST_RTSP_STREAM_TRANSPORT_H__ + +#include "rtsp-server-prelude.h" + +G_BEGIN_DECLS + +/* types for the media */ +#define GST_TYPE_RTSP_STREAM_TRANSPORT (gst_rtsp_stream_transport_get_type ()) +#define GST_IS_RTSP_STREAM_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_STREAM_TRANSPORT)) +#define GST_IS_RTSP_STREAM_TRANSPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_STREAM_TRANSPORT)) +#define GST_RTSP_STREAM_TRANSPORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_STREAM_TRANSPORT, GstRTSPStreamTransportClass)) +#define GST_RTSP_STREAM_TRANSPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_STREAM_TRANSPORT, GstRTSPStreamTransport)) +#define GST_RTSP_STREAM_TRANSPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_STREAM_TRANSPORT, GstRTSPStreamTransportClass)) +#define GST_RTSP_STREAM_TRANSPORT_CAST(obj) ((GstRTSPStreamTransport*)(obj)) +#define GST_RTSP_STREAM_TRANSPORT_CLASS_CAST(klass) ((GstRTSPStreamTransportClass*)(klass)) + +typedef struct _GstRTSPStreamTransport GstRTSPStreamTransport; +typedef struct _GstRTSPStreamTransportClass GstRTSPStreamTransportClass; +typedef struct _GstRTSPStreamTransportPrivate GstRTSPStreamTransportPrivate; + +#include "rtsp-stream.h" + +/** + * GstRTSPSendFunc: + * @buffer: a #GstBuffer + * @channel: a channel + * @user_data: user data + * + * Function registered with gst_rtsp_stream_transport_set_callbacks() and + * called when @buffer must be sent on @channel. + * + * Returns: %TRUE on success + */ +typedef gboolean (*GstRTSPSendFunc) (GstBuffer *buffer, guint8 channel, gpointer user_data); + +/** + * GstRTSPSendListFunc: + * @buffer_list: a #GstBufferList + * @channel: a channel + * @user_data: user data + * + * Function registered with gst_rtsp_stream_transport_set_callbacks() and + * called when @buffer_list must be sent on @channel. + * + * Returns: %TRUE on success + * + * Since: 1.16 + */ +typedef gboolean (*GstRTSPSendListFunc) (GstBufferList *buffer_list, guint8 channel, gpointer user_data); + +/** + * GstRTSPKeepAliveFunc: + * @user_data: user data + * + * Function registered with gst_rtsp_stream_transport_set_keepalive() and called + * when the stream is active. + */ +typedef void (*GstRTSPKeepAliveFunc) (gpointer user_data); + +/** + * GstRTSPMessageSentFunc: + * @user_data: user data + * + * Function registered with gst_rtsp_stream_transport_set_message_sent() + * and called when a message has been sent on the transport. + */ +typedef void (*GstRTSPMessageSentFunc) (gpointer user_data); + +/** + * GstRTSPMessageSentFuncFull: + * @user_data: user data + * + * Function registered with gst_rtsp_stream_transport_set_message_sent_full() + * and called when a message has been sent on the transport. + * + * Since: 1.18 + */ +typedef void (*GstRTSPMessageSentFuncFull) (GstRTSPStreamTransport *trans, gpointer user_data); + +/** + * GstRTSPStreamTransport: + * @parent: parent instance + * + * A Transport description for a stream + */ +struct _GstRTSPStreamTransport { + GObject parent; + + /*< private >*/ + GstRTSPStreamTransportPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; +}; + +struct _GstRTSPStreamTransportClass { + GObjectClass parent_class; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_stream_transport_get_type (void); + +GST_RTSP_SERVER_API +GstRTSPStreamTransport * gst_rtsp_stream_transport_new (GstRTSPStream *stream, + GstRTSPTransport *tr); + +GST_RTSP_SERVER_API +GstRTSPStream * gst_rtsp_stream_transport_get_stream (GstRTSPStreamTransport *trans); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_transport_set_transport (GstRTSPStreamTransport *trans, + GstRTSPTransport * tr); + +GST_RTSP_SERVER_API +const GstRTSPTransport * gst_rtsp_stream_transport_get_transport (GstRTSPStreamTransport *trans); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_transport_set_url (GstRTSPStreamTransport *trans, + const GstRTSPUrl * url); + +GST_RTSP_SERVER_API +const GstRTSPUrl * gst_rtsp_stream_transport_get_url (GstRTSPStreamTransport *trans); + + +GST_RTSP_SERVER_API +gchar * gst_rtsp_stream_transport_get_rtpinfo (GstRTSPStreamTransport *trans, + GstClockTime start_time); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_transport_set_callbacks (GstRTSPStreamTransport *trans, + GstRTSPSendFunc send_rtp, + GstRTSPSendFunc send_rtcp, + gpointer user_data, + GDestroyNotify notify); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_transport_set_list_callbacks (GstRTSPStreamTransport *trans, + GstRTSPSendListFunc send_rtp_list, + GstRTSPSendListFunc send_rtcp_list, + gpointer user_data, + GDestroyNotify notify); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_transport_set_keepalive (GstRTSPStreamTransport *trans, + GstRTSPKeepAliveFunc keep_alive, + gpointer user_data, + GDestroyNotify notify); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_transport_set_message_sent (GstRTSPStreamTransport *trans, + GstRTSPMessageSentFunc message_sent, + gpointer user_data, + GDestroyNotify notify); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_transport_set_message_sent_full (GstRTSPStreamTransport *trans, + GstRTSPMessageSentFuncFull message_sent, + gpointer user_data, + GDestroyNotify notify); +GST_RTSP_SERVER_API +void gst_rtsp_stream_transport_keep_alive (GstRTSPStreamTransport *trans); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_transport_message_sent (GstRTSPStreamTransport *trans); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_transport_set_active (GstRTSPStreamTransport *trans, + gboolean active); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_transport_set_timed_out (GstRTSPStreamTransport *trans, + gboolean timedout); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_transport_is_timed_out (GstRTSPStreamTransport *trans); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_transport_send_rtp (GstRTSPStreamTransport *trans, + GstBuffer *buffer); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_transport_send_rtcp (GstRTSPStreamTransport *trans, + GstBuffer *buffer); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_transport_send_rtp_list (GstRTSPStreamTransport *trans, + GstBufferList *buffer_list); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_transport_send_rtcp_list(GstRTSPStreamTransport *trans, + GstBufferList *buffer_list); + +GST_RTSP_SERVER_API +GstFlowReturn gst_rtsp_stream_transport_recv_data (GstRTSPStreamTransport *trans, + guint channel, GstBuffer *buffer); + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPStreamTransport, gst_object_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_STREAM_TRANSPORT_H__ */ diff --git a/include/gst/rtsp-server/rtsp-stream.h b/include/gst/rtsp-server/rtsp-stream.h new file mode 100644 index 0000000000..5e6ff2151a --- /dev/null +++ b/include/gst/rtsp-server/rtsp-stream.h @@ -0,0 +1,406 @@ +/* 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. + */ + +#include <gst/gst.h> +#include <gst/rtsp/rtsp.h> +#include <gio/gio.h> + +#ifndef __GST_RTSP_STREAM_H__ +#define __GST_RTSP_STREAM_H__ + +#include "rtsp-server-prelude.h" + +G_BEGIN_DECLS + +/* types for the media stream */ +#define GST_TYPE_RTSP_STREAM (gst_rtsp_stream_get_type ()) +#define GST_IS_RTSP_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_STREAM)) +#define GST_IS_RTSP_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_STREAM)) +#define GST_RTSP_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_STREAM, GstRTSPStreamClass)) +#define GST_RTSP_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_STREAM, GstRTSPStream)) +#define GST_RTSP_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_STREAM, GstRTSPStreamClass)) +#define GST_RTSP_STREAM_CAST(obj) ((GstRTSPStream*)(obj)) +#define GST_RTSP_STREAM_CLASS_CAST(klass) ((GstRTSPStreamClass*)(klass)) + +typedef struct _GstRTSPStream GstRTSPStream; +typedef struct _GstRTSPStreamClass GstRTSPStreamClass; +typedef struct _GstRTSPStreamPrivate GstRTSPStreamPrivate; + +#include "rtsp-stream-transport.h" +#include "rtsp-address-pool.h" +#include "rtsp-session.h" +#include "rtsp-media.h" + +/** + * GstRTSPStream: + * + * The definition of a media stream. + */ +struct _GstRTSPStream { + GObject parent; + + /*< private >*/ + GstRTSPStreamPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; +}; + +struct _GstRTSPStreamClass { + GObjectClass parent_class; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_stream_get_type (void); + +GST_RTSP_SERVER_API +GstRTSPStream * gst_rtsp_stream_new (guint idx, GstElement *payloader, + GstPad *pad); + +GST_RTSP_SERVER_API +guint gst_rtsp_stream_get_index (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +guint gst_rtsp_stream_get_pt (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +GstPad * gst_rtsp_stream_get_srcpad (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +GstPad * gst_rtsp_stream_get_sinkpad (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_control (GstRTSPStream *stream, const gchar *control); + +GST_RTSP_SERVER_API +gchar * gst_rtsp_stream_get_control (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_has_control (GstRTSPStream *stream, const gchar *control); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_mtu (GstRTSPStream *stream, guint mtu); + +GST_RTSP_SERVER_API +guint gst_rtsp_stream_get_mtu (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_dscp_qos (GstRTSPStream *stream, gint dscp_qos); + +GST_RTSP_SERVER_API +gint gst_rtsp_stream_get_dscp_qos (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_is_transport_supported (GstRTSPStream *stream, + GstRTSPTransport *transport); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_profiles (GstRTSPStream *stream, GstRTSPProfile profiles); + +GST_RTSP_SERVER_API +GstRTSPProfile gst_rtsp_stream_get_profiles (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_protocols (GstRTSPStream *stream, GstRTSPLowerTrans protocols); + +GST_RTSP_SERVER_API +GstRTSPLowerTrans gst_rtsp_stream_get_protocols (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_address_pool (GstRTSPStream *stream, GstRTSPAddressPool *pool); + +GST_RTSP_SERVER_API +GstRTSPAddressPool * + gst_rtsp_stream_get_address_pool (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_multicast_iface (GstRTSPStream *stream, const gchar * multicast_iface); + +GST_RTSP_SERVER_API +gchar * gst_rtsp_stream_get_multicast_iface (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +GstRTSPAddress * gst_rtsp_stream_reserve_address (GstRTSPStream *stream, + const gchar * address, + guint port, + guint n_ports, + guint ttl); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_join_bin (GstRTSPStream *stream, + GstBin *bin, GstElement *rtpbin, + GstState state); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_leave_bin (GstRTSPStream *stream, + GstBin *bin, GstElement *rtpbin); + +GST_RTSP_SERVER_API +GstBin * gst_rtsp_stream_get_joined_bin (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_set_blocked (GstRTSPStream * stream, + gboolean blocked); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_is_blocking (GstRTSPStream * stream); + + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_unblock_linked (GstRTSPStream * stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_client_side (GstRTSPStream *stream, gboolean client_side); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_is_client_side (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_get_server_port (GstRTSPStream *stream, + GstRTSPRange *server_port, + GSocketFamily family); + +GST_RTSP_SERVER_API +GstRTSPAddress * gst_rtsp_stream_get_multicast_address (GstRTSPStream *stream, + GSocketFamily family); + + +GST_RTSP_SERVER_API +GObject * gst_rtsp_stream_get_rtpsession (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +GstElement * gst_rtsp_stream_get_srtp_encoder (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_get_ssrc (GstRTSPStream *stream, + guint *ssrc); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_get_rtpinfo (GstRTSPStream *stream, + guint *rtptime, guint *seq, + guint *clock_rate, + GstClockTime *running_time); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_get_rates (GstRTSPStream * stream, + gdouble * rate, + gdouble * applied_rate); + +GST_RTSP_SERVER_API +GstCaps * gst_rtsp_stream_get_caps (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +GstFlowReturn gst_rtsp_stream_recv_rtp (GstRTSPStream *stream, + GstBuffer *buffer); + +GST_RTSP_SERVER_API +GstFlowReturn gst_rtsp_stream_recv_rtcp (GstRTSPStream *stream, + GstBuffer *buffer); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_add_transport (GstRTSPStream *stream, + GstRTSPStreamTransport *trans); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_remove_transport (GstRTSPStream *stream, + GstRTSPStreamTransport *trans); + +GST_RTSP_SERVER_API +GSocket * gst_rtsp_stream_get_rtp_socket (GstRTSPStream *stream, + GSocketFamily family); + +GST_RTSP_SERVER_API +GSocket * gst_rtsp_stream_get_rtcp_socket (GstRTSPStream *stream, + GSocketFamily family); + +GST_RTSP_SERVER_API +GSocket * gst_rtsp_stream_get_rtp_multicast_socket (GstRTSPStream *stream, + GSocketFamily family); + +GST_RTSP_SERVER_API +GSocket * gst_rtsp_stream_get_rtcp_multicast_socket (GstRTSPStream *stream, + GSocketFamily family); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_add_multicast_client_address (GstRTSPStream * stream, + const gchar * destination, + guint rtp_port, + guint rtcp_port, + GSocketFamily family); + +GST_RTSP_SERVER_API +gchar * gst_rtsp_stream_get_multicast_client_addresses (GstRTSPStream * stream); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_update_crypto (GstRTSPStream * stream, + guint ssrc, GstCaps * crypto); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_query_position (GstRTSPStream * stream, + gint64 * position); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_query_stop (GstRTSPStream * stream, + gint64 * stop); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_seekable (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_seqnum_offset (GstRTSPStream *stream, guint16 seqnum); + +GST_RTSP_SERVER_API +guint16 gst_rtsp_stream_get_current_seqnum (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_retransmission_time (GstRTSPStream *stream, GstClockTime time); + +GST_RTSP_SERVER_API +GstClockTime gst_rtsp_stream_get_retransmission_time (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +guint gst_rtsp_stream_get_retransmission_pt (GstRTSPStream * stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_retransmission_pt (GstRTSPStream * stream, + guint rtx_pt); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_buffer_size (GstRTSPStream *stream, guint size); + +GST_RTSP_SERVER_API +guint gst_rtsp_stream_get_buffer_size (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_pt_map (GstRTSPStream * stream, guint pt, GstCaps * caps); + +GST_RTSP_SERVER_API +GstElement * gst_rtsp_stream_request_aux_sender (GstRTSPStream * stream, guint sessid); + +GST_RTSP_SERVER_API +GstElement * gst_rtsp_stream_request_aux_receiver (GstRTSPStream * stream, guint sessid); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_allocate_udp_sockets (GstRTSPStream * stream, GSocketFamily family, + GstRTSPTransport *transport, gboolean use_client_settings); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_publish_clock_mode (GstRTSPStream * stream, GstRTSPPublishClockMode mode); + +GST_RTSP_SERVER_API +GstRTSPPublishClockMode gst_rtsp_stream_get_publish_clock_mode (GstRTSPStream * stream); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_set_max_mcast_ttl (GstRTSPStream *stream, guint ttl); + +GST_RTSP_SERVER_API +guint gst_rtsp_stream_get_max_mcast_ttl (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_verify_mcast_ttl (GstRTSPStream *stream, guint ttl); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_bind_mcast_address (GstRTSPStream * stream, gboolean bind_mcast_addr); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_is_bind_mcast_address (GstRTSPStream * stream); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_complete_stream (GstRTSPStream * stream, const GstRTSPTransport * transport); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_is_complete (GstRTSPStream * stream); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_is_sender (GstRTSPStream * stream); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_is_receiver (GstRTSPStream * stream); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_handle_keymgmt (GstRTSPStream *stream, const gchar *keymgmt); + +/* ULP Forward Error Correction (RFC 5109) */ +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_get_ulpfec_enabled (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_ulpfec_pt (GstRTSPStream *stream, guint pt); + +GST_RTSP_SERVER_API +guint gst_rtsp_stream_get_ulpfec_pt (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +GstElement * gst_rtsp_stream_request_ulpfec_decoder (GstRTSPStream *stream, GstElement *rtpbin, guint sessid); + +GST_RTSP_SERVER_API +GstElement * gst_rtsp_stream_request_ulpfec_encoder (GstRTSPStream *stream, guint sessid); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_ulpfec_percentage (GstRTSPStream *stream, guint percentage); + +GST_RTSP_SERVER_API +guint gst_rtsp_stream_get_ulpfec_percentage (GstRTSPStream *stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_set_rate_control (GstRTSPStream * stream, gboolean enabled); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_stream_get_rate_control (GstRTSPStream * stream); + +GST_RTSP_SERVER_API +void gst_rtsp_stream_unblock_rtcp (GstRTSPStream * stream); + +/** + * GstRTSPStreamTransportFilterFunc: + * @stream: a #GstRTSPStream object + * @trans: a #GstRTSPStreamTransport in @stream + * @user_data: user data that has been given to gst_rtsp_stream_transport_filter() + * + * This function will be called by the gst_rtsp_stream_transport_filter(). An + * implementation should return a value of #GstRTSPFilterResult. + * + * When this function returns #GST_RTSP_FILTER_REMOVE, @trans will be removed + * from @stream. + * + * A return value of #GST_RTSP_FILTER_KEEP will leave @trans untouched in + * @stream. + * + * A value of #GST_RTSP_FILTER_REF will add @trans to the result #GList of + * gst_rtsp_stream_transport_filter(). + * + * Returns: a #GstRTSPFilterResult. + */ +typedef GstRTSPFilterResult (*GstRTSPStreamTransportFilterFunc) (GstRTSPStream *stream, + GstRTSPStreamTransport *trans, + gpointer user_data); + +GST_RTSP_SERVER_API +GList * gst_rtsp_stream_transport_filter (GstRTSPStream *stream, + GstRTSPStreamTransportFilterFunc func, + gpointer user_data); + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPStream, gst_object_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_STREAM_H__ */ diff --git a/include/gst/rtsp-server/rtsp-thread-pool.h b/include/gst/rtsp-server/rtsp-thread-pool.h new file mode 100644 index 0000000000..01ca3ac711 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-thread-pool.h @@ -0,0 +1,191 @@ +/* GStreamer + * Copyright (C) 2010 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. + */ + +#include <gst/gst.h> + +#ifndef __GST_RTSP_THREAD_POOL_H__ +#define __GST_RTSP_THREAD_POOL_H__ + +typedef struct _GstRTSPThread GstRTSPThread; +typedef struct _GstRTSPThreadPool GstRTSPThreadPool; +typedef struct _GstRTSPThreadPoolClass GstRTSPThreadPoolClass; +typedef struct _GstRTSPThreadPoolPrivate GstRTSPThreadPoolPrivate; + +#include "rtsp-client.h" + +G_BEGIN_DECLS + +#define GST_TYPE_RTSP_THREAD_POOL (gst_rtsp_thread_pool_get_type ()) +#define GST_IS_RTSP_THREAD_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_THREAD_POOL)) +#define GST_IS_RTSP_THREAD_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_THREAD_POOL)) +#define GST_RTSP_THREAD_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_THREAD_POOL, GstRTSPThreadPoolClass)) +#define GST_RTSP_THREAD_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_THREAD_POOL, GstRTSPThreadPool)) +#define GST_RTSP_THREAD_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_THREAD_POOL, GstRTSPThreadPoolClass)) +#define GST_RTSP_THREAD_POOL_CAST(obj) ((GstRTSPThreadPool*)(obj)) +#define GST_RTSP_THREAD_POOL_CLASS_CAST(klass) ((GstRTSPThreadPoolClass*)(klass)) + +GST_RTSP_SERVER_API +GType gst_rtsp_thread_get_type (void); + +#define GST_TYPE_RTSP_THREAD (gst_rtsp_thread_get_type ()) +#define GST_IS_RTSP_THREAD(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_RTSP_THREAD)) +#define GST_RTSP_THREAD_CAST(obj) ((GstRTSPThread*)(obj)) +#define GST_RTSP_THREAD(obj) (GST_RTSP_THREAD_CAST(obj)) + +/** + * GstRTSPThreadType: + * @GST_RTSP_THREAD_TYPE_CLIENT: a thread to handle the client communication + * @GST_RTSP_THREAD_TYPE_MEDIA: a thread to handle media + * + * Different thread types + */ +typedef enum +{ + GST_RTSP_THREAD_TYPE_CLIENT, + GST_RTSP_THREAD_TYPE_MEDIA +} GstRTSPThreadType; + +/** + * GstRTSPThread: + * @mini_object: parent #GstMiniObject + * @type: the thread type + * @context: a #GMainContext + * @loop: a #GMainLoop + * + * Structure holding info about a mainloop running in a thread + */ +struct _GstRTSPThread { + GstMiniObject mini_object; + + GstRTSPThreadType type; + GMainContext *context; + GMainLoop *loop; +}; + +GST_RTSP_SERVER_API +GstRTSPThread * gst_rtsp_thread_new (GstRTSPThreadType type); + +GST_RTSP_SERVER_API +gboolean gst_rtsp_thread_reuse (GstRTSPThread * thread); + +GST_RTSP_SERVER_API +void gst_rtsp_thread_stop (GstRTSPThread * thread); + +/** + * gst_rtsp_thread_ref: + * @thread: The thread to refcount + * + * Increase the refcount of this thread. + * + * Returns: (transfer full): @thread (for convenience when doing assignments) + */ +static inline GstRTSPThread * +gst_rtsp_thread_ref (GstRTSPThread * thread) +{ + return (GstRTSPThread *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (thread)); +} + +/** + * gst_rtsp_thread_unref: + * @thread: (transfer full): the thread to refcount + * + * Decrease the refcount of an thread, freeing it if the refcount reaches 0. + */ +static inline void +gst_rtsp_thread_unref (GstRTSPThread * thread) +{ + gst_mini_object_unref (GST_MINI_OBJECT_CAST (thread)); +} + +/** + * GstRTSPThreadPool: + * + * The thread pool structure. + */ +struct _GstRTSPThreadPool { + GObject parent; + + /*< private >*/ + GstRTSPThreadPoolPrivate *priv; + gpointer _gst_reserved[GST_PADDING]; +}; + +/** + * GstRTSPThreadPoolClass: + * @pool: a #GThreadPool used internally + * @get_thread: this function should make or reuse an existing thread that runs + * a mainloop. + * @configure_thread: configure a thread object. this vmethod is called when + * a new thread has been created and should be configured. + * @thread_enter: called from the thread when it is entered + * @thread_leave: called from the thread when it is left + * + * Class for managing threads. + */ +struct _GstRTSPThreadPoolClass { + GObjectClass parent_class; + + GThreadPool *pool; + + GstRTSPThread * (*get_thread) (GstRTSPThreadPool *pool, + GstRTSPThreadType type, + GstRTSPContext *ctx); + void (*configure_thread) (GstRTSPThreadPool *pool, + GstRTSPThread * thread, + GstRTSPContext *ctx); + + void (*thread_enter) (GstRTSPThreadPool *pool, + GstRTSPThread *thread); + void (*thread_leave) (GstRTSPThreadPool *pool, + GstRTSPThread *thread); + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTSP_SERVER_API +GType gst_rtsp_thread_pool_get_type (void); + +GST_RTSP_SERVER_API +GstRTSPThreadPool * gst_rtsp_thread_pool_new (void); + +GST_RTSP_SERVER_API +void gst_rtsp_thread_pool_set_max_threads (GstRTSPThreadPool * pool, gint max_threads); + +GST_RTSP_SERVER_API +gint gst_rtsp_thread_pool_get_max_threads (GstRTSPThreadPool * pool); + +GST_RTSP_SERVER_API +GstRTSPThread * gst_rtsp_thread_pool_get_thread (GstRTSPThreadPool *pool, + GstRTSPThreadType type, + GstRTSPContext *ctx); + +GST_RTSP_SERVER_API +void gst_rtsp_thread_pool_cleanup (void); +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPThread, gst_rtsp_thread_unref) +#endif + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPThreadPool, gst_object_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_THREAD_POOL_H__ */ diff --git a/include/gst/rtsp-server/rtsp-token.h b/include/gst/rtsp-server/rtsp-token.h new file mode 100644 index 0000000000..27e18fbc48 --- /dev/null +++ b/include/gst/rtsp-server/rtsp-token.h @@ -0,0 +1,113 @@ +/* GStreamer + * Copyright (C) 2010 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. + */ + +#include <gst/gst.h> + +#ifndef __GST_RTSP_TOKEN_H__ +#define __GST_RTSP_TOKEN_H__ + +typedef struct _GstRTSPToken GstRTSPToken; + +#include "rtsp-auth.h" + +G_BEGIN_DECLS + +GST_RTSP_SERVER_API +GType gst_rtsp_token_get_type(void); + +#define GST_TYPE_RTSP_TOKEN (gst_rtsp_token_get_type()) +#define GST_IS_RTSP_TOKEN(obj) (GST_IS_MINI_OBJECT_TYPE (obj, GST_TYPE_RTSP_TOKEN)) +#define GST_RTSP_TOKEN_CAST(obj) ((GstRTSPToken*)(obj)) +#define GST_RTSP_TOKEN(obj) (GST_RTSP_TOKEN_CAST(obj)) + +/** + * GstRTSPToken: + * + * An opaque object used for checking authorisations. + * It is generated after successful authentication. + */ +struct _GstRTSPToken { + GstMiniObject mini_object; +}; + +/* refcounting */ +/** + * gst_rtsp_token_ref: + * @token: The token to refcount + * + * Increase the refcount of this token. + * + * Returns: (transfer full): @token (for convenience when doing assignments) + */ +static inline GstRTSPToken * +gst_rtsp_token_ref (GstRTSPToken * token) +{ + return (GstRTSPToken *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (token)); +} + +/** + * gst_rtsp_token_unref: + * @token: (transfer full): the token to refcount + * + * Decrease the refcount of an token, freeing it if the refcount reaches 0. + */ +static inline void +gst_rtsp_token_unref (GstRTSPToken * token) +{ + gst_mini_object_unref (GST_MINI_OBJECT_CAST (token)); +} + + +GST_RTSP_SERVER_API +GstRTSPToken * gst_rtsp_token_new_empty (void); + +GST_RTSP_SERVER_API +GstRTSPToken * gst_rtsp_token_new (const gchar * firstfield, ...); + +GST_RTSP_SERVER_API +GstRTSPToken * gst_rtsp_token_new_valist (const gchar * firstfield, va_list var_args); + +GST_RTSP_SERVER_API +const GstStructure * gst_rtsp_token_get_structure (GstRTSPToken *token); + +GST_RTSP_SERVER_API +GstStructure * gst_rtsp_token_writable_structure (GstRTSPToken *token); + +GST_RTSP_SERVER_API +void gst_rtsp_token_set_string (GstRTSPToken * token, + const gchar * field, + const gchar * string_value); +GST_RTSP_SERVER_API +const gchar * gst_rtsp_token_get_string (GstRTSPToken *token, + const gchar *field); +GST_RTSP_SERVER_API +void gst_rtsp_token_set_bool (GstRTSPToken * token, + const gchar * field, + gboolean bool_value); +GST_RTSP_SERVER_API +gboolean gst_rtsp_token_is_allowed (GstRTSPToken *token, + const gchar *field); + +#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPToken, gst_rtsp_token_unref) +#endif + +G_END_DECLS + +#endif /* __GST_RTSP_TOKEN_H__ */ |