gstreamer_core/gst/gstquery.h
changeset 0 0e761a78d257
child 7 567bb019e3e3
equal deleted inserted replaced
-1:000000000000 0:0e761a78d257
       
     1 /* GStreamer
       
     2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
       
     3  *                    2000 Wim Taymans <wim.taymans@chello.be>
       
     4  *                    2005 Wim Taymans <wim@fluendo.com>
       
     5  *
       
     6  * gstquery.h: GstQuery API declaration
       
     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 
       
    28 #include <glib.h>
       
    29 
       
    30 #include <gst/gstiterator.h>
       
    31 #include <gst/gstminiobject.h>
       
    32 #include <gst/gststructure.h>
       
    33 #include <gst/gstformat.h>
       
    34 
       
    35 G_BEGIN_DECLS
       
    36 
       
    37 /**
       
    38  * GstQueryType:
       
    39  * @GST_QUERY_NONE: invalid query type
       
    40  * @GST_QUERY_POSITION: current position in stream
       
    41  * @GST_QUERY_DURATION: total duration of the stream
       
    42  * @GST_QUERY_LATENCY: latency of stream
       
    43  * @GST_QUERY_JITTER: current jitter of stream
       
    44  * @GST_QUERY_RATE: current rate of the stream
       
    45  * @GST_QUERY_SEEKING: seeking capabilities
       
    46  * @GST_QUERY_SEGMENT: segment start/stop positions
       
    47  * @GST_QUERY_CONVERT: convert values between formats
       
    48  * @GST_QUERY_FORMATS: query supported formats for convert
       
    49  *
       
    50  * Standard predefined Query types
       
    51  */
       
    52 /* NOTE: don't forget to update the table in gstquery.c when changing
       
    53  * this enum */
       
    54 typedef enum {
       
    55   GST_QUERY_NONE = 0,
       
    56   GST_QUERY_POSITION,
       
    57   GST_QUERY_DURATION,
       
    58   GST_QUERY_LATENCY,
       
    59   GST_QUERY_JITTER, 	/* not in draft-query, necessary? */
       
    60   GST_QUERY_RATE,
       
    61   GST_QUERY_SEEKING,
       
    62   GST_QUERY_SEGMENT,
       
    63   GST_QUERY_CONVERT,
       
    64   GST_QUERY_FORMATS
       
    65 } GstQueryType;
       
    66 
       
    67 typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition;
       
    68 typedef struct _GstQuery GstQuery;
       
    69 typedef struct _GstQueryClass GstQueryClass;
       
    70 
       
    71 /**
       
    72  * GstQueryTypeDefinition:
       
    73  * @value: the unique id of the Query type
       
    74  * @nick: a short nick
       
    75  * @description: a longer description of the query type
       
    76  * @quark: the quark for the nick
       
    77  *
       
    78  * A Query Type definition
       
    79  */
       
    80 struct _GstQueryTypeDefinition
       
    81 {
       
    82   GstQueryType   value;
       
    83   gchar  	*nick;
       
    84   gchar  	*description;
       
    85   GQuark         quark;
       
    86 };
       
    87 
       
    88 #define GST_TYPE_QUERY				(gst_query_get_type())
       
    89 #define GST_IS_QUERY(obj)                      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_QUERY))
       
    90 #define GST_IS_QUERY_CLASS(klass)              (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_QUERY))
       
    91 #define GST_QUERY_GET_CLASS(obj)               (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_QUERY, GstQueryClass))
       
    92 #define GST_QUERY(obj)                         (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_QUERY, GstQuery))
       
    93 #define GST_QUERY_CLASS(klass)                 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_QUERY, GstQueryClass))
       
    94 
       
    95 /**
       
    96  * GST_QUERY_TYPE:
       
    97  * @query: the query to query
       
    98  *
       
    99  * Get the #GstQueryType of the query.
       
   100  */
       
   101 #define GST_QUERY_TYPE(query)  (((GstQuery*)(query))->type)
       
   102 
       
   103 /**
       
   104  * GST_QUERY_TYPE_NAME:
       
   105  * @query: the query to query
       
   106  *
       
   107  * Get a constant string representation of the #GstQueryType of the query.
       
   108  *
       
   109  * Since: 0.10.4
       
   110  */
       
   111 #define GST_QUERY_TYPE_NAME(query) (gst_query_type_get_name(GST_QUERY_TYPE(query)))
       
   112 
       
   113 
       
   114 /**
       
   115  * GstQuery:
       
   116  * @mini_object: The parent #GstMiniObject type
       
   117  * @type: the #GstQueryType
       
   118  * @structure: the #GstStructure containing the query details.
       
   119  *
       
   120  * The #GstQuery structure.
       
   121  */
       
   122 struct _GstQuery
       
   123 {
       
   124   GstMiniObject mini_object;
       
   125 
       
   126   /*< public > *//* with COW */
       
   127   GstQueryType type;
       
   128 
       
   129   GstStructure *structure;
       
   130 
       
   131   /*< private > */
       
   132   gpointer _gst_reserved;
       
   133 };
       
   134 
       
   135 struct _GstQueryClass {
       
   136   GstMiniObjectClass mini_object_class;
       
   137 
       
   138   /*< private > */
       
   139   gpointer _gst_reserved[GST_PADDING];
       
   140 };
       
   141 #ifdef __SYMBIAN32__
       
   142 IMPORT_C
       
   143 #endif
       
   144 
       
   145 
       
   146 const gchar*    gst_query_type_get_name        (GstQueryType query);
       
   147 #ifdef __SYMBIAN32__
       
   148 IMPORT_C
       
   149 #endif
       
   150 
       
   151 GQuark          gst_query_type_to_quark        (GstQueryType query);
       
   152 #ifdef __SYMBIAN32__
       
   153 IMPORT_C
       
   154 #endif
       
   155 
       
   156 
       
   157 GType		gst_query_get_type             (void);
       
   158 
       
   159 /* register a new query */
       
   160 #ifdef __SYMBIAN32__
       
   161 IMPORT_C
       
   162 #endif
       
   163 
       
   164 GstQueryType    gst_query_type_register        (const gchar *nick,
       
   165                                                 const gchar *description);
       
   166 #ifdef __SYMBIAN32__
       
   167 IMPORT_C
       
   168 #endif
       
   169 
       
   170 GstQueryType    gst_query_type_get_by_nick     (const gchar *nick);
       
   171 
       
   172 /* check if a query is in an array of querys */
       
   173 #ifdef __SYMBIAN32__
       
   174 IMPORT_C
       
   175 #endif
       
   176 
       
   177 gboolean        gst_query_types_contains       (const GstQueryType *types,
       
   178                                                 GstQueryType type);
       
   179 
       
   180 /* query for query details */
       
   181 #ifdef __SYMBIAN32__
       
   182 IMPORT_C
       
   183 #endif
       
   184 
       
   185 
       
   186 G_CONST_RETURN GstQueryTypeDefinition*
       
   187                 gst_query_type_get_details         (GstQueryType type);
       
   188 #ifdef __SYMBIAN32__
       
   189 IMPORT_C
       
   190 #endif
       
   191 
       
   192 GstIterator*    gst_query_type_iterate_definitions (void);
       
   193 
       
   194 /* refcounting */
       
   195 /**
       
   196  * gst_query_ref:
       
   197  * @q: a #GstQuery to increase the refcount of.
       
   198  *
       
   199  * Increases the refcount of the given query by one.
       
   200  */
       
   201 #define         gst_query_ref(q)		GST_QUERY (gst_mini_object_ref (GST_MINI_OBJECT (q)))
       
   202 /**
       
   203  * gst_query_unref:
       
   204  * @q: a #GstQuery to decrease the refcount of.
       
   205  *
       
   206  * Decreases the refcount of the query. If the refcount reaches 0, the query
       
   207  * will be freed.
       
   208  */
       
   209 #define         gst_query_unref(q)		gst_mini_object_unref (GST_MINI_OBJECT (q))
       
   210 
       
   211 /* copy query */
       
   212 /**
       
   213  * gst_query_copy:
       
   214  * @q: a #GstQuery to copy.
       
   215  *
       
   216  * Copies the given query using the copy function of the parent #GstData
       
   217  * structure.
       
   218  */
       
   219 #define         gst_query_copy(q)		GST_QUERY (gst_mini_object_copy (GST_MINI_OBJECT (q)))
       
   220 /**
       
   221  * gst_query_make_writable:
       
   222  * @q: a #GstQuery to make writable
       
   223  *
       
   224  * Makes a writable query from the given query.
       
   225  */
       
   226 #define         gst_query_make_writable(q)	GST_QUERY (gst_mini_object_make_writable (GST_MINI_OBJECT (q)))
       
   227 
       
   228 /* position query */
       
   229 #ifdef __SYMBIAN32__
       
   230 IMPORT_C
       
   231 #endif
       
   232 
       
   233 GstQuery*	gst_query_new_position		(GstFormat format);
       
   234 #ifdef __SYMBIAN32__
       
   235 IMPORT_C
       
   236 #endif
       
   237 
       
   238 void		gst_query_set_position		(GstQuery *query, GstFormat format, gint64 cur);
       
   239 #ifdef __SYMBIAN32__
       
   240 IMPORT_C
       
   241 #endif
       
   242 
       
   243 void		gst_query_parse_position	(GstQuery *query, GstFormat *format, gint64 *cur);
       
   244 
       
   245 /* duration query */
       
   246 #ifdef __SYMBIAN32__
       
   247 IMPORT_C
       
   248 #endif
       
   249 
       
   250 GstQuery*	gst_query_new_duration		(GstFormat format);
       
   251 #ifdef __SYMBIAN32__
       
   252 IMPORT_C
       
   253 #endif
       
   254 
       
   255 void		gst_query_set_duration		(GstQuery *query, GstFormat format, gint64 duration);
       
   256 #ifdef __SYMBIAN32__
       
   257 IMPORT_C
       
   258 #endif
       
   259 
       
   260 void		gst_query_parse_duration	(GstQuery *query, GstFormat *format, gint64 *duration);
       
   261 
       
   262 /* latency query */
       
   263 #ifdef __SYMBIAN32__
       
   264 IMPORT_C
       
   265 #endif
       
   266 
       
   267 GstQuery*	gst_query_new_latency		(void);
       
   268 #ifdef __SYMBIAN32__
       
   269 IMPORT_C
       
   270 #endif
       
   271 
       
   272 void		gst_query_set_latency		(GstQuery *query, gboolean live, GstClockTime min_latency,
       
   273 		                                 GstClockTime max_latency);
       
   274 #ifdef __SYMBIAN32__
       
   275 IMPORT_C
       
   276 #endif
       
   277 
       
   278 void		gst_query_parse_latency		(GstQuery *query, gboolean *live, GstClockTime *min_latency, 
       
   279 		                                 GstClockTime *max_latency);
       
   280 
       
   281 /* convert query */
       
   282 #ifdef __SYMBIAN32__
       
   283 IMPORT_C
       
   284 #endif
       
   285 
       
   286 GstQuery*	gst_query_new_convert		(GstFormat src_format, gint64 value, GstFormat dest_format);
       
   287 #ifdef __SYMBIAN32__
       
   288 IMPORT_C
       
   289 #endif
       
   290 
       
   291 void		gst_query_set_convert		(GstQuery *query, GstFormat src_format, gint64 src_value,
       
   292 						 GstFormat dest_format, gint64 dest_value);
       
   293 #ifdef __SYMBIAN32__
       
   294 IMPORT_C
       
   295 #endif
       
   296 
       
   297 void		gst_query_parse_convert		(GstQuery *query, GstFormat *src_format, gint64 *src_value,
       
   298 						 GstFormat *dest_format, gint64 *dest_value);
       
   299 /* segment query */
       
   300 #ifdef __SYMBIAN32__
       
   301 IMPORT_C
       
   302 #endif
       
   303 
       
   304 GstQuery*       gst_query_new_segment           (GstFormat format);
       
   305 #ifdef __SYMBIAN32__
       
   306 IMPORT_C
       
   307 #endif
       
   308 
       
   309 void            gst_query_set_segment           (GstQuery *query, gdouble rate, GstFormat format,
       
   310                                                  gint64 start_value, gint64 stop_value);
       
   311 #ifdef __SYMBIAN32__
       
   312 IMPORT_C
       
   313 #endif
       
   314 
       
   315 void            gst_query_parse_segment         (GstQuery *query, gdouble *rate, GstFormat *format,
       
   316                                                  gint64 *start_value, gint64 *stop_value);
       
   317 
       
   318 /* application specific query */
       
   319 #ifdef __SYMBIAN32__
       
   320 IMPORT_C
       
   321 #endif
       
   322 
       
   323 GstQuery *	gst_query_new_application 	(GstQueryType type,
       
   324                                                  GstStructure *structure);
       
   325 #ifdef __SYMBIAN32__
       
   326 IMPORT_C
       
   327 #endif
       
   328 
       
   329 GstStructure *  gst_query_get_structure		(GstQuery *query);
       
   330 
       
   331 /* seeking query */
       
   332 #ifdef __SYMBIAN32__
       
   333 IMPORT_C
       
   334 #endif
       
   335 
       
   336 GstQuery*       gst_query_new_seeking           (GstFormat format);
       
   337 #ifdef __SYMBIAN32__
       
   338 IMPORT_C
       
   339 #endif
       
   340 
       
   341 void            gst_query_set_seeking           (GstQuery *query, GstFormat format,
       
   342                                                  gboolean seekable,
       
   343                                                  gint64 segment_start,
       
   344                                                  gint64 segment_end);
       
   345 #ifdef __SYMBIAN32__
       
   346 IMPORT_C
       
   347 #endif
       
   348 
       
   349 void            gst_query_parse_seeking         (GstQuery *query, GstFormat *format,
       
   350                                                  gboolean *seekable,
       
   351                                                  gint64 *segment_start,
       
   352                                                  gint64 *segment_end);
       
   353 /* formats query */
       
   354 #ifdef __SYMBIAN32__
       
   355 IMPORT_C
       
   356 #endif
       
   357 
       
   358 GstQuery*       gst_query_new_formats           (void);
       
   359 #ifdef __SYMBIAN32__
       
   360 IMPORT_C
       
   361 #endif
       
   362 
       
   363 void            gst_query_set_formats           (GstQuery *query, gint n_formats, ...);
       
   364 #ifdef __SYMBIAN32__
       
   365 IMPORT_C
       
   366 #endif
       
   367 
       
   368 void            gst_query_set_formatsv          (GstQuery *query, gint n_formats, GstFormat *formats);
       
   369 #ifdef __SYMBIAN32__
       
   370 IMPORT_C
       
   371 #endif
       
   372 
       
   373 void            gst_query_parse_formats_length  (GstQuery *query, guint *n_formats);
       
   374 #ifdef __SYMBIAN32__
       
   375 IMPORT_C
       
   376 #endif
       
   377 
       
   378 void            gst_query_parse_formats_nth     (GstQuery *query, guint nth, GstFormat *format);
       
   379 
       
   380 G_END_DECLS
       
   381 
       
   382 #endif /* __GST_QUERY_H__ */
       
   383