コード例 #1
0
ファイル: gstspotsrc.c プロジェクト: popdevelop/dogvibes_old
static gboolean
gst_spot_src_set_spotifyuri (GstSpotSrc * spot, const gchar * uri)
{
  GstState state;
  gchar *protocol = NULL;
  gchar *location;

  /* hopefully not possible */
  g_assert (uri);

  /* the element must be stopped in order to do this */
  state = GST_STATE (spot);
  if (state != GST_STATE_READY && state != GST_STATE_NULL) {
    GST_WARNING_OBJECT (spot, "Setting spotify_uri in wrong state");
    goto wrong_state;
  }

  if (!gst_uri_is_valid (uri)) {
    GST_WARNING_OBJECT (spot, "Invalid URI '%s' for spotsrc", uri);
    goto invalid_uri;
  }

  protocol = gst_uri_get_protocol (uri);
  if (strcmp (protocol, "spotify") != 0) {
     GST_WARNING_OBJECT (spot, "Setting spotify_uri with wrong protocol");
     goto wrong_protocol;
  }
  g_free (protocol);

  location = gst_uri_get_location (uri);
  if (!location) {
    GST_WARNING_OBJECT (spot, "Setting spotify_uri with wrong/no location");
    goto wrong_location;
  }

  /* we store the spotify_uri as received by the application. On Windoes this
   * should be UTF8 */
  g_free (GST_SPOT_SRC_URI (spot));

  GST_SPOT_SRC_URI (spot) = g_strdup (uri);
  
  g_object_notify (G_OBJECT (spot), "uri"); /* why? */
  gst_uri_handler_new_uri (GST_URI_HANDLER (spot), spot->uri);

  return TRUE;

  /* ERROR */
invalid_uri:

wrong_protocol:
  g_free (protocol);
wrong_state:
wrong_location:
  return FALSE;
}
コード例 #2
0
ファイル: gstfilesrc.c プロジェクト: puce77/openjfx-8u-dev-rt
static gboolean
gst_file_src_set_location (GstFileSrc * src, const gchar * location)
{
  GstState state;

  /* the element must be stopped in order to do this */
  GST_OBJECT_LOCK (src);
  state = GST_STATE (src);
  if (state != GST_STATE_READY && state != GST_STATE_NULL)
    goto wrong_state;
  GST_OBJECT_UNLOCK (src);

  g_free (src->filename);
  g_free (src->uri);

  /* clear the filename if we get a NULL (is that possible?) */
  if (location == NULL) {
    src->filename = NULL;
    src->uri = NULL;
  } else {
    /* we store the filename as received by the application. On Windows this
     * should be UTF8 */
    src->filename = g_strdup (location);
    src->uri = gst_filename_to_uri (location, NULL);
    GST_INFO ("filename : %s", src->filename);
    GST_INFO ("uri      : %s", src->uri);
  }
  g_object_notify (G_OBJECT (src), "location");
  gst_uri_handler_new_uri (GST_URI_HANDLER (src), src->uri);

  return TRUE;

  /* ERROR */
wrong_state:
  {
    g_warning ("Changing the `location' property on filesrc when a file is "
        "open is not supported.");
    GST_OBJECT_UNLOCK (src);
    return FALSE;
  }
}
コード例 #3
0
static gboolean
gst_file_src_set_location (GstFileSrc * src, const gchar * location)
{
  GstState state;

  /* the element must be stopped in order to do this */
  GST_OBJECT_LOCK (src);
  state = GST_STATE (src);
  if (state != GST_STATE_READY && state != GST_STATE_NULL)
    goto wrong_state;
  GST_OBJECT_UNLOCK (src);

  g_free (src->filename);
  g_free (src->uri);

  /* clear the filename if we get a NULL (is that possible?) */
  if (location == NULL) {
    src->filename = NULL;
    src->uri = NULL;
  } else {
    src->filename = g_strdup (location);
    src->uri = gst_uri_construct ("file", src->filename);
  }
  g_object_notify (G_OBJECT (src), "location");
  gst_uri_handler_new_uri (GST_URI_HANDLER (src), src->uri);

  return TRUE;

  /* ERROR */
wrong_state:
  {
    GST_DEBUG_OBJECT (src, "setting location in wrong state");
    GST_OBJECT_UNLOCK (src);
    return FALSE;
  }
}