2 * Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
4 * gstqueryutils.c: Utility functions for creating and parsing GstQueries.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 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 GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
25 #include "gstqueryutils.h"
26 #include "gstenumtypes.h"
28 #include "gst_private.h"
30 /* some macros are just waiting to be defined here */
33 gst_query_parse_seeking_query (GstQuery * query, GstFormat * format)
35 GstStructure *structure;
37 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEEKING);
39 structure = gst_query_get_structure (query);
41 *format = g_value_get_enum (gst_structure_get_value (structure, "format"));
45 gst_query_set_seeking (GstQuery * query, GstFormat format,
46 gboolean seekable, gint64 segment_start, gint64 segment_end)
48 GstStructure *structure;
50 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEEKING);
52 structure = gst_query_get_structure (query);
53 gst_structure_set (structure,
54 "format", GST_TYPE_FORMAT, format,
55 "seekable", G_TYPE_BOOLEAN, seekable,
56 "segment-start", G_TYPE_INT64, segment_start,
57 "segment-end", G_TYPE_INT64, segment_end, NULL);
61 gst_query_parse_seeking_response (GstQuery * query, GstFormat * format,
62 gboolean * seekable, gint64 * segment_start, gint64 * segment_end)
64 GstStructure *structure;
66 g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_SEEKING);
68 structure = gst_query_get_structure (query);
70 *format = g_value_get_enum (gst_structure_get_value (structure, "format"));
72 *seekable = g_value_get_boolean (gst_structure_get_value
73 (structure, "seekable"));
75 *segment_start = g_value_get_int64 (gst_structure_get_value
76 (structure, "segment-start"));
78 *segment_end = g_value_get_int64 (gst_structure_get_value
79 (structure, "segment-end"));
83 gst_query_set_formats (GstQuery * query, gint n_formats, ...)
88 GstStructure *structure;
91 g_value_init (&list, GST_TYPE_LIST);
93 va_start (ap, n_formats);
95 for (i = 0; i < n_formats; i++) {
96 g_value_init (&item, GST_TYPE_FORMAT);
97 g_value_set_enum (&item, va_arg (ap, GstFormat));
98 gst_value_list_append_value (&list, &item);
99 g_value_unset (&item);
104 structure = gst_query_get_structure (query);
105 gst_structure_set_value (structure, "formats", &list);