Пример #1
0
static gboolean
gst_gio_base_src_query (GstBaseSrc * base_src, GstQuery * query)
{
  gboolean ret = FALSE;
  GstGioBaseSrc *src = GST_GIO_BASE_SRC (base_src);

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_URI:
      if (GST_IS_URI_HANDLER (src)) {
        gchar *uri = gst_uri_handler_get_uri (GST_URI_HANDLER (src));
        gst_query_set_uri (query, uri);
        g_free (uri);
        ret = TRUE;
      }
      break;
    default:
      ret = FALSE;
      break;
  }

  if (!ret)
    ret = GST_BASE_SRC_CLASS (parent_class)->query (base_src, query);

  return ret;
}
Пример #2
0
static void
print_uri_handler_info (GstElement * element)
{
  if (GST_IS_URI_HANDLER (element)) {
    const gchar *const *uri_protocols;
    const gchar *uri_type;

    if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) == GST_URI_SRC)
      uri_type = "source";
    else if (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element)) ==
        GST_URI_SINK)
      uri_type = "sink";
    else
      uri_type = "unknown";

    uri_protocols = gst_uri_handler_get_protocols (GST_URI_HANDLER (element));

    n_print ("\n");
    n_print ("URI handling capabilities:\n");
    n_print ("  Element can act as %s.\n", uri_type);

    if (uri_protocols && *uri_protocols) {
      n_print ("  Supported URI protocols:\n");
      for (; *uri_protocols != NULL; uri_protocols++)
        n_print ("    %s\n", *uri_protocols);
    } else {
      n_print ("  No supported URI protocols\n");
    }
  } else {
    n_print ("Element has no URI handling capabilities.\n");
  }
}
Пример #3
0
static gboolean
gst_gio_base_sink_query (GstPad * pad, GstQuery * query)
{
    GstGioBaseSink *sink = GST_GIO_BASE_SINK (GST_PAD_PARENT (pad));
    GstFormat format;

    switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_POSITION:
        gst_query_parse_position (query, &format, NULL);
        switch (format) {
        case GST_FORMAT_BYTES:
        case GST_FORMAT_DEFAULT:
            gst_query_set_position (query, GST_FORMAT_BYTES, sink->position);
            return TRUE;
        default:
            return FALSE;
        }
    case GST_QUERY_FORMATS:
        gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
        return TRUE;
    case GST_QUERY_URI:
        if (GST_IS_URI_HANDLER (sink)) {
            const gchar *uri;

            uri = gst_uri_handler_get_uri (GST_URI_HANDLER (sink));
            gst_query_set_uri (query, uri);
            return TRUE;
        }
        return FALSE;
    default:
        return gst_pad_query_default (pad, query);
    }
}
Пример #4
0
static gboolean
gst_gio_base_sink_query (GstBaseSink * bsink, GstQuery * query)
{
  GstGioBaseSink *sink = GST_GIO_BASE_SINK (bsink);
  GstFormat format;

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_POSITION:
      gst_query_parse_position (query, &format, NULL);
      switch (format) {
        case GST_FORMAT_BYTES:
        case GST_FORMAT_DEFAULT:
          gst_query_set_position (query, format, sink->position);
          return TRUE;
        default:
          return FALSE;
      }
    case GST_QUERY_FORMATS:
      gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
      return TRUE;
    case GST_QUERY_URI:
      if (GST_IS_URI_HANDLER (sink)) {
        gchar *uri;

        uri = gst_uri_handler_get_uri (GST_URI_HANDLER (sink));
        gst_query_set_uri (query, uri);
        g_free (uri);
        return TRUE;
      }
      return FALSE;
    case GST_QUERY_SEEKING:
      gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
      if (format == GST_FORMAT_BYTES || format == GST_FORMAT_DEFAULT) {
        gst_query_set_seeking (query, format,
            GST_GIO_STREAM_IS_SEEKABLE (sink->stream), 0, -1);
      } else {
        gst_query_set_seeking (query, format, FALSE, 0, -1);
      }
      return TRUE;
    default:
      return GST_BASE_SINK_CLASS (parent_class)->query (bsink, query);
  }
}
Пример #5
0
static void
print_all_uri_handlers (void)
{
  GList *plugins, *p, *features, *f;

  plugins = gst_registry_get_plugin_list (gst_registry_get ());

  for (p = plugins; p; p = p->next) {
    GstPlugin *plugin = (GstPlugin *) (p->data);

    features =
        gst_registry_get_feature_list_by_plugin (gst_registry_get (),
        gst_plugin_get_name (plugin));

    for (f = features; f; f = f->next) {
      GstPluginFeature *feature = GST_PLUGIN_FEATURE (f->data);

      if (GST_IS_ELEMENT_FACTORY (feature)) {
        GstElementFactory *factory;
        GstElement *element;

        factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (feature));
        if (!factory) {
          g_print ("element plugin %s couldn't be loaded\n",
              gst_plugin_get_name (plugin));
          continue;
        }

        element = gst_element_factory_create (factory, NULL);
        if (!element) {
          g_print ("couldn't construct element for %s for some reason\n",
              GST_OBJECT_NAME (factory));
          gst_object_unref (factory);
          continue;
        }

        if (GST_IS_URI_HANDLER (element)) {
          const gchar *const *uri_protocols;
          const gchar *dir;
          gchar *joined;

          switch (gst_uri_handler_get_uri_type (GST_URI_HANDLER (element))) {
            case GST_URI_SRC:
              dir = "read";
              break;
            case GST_URI_SINK:
              dir = "write";
              break;
            default:
              dir = "unknown";
              break;
          }

          uri_protocols =
              gst_uri_handler_get_protocols (GST_URI_HANDLER (element));
          joined = g_strjoinv (", ", (gchar **) uri_protocols);

          g_print ("%s (%s, rank %u): %s\n",
              gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)), dir,
              gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)),
              joined);

          g_free (joined);
        }

        gst_object_unref (element);
        gst_object_unref (factory);
      }
    }

    gst_plugin_feature_list_free (features);
  }

  gst_plugin_list_free (plugins);
}