static gboolean gst_fd_src_uri_set_uri (GstURIHandler * handler, const gchar * uri) { gchar *protocol; GstFdSrc *src = GST_FD_SRC (handler); gint fd; protocol = gst_uri_get_protocol (uri); if (strcmp (protocol, "fd") != 0) { g_free (protocol); return FALSE; } g_free (protocol); if (sscanf (uri, "fd://%d", &fd) != 1 || fd < 0) return FALSE; src->new_fd = fd; GST_OBJECT_LOCK (src); if (GST_STATE (GST_ELEMENT (src)) <= GST_STATE_READY) { gst_fd_src_update_fd (src); } GST_OBJECT_UNLOCK (src); return TRUE; }
static void gst_fd_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstFdSrc *src = GST_FD_SRC (object); switch (prop_id) { case PROP_FD: src->new_fd = g_value_get_int (value); /* If state is ready or below, update the current fd immediately * so it is reflected in get_properties and uri */ GST_OBJECT_LOCK (object); if (GST_STATE (GST_ELEMENT (src)) <= GST_STATE_READY) { GST_DEBUG_OBJECT (src, "state ready or lower, updating to use new fd"); gst_fd_src_update_fd (src); } else { GST_DEBUG_OBJECT (src, "state above ready, not updating to new fd yet"); } GST_OBJECT_UNLOCK (object); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static gboolean gst_fd_src_uri_set_uri (GstURIHandler * handler, const gchar * uri) { gchar *protocol, *q; GstFdSrc *src = GST_FD_SRC (handler); gint fd; guint64 size = -1; GST_INFO_OBJECT (src, "checking uri %s", uri); protocol = gst_uri_get_protocol (uri); if (strcmp (protocol, "fd") != 0) { g_free (protocol); return FALSE; } g_free (protocol); if (sscanf (uri, "fd://%d", &fd) != 1 || fd < 0) return FALSE; if ((q = g_strstr_len (uri, -1, "?"))) { gchar *sp; GST_INFO_OBJECT (src, "found ?"); if ((sp = g_strstr_len (q, -1, "size="))) { if (sscanf (sp, "size=%" G_GUINT64_FORMAT, &size) != 1) { GST_INFO_OBJECT (src, "parsing size failed"); size = -1; } else { GST_INFO_OBJECT (src, "found size %" G_GUINT64_FORMAT, size); } } } src->new_fd = fd; GST_OBJECT_LOCK (src); if (GST_STATE (GST_ELEMENT (src)) <= GST_STATE_READY) { gst_fd_src_update_fd (src, size); } GST_OBJECT_UNLOCK (src); return TRUE; }
static gboolean gst_fd_src_start (GstBaseSrc * bsrc) { GstFdSrc *src = GST_FD_SRC (bsrc); src->curoffset = 0; if ((src->fdset = gst_poll_new (TRUE)) == NULL) goto socket_pair; gst_fd_src_update_fd (src); return TRUE; /* ERRORS */ socket_pair: { GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE, (NULL), GST_ERROR_SYSTEM); return FALSE; } }