ted.lua: Fix choose_best, iter_formats
[quvi.git] / examples / simple.c
blob7724cadba2047c3b7e3db83208ebd1fcf3dedcb7
1 /* quvi
2 * Copyright (C) 2009,2010,2011 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
17 * 02110-1301 USA
20 /* simple.c -- A very basic example. See src/quvi.c for a more complete
21 * example. */
23 #include <stdio.h>
24 #include <quvi/quvi.h>
26 #include "common.h"
28 /* See src/quvi.c for a more complete example of status callback
29 * function */
30 static int status_callback(long param, void *data)
32 quvi_word status, type;
34 status = quvi_loword(param);
35 type = quvi_hiword(param);
37 printf("status: %d, type: %d\n", status, type);
39 return (0);
42 int main(int argc, char **argv)
44 quvi_media_t m; /* Media handle */
45 QUVIcode rc; /* quvi return code */
46 char *url; /* Holds parsed media stream URL */
47 quvi_t q; /* Session handle */
49 /* Start a new session. */
50 rc = quvi_init(&q);
51 check_error(q, rc);
53 /* Set session options. */
54 quvi_setopt(q, QUVIOPT_STATUSFUNCTION, &status_callback);
55 quvi_setopt(q, QUVIOPT_NOVERIFY, 1L); /* Do not verify media stream URL */
57 /* Parse media details from the specified URL. */
58 rc = quvi_parse(q, "http://vimeo.com/1485507", &m);
59 check_error(q, rc);
61 /* Access the parsed media details. */
62 quvi_getprop(m, QUVIPROP_MEDIAURL, &url);
63 puts(url);
65 /* When done with the parsed details, free them. */
66 quvi_parse_close(&m);
68 /* When done, close the session. */
69 quvi_close(&q);
71 return (0);
74 /* vim: set ts=2 sw=2 tw=72 expandtab: */