Commit cf187096 authored by Wim Taymans's avatar Wim Taymans Committed by Wim Taymans

More improvements

Rename GstRTSPMediaBin to GstRTSPMedia
Parse the request url into a GstRTSPUri object and pass this object to the
various handlers and methods that require the uri.
parent 83cf4d8e
......@@ -78,7 +78,7 @@ handle_generic_response (GstRTSPClient *client, GstRTSPStatusCode code,
}
static gboolean
handle_teardown_response (GstRTSPClient *client, const gchar *uri, GstRTSPMessage *request)
handle_teardown_response (GstRTSPClient *client, GstRTSPUrl *uri, GstRTSPMessage *request)
{
GstRTSPResult res;
GstRTSPSessionMedia *media;
......@@ -137,7 +137,7 @@ not_found:
}
static gboolean
handle_pause_response (GstRTSPClient *client, const gchar *uri, GstRTSPMessage *request)
handle_pause_response (GstRTSPClient *client, GstRTSPUrl *uri, GstRTSPMessage *request)
{
GstRTSPResult res;
GstRTSPSessionMedia *media;
......@@ -189,7 +189,7 @@ not_found:
}
static gboolean
handle_play_response (GstRTSPClient *client, const gchar *uri, GstRTSPMessage *request)
handle_play_response (GstRTSPClient *client, GstRTSPUrl *uri, GstRTSPMessage *request)
{
GstRTSPResult res;
GstRTSPSessionMedia *media;
......@@ -233,18 +233,22 @@ handle_play_response (GstRTSPClient *client, const gchar *uri, GstRTSPMessage *r
/* grab RTPInfo from the payloaders now */
rtpinfo = g_string_new ("");
n_streams = gst_rtsp_media_bin_n_streams (media->mediabin);
n_streams = gst_rtsp_media_n_streams (media->media);
for (i = 0; i < n_streams; i++) {
GstRTSPMediaStream *stream;
gchar *uristr;
stream = gst_rtsp_media_bin_get_stream (media->mediabin, i);
stream = gst_rtsp_media_get_stream (media->media, i);
g_object_get (G_OBJECT (stream->payloader), "seqnum", &seqnum, NULL);
g_object_get (G_OBJECT (stream->payloader), "timestamp", &timestamp, NULL);
if (i > 0)
g_string_append (rtpinfo, ", ");
g_string_append_printf (rtpinfo, "url=%s/stream=%d;seq=%u;rtptime=%u", uri, i, seqnum, timestamp);
uristr = gst_rtsp_url_get_request_uri (uri);
g_string_append_printf (rtpinfo, "url=%s/stream=%d;seq=%u;rtptime=%u", uristr, i, seqnum, timestamp);
g_free (uristr);
}
/* construct the response now */
......@@ -282,7 +286,7 @@ not_found:
}
static gboolean
handle_setup_response (GstRTSPClient *client, const gchar *location, GstRTSPMessage *request)
handle_setup_response (GstRTSPClient *client, GstRTSPUrl *uri, GstRTSPMessage *request)
{
GstRTSPResult res;
gchar *sessid;
......@@ -290,7 +294,6 @@ handle_setup_response (GstRTSPClient *client, const gchar *location, GstRTSPMess
gchar **transports;
gboolean have_transport;
GstRTSPTransport *ct, *st;
GstRTSPUrl *uri;
GstRTSPSession *session;
gint i;
GstRTSPLowerTrans supported;
......@@ -303,11 +306,8 @@ handle_setup_response (GstRTSPClient *client, const gchar *location, GstRTSPMess
gboolean need_session;
/* the uri contains the stream number we added in the SDP config, which is
* always /stream=%d so we need to strip that off */
if ((res = gst_rtsp_url_parse (location, &uri)) != GST_RTSP_OK)
goto bad_url;
/* parse the stream we need to configure, look for the stream in the abspath
* always /stream=%d so we need to strip that off
* parse the stream we need to configure, look for the stream in the abspath
* first and then in the query. */
if (!(pos = strstr (uri->abspath, "/stream="))) {
if (!(pos = strstr (uri->query, "/stream=")))
......@@ -382,7 +382,7 @@ handle_setup_response (GstRTSPClient *client, const gchar *location, GstRTSPMess
}
/* get a handle to the configuration of the media in the session */
media = gst_rtsp_session_get_media (session, uri->abspath, client->factory);
media = gst_rtsp_session_get_media (session, uri, client->factory);
if (!media)
goto not_found;
......@@ -410,11 +410,6 @@ handle_setup_response (GstRTSPClient *client, const gchar *location, GstRTSPMess
return TRUE;
/* ERRORS */
bad_url:
{
handle_generic_response (client, GST_RTSP_STS_BAD_REQUEST, request);
return FALSE;
}
bad_request:
{
handle_generic_response (client, GST_RTSP_STS_BAD_REQUEST, request);
......@@ -444,48 +439,53 @@ service_unavailable:
/* for the describe we must generate an SDP */
static gboolean
handle_describe_response (GstRTSPClient *client, const gchar *location, GstRTSPMessage *request)
handle_describe_response (GstRTSPClient *client, GstRTSPUrl *uri, GstRTSPMessage *request)
{
GstRTSPMessage response = { 0 };
GstRTSPResult res;
GstSDPMessage *sdp;
GstRTSPUrl *uri;
guint n_streams, i;
gchar *sdptext;
GstRTSPMediaFactory *factory;
GstRTSPMediaBin *mediabin;
GstRTSPMedia *media;
GstElement *pipeline;
GstStateChangeReturn ret;
/* the uri contains the stream number we added in the SDP config, which is
* always /stream=%d so we need to strip that off */
if ((res = gst_rtsp_url_parse (location, &uri)) != GST_RTSP_OK)
goto bad_url;
/* find the factory for the uri first */
if (!(factory = gst_rtsp_media_mapping_find_factory (client->mapping, uri)))
goto no_factory;
/* check what kind of format is accepted */
/* check what kind of format is accepted, we don't really do anything with it
* and always return SDP for now. */
for (i = 0; i++; ) {
gchar *accept;
res = gst_rtsp_message_get_header (request, GST_RTSP_HDR_ACCEPT, &accept, i);
if (res == GST_RTSP_ENOTIMPL)
break;
if (g_ascii_strcasecmp (accept, "application/sdp") == 0)
break;
}
/* create a pipeline to preroll the media */
pipeline = gst_pipeline_new ("client-describe-pipeline");
/* prepare the media and add it to the pipeline */
if (!(mediabin = gst_rtsp_media_factory_construct (factory, uri->abspath)))
goto no_media_bin;
if (!(media = gst_rtsp_media_factory_construct (factory, uri)))
goto no_media;
gst_bin_add (GST_BIN_CAST (pipeline), mediabin->element);
gst_bin_add (GST_BIN_CAST (pipeline), media->element);
/* link fakesink to all stream pads and set the pipeline to PLAYING */
n_streams = gst_rtsp_media_bin_n_streams (mediabin);
n_streams = gst_rtsp_media_n_streams (media);
for (i = 0; i < n_streams; i++) {
GstRTSPMediaStream *stream;
GstElement *sink;
GstPad *sinkpad;
GstPadLinkReturn lret;
stream = gst_rtsp_media_bin_get_stream (mediabin, i);
stream = gst_rtsp_media_get_stream (media, i);
sink = gst_element_factory_make ("fakesink", NULL);
gst_bin_add (GST_BIN (pipeline), sink);
......@@ -530,7 +530,7 @@ handle_describe_response (GstRTSPClient *client, const gchar *location, GstRTSPM
gboolean first;
GString *fmtp;
stream = gst_rtsp_media_bin_get_stream (mediabin, i);
stream = gst_rtsp_media_get_stream (media, i);
gst_sdp_media_new (&smedia);
s = gst_caps_get_structure (stream->caps, 0);
......@@ -623,6 +623,8 @@ handle_describe_response (GstRTSPClient *client, const gchar *location, GstRTSPM
gst_rtsp_message_init_response (&response, GST_RTSP_STS_OK,
gst_rtsp_status_as_text (GST_RTSP_STS_OK), request);
gst_rtsp_message_add_header (&response, GST_RTSP_HDR_CONTENT_TYPE, "application/sdp");
/* add SDP to the response body */
sdptext = gst_sdp_message_as_text (sdp);
gst_rtsp_message_take_body (&response, (guint8 *)sdptext, strlen (sdptext));
......@@ -633,17 +635,12 @@ handle_describe_response (GstRTSPClient *client, const gchar *location, GstRTSPM
return TRUE;
/* ERRORS */
bad_url:
{
handle_generic_response (client, GST_RTSP_STS_BAD_REQUEST, request);
return FALSE;
}
no_factory:
{
handle_generic_response (client, GST_RTSP_STS_NOT_FOUND, request);
return FALSE;
}
no_media_bin:
no_media:
{
handle_generic_response (client, GST_RTSP_STS_SERVICE_UNAVAILABLE, request);
g_object_unref (factory);
......@@ -659,7 +656,7 @@ cant_play:
}
static void
handle_options_response (GstRTSPClient *client, const gchar *uri, GstRTSPMessage *request)
handle_options_response (GstRTSPClient *client, GstRTSPUrl *uri, GstRTSPMessage *request)
{
GstRTSPMessage response = { 0 };
GstRTSPMethod options;
......@@ -714,7 +711,8 @@ handle_client (GstRTSPClient *client)
GstRTSPMessage request = { 0 };
GstRTSPResult res;
GstRTSPMethod method;
const gchar *uri;
const gchar *uristr;
GstRTSPUrl *uri;
GstRTSPVersion version;
while (TRUE) {
......@@ -727,7 +725,7 @@ handle_client (GstRTSPClient *client)
gst_rtsp_message_dump (&request);
#endif
gst_rtsp_message_parse_request (&request, &method, &uri, &version);
gst_rtsp_message_parse_request (&request, &method, &uristr, &version);
if (version != GST_RTSP_VERSION_1_0) {
/* we can only handle 1.0 requests */
......@@ -735,6 +733,12 @@ handle_client (GstRTSPClient *client)
continue;
}
/* we always try to parse the url first */
if ((res = gst_rtsp_url_parse (uristr, &uri)) != GST_RTSP_OK) {
handle_generic_response (client, GST_RTSP_STS_BAD_REQUEST, &request);
continue;
}
/* now see what is asked and dispatch to a dedicated handler */
switch (method) {
case GST_RTSP_OPTIONS:
......@@ -767,6 +771,7 @@ handle_client (GstRTSPClient *client)
handle_generic_response (client, GST_RTSP_STS_BAD_REQUEST, &request);
break;
}
gst_rtsp_url_free (uri);
}
g_object_unref (client);
return NULL;
......
......@@ -34,8 +34,8 @@ static void gst_rtsp_media_factory_set_property (GObject *object, guint propid,
const GValue *value, GParamSpec *pspec);
static void gst_rtsp_media_factory_finalize (GObject * obj);
static GstRTSPMediaBin * default_construct (GstRTSPMediaFactory *factory, const gchar *location);
static GstElement * default_get_element (GstRTSPMediaFactory *factory, const gchar *location);
static GstRTSPMedia * default_construct (GstRTSPMediaFactory *factory, const GstRTSPUrl *url);
static GstElement * default_get_element (GstRTSPMediaFactory *factory, const GstRTSPUrl *url);
G_DEFINE_TYPE (GstRTSPMediaFactory, gst_rtsp_media_factory, G_TYPE_OBJECT);
......@@ -121,8 +121,7 @@ gst_rtsp_media_factory_set_property (GObject *object, guint propid,
*
* Create a new #GstRTSPMediaFactory instance.
*
* Returns: a new #GstRTSPMediaFactory object or %NULL when location did not contain a
* valid or understood URL.
* Returns: a new #GstRTSPMediaFactory object.
*/
GstRTSPMediaFactory *
gst_rtsp_media_factory_new (void)
......@@ -181,9 +180,9 @@ gst_rtsp_media_factory_get_launch (GstRTSPMediaFactory *factory)
/**
* gst_rtsp_media_factory_construct:
* @factory: a #GstRTSPMediaFactory
* @location: the url used
* @url: the url used
*
* Prepare the media bin object and create its streams. Implementations
* Prepare the media object and create its streams. Implementations
* should create the needed gstreamer elements and add them to the result
* object. No state changes should be performed on them yet.
*
......@@ -191,22 +190,22 @@ gst_rtsp_media_factory_get_launch (GstRTSPMediaFactory *factory)
* the srcpad member set to a source pad that produces buffer of type
* application/x-rtp.
*
* Returns: a new #GstRTSPMediaBin if the media could be prepared.
* Returns: a new #GstRTSPMedia if the media could be prepared.
*/
GstRTSPMediaBin *
gst_rtsp_media_factory_construct (GstRTSPMediaFactory *factory, const gchar *location)
GstRTSPMedia *
gst_rtsp_media_factory_construct (GstRTSPMediaFactory *factory, const GstRTSPUrl *url)
{
GstRTSPMediaBin *res;
GstRTSPMedia *res;
GstRTSPMediaFactoryClass *klass;
klass = GST_RTSP_MEDIA_FACTORY_GET_CLASS (factory);
if (klass->construct)
res = klass->construct (factory, location);
res = klass->construct (factory, url);
else
res = NULL;
g_message ("constructed mediabin %p for location %s", res, location);
g_message ("constructed media %p for url %s", res, url->abspath);
return res;
}
......@@ -221,7 +220,7 @@ caps_notify (GstPad * pad, GParamSpec * unused, GstRTSPMediaStream * stream)
}
static GstElement *
default_get_element (GstRTSPMediaFactory *factory, const gchar *location)
default_get_element (GstRTSPMediaFactory *factory, const GstRTSPUrl *url)
{
GstElement *element;
GError *error = NULL;
......@@ -258,10 +257,10 @@ parse_error:
}
}
static GstRTSPMediaBin *
default_construct (GstRTSPMediaFactory *factory, const gchar *location)
static GstRTSPMedia *
default_construct (GstRTSPMediaFactory *factory, const GstRTSPUrl *url)
{
GstRTSPMediaBin *bin;
GstRTSPMedia *media;
GstRTSPMediaStream *stream;
GstElement *pay, *element;
GstPad * pad;
......@@ -271,14 +270,14 @@ default_construct (GstRTSPMediaFactory *factory, const gchar *location)
klass = GST_RTSP_MEDIA_FACTORY_GET_CLASS (factory);
if (klass->get_element)
element = klass->get_element (factory, location);
element = klass->get_element (factory, url);
else
element = NULL;
if (element == NULL)
goto no_element;
bin = g_object_new (GST_TYPE_RTSP_MEDIA_BIN, NULL);
bin->element = element;
media = g_object_new (GST_TYPE_RTSP_MEDIA, NULL);
media->element = element;
/* try to find all the payloader elements, they should be named 'pay%d'. for
* each of the payloaders we will create a stream, collect the source pad and
......@@ -297,10 +296,10 @@ default_construct (GstRTSPMediaFactory *factory, const gchar *location)
/* create the stream */
stream = g_new0 (GstRTSPMediaStream, 1);
stream->mediabin = bin;
stream->media = media;
stream->element = element;
stream->payloader = pay;
stream->idx = bin->streams->len;
stream->idx = media->streams->len;
pad = gst_element_get_static_pad (pay, "src");
......@@ -312,13 +311,13 @@ default_construct (GstRTSPMediaFactory *factory, const gchar *location)
gst_object_unref (pad);
/* add stream now */
g_array_append_val (bin->streams, stream);
g_array_append_val (media->streams, stream);
gst_object_unref (pay);
g_free (name);
}
return bin;
return media;
/* ERRORS */
no_element:
......
......@@ -61,17 +61,17 @@ struct _GstRTSPMediaFactory {
* pay%d for each stream. The default implementation of this functions
* returns the bin created from the launch parameter.
* @construct: the vmethod that will be called when the factory has to create the
* #GstRTSPMediaBin for @location. The default implementation of this
* #GstRTSPMedia for @url. The default implementation of this
* function calls get_element to retrieve an element and then looks for
* pay%d to create the streams.
*
* the #GstRTSPMediaFactory class structure.
*/
struct _GstRTSPMediaFactoryClass {
GObjectClass parent_class;
GstElement * (*get_element) (GstRTSPMediaFactory *factory, const gchar *location);
GstRTSPMediaBin * (*construct) (GstRTSPMediaFactory *factory, const gchar *location);
GstElement * (*get_element) (GstRTSPMediaFactory *factory, const GstRTSPUrl *url);
GstRTSPMedia * (*construct) (GstRTSPMediaFactory *factory, const GstRTSPUrl *url);
};
GType gst_rtsp_media_factory_get_type (void);
......@@ -79,11 +79,18 @@ GType gst_rtsp_media_factory_get_type (void);
/* configuring the factory */
GstRTSPMediaFactory * gst_rtsp_media_factory_new (void);
void gst_rtsp_media_factory_set_launch (GstRTSPMediaFactory *factory, const gchar *launch);
void gst_rtsp_media_factory_set_launch (GstRTSPMediaFactory *factory,
const gchar *launch);
gchar * gst_rtsp_media_factory_get_launch (GstRTSPMediaFactory *factory);
void gst_rtsp_media_factory_set_shared (GstRTSPMediaFactory *factory,
gboolean shared);
gboolean gst_rtsp_media_factory_is_shared (GstRTSPMediaFactory *factory);
/* creating the media bin from the factory */
GstRTSPMediaBin * gst_rtsp_media_factory_construct (GstRTSPMediaFactory *factory, const gchar *location);
GstRTSPMedia * gst_rtsp_media_factory_construct (GstRTSPMediaFactory *factory,
const GstRTSPUrl *url);
G_END_DECLS
......
......@@ -19,24 +19,24 @@
#include "rtsp-media.h"
static void gst_rtsp_media_bin_finalize (GObject * obj);
static void gst_rtsp_media_finalize (GObject * obj);
G_DEFINE_TYPE (GstRTSPMediaBin, gst_rtsp_media_bin, G_TYPE_OBJECT);
G_DEFINE_TYPE (GstRTSPMedia, gst_rtsp_media, G_TYPE_OBJECT);
static void
gst_rtsp_media_bin_class_init (GstRTSPMediaBinClass * klass)
gst_rtsp_media_class_init (GstRTSPMediaClass * klass)
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = gst_rtsp_media_bin_finalize;
gobject_class->finalize = gst_rtsp_media_finalize;
}
static void
gst_rtsp_media_bin_init (GstRTSPMediaBin * bin)
gst_rtsp_media_init (GstRTSPMedia * media)
{
bin->streams = g_array_new (FALSE, TRUE, sizeof (GstRTSPMediaStream *));
media->streams = g_array_new (FALSE, TRUE, sizeof (GstRTSPMediaStream *));
}
static void
......@@ -45,59 +45,59 @@ gst_rtsp_media_stream_free (GstRTSPMediaStream *stream)
}
static void
gst_rtsp_media_bin_finalize (GObject * obj)
gst_rtsp_media_finalize (GObject * obj)
{
GstRTSPMediaBin *bin;
GstRTSPMedia *media;
guint i;
bin = GST_RTSP_MEDIA_BIN (obj);
media = GST_RTSP_MEDIA (obj);
for (i = 0; i < bin->streams->len; i++) {
for (i = 0; i < media->streams->len; i++) {
GstRTSPMediaStream *stream;
stream = g_array_index (bin->streams, GstRTSPMediaStream *, i);
stream = g_array_index (media->streams, GstRTSPMediaStream *, i);
gst_rtsp_media_stream_free (stream);
}
g_array_free (bin->streams, TRUE);
g_array_free (media->streams, TRUE);
G_OBJECT_CLASS (gst_rtsp_media_bin_parent_class)->finalize (obj);
G_OBJECT_CLASS (gst_rtsp_media_parent_class)->finalize (obj);
}
/**
* gst_rtsp_media_bin_n_streams:
* @media: a #GstRTSPMediaBin
* gst_rtsp_media_n_streams:
* @media: a #GstRTSPMedia
*
* Get the number of streams in this mediabin.
* Get the number of streams in this media.
*
* Returns: The number of streams.
*/
guint
gst_rtsp_media_bin_n_streams (GstRTSPMediaBin *bin)
gst_rtsp_media_n_streams (GstRTSPMedia *media)
{
g_return_val_if_fail (GST_IS_RTSP_MEDIA_BIN (bin), 0);
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), 0);
return bin->streams->len;
return media->streams->len;
}
/**
* gst_rtsp_media_bin_get_stream:
* @bin: a #GstRTSPMediaBin
* gst_rtsp_media_get_stream:
* @media: a #GstRTSPMedia
* @idx: the stream index
*
* Retrieve the stream with index @idx from @bin.
* Retrieve the stream with index @idx from @media.
*
* Returns: the #GstRTSPMediaStream at index @idx.
*/
GstRTSPMediaStream *
gst_rtsp_media_bin_get_stream (GstRTSPMediaBin *bin, guint idx)
gst_rtsp_media_get_stream (GstRTSPMedia *media, guint idx)
{
GstRTSPMediaStream *res;
g_return_val_if_fail (GST_IS_RTSP_MEDIA_BIN (bin), NULL);
g_return_val_if_fail (idx < bin->streams->len, NULL);
g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), NULL);
g_return_val_if_fail (idx < media->streams->len, NULL);
res = g_array_index (bin->streams, GstRTSPMediaStream *, idx);
res = g_array_index (media->streams, GstRTSPMediaStream *, idx);
return res;
}
......
......@@ -25,19 +25,19 @@
G_BEGIN_DECLS
/* types for the media bin */
#define GST_TYPE_RTSP_MEDIA_BIN (gst_rtsp_media_bin_get_type ())
#define GST_IS_RTSP_MEDIA_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_MEDIA_BIN))
#define GST_IS_RTSP_MEDIA_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_MEDIA_BIN))
#define GST_RTSP_MEDIA_BIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_MEDIA_BIN, GstRTSPMediaBinClass))
#define GST_RTSP_MEDIA_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_MEDIA_BIN, GstRTSPMediaBin))
#define GST_RTSP_MEDIA_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_MEDIA_BIN, GstRTSPMediaBinClass))
#define GST_RTSP_MEDIA_BIN_CAST(obj) ((GstRTSPMediaBin*)(obj))
#define GST_RTSP_MEDIA_BIN_CLASS_CAST(klass) ((GstRTSPMediaBinClass*)(klass))
/* 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 _GstRTSPMediaStream GstRTSPMediaStream;
typedef struct _GstRTSPMediaBin GstRTSPMediaBin;
typedef struct _GstRTSPMediaBinClass GstRTSPMediaBinClass;
typedef struct _GstRTSPMedia GstRTSPMedia;
typedef struct _GstRTSPMediaClass GstRTSPMediaClass;
/**
* GstRTSPMediaStream:
......@@ -45,14 +45,14 @@ typedef struct _GstRTSPMediaBinClass GstRTSPMediaBinClass;
* @idx: the stream index
* @element: the toplevel element
* @srcpad: the srcpad of the stream
* @payloader: the payloader of the formattt
* @payloader: the payloader of the format
* @caps_sig: the signal id for detecting caps
* @caps: the caps of the stream
*
* The definition of a media stream. The streams are identified by @id.
*/
struct _GstRTSPMediaStream {
GstRTSPMediaBin *mediabin;
GstRTSPMedia *media;
guint idx;
......@@ -64,28 +64,28 @@ struct _GstRTSPMediaStream {
};
/**
* GstRTSPMediaBin:
* GstRTSPMedia:
* @media: the owner #GstRTSPMedia
*
* A class that contains the elements to handle the media
* provided by @media.
*/
struct _GstRTSPMediaBin {
struct _GstRTSPMedia {
GObject parent;
GstElement *element;
GArray *streams;
};
struct _GstRTSPMediaBinClass {
struct _GstRTSPMediaClass {
GObjectClass parent_class;
};
GType gst_rtsp_media_bin_get_type (void);
GType gst_rtsp_media_get_type (void);
/* dealing with the media bin */
guint gst_rtsp_media_bin_n_streams (GstRTSPMediaBin *bin);
GstRTSPMediaStream * gst_rtsp_media_bin_get_stream (GstRTSPMediaBin *bin, guint idx);
/* dealing with the media */
guint gst_rtsp_media_n_streams (GstRTSPMedia *media);
GstRTSPMediaStream * gst_rtsp_media_get_stream (GstRTSPMedia *media, guint idx);
G_END_DECLS
......
......@@ -98,7 +98,7 @@ gst_rtsp_session_finalize (GObject * obj)
/**
* gst_rtsp_session_get_media:
* @sess: a #GstRTSPSession
* @location: the url for the media
* @url: the url for the media
* @factory: a #GstRTSPMediaFactory
*
* Get or create the session information for @factory.
......@@ -106,7 +106,7 @@ gst_rtsp_session_finalize (GObject * obj)
* Returns: the configuration for @factory in @sess.
*/
GstRTSPSessionMedia *
gst_rtsp_session_get_media (GstRTSPSession *sess, const gchar *location, GstRTSPMediaFactory *factory)
gst_rtsp_session_get_media (GstRTSPSession *sess, const GstRTSPUrl *url, GstRTSPMediaFactory *factory)
{
GstRTSPSessionMedia *result;
GList *walk;
......@@ -127,11 +127,11 @@ gst_rtsp_session_get_media (GstRTSPSession *sess, const gchar *location, GstRTSP
result->pipeline = gst_pipeline_new ("pipeline");
/* construct media and add to the pipeline */
result->mediabin = gst_rtsp_media_factory_construct (factory, location);
if (result->mediabin == NULL)
result->media = gst_rtsp_media_factory_construct (factory, url);
if (result->media == NULL)
goto no_media;
gst_bin_add (GST_BIN_CAST (result->pipeline), result->mediabin->element);
gst_bin_add (GST_BIN_CAST (result->pipeline), result->media->element);
result->rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin");
......@@ -182,7 +182,7 @@ gst_rtsp_session_media_get_stream (GstRTSPSessionMedia *media, guint idx)
result = g_new0 (GstRTSPSessionStream, 1);
result->idx = idx;
result->media = media;
result->media_stream = gst_rtsp_media_bin_get_stream (media->mediabin, idx);
result->media_stream = gst_rtsp_media_get_stream (media->media, idx);
media->streams = g_list_prepend (media->streams, result);
}
......@@ -508,4 +508,3 @@ gst_rtsp_session_media_stop (GstRTSPSessionMedia *media)
return ret;
}
......@@ -92,7 +92,7 @@ struct _GstRTSPSessionMedia
/* the pipeline for the media */
GstElement *pipeline;
GstRTSPMediaBin *mediabin;
GstRTSPMedia *media;
/* RTP session manager */
GstElement *rtpbin;
......@@ -127,7 +127,7 @@ GType gst_rtsp_session_get_type (void);
GstRTSPSession * gst_rtsp_session_new (const gchar *sessionid);
GstRTSPSessionMedia * gst_rtsp_session_get_media (GstRTSPSession *sess, const gchar *location,
GstRTSPSessionMedia * gst_rtsp_session_get_media (GstRTSPSession *sess, const GstRTSPUrl *url,
GstRTSPMediaFactory *factory);
GstStateChangeReturn gst_rtsp_session_media_play (GstRTSPSessionMedia *media);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment