예제 #1
0
static gboolean
make_source (GstUriTranscodeBin * self)
{
  GError *err = NULL;

  if (!gst_uri_is_valid (self->source_uri))
    goto invalid_uri;

  self->src = gst_element_make_from_uri (GST_URI_SRC, self->source_uri,
      "src", &err);
  if (!self->src)
    goto no_sink;

  gst_bin_add (GST_BIN (self), self->src);

  if (!gst_element_link (self->src, self->transcodebin))
    return FALSE;

  return TRUE;

invalid_uri:
  {
    GST_ELEMENT_ERROR (self, RESOURCE, NOT_FOUND,
        ("Invalid URI \"%s\".", self->source_uri), (NULL));
    g_clear_error (&err);
    return FALSE;
  }

no_sink:
  {
    /* whoops, could not create the source element, dig a little deeper to
     * figure out what might be wrong. */
    if (err != NULL && err->code == GST_URI_ERROR_UNSUPPORTED_PROTOCOL) {
      gchar *prot;

      prot = gst_uri_get_protocol (self->source_uri);
      if (prot == NULL)
        goto invalid_uri;

      gst_element_post_message (GST_ELEMENT_CAST (self),
          gst_missing_uri_source_message_new (GST_ELEMENT (self), prot));

      GST_ELEMENT_ERROR (self, CORE, MISSING_PLUGIN,
          ("No URI handler implemented for \"%s\".", prot), (NULL));

      g_free (prot);
    } else {
      GST_ELEMENT_ERROR (self, RESOURCE, NOT_FOUND,
          ("%s", (err) ? err->message : "URI was not accepted by any element"),
          ("No element accepted URI '%s'", self->dest_uri));
    }

    g_clear_error (&err);

    return FALSE;
  }
}
예제 #2
0
static VALUE
missing_uri_source_message_initialize(VALUE self, VALUE element, VALUE protocol)
{
    GstMessage *message;

    message = gst_missing_uri_source_message_new(RVAL2GST_ELEMENT(element),
                                                 RVAL2CSTR(protocol));
    G_INITIALIZE(self, message);
    return Qnil;
}