static gboolean gst_gnome_vfs_src_check_get_range (GstBaseSrc * basesrc) { GstGnomeVFSSrc *src; const gchar *protocol; src = GST_GNOME_VFS_SRC (basesrc); if (src->uri == NULL) { GST_WARNING_OBJECT (src, "no URI set yet"); return FALSE; } if (gnome_vfs_uri_is_local (src->uri)) { GST_LOG_OBJECT (src, "local URI (%s), assuming random access is possible", GST_STR_NULL (src->uri_name)); return TRUE; } /* blacklist certain protocols we know won't work getrange-based */ protocol = gnome_vfs_uri_get_scheme (src->uri); if (protocol == NULL) goto undecided; if (strcmp (protocol, "http") == 0 || strcmp (protocol, "https") == 0) { GST_LOG_OBJECT (src, "blacklisted protocol '%s', no random access possible" " (URI=%s)", protocol, GST_STR_NULL (src->uri_name)); return FALSE; } /* fall through to undecided */ undecided: { /* don't know what to do, let the basesrc class decide for us */ GST_LOG_OBJECT (src, "undecided about URI '%s', let base class handle it", GST_STR_NULL (src->uri_name)); if (GST_BASE_SRC_CLASS (parent_class)->check_get_range) return GST_BASE_SRC_CLASS (parent_class)->check_get_range (basesrc); return FALSE; } }
static gboolean gst_gnome_vfs_src_get_size (GstBaseSrc * basesrc, guint64 * size) { GstGnomeVFSSrc *src; GnomeVFSFileInfo *info; GnomeVFSFileInfoOptions options; GnomeVFSResult res; src = GST_GNOME_VFS_SRC (basesrc); *size = -1; info = gnome_vfs_file_info_new (); options = GNOME_VFS_FILE_INFO_DEFAULT | GNOME_VFS_FILE_INFO_FOLLOW_LINKS; res = gnome_vfs_get_file_info_from_handle (src->handle, info, options); if (res == GNOME_VFS_OK) { if ((info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) { *size = info->size; GST_DEBUG_OBJECT (src, "from handle: %" G_GUINT64_FORMAT " bytes", *size); } else if (src->own_handle && gnome_vfs_uri_is_local (src->uri)) { GST_DEBUG_OBJECT (src, "file size not known, file local, trying fallback"); res = gnome_vfs_get_file_info_uri (src->uri, info, options); if (res == GNOME_VFS_OK && (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) { *size = info->size; GST_DEBUG_OBJECT (src, "from uri: %" G_GUINT64_FORMAT " bytes", *size); } } } else { GST_WARNING_OBJECT (src, "getting info failed: %s", gnome_vfs_result_to_string (res)); } gnome_vfs_file_info_unref (info); if (*size == (GnomeVFSFileSize) - 1) return FALSE; GST_DEBUG_OBJECT (src, "return size %" G_GUINT64_FORMAT, *size); return TRUE; }
/** \return A new document just for you! \brief This function takes in a filename of a SVG document and turns it into a SPDocument. \param mod Module to use \param uri The path to the file (UTF-8) This function is really simple, it just calls sp_document_new... */ SPDocument * Svg::open (Inkscape::Extension::Input */*mod*/, const gchar *uri) { #ifdef WITH_GNOME_VFS if (!gnome_vfs_initialized() || gnome_vfs_uri_is_local(gnome_vfs_uri_new(uri))) { // Use built-in loader instead of VFS for this return sp_document_new(uri, TRUE); } gchar * buffer = _load_uri(uri); if (buffer == NULL) { g_warning("Error: Could not open file '%s' with VFS\n", uri); return NULL; } SPDocument * doc = sp_document_new_from_mem(buffer, strlen(buffer), 1); g_free(buffer); return doc; #else return sp_document_new (uri, TRUE); #endif }