static gchar * play_uri_get_display_name (GstPlay * play, const gchar * uri) { gchar *loc; if (gst_uri_has_protocol (uri, "file")) { loc = g_filename_from_uri (uri, NULL, NULL); } else if (gst_uri_has_protocol (uri, "pushfile")) { loc = g_filename_from_uri (uri + 4, NULL, NULL); } else { loc = g_strdup (uri); } /* Maybe additionally use glib's filename to display name function */ return loc; }
gboolean ges_formatter_can_save_uri (const gchar * uri) { if (!(gst_uri_is_valid (uri))) { GST_ERROR ("%s invalid uri!", uri); return FALSE; } if (!(gst_uri_has_protocol (uri, "file"))) { gchar *proto = gst_uri_get_protocol (uri); GST_ERROR ("Unspported protocol '%s'", proto); g_free (proto); return FALSE; } /* TODO: implement file format registry */ /* TODO: search through the registry and chose a GESFormatter class that can * handle the URI.*/ return TRUE; }
static gboolean gst_vcdsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri) { GstVCDSrc *src = GST_VCDSRC (handler); gchar *location = NULL; gint tracknr; GST_DEBUG_OBJECT (src, "setting uri '%s'", uri); if (!gst_uri_has_protocol (uri, "vcd")) goto wrong_protocol; /* parse out the track in the location */ if (!(location = gst_uri_get_location (uri))) goto no_location; GST_DEBUG_OBJECT (src, "have location '%s'", location); /* * URI structure: vcd:///path/to/device,track-num */ if (g_str_has_prefix (uri, "vcd://")) { GST_OBJECT_LOCK (src); g_free (src->device); if (strlen (uri) > 6) src->device = g_strdup (uri + 6); else src->device = g_strdup (DEFAULT_DEVICE); GST_DEBUG_OBJECT (src, "configured device %s", src->device); GST_OBJECT_UNLOCK (src); } /* Parse the track number */ { char **split; split = g_strsplit (location, ",", 2); if (split == NULL || *split == NULL || split[1] == NULL) { tracknr = 1; } else if (sscanf (split[1], "%d", &tracknr) != 1 || tracknr < 1) { g_strfreev (split); goto invalid_location; } g_strfreev (split); } GST_OBJECT_LOCK (src); src->track = tracknr; GST_DEBUG_OBJECT (src, "configured track %d", src->track); GST_OBJECT_UNLOCK (src); g_free (location); return TRUE; /* ERRORS */ wrong_protocol: { GST_ERROR_OBJECT (src, "wrong protocol, uri = %s", uri); return FALSE; } no_location: { GST_ERROR_OBJECT (src, "no location specified"); return FALSE; } invalid_location: { GST_ERROR_OBJECT (src, "Invalid location %s in URI '%s'", location, uri); g_free (location); return FALSE; } }