/* we really need to be unjoined now */
g_return_if_fail (!stream->is_joined);
+ if (stream->addr)
+ gst_rtsp_address_free (stream->addr);
+ if (stream->pool)
+ g_object_unref (stream->pool);
gst_object_unref (stream->payloader);
gst_object_unref (stream->srcpad);
g_mutex_clear (&stream->lock);
return mtu;
}
+/**
+ * gst_rtsp_stream_set_address_pool:
+ * @stream: a #GstRTSPStream
+ * @pool: a #GstRTSPAddressPool
+ *
+ * configure @pool to be used as the address pool of @stream.
+ */
+void
+gst_rtsp_stream_set_address_pool (GstRTSPStream * stream,
+ GstRTSPAddressPool * pool)
+{
+ GstRTSPAddressPool *old;
+
+ g_return_if_fail (GST_IS_RTSP_STREAM (stream));
+
+ g_mutex_lock (&stream->lock);
+ if ((old = stream->pool) != pool)
+ stream->pool = pool ? g_object_ref (pool) : NULL;
+ else
+ old = NULL;
+ g_mutex_unlock (&stream->lock);
+
+ if (old)
+ g_object_unref (old);
+}
+
+/**
+ * gst_rtsp_stream_get_address_pool:
+ * @stream: a #GstRTSPStream
+ *
+ * Get the #GstRTSPAddressPool used as the address pool of @stream.
+ *
+ * Returns: (transfer full): the #GstRTSPAddressPool of @stream. g_object_unref() after
+ * usage.
+ */
+GstRTSPAddressPool *
+gst_rtsp_stream_get_address_pool (GstRTSPStream * stream)
+{
+ GstRTSPAddressPool *result;
+
+ g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), NULL);
+
+ g_mutex_lock (&stream->lock);
+ if ((result = stream->pool))
+ g_object_ref (result);
+ g_mutex_unlock (&stream->lock);
+
+ return result;
+}
+
+/**
+ * gst_rtsp_stream_get_address:
+ * @stream: a #GstRTSPStream
+ *
+ * Get the multicast address of @stream.
+ *
+ * Returns: the #GstRTSPAddress of @stream or %NULL when no address could be
+ * allocated. gst_rtsp_address_free() after usage.
+ */
+GstRTSPAddress *
+gst_rtsp_stream_get_address (GstRTSPStream * stream)
+{
+ GstRTSPAddress *result;
+
+ g_mutex_lock (&stream->lock);
+ if (stream->addr == NULL) {
+ if (stream->pool == NULL)
+ goto no_pool;
+
+ stream->addr = gst_rtsp_address_pool_acquire_address (stream->pool,
+ GST_RTSP_ADDRESS_FLAG_EVEN_PORT, 2);
+ if (stream->addr == NULL)
+ goto no_address;
+ }
+ result = gst_rtsp_address_copy (stream->addr);
+ g_mutex_unlock (&stream->lock);
+
+ return result;
+
+ /* ERRORS */
+no_pool:
+ {
+ GST_ERROR_OBJECT (stream, "no address pool specified");
+ g_mutex_unlock (&stream->lock);
+ return NULL;
+ }
+no_address:
+ {
+ GST_ERROR_OBJECT (stream, "failed to acquire address from pool");
+ g_mutex_unlock (&stream->lock);
+ return NULL;
+ }
+}
+
/* must be called with lock */
static gboolean
alloc_ports (GstRTSPStream * stream)
typedef struct _GstRTSPStreamClass GstRTSPStreamClass;
#include "rtsp-stream-transport.h"
+#include "rtsp-address-pool.h"
/**
* GstRTSPStream:
* @tee: tee for the sending to udpsink and appsink
* @funnel: tee for the receiving from udpsrc and appsrc
* @server_port: the server ports for this stream
+ * @pool: the address pool for this stream
+ * @addr: the address for this stream
* @caps_sig: the signal id for detecting caps
* @caps: the caps of the stream
* @n_active: the number of active transports in @transports
/* server ports for sending/receiving */
GstRTSPRange server_port;
+ /* multicast addresses */
+ GstRTSPAddressPool *pool;
+ GstRTSPAddress *addr;
+
/* the caps of the stream */
gulong caps_sig;
GstCaps *caps;
void gst_rtsp_stream_set_mtu (GstRTSPStream * stream, guint mtu);
guint gst_rtsp_stream_get_mtu (GstRTSPStream * stream);
+void gst_rtsp_stream_set_address_pool (GstRTSPStream *stream, GstRTSPAddressPool *pool);
+GstRTSPAddressPool *
+ gst_rtsp_stream_get_address_pool (GstRTSPStream *stream);
+
+GstRTSPAddress * gst_rtsp_stream_get_address (GstRTSPStream *stream);
+
gboolean gst_rtsp_stream_join_bin (GstRTSPStream * stream,
GstBin *bin, GstElement *rtpbin,
GstState state);