diff options
author | Parthasarathi Susarla <partha.susarla@collabora.co.uk> | 2010-08-14 22:46:29 +0530 |
---|---|---|
committer | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2010-08-14 23:26:52 +0530 |
commit | 33890a344053b36deb2ed4717aa65fd968537bd8 (patch) | |
tree | b421d0824c0cf70523ab1cd2bf9eac592e982d25 /tools | |
parent | 6a136db697f81055194c899d8893ffe53a674b65 (diff) | |
download | gupnp-dlna-33890a344053b36deb2ed4717aa65fd968537bd8.tar.gz |
tools: Add a tool to list supported profiles
This lists all supported profiles. There is a verbose mode (-v) which
dumps the GstCaps for the restrictions of that profile.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Makefile.am | 2 | ||||
-rw-r--r-- | tools/gupnp-dlna-ls-profiles.c | 128 |
2 files changed, 129 insertions, 1 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am index 5ea2799..053b963 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,4 +1,4 @@ -bin_PROGRAMS = gupnp-dlna-info +bin_PROGRAMS = gupnp-dlna-info gupnp-dlna-ls-profiles AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/gst-convenience/gst-libs $(GST_CFLAGS) AM_LDFLAGS = $(top_builddir)/libgupnp-dlna/libgupnp-dlna-1.0.la $(top_builddir)/gst-convenience/gst-libs/gst/profile/.libs/libgstprofile-gupnp-dlna-@GST_MAJORMINOR@.la $(GST_PBU_LIBS) diff --git a/tools/gupnp-dlna-ls-profiles.c b/tools/gupnp-dlna-ls-profiles.c new file mode 100644 index 0000000..fee2300 --- /dev/null +++ b/tools/gupnp-dlna-ls-profiles.c @@ -0,0 +1,128 @@ +/* GUPnPDLNA + * gupnp-dlna-ls-profiles.c + * + * Copyright (C) 2010 Nokia Corporation + * Copyright (C) 2010 Collabora Multimedia + * + * Authors: Parthasarathi Susarla <partha.susarla@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> +#include <string.h> + +#include <glib.h> +#include <glib-object.h> +#include <gio/gio.h> + +#include <libgupnp-dlna/gupnp-dlna-profile.h> +#include <libgupnp-dlna/gupnp-dlna-discoverer.h> + +#include <gst/profile/gstprofile.h> + +static gboolean verbose = FALSE; + +static void print_caps (GstCaps *caps) +{ + int i; + + for (i = 0; i < gst_caps_get_size (caps); i++) { + GstStructure *structure = gst_caps_get_structure (caps, i); + gchar *tmp = gst_structure_to_string (structure); + + g_print ("%s`- %s\n", i ? " " : "", tmp); + + g_free (tmp); + } +} + +static void +print_profile (GUPnPDLNAProfile *profile, gpointer unused) +{ + const GstEncodingProfile *enc_profile; + GList *tmp; + gchar *caps_str; + + enc_profile = gupnp_dlna_profile_get_encoding_profile (profile); + tmp = enc_profile->encodingprofiles; + + g_print ("%s, %s", + gupnp_dlna_profile_get_name (profile), + gupnp_dlna_profile_get_mime (profile)); + + if (verbose) { + caps_str = gst_caps_to_string (enc_profile->format); + g_print ("\n`- container: %s\n", caps_str); + g_free (caps_str); + + while (tmp) { + print_caps (((GstStreamEncodingProfile *) tmp->data)->format); + tmp = tmp->next; + } + } + + g_print ("\n"); +} + +int +main (int argc, char **argv) +{ + GError *err = NULL; + GList *profiles = NULL; + GUPnPDLNADiscoverer *discover; + + GOptionEntry options[] = { + {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, + "Print (very) verbose output", NULL}, + {NULL} + }; + + GOptionContext *ctx; + + g_thread_init(NULL); + + ctx = g_option_context_new (" - program to list all the DLNA profiles supported by gupnp-dlna"); + g_option_context_add_main_entries (ctx, options, NULL); + g_option_context_add_group (ctx, gst_init_get_option_group ()); + + if (!g_option_context_parse (ctx, &argc, &argv, &err)) { + + g_print ("Error initializing: %s\n", err->message); + exit (1); + } + + g_option_context_free (ctx); + + gst_init (&argc, &argv); + + discover = gupnp_dlna_discoverer_new ((GstClockTime) GST_SECOND); + + profiles = (GList *) gupnp_dlna_discoverer_list_profiles (discover); + + if (!verbose) { + g_print ("Name, MIME type\n"); + g_print ("=================================================\n"); + } + g_list_foreach (profiles, (GFunc) print_profile, NULL); + + g_object_unref (discover); + + return 0; +} |