2 * gupnp-dlna-ls-profiles.c
4 * Copyright (C) 2010 Nokia Corporation
5 * Copyright (C) 2010 Collabora Multimedia
7 * Authors: Parthasarathi Susarla <partha.susarla@collabora.co.uk>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
32 #include <glib-object.h>
35 #include <libgupnp-dlna/gupnp-dlna-profile.h>
36 #include <libgupnp-dlna/gupnp-dlna-discoverer.h>
38 #include <gst/profile/gstprofile.h>
40 static gboolean verbose = FALSE, relaxed = FALSE;
42 static void print_caps (GstCaps *caps)
46 for (i = 0; i < gst_caps_get_size (caps); i++) {
47 GstStructure *structure = gst_caps_get_structure (caps, i);
48 gchar *tmp = gst_structure_to_string (structure);
50 g_print ("%s`- %s\n", i ? " " : "", tmp);
57 print_profile (GUPnPDLNAProfile *profile, gpointer unused)
59 const GstEncodingProfile *enc_profile;
63 enc_profile = gupnp_dlna_profile_get_encoding_profile (profile);
64 tmp = enc_profile->encodingprofiles;
66 g_print ("%s %-30s%-35s",
67 gupnp_dlna_profile_get_extended (profile) ? "*" : " ",
68 gupnp_dlna_profile_get_name (profile),
69 gupnp_dlna_profile_get_mime (profile));
72 caps_str = gst_caps_to_string (enc_profile->format);
73 g_print ("\n`- container: %s\n", caps_str);
77 print_caps (((GstStreamEncodingProfile *) tmp->data)->format);
86 main (int argc, char **argv)
89 GList *profiles = NULL;
90 GUPnPDLNADiscoverer *discover;
92 GOptionEntry options[] = {
93 {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
94 "Print (very) verbose output", NULL},
95 {"relaxed", 'r', 0, G_OPTION_ARG_NONE, &relaxed,
96 "Read profiles in relaxed mode (only useful with -v)", NULL},
104 ctx = g_option_context_new (" - program to list all the DLNA profiles supported by gupnp-dlna");
105 g_option_context_add_main_entries (ctx, options, NULL);
106 g_option_context_add_group (ctx, gst_init_get_option_group ());
108 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
110 g_print ("Error initializing: %s\n", err->message);
114 g_option_context_free (ctx);
116 gst_init (&argc, &argv);
118 discover = gupnp_dlna_discoverer_new ((GstClockTime) GST_SECOND,
122 profiles = (GList *) gupnp_dlna_discoverer_list_profiles (discover);
125 g_print (" %-30s%s\n", "Name", "MIME type");
126 g_print ("---------------------------------------------------"
127 "---------------------\n");
129 g_list_foreach (profiles, (GFunc) print_profile, NULL);
130 g_print ("\nProfiles with a '*' against their name are extended "
131 "(non-standard) profiles.\n\n");
133 g_object_unref (discover);