Update for GstURIHandler get_protocols() changes

This commit is contained in:
Tim-Philipp Müller 2011-11-13 23:55:56 +00:00
parent 7b80e0773f
commit 357d7bdfed
7 changed files with 98 additions and 63 deletions

View file

@ -68,7 +68,7 @@ static gboolean gst_mms_do_seek (GstBaseSrc * src, GstSegment * segment);
static GstFlowReturn gst_mms_create (GstPushSrc * psrc, GstBuffer ** buf);
static gboolean gst_mms_uri_set_uri (GstURIHandler * handler,
const gchar * uri);
const gchar * uri, GError ** error);
#define gst_mms_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstMMS, gst_mms, GST_TYPE_PUSH_SRC,
@ -476,7 +476,7 @@ gst_mms_set_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_LOCATION:
gst_mms_uri_set_uri (GST_URI_HANDLER (mmssrc),
g_value_get_string (value));
g_value_get_string (value), NULL);
break;
case PROP_CONNECTION_SPEED:
GST_OBJECT_LOCK (mmssrc);
@ -528,20 +528,21 @@ gst_mms_uri_get_type (GType type)
return GST_URI_SRC;
}
static gchar **
static const gchar *const *
gst_mms_uri_get_protocols (GType type)
{
static const gchar *protocols[] = { "mms", "mmsh", "mmst", "mmsu", NULL };
return (gchar **) protocols;
return protocols;
}
static const gchar *
static gchar *
gst_mms_uri_get_uri (GstURIHandler * handler)
{
GstMMS *src = GST_MMS (handler);
return src->uri_name;
/* FIXME: make thread-safe */
return g_strdup (src->uri_name);
}
static gchar *
@ -593,14 +594,18 @@ gst_mms_src_make_valid_uri (const gchar * uri)
}
static gboolean
gst_mms_uri_set_uri (GstURIHandler * handler, const gchar * uri)
gst_mms_uri_set_uri (GstURIHandler * handler, const gchar * uri,
GError ** error)
{
GstMMS *src = GST_MMS (handler);
gchar *fixed_uri;
fixed_uri = gst_mms_src_make_valid_uri (uri);
if (!fixed_uri && uri)
if (!fixed_uri && uri) {
g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
"Invalid MMS URI");
return FALSE;
}
GST_OBJECT_LOCK (src);
if (src->uri_name)

View file

@ -1136,11 +1136,12 @@ gst_neonhttp_src_uri_get_type (void)
return GST_URI_SRC;
}
static gchar **
static const gchar *const *
gst_neonhttp_src_uri_get_protocols (void)
{
static const gchar *protocols[] = { "http", "https", NULL };
return (gchar **) protocols;
return protocols;
}
static const gchar *

View file

@ -170,10 +170,10 @@ rsn_dvdbin_uri_get_type (void)
return GST_URI_SRC;
}
static gchar **
static const gchar *const *
rsn_dvdbin_uri_get_protocols (void)
{
static gchar *protocols[] = { (char *) "dvd", NULL };
static const gchar *protocols[] = { "dvd", NULL };
return protocols;
}

View file

@ -251,31 +251,35 @@ gst_rtmp_sink_uri_get_type (GType type)
return GST_URI_SINK;
}
static gchar **
static const gchar *const *
gst_rtmp_sink_uri_get_protocols (GType type)
{
static gchar *protocols[] =
{ (char *) "rtmp", (char *) "rtmpt", (char *) "rtmps", (char *) "rtmpe",
(char *) "rtmfp", (char *) "rtmpte", (char *) "rtmpts", NULL
};
static const gchar *protocols[] =
{ "rtmp", "rtmpt", "rtmps", "rtmpe", "rtmfp", "rtmpte", "rtmpts", NULL };
return protocols;
}
static const gchar *
static gchar *
gst_rtmp_sink_uri_get_uri (GstURIHandler * handler)
{
GstRTMPSink *sink = GST_RTMP_SINK (handler);
return sink->uri;
/* FIXME: make thread-safe */
return g_strdup (sink->uri);
}
static gboolean
gst_rtmp_sink_uri_set_uri (GstURIHandler * handler, const gchar * uri)
gst_rtmp_sink_uri_set_uri (GstURIHandler * handler, const gchar * uri,
GError ** error)
{
GstRTMPSink *sink = GST_RTMP_SINK (handler);
if (GST_STATE (sink) >= GST_STATE_PAUSED)
if (GST_STATE (sink) >= GST_STATE_PAUSED) {
g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_STATE,
"Changing the URI on rtmpsrc when it is running is not supported");
return FALSE;
}
g_free (sink->uri);
sink->uri = NULL;
@ -290,6 +294,8 @@ gst_rtmp_sink_uri_set_uri (GstURIHandler * handler, const gchar * uri)
!host.av_len || !playpath.av_len) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
("Failed to parse URI %s", uri), (NULL));
g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
"Could not parse RTMP URI");
return FALSE;
}
sink->uri = g_strdup (uri);
@ -320,7 +326,7 @@ gst_rtmp_sink_set_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_LOCATION:
gst_rtmp_sink_uri_set_uri (GST_URI_HANDLER (sink),
g_value_get_string (value));
g_value_get_string (value), NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);

View file

@ -166,31 +166,35 @@ gst_rtmp_src_uri_get_type (GType type)
return GST_URI_SRC;
}
static gchar **
static const gchar *const *
gst_rtmp_src_uri_get_protocols (GType type)
{
static gchar *protocols[] =
{ (char *) "rtmp", (char *) "rtmpt", (char *) "rtmps", (char *) "rtmpe",
(char *) "rtmfp", (char *) "rtmpte", (char *) "rtmpts", NULL
};
static const gchar *protocols[] =
{ "rtmp", "rtmpt", "rtmps", "rtmpe", "rtmfp", "rtmpte", "rtmpts", NULL };
return protocols;
}
static const gchar *
static gchar *
gst_rtmp_src_uri_get_uri (GstURIHandler * handler)
{
GstRTMPSrc *src = GST_RTMP_SRC (handler);
return src->uri;
/* FIXME: make thread-safe */
return g_strdup (src->uri);
}
static gboolean
gst_rtmp_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
gst_rtmp_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
GError ** error)
{
GstRTMPSrc *src = GST_RTMP_SRC (handler);
if (GST_STATE (src) >= GST_STATE_PAUSED)
if (GST_STATE (src) >= GST_STATE_PAUSED) {
g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_STATE,
"Changing the URI on rtmpsrc when it is running is not supported");
return FALSE;
}
g_free (src->uri);
src->uri = NULL;
@ -204,6 +208,8 @@ gst_rtmp_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
if (!RTMP_ParseURL (uri, &protocol, &host, &port, &playpath, &app) ||
!host.av_len || !playpath.av_len) {
GST_ERROR_OBJECT (src, "Failed to parse URI %s", uri);
g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
"Could not parse RTMP URI");
return FALSE;
}
src->uri = g_strdup (uri);
@ -236,7 +242,7 @@ gst_rtmp_src_set_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_LOCATION:{
gst_rtmp_src_uri_set_uri (GST_URI_HANDLER (src),
g_value_get_string (value));
g_value_get_string (value), NULL);
break;
}
default:

View file

@ -71,10 +71,10 @@ static gboolean gst_data_uri_src_start (GstBaseSrc * src);
static void gst_data_uri_src_handler_init (gpointer g_iface,
gpointer iface_data);
static GstURIType gst_data_uri_src_get_uri_type (GType type);
static gchar **gst_data_uri_src_get_protocols (GType type);
static const gchar *gst_data_uri_src_get_uri (GstURIHandler * handler);
static const gchar *const *gst_data_uri_src_get_protocols (GType type);
static gchar *gst_data_uri_src_get_uri (GstURIHandler * handler);
static gboolean gst_data_uri_src_set_uri (GstURIHandler * handler,
const gchar * uri);
const gchar * uri, GError ** error);
#define gst_data_uri_src_parent_class parent_class
@ -145,7 +145,7 @@ gst_data_uri_src_set_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_URI:
gst_data_uri_src_set_uri (GST_URI_HANDLER (src),
g_value_get_string (value));
g_value_get_string (value), NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -276,24 +276,26 @@ gst_data_uri_src_get_uri_type (GType type)
return GST_URI_SRC;
}
static gchar **
static const gchar *const *
gst_data_uri_src_get_protocols (GType type)
{
static gchar *protocols[] = { (char *) "data", 0 };
static const gchar *protocols[] = { "data", 0 };
return protocols;
}
static const gchar *
static gchar *
gst_data_uri_src_get_uri (GstURIHandler * handler)
{
GstDataURISrc *src = GST_DATA_URI_SRC (handler);
return src->uri;
/* FIXME: make thread-safe */
return g_strdup (src->uri);
}
static gboolean
gst_data_uri_src_set_uri (GstURIHandler * handler, const gchar * uri)
gst_data_uri_src_set_uri (GstURIHandler * handler, const gchar * uri,
GError ** error)
{
GstDataURISrc *src = GST_DATA_URI_SRC (handler);
gboolean ret = FALSE;
@ -413,16 +415,23 @@ wrong_state:
GST_WARNING_OBJECT (src, "Can't set URI in %s state",
gst_element_state_get_name (GST_STATE (src)));
GST_OBJECT_UNLOCK (src);
g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_STATE,
"Changing the 'uri' property on dataurisrc while it is running "
"is not supported");
goto out;
}
invalid_uri:
{
GST_WARNING_OBJECT (src, "invalid URI '%s'", uri);
g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
"Invalid data URI");
goto out;
}
invalid_uri_encoded_data:
{
GST_WARNING_OBJECT (src, "Failed to parse data encoded in URI '%s'", uri);
g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
"Could not parse data encoded in data URI");
goto out;
}
}

View file

@ -958,45 +958,53 @@ dvb_base_bin_uri_get_type (GType type)
return GST_URI_SRC;
}
static gchar **
static const gchar *const *
dvb_base_bin_uri_get_protocols (GType type)
{
static gchar *protocols[] = { (char *) "dvb", NULL };
static const gchar *protocols[] = { "dvb", NULL };
return protocols;
}
static const gchar *
static gchar *
dvb_base_bin_uri_get_uri (GstURIHandler * handler)
{
return "dvb://";
return g_strdup ("dvb://");
}
static gboolean
dvb_base_bin_uri_set_uri (GstURIHandler * handler, const gchar * uri)
dvb_base_bin_uri_set_uri (GstURIHandler * handler, const gchar * uri,
GError ** error)
{
gboolean ret;
gchar *protocol;
DvbBaseBin *dvbbasebin = GST_DVB_BASE_BIN (handler);
gchar *location;
protocol = gst_uri_get_protocol (uri);
location = gst_uri_get_location (uri);
if (strcmp (protocol, "dvb") != 0) {
ret = FALSE;
} else {
gchar *location = gst_uri_get_location (uri);
if (location == NULL)
goto no_location;
if (location != NULL) {
ret = set_properties_for_channel (G_OBJECT (dvbbasebin), location);
g_free (location);
} else
ret = FALSE;
if (!set_properties_for_channel (G_OBJECT (dvbbasebin), location))
goto set_properties_failed;
/* FIXME: here is where we parse channels.conf */
g_free (location);
return TRUE;
/* ERRORS */
no_location:
{
g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
"No details to DVB URI");
return FALSE;
}
set_properties_failed:
{
g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
"Could not set properties from DVB URI");
g_free (location);
return FALSE;
}
/* here is where we parse channels.conf */
g_free (protocol);
return ret;
}
static void