GError ** error)
{
DvbBaseBin *dvbbasebin = GST_DVB_BASE_BIN (handler);
+ GError *err = NULL;
gchar *location;
location = gst_uri_get_location (uri);
if (location == NULL)
goto no_location;
- if (!set_properties_for_channel (GST_ELEMENT (dvbbasebin), location))
+ if (!set_properties_for_channel (GST_ELEMENT (dvbbasebin), location, &err))
goto set_properties_failed;
/* FIXME: here is where we parse channels.conf */
g_free (location);
return TRUE;
/* ERRORS */
+post_error_and_exit:
+ {
+ gst_element_message_full (GST_ELEMENT (dvbbasebin), GST_MESSAGE_ERROR,
+ err->domain, err->code, g_strdup (err->message), NULL, __FILE__,
+ GST_FUNCTION, __LINE__);
+ g_propagate_error (error, err);
+ return FALSE;
+ }
no_location:
{
- g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
+ g_set_error (&err, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
"No details to DVB URI");
- return FALSE;
+ goto post_error_and_exit;
}
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;
+ goto post_error_and_exit;
}
}
{
GST_DEBUG_CATEGORY_INIT (gstdvbsrc_debug, "dvbsrc", 0, "DVB Source Element");
-#ifdef ENABLE_NLS
- GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
- LOCALEDIR);
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-#endif /* ENABLE_NLS */
-
return gst_element_register (plugin, "dvbsrc", GST_RANK_NONE,
GST_TYPE_DVBSRC);
}
#include <string.h>
#include <gst/gst.h>
+#include <gst/gst-i18n-plugin.h>
+
#include "parsechannels.h"
GST_DEBUG_CATEGORY_EXTERN (dvb_base_bin_debug);
/* this will do zap style channels.conf only for the moment */
static GHashTable *
-parse_channels_conf_from_file (GstElement * dvbbasebin, const gchar * filename)
+parse_channels_conf_from_file (GstElement * dvbbasebin, const gchar * filename,
+ GError ** error)
{
gchar *contents;
gchar **lines;
open_fail:
{
- GST_ELEMENT_ERROR (dvbbasebin, RESOURCE, READ, (NULL),
- ("Opening channels configuration file '%s' failed : %s", filename,
- err->message));
+ if (err->code == G_FILE_ERROR_NOENT) {
+ g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_NOT_FOUND,
+ _("Couldn't find DVB channel configuration file"));
+ } else {
+ g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_READ,
+ _("Couldn't load DVB channel configuration file: %s"), err->message);
+ }
g_clear_error (&err);
return NULL;
}
no_channels:
{
- GST_ELEMENT_ERROR (dvbbasebin, RESOURCE, READ, (NULL),
- ("Channels configuration file doesn't contain any channels"));
+ g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
+ _("DVB channel configuration file doesn't contain any channels"));
g_hash_table_unref (res);
return NULL;
}
}
gboolean
-set_properties_for_channel (GstElement * dvbbasebin, const gchar * channel_name)
+set_properties_for_channel (GstElement * dvbbasebin,
+ const gchar * channel_name, GError ** error)
{
gboolean ret = FALSE;
GHashTable *channels, *params;
filename = g_build_filename (g_get_user_config_dir (),
"gstreamer-" GST_API_VERSION, "dvb-channels.conf", NULL);
}
- channels = parse_channels_conf_from_file (dvbbasebin, filename);
+ channels = parse_channels_conf_from_file (dvbbasebin, filename, error);
g_free (filename);
if (!channels)
unknown_channel:
{
- GST_ELEMENT_ERROR (dvbbasebin, RESOURCE, READ, (NULL),
- ("Couldn't find configuration properties for channel \"%s\"",
- channel_name));
+ /* FIXME: is channel name guaranteed to be ASCII or UTF-8? */
+ g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_NOT_FOUND,
+ _("Couldn't find details for DVB channel %s"), channel_name);
destroy_channels_hash (channels);
return FALSE;
}