Wim Taymans | 347505b | 2002-12-30 17:42:11 +0000 | [diff] [blame] | 1 | /* GStreamer |
| 2 | * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> |
| 3 | * 2000 Wim Taymans <wim.taymans@chello.be> |
Wim Taymans | c47dc4d | 2005-03-07 18:27:42 +0000 | [diff] [blame] | 4 | * 2005 Wim Taymans <wim@fluendo.com> |
Wim Taymans | 347505b | 2002-12-30 17:42:11 +0000 | [diff] [blame] | 5 | * |
Andy Wingo | 73f2d45 | 2003-07-16 15:49:40 +0000 | [diff] [blame] | 6 | * gstquery.h: GstQuery API declaration |
Wim Taymans | 347505b | 2002-12-30 17:42:11 +0000 | [diff] [blame] | 7 | * |
| 8 | * This library is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU Library General Public |
| 10 | * License as published by the Free Software Foundation; either |
| 11 | * version 2 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This library is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * Library General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Library General Public |
| 19 | * License along with this library; if not, write to the |
| 20 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 21 | * Boston, MA 02111-1307, USA. |
| 22 | */ |
| 23 | |
| 24 | |
| 25 | #ifndef __GST_QUERY_H__ |
| 26 | #define __GST_QUERY_H__ |
| 27 | |
Wim Taymans | eb6c33f | 2003-01-01 03:09:39 +0000 | [diff] [blame] | 28 | #include <glib.h> |
Wim Taymans | 347505b | 2002-12-30 17:42:11 +0000 | [diff] [blame] | 29 | |
Wim Taymans | c47dc4d | 2005-03-07 18:27:42 +0000 | [diff] [blame] | 30 | #include <gst/gstiterator.h> |
David Schleef | e134f7f | 2005-05-16 20:21:55 +0000 | [diff] [blame] | 31 | #include <gst/gstminiobject.h> |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 32 | #include <gst/gststructure.h> |
Wim Taymans | 8df6cd7 | 2005-05-09 10:53:13 +0000 | [diff] [blame] | 33 | #include <gst/gstformat.h> |
Wim Taymans | c47dc4d | 2005-03-07 18:27:42 +0000 | [diff] [blame] | 34 | |
Johan Dahlin | ecd88e3 | 2004-03-15 14:43:35 +0000 | [diff] [blame] | 35 | G_BEGIN_DECLS |
| 36 | |
Stefan Kost | ba327dc | 2005-08-29 21:41:02 +0000 | [diff] [blame] | 37 | /** |
| 38 | * GstQueryType: |
| 39 | * @GST_QUERY_NONE: invalid query type |
Wim Taymans | 7612a38 | 2005-10-19 15:50:10 +0000 | [diff] [blame] | 40 | * @GST_QUERY_POSITION: current position in stream |
| 41 | * @GST_QUERY_DURATION: total duration of the stream |
Stefan Kost | ba327dc | 2005-08-29 21:41:02 +0000 | [diff] [blame] | 42 | * @GST_QUERY_LATENCY: latency of stream |
| 43 | * @GST_QUERY_JITTER: current jitter of stream |
| 44 | * @GST_QUERY_RATE: current rate of the stream |
Wim Taymans | 4793bc2 | 2005-09-22 16:51:27 +0000 | [diff] [blame] | 45 | * @GST_QUERY_SEEKING: seeking capabilities |
| 46 | * @GST_QUERY_SEGMENT: segment start/stop positions |
Michael Smith | 9693691 | 2005-11-10 10:17:01 +0000 | [diff] [blame] | 47 | * @GST_QUERY_CONVERT: convert values between formats |
Stefan Kost | ba327dc | 2005-08-29 21:41:02 +0000 | [diff] [blame] | 48 | * @GST_QUERY_FORMATS: query supported formats for convert |
| 49 | * |
| 50 | * Standard predefined Query types |
| 51 | */ |
Wim Taymans | 8d46970 | 2005-11-19 18:57:00 +0000 | [diff] [blame] | 52 | /* NOTE: don't forget to update the table in gstquery.c when changing |
| 53 | * this enum */ |
Johan Dahlin | ecd88e3 | 2004-03-15 14:43:35 +0000 | [diff] [blame] | 54 | typedef enum { |
Wim Taymans | 347505b | 2002-12-30 17:42:11 +0000 | [diff] [blame] | 55 | GST_QUERY_NONE = 0, |
Stefan Kost | ba327dc | 2005-08-29 21:41:02 +0000 | [diff] [blame] | 56 | GST_QUERY_POSITION, |
Wim Taymans | 7612a38 | 2005-10-19 15:50:10 +0000 | [diff] [blame] | 57 | GST_QUERY_DURATION, |
Stefan Kost | ba327dc | 2005-08-29 21:41:02 +0000 | [diff] [blame] | 58 | GST_QUERY_LATENCY, |
Wim Taymans | b9880f8 | 2005-07-07 08:43:17 +0000 | [diff] [blame] | 59 | GST_QUERY_JITTER, /* not in draft-query, necessary? */ |
Stefan Kost | ba327dc | 2005-08-29 21:41:02 +0000 | [diff] [blame] | 60 | GST_QUERY_RATE, |
| 61 | GST_QUERY_SEEKING, |
Wim Taymans | 4793bc2 | 2005-09-22 16:51:27 +0000 | [diff] [blame] | 62 | GST_QUERY_SEGMENT, |
Stefan Kost | ba327dc | 2005-08-29 21:41:02 +0000 | [diff] [blame] | 63 | GST_QUERY_CONVERT, |
| 64 | GST_QUERY_FORMATS |
Johan Dahlin | ecd88e3 | 2004-03-15 14:43:35 +0000 | [diff] [blame] | 65 | } GstQueryType; |
Wim Taymans | 347505b | 2002-12-30 17:42:11 +0000 | [diff] [blame] | 66 | |
Stefan Kost | ba327dc | 2005-08-29 21:41:02 +0000 | [diff] [blame] | 67 | /** |
| 68 | * GST_QUERY_TYPE_RATE_DEN: |
| 69 | * |
| 70 | * Rates are relative to this value |
| 71 | */ |
Wim Taymans | 136e5d2 | 2003-02-10 20:16:38 +0000 | [diff] [blame] | 72 | #define GST_QUERY_TYPE_RATE_DEN G_GINT64_CONSTANT (1000000) |
Wim Taymans | eb6c33f | 2003-01-01 03:09:39 +0000 | [diff] [blame] | 73 | |
| 74 | typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition; |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 75 | typedef struct _GstQuery GstQuery; |
David Schleef | e134f7f | 2005-05-16 20:21:55 +0000 | [diff] [blame] | 76 | typedef struct _GstQueryClass GstQueryClass; |
Wim Taymans | eb6c33f | 2003-01-01 03:09:39 +0000 | [diff] [blame] | 77 | |
Stefan Kost | ba327dc | 2005-08-29 21:41:02 +0000 | [diff] [blame] | 78 | /** |
| 79 | * GstQueryTypeDefinition: |
| 80 | * @value: the unique id of the Query type |
| 81 | * @nick: a short nick |
| 82 | * @description: a longer description of the query type |
Wim Taymans | 10a32af | 2005-11-20 14:50:43 +0000 | [diff] [blame] | 83 | * @quark: the quark for the nick |
Stefan Kost | ba327dc | 2005-08-29 21:41:02 +0000 | [diff] [blame] | 84 | * |
| 85 | * A Query Type definition |
| 86 | */ |
Wim Taymans | eb6c33f | 2003-01-01 03:09:39 +0000 | [diff] [blame] | 87 | struct _GstQueryTypeDefinition |
| 88 | { |
Johan Dahlin | ecd88e3 | 2004-03-15 14:43:35 +0000 | [diff] [blame] | 89 | GstQueryType value; |
| 90 | gchar *nick; |
| 91 | gchar *description; |
Wim Taymans | 8d46970 | 2005-11-19 18:57:00 +0000 | [diff] [blame] | 92 | GQuark quark; |
Wim Taymans | eb6c33f | 2003-01-01 03:09:39 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
David Schleef | e134f7f | 2005-05-16 20:21:55 +0000 | [diff] [blame] | 95 | #define GST_TYPE_QUERY (gst_query_get_type()) |
| 96 | #define GST_IS_QUERY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QUERY)) |
| 97 | #define GST_IS_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QUERY)) |
| 98 | #define GST_QUERY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_QUERY, GstQueryClass)) |
| 99 | #define GST_QUERY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_QUERY, GstQuery)) |
| 100 | #define GST_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_QUERY, GstQueryClass)) |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 101 | |
David Schleef | e134f7f | 2005-05-16 20:21:55 +0000 | [diff] [blame] | 102 | #define GST_QUERY_TYPE(query) (((GstQuery*)(query))->type) |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 103 | |
Wim Taymans | a9f7f7b | 2005-11-24 09:44:07 +0000 | [diff] [blame] | 104 | /** |
| 105 | * GstQuery: |
| 106 | * @mini_object: The parent #GstMiniObject type |
| 107 | * @type: the #GstQueryType |
| 108 | * @structure: the #GstStructure containing the query details. |
| 109 | * |
| 110 | * The #GstQuery structure. |
| 111 | */ |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 112 | struct _GstQuery |
| 113 | { |
David Schleef | e134f7f | 2005-05-16 20:21:55 +0000 | [diff] [blame] | 114 | GstMiniObject mini_object; |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 115 | |
Wim Taymans | a9f7f7b | 2005-11-24 09:44:07 +0000 | [diff] [blame] | 116 | /*< public > *//* with COW */ |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 117 | GstQueryType type; |
| 118 | |
| 119 | GstStructure *structure; |
Thomas Vander Stichele | 2dd1598 | 2005-10-15 15:30:24 +0000 | [diff] [blame] | 120 | |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 121 | /*< private > */ |
Andy Wingo | 65ce5ed | 2005-11-29 18:57:59 +0000 | [diff] [blame] | 122 | gpointer _gst_reserved; |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 123 | }; |
| 124 | |
David Schleef | e134f7f | 2005-05-16 20:21:55 +0000 | [diff] [blame] | 125 | struct _GstQueryClass { |
| 126 | GstMiniObjectClass mini_object_class; |
Thomas Vander Stichele | 2dd1598 | 2005-10-15 15:30:24 +0000 | [diff] [blame] | 127 | |
Wim Taymans | e1aeec6 | 2005-07-18 12:49:53 +0000 | [diff] [blame] | 128 | /*< private > */ |
| 129 | gpointer _gst_reserved[GST_PADDING]; |
David Schleef | e134f7f | 2005-05-16 20:21:55 +0000 | [diff] [blame] | 130 | }; |
| 131 | |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 132 | void _gst_query_initialize (void); |
Wim Taymans | 8d46970 | 2005-11-19 18:57:00 +0000 | [diff] [blame] | 133 | |
| 134 | const gchar* gst_query_type_get_name (GstQueryType query); |
| 135 | GQuark gst_query_type_to_quark (GstQueryType query); |
| 136 | |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 137 | GType gst_query_get_type (void); |
Wim Taymans | eb6c33f | 2003-01-01 03:09:39 +0000 | [diff] [blame] | 138 | |
| 139 | /* register a new query */ |
Thomas Vander Stichele | 2dd1598 | 2005-10-15 15:30:24 +0000 | [diff] [blame] | 140 | GstQueryType gst_query_type_register (const gchar *nick, |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 141 | const gchar *description); |
| 142 | GstQueryType gst_query_type_get_by_nick (const gchar *nick); |
Wim Taymans | eb6c33f | 2003-01-01 03:09:39 +0000 | [diff] [blame] | 143 | |
| 144 | /* check if a query is in an array of querys */ |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 145 | gboolean gst_query_types_contains (const GstQueryType *types, |
| 146 | GstQueryType type); |
Wim Taymans | eb6c33f | 2003-01-01 03:09:39 +0000 | [diff] [blame] | 147 | |
| 148 | /* query for query details */ |
Stefan Kost | ba327dc | 2005-08-29 21:41:02 +0000 | [diff] [blame] | 149 | |
Thomas Vander Stichele | 2dd1598 | 2005-10-15 15:30:24 +0000 | [diff] [blame] | 150 | G_CONST_RETURN GstQueryTypeDefinition* |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 151 | gst_query_type_get_details (GstQueryType type); |
| 152 | GstIterator* gst_query_type_iterate_definitions (void); |
| 153 | |
| 154 | /* refcounting */ |
Wim Taymans | c3fecfa | 2005-10-20 21:08:47 +0000 | [diff] [blame] | 155 | /** |
| 156 | * gst_query_ref: |
| 157 | * @q: a #GstQuery to increase the refcount of. |
| 158 | * |
| 159 | * Increases the refcount of the given query by one. |
| 160 | */ |
| 161 | #define gst_query_ref(q) GST_QUERY (gst_mini_object_ref (GST_MINI_OBJECT (q))) |
| 162 | /** |
| 163 | * gst_query_unref: |
| 164 | * @q: a #GstQuery to decrease the refcount of. |
| 165 | * |
| 166 | * Decreases the refcount of the query. If the refcount reaches 0, the query |
| 167 | * will be freed. |
| 168 | */ |
| 169 | #define gst_query_unref(q) gst_mini_object_unref (GST_MINI_OBJECT (q)) |
| 170 | |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 171 | /* copy query */ |
Wim Taymans | c3fecfa | 2005-10-20 21:08:47 +0000 | [diff] [blame] | 172 | /** |
| 173 | * gst_query_copy: |
| 174 | * @q: a #GstQuery to copy. |
| 175 | * |
| 176 | * Copies the given query using the copy function of the parent #GstData |
| 177 | * structure. |
| 178 | */ |
| 179 | #define gst_query_copy(q) GST_QUERY (gst_mini_object_copy (GST_MINI_OBJECT (q))) |
| 180 | /** |
| 181 | * gst_query_make_writable: |
| 182 | * @q: a #GstQuery to make writable |
| 183 | * |
| 184 | * Makes a writable query from the given query. |
| 185 | */ |
| 186 | #define gst_query_make_writable(q) GST_QUERY (gst_mini_object_make_writable (GST_MINI_OBJECT (q))) |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 187 | |
Wim Taymans | 8df6cd7 | 2005-05-09 10:53:13 +0000 | [diff] [blame] | 188 | /* position query */ |
| 189 | GstQuery* gst_query_new_position (GstFormat format); |
Wim Taymans | 7612a38 | 2005-10-19 15:50:10 +0000 | [diff] [blame] | 190 | void gst_query_set_position (GstQuery *query, GstFormat format, gint64 cur); |
| 191 | void gst_query_parse_position (GstQuery *query, GstFormat *format, gint64 *cur); |
| 192 | |
| 193 | /* duration query */ |
| 194 | GstQuery* gst_query_new_duration (GstFormat format); |
| 195 | void gst_query_set_duration (GstQuery *query, GstFormat format, gint64 duration); |
| 196 | void gst_query_parse_duration (GstQuery *query, GstFormat *format, gint64 *duration); |
| 197 | |
Wim Taymans | 8df6cd7 | 2005-05-09 10:53:13 +0000 | [diff] [blame] | 198 | /* convert query */ |
Wim Taymans | 8c96da0 | 2005-10-20 19:47:07 +0000 | [diff] [blame] | 199 | GstQuery* gst_query_new_convert (GstFormat src_format, gint64 value, GstFormat dest_format); |
Wim Taymans | 8df6cd7 | 2005-05-09 10:53:13 +0000 | [diff] [blame] | 200 | void gst_query_set_convert (GstQuery *query, GstFormat src_format, gint64 src_value, |
| 201 | GstFormat dest_format, gint64 dest_value); |
| 202 | void gst_query_parse_convert (GstQuery *query, GstFormat *src_format, gint64 *src_value, |
| 203 | GstFormat *dest_format, gint64 *dest_value); |
Wim Taymans | 1901cd0 | 2005-09-22 17:40:42 +0000 | [diff] [blame] | 204 | /* segment query */ |
| 205 | GstQuery* gst_query_new_segment (GstFormat format); |
| 206 | void gst_query_set_segment (GstQuery *query, gdouble rate, GstFormat format, |
Wim Taymans | 7612a38 | 2005-10-19 15:50:10 +0000 | [diff] [blame] | 207 | gint64 start_value, gint64 stop_value); |
Wim Taymans | 1901cd0 | 2005-09-22 17:40:42 +0000 | [diff] [blame] | 208 | void gst_query_parse_segment (GstQuery *query, gdouble *rate, GstFormat *format, |
Wim Taymans | 7612a38 | 2005-10-19 15:50:10 +0000 | [diff] [blame] | 209 | gint64 *start_value, gint64 *stop_value); |
Wim Taymans | 1901cd0 | 2005-09-22 17:40:42 +0000 | [diff] [blame] | 210 | |
Wim Taymans | 8df6cd7 | 2005-05-09 10:53:13 +0000 | [diff] [blame] | 211 | |
| 212 | /* application specific query */ |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 213 | GstQuery * gst_query_new_application (GstQueryType type, |
| 214 | GstStructure *structure); |
| 215 | |
Wim Taymans | 8df6cd7 | 2005-05-09 10:53:13 +0000 | [diff] [blame] | 216 | |
Andy Wingo | 8970bda | 2005-05-06 21:41:22 +0000 | [diff] [blame] | 217 | GstStructure * gst_query_get_structure (GstQuery *query); |
| 218 | |
Thomas Vander Stichele | b98900a | 2005-09-26 15:03:43 +0000 | [diff] [blame] | 219 | /* moved from old gstqueryutils.h */ |
Jan Schmidt | 8427984 | 2005-11-27 22:50:09 +0000 | [diff] [blame] | 220 | GstQuery* gst_query_new_seeking (GstFormat format); |
Wim Taymans | cf925eb | 2005-11-22 18:28:44 +0000 | [diff] [blame] | 221 | void gst_query_set_seeking (GstQuery *query, GstFormat format, |
| 222 | gboolean seekable, |
| 223 | gint64 segment_start, |
| 224 | gint64 segment_end); |
Jan Schmidt | 8427984 | 2005-11-27 22:50:09 +0000 | [diff] [blame] | 225 | void gst_query_parse_seeking (GstQuery *query, GstFormat *format, |
| 226 | gboolean *seekable, |
| 227 | gint64 *segment_start, |
| 228 | gint64 *segment_end); |
| 229 | |
Wim Taymans | cf925eb | 2005-11-22 18:28:44 +0000 | [diff] [blame] | 230 | void gst_query_set_formats (GstQuery *query, gint n_formats, ...); |
Thomas Vander Stichele | b98900a | 2005-09-26 15:03:43 +0000 | [diff] [blame] | 231 | |
Wim Taymans | 347505b | 2002-12-30 17:42:11 +0000 | [diff] [blame] | 232 | G_END_DECLS |
Johan Dahlin | ecd88e3 | 2004-03-15 14:43:35 +0000 | [diff] [blame] | 233 | |
Wim Taymans | 347505b | 2002-12-30 17:42:11 +0000 | [diff] [blame] | 234 | #endif /* __GST_QUERY_H__ */ |
Johan Dahlin | ecd88e3 | 2004-03-15 14:43:35 +0000 | [diff] [blame] | 235 | |