2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
39 static struct _opts_s opts
;
41 static const GOptionEntry entries
[] =
44 "stream", 's', 0, G_OPTION_ARG_STRING
, &opts
.stream
,
45 "Select stream ID, or a comma-separated list of IDs", "ID"
48 "best", 'b', 0, G_OPTION_ARG_NONE
, &opts
.best
,
49 "Choose the best available stream, negates --stream", NULL
52 "autoproxy", 'a', 0, G_OPTION_ARG_NONE
, &opts
.autoproxy
,
53 "Enable the autoproxy feature", NULL
56 "verbose", 'v', 0, G_OPTION_ARG_NONE
, &opts
.verbose
,
57 "Verbose libcurl output", NULL
60 G_OPTION_REMAINING
, 0, 0, G_OPTION_ARG_STRING_ARRAY
, &opts
.url
, "URL"
62 {NULL
, 0, 0, 0, NULL
, NULL
, NULL
}
65 static void dump_stream()
69 quvi_media_get(qm
, QUVI_MEDIA_STREAM_PROPERTY_URL
, &url
);
70 quvi_media_get(qm
, QUVI_MEDIA_STREAM_PROPERTY_ID
, &id
);
72 g_print(" id='%s', url='%s'\n", id
, url
);
75 static void dump_streams()
77 while (quvi_media_stream_next(qm
) == QUVI_TRUE
)
81 static gint
opts_new(gint argc
, gchar
**argv
)
88 c
= g_option_context_new("URL");
93 g_option_context_set_help_enabled(c
, TRUE
);
94 g_option_context_add_main_entries(c
, entries
, NULL
);
96 if (g_option_context_parse(c
, &argc
, &argv
, &e
) == FALSE
)
98 g_printerr("error: %s\n", e
->message
);
104 g_option_context_free(c
);
109 if (opts
.url
== NULL
)
111 g_printerr("error: no input URL\n");
112 return (EXIT_FAILURE
);
118 static void opts_free()
123 g_strfreev(opts
.url
);
127 typedef quvi_callback_status qcs
;
129 gint
main(gint argc
, gchar
**argv
)
134 g_assert(qm
== NULL
);
137 memset(&opts
, 0, sizeof(struct _opts_s
));
138 setlocale(LC_ALL
, "");
140 r
= opts_new(argc
, argv
);
141 if (r
!= EXIT_SUCCESS
)
145 examples_exit_if_error();
147 if (opts
.autoproxy
== TRUE
)
148 examples_enable_autoproxy();
150 if (opts
.verbose
== TRUE
)
151 examples_enable_verbose();
153 quvi_set(q
, QUVI_OPTION_CALLBACK_STATUS
, (qcs
) examples_status
);
155 for (i
=0; opts
.url
[i
] != NULL
; ++i
)
157 qm
= quvi_media_new(q
, opts
.url
[i
]);
158 examples_exit_if_error();
160 quvi_media_get(qm
, QUVI_MEDIA_PROPERTY_TITLE
, &s
);
161 g_print("[%s]\n title='%s'\n", __func__
, s
);
163 if (opts
.best
== TRUE
)
165 quvi_media_stream_choose_best(qm
);
168 else if (opts
.stream
!= NULL
)
170 quvi_media_stream_select(qm
, opts
.stream
);
171 examples_exit_if_error();
184 g_assert(qm
== NULL
);
190 /* vim: set ts=2 sw=2 tw=72 expandtab: */