Pass lua_State arg to l_quvi_object_opts_croak_if_error
[libquvi.git] / src / api / media_stream_choose_best.c
blobcaece3c837de88ca62bc58a2fec68f01c8cafbfb
1 /* libquvi
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This file is part of libquvi <http://quvi.sourceforge.net/>.
6 * This library is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public
8 * License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General
17 * Public License along with this library. If not, see
18 * <http://www.gnu.org/licenses/>.
21 /** @file media_stream_choose_best.c */
23 #include "config.h"
25 #include <glib.h>
27 #include "quvi.h"
28 /* -- */
29 #include "_quvi_s.h"
30 #include "_quvi_media_s.h"
32 /** @brief Selects the @ref m_stream that was determined to be of the "best quality"
33 @note
34 - Only useful when there are >1 media streams available, otherwise the
35 function falls back to the first available @ref m_stream (the
36 default)
37 - The @ref m_script determines the best quality @ref m_stream
38 @sa @ref parse_media
39 @ingroup mediaprop
41 void quvi_media_stream_choose_best(quvi_media_t handle)
43 _quvi_media_stream_t qms;
44 _quvi_media_t qm;
46 qm = (_quvi_media_t) handle;
48 /* If G_DISABLE_CHECKS is defined then the check is not performed. */
49 g_return_if_fail(handle != NULL);
51 quvi_media_stream_reset(qm);
53 while (quvi_media_stream_next(qm) == QUVI_TRUE)
55 qms = (_quvi_media_stream_t) qm->curr.stream->data;
56 g_assert(qms != NULL);
58 if (qms->flags.best == TRUE)
59 break;
63 * If nothing was flagged as such, let it fall through.
64 * Use whatever is the first.
68 /* vim: set ts=2 sw=2 tw=72 expandtab: */