gstreamer_core/gst/gstevent.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
    81 
    81 
    82 #include "gstinfo.h"
    82 #include "gstinfo.h"
    83 #include "gstevent.h"
    83 #include "gstevent.h"
    84 #include "gstenumtypes.h"
    84 #include "gstenumtypes.h"
    85 #include "gstutils.h"
    85 #include "gstutils.h"
    86 #include "gstquark.h"
    86 
    87 
    87 static void gst_event_init (GTypeInstance * instance, gpointer g_class);
    88 #define GST_EVENT_SEQNUM(e) ((GstEvent*)e)->abidata.seqnum
    88 static void gst_event_class_init (gpointer g_class, gpointer class_data);
    89 
       
    90 static void gst_event_finalize (GstEvent * event);
    89 static void gst_event_finalize (GstEvent * event);
    91 static GstEvent *_gst_event_copy (GstEvent * event);
    90 static GstEvent *_gst_event_copy (GstEvent * event);
    92 
    91 
    93 static GstMiniObjectClass *parent_class = NULL;
    92 static GstMiniObjectClass *parent_class = NULL;
    94 #ifdef __SYMBIAN32__
    93 #ifdef __SYMBIAN32__
   199 
   198 
   200   ret = type & ((1 << GST_EVENT_TYPE_SHIFT) - 1);
   199   ret = type & ((1 << GST_EVENT_TYPE_SHIFT) - 1);
   201 
   200 
   202   return ret;
   201   return ret;
   203 }
   202 }
   204 
   203 #ifdef __SYMBIAN32__
   205 #define _do_init \
   204 EXPORT_C
   206 { \
   205 #endif
   207   gint i; \
   206 
   208   \
   207 
   209   for (i = 0; event_quarks[i].name; i++) { \
   208 GType
   210     event_quarks[i].quark = g_quark_from_static_string (event_quarks[i].name); \
   209 gst_event_get_type (void)
   211   } \
   210 {
   212 }
   211   static GType _gst_event_type = 0;
   213 
   212   int i;
   214 G_DEFINE_TYPE_WITH_CODE (GstEvent, gst_event, GST_TYPE_MINI_OBJECT, _do_init);
   213 
       
   214   if (G_UNLIKELY (_gst_event_type == 0)) {
       
   215     static const GTypeInfo event_info = {
       
   216       sizeof (GstEventClass),
       
   217       NULL,
       
   218       NULL,
       
   219       gst_event_class_init,
       
   220       NULL,
       
   221       NULL,
       
   222       sizeof (GstEvent),
       
   223       0,
       
   224       gst_event_init,
       
   225       NULL
       
   226     };
       
   227 
       
   228     _gst_event_type = g_type_register_static (GST_TYPE_MINI_OBJECT,
       
   229         "GstEvent", &event_info, 0);
       
   230 
       
   231     for (i = 0; event_quarks[i].name; i++) {
       
   232       event_quarks[i].quark = g_quark_from_static_string (event_quarks[i].name);
       
   233     }
       
   234   }
       
   235 
       
   236   return _gst_event_type;
       
   237 }
   215 
   238 
   216 static void
   239 static void
   217 gst_event_class_init (GstEventClass * klass)
   240 gst_event_class_init (gpointer g_class, gpointer class_data)
   218 {
   241 {
   219   parent_class = g_type_class_peek_parent (klass);
   242   GstEventClass *event_class = GST_EVENT_CLASS (g_class);
   220 
   243 
   221   klass->mini_object_class.copy = (GstMiniObjectCopyFunction) _gst_event_copy;
   244   parent_class = g_type_class_peek_parent (g_class);
   222   klass->mini_object_class.finalize =
   245 
       
   246   event_class->mini_object_class.copy =
       
   247       (GstMiniObjectCopyFunction) _gst_event_copy;
       
   248   event_class->mini_object_class.finalize =
   223       (GstMiniObjectFinalizeFunction) gst_event_finalize;
   249       (GstMiniObjectFinalizeFunction) gst_event_finalize;
   224 }
   250 }
   225 
   251 
   226 static void
   252 static void
   227 gst_event_init (GstEvent * event)
   253 gst_event_init (GTypeInstance * instance, gpointer g_class)
   228 {
   254 {
       
   255   GstEvent *event;
       
   256 
       
   257   event = GST_EVENT (instance);
       
   258 
   229   GST_EVENT_TIMESTAMP (event) = GST_CLOCK_TIME_NONE;
   259   GST_EVENT_TIMESTAMP (event) = GST_CLOCK_TIME_NONE;
   230 }
   260 }
   231 
   261 
   232 static void
   262 static void
   233 gst_event_finalize (GstEvent * event)
   263 gst_event_finalize (GstEvent * event)
   245   if (event->structure) {
   275   if (event->structure) {
   246     gst_structure_set_parent_refcount (event->structure, NULL);
   276     gst_structure_set_parent_refcount (event->structure, NULL);
   247     gst_structure_free (event->structure);
   277     gst_structure_free (event->structure);
   248   }
   278   }
   249 
   279 
   250 /*   GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (event)); */
   280   GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (event));
   251 }
   281 }
   252 
   282 
   253 static GstEvent *
   283 static GstEvent *
   254 _gst_event_copy (GstEvent * event)
   284 _gst_event_copy (GstEvent * event)
   255 {
   285 {
   257 
   287 
   258   copy = (GstEvent *) gst_mini_object_new (GST_TYPE_EVENT);
   288   copy = (GstEvent *) gst_mini_object_new (GST_TYPE_EVENT);
   259 
   289 
   260   GST_EVENT_TYPE (copy) = GST_EVENT_TYPE (event);
   290   GST_EVENT_TYPE (copy) = GST_EVENT_TYPE (event);
   261   GST_EVENT_TIMESTAMP (copy) = GST_EVENT_TIMESTAMP (event);
   291   GST_EVENT_TIMESTAMP (copy) = GST_EVENT_TIMESTAMP (event);
   262   GST_EVENT_SEQNUM (copy) = GST_EVENT_SEQNUM (event);
       
   263 
   292 
   264   if (GST_EVENT_SRC (event)) {
   293   if (GST_EVENT_SRC (event)) {
   265     GST_EVENT_SRC (copy) = gst_object_ref (GST_EVENT_SRC (event));
   294     GST_EVENT_SRC (copy) = gst_object_ref (GST_EVENT_SRC (event));
   266   }
   295   }
   267   if (event->structure) {
   296   if (event->structure) {
   283       gst_event_type_get_name (type), type);
   312       gst_event_type_get_name (type), type);
   284 
   313 
   285   event->type = type;
   314   event->type = type;
   286   event->src = NULL;
   315   event->src = NULL;
   287   event->structure = NULL;
   316   event->structure = NULL;
   288   GST_EVENT_SEQNUM (event) = gst_util_seqnum_next ();
       
   289 
   317 
   290   return event;
   318   return event;
   291 }
   319 }
   292 
   320 
   293 /**
   321 /**
   350 gst_event_get_structure (GstEvent * event)
   378 gst_event_get_structure (GstEvent * event)
   351 {
   379 {
   352   g_return_val_if_fail (GST_IS_EVENT (event), NULL);
   380   g_return_val_if_fail (GST_IS_EVENT (event), NULL);
   353 
   381 
   354   return event->structure;
   382   return event->structure;
   355 }
       
   356 
       
   357 /**
       
   358  * gst_event_has_name:
       
   359  * @event: The #GstEvent.
       
   360  * @name: name to check
       
   361  *
       
   362  * Checks if @event has the given @name. This function is usually used to
       
   363  * check the name of a custom event.
       
   364  *
       
   365  * Returns: %TRUE if @name matches the name of the event structure.
       
   366  *
       
   367  * Since: 0.10.20
       
   368  */
       
   369 #ifdef __SYMBIAN32__
       
   370 EXPORT_C
       
   371 #endif
       
   372 
       
   373 gboolean
       
   374 gst_event_has_name (GstEvent * event, const gchar * name)
       
   375 {
       
   376   g_return_val_if_fail (GST_IS_EVENT (event), FALSE);
       
   377 
       
   378   if (event->structure == NULL)
       
   379     return FALSE;
       
   380 
       
   381   return gst_structure_has_name (event->structure, name);
       
   382 }
       
   383 
       
   384 /**
       
   385  * gst_event_get_seqnum:
       
   386  * @event: A #GstEvent.
       
   387  *
       
   388  * Retrieve the sequence number of a event.
       
   389  *
       
   390  * Events have ever-incrementing sequence numbers, which may also be set
       
   391  * explicitly via gst_event_set_seqnum(). Sequence numbers are typically used to
       
   392  * indicate that a event corresponds to some other set of events or messages,
       
   393  * for example an EOS event corresponding to a SEEK event. It is considered good
       
   394  * practice to make this correspondence when possible, though it is not
       
   395  * required.
       
   396  *
       
   397  * Note that events and messages share the same sequence number incrementor;
       
   398  * two events or messages will never not have the same sequence number unless
       
   399  * that correspondence was made explicitly.
       
   400  *
       
   401  * Returns: The event's sequence number.
       
   402  *
       
   403  * MT safe.
       
   404  *
       
   405  * Since: 0.10.22
       
   406  */
       
   407 #ifdef __SYMBIAN32__
       
   408 EXPORT_C
       
   409 #endif
       
   410 
       
   411 guint32
       
   412 gst_event_get_seqnum (GstEvent * event)
       
   413 {
       
   414   g_return_val_if_fail (GST_IS_EVENT (event), -1);
       
   415 
       
   416   return GST_EVENT_SEQNUM (event);
       
   417 }
       
   418 
       
   419 /**
       
   420  * gst_event_set_seqnum:
       
   421  * @event: A #GstEvent.
       
   422  * @seqnum: A sequence number.
       
   423  *
       
   424  * Set the sequence number of a event.
       
   425  *
       
   426  * This function might be called by the creator of a event to indicate that the
       
   427  * event relates to other events or messages. See gst_event_get_seqnum() for
       
   428  * more information.
       
   429  *
       
   430  * MT safe.
       
   431  *
       
   432  * Since: 0.10.22
       
   433  */
       
   434 #ifdef __SYMBIAN32__
       
   435 EXPORT_C
       
   436 #endif
       
   437 
       
   438 void
       
   439 gst_event_set_seqnum (GstEvent * event, guint32 seqnum)
       
   440 {
       
   441   g_return_if_fail (GST_IS_EVENT (event));
       
   442 
       
   443   GST_EVENT_SEQNUM (event) = seqnum;
       
   444 }
   383 }
   445 
   384 
   446 /**
   385 /**
   447  * gst_event_new_flush_start:
   386  * gst_event_new_flush_start:
   448  *
   387  *
   600  * Allocate a new newsegment event with the given format/values triplets.
   539  * Allocate a new newsegment event with the given format/values triplets.
   601  *
   540  *
   602  * The newsegment event marks the range of buffers to be processed. All
   541  * The newsegment event marks the range of buffers to be processed. All
   603  * data not within the segment range is not to be processed. This can be
   542  * data not within the segment range is not to be processed. This can be
   604  * used intelligently by plugins to apply more efficient methods of skipping
   543  * used intelligently by plugins to apply more efficient methods of skipping
   605  * unneeded data. The valid range is expressed with the @start and @stop
   544  * unneeded data.
   606  * values.
       
   607  *
   545  *
   608  * The position value of the segment is used in conjunction with the start
   546  * The position value of the segment is used in conjunction with the start
   609  * value to convert the buffer timestamps into the stream time. This is 
   547  * value to convert the buffer timestamps into the stream time. This is 
   610  * usually done in sinks to report the current stream_time. 
   548  * usually done in sinks to report the current stream_time. 
   611  * @position represents the stream_time of a buffer carrying a timestamp of 
   549  * @position represents the stream_time of a buffer carrying a timestamp of 
   632  * Since: 0.10.6
   570  * Since: 0.10.6
   633  */
   571  */
   634 #ifdef __SYMBIAN32__
   572 #ifdef __SYMBIAN32__
   635 EXPORT_C
   573 EXPORT_C
   636 #endif
   574 #endif
   637 
       
   638 GstEvent *
   575 GstEvent *
   639 gst_event_new_new_segment_full (gboolean update, gdouble rate,
   576 gst_event_new_new_segment_full (gboolean update, gdouble rate,
   640     gdouble applied_rate, GstFormat format, gint64 start, gint64 stop,
   577     gdouble applied_rate, GstFormat format, gint64 start, gint64 stop,
   641     gint64 position)
   578     gint64 position)
   642 {
   579 {
   643   GstEvent *event;
       
   644   GstStructure *structure;
       
   645 
       
   646   g_return_val_if_fail (rate != 0.0, NULL);
   580   g_return_val_if_fail (rate != 0.0, NULL);
   647   g_return_val_if_fail (applied_rate != 0.0, NULL);
   581   g_return_val_if_fail (applied_rate != 0.0, NULL);
   648 
   582 
   649   if (format == GST_FORMAT_TIME) {
   583   if (format == GST_FORMAT_TIME) {
   650     GST_CAT_INFO (GST_CAT_EVENT,
   584     GST_CAT_INFO (GST_CAT_EVENT,
   653         ", position %" GST_TIME_FORMAT,
   587         ", position %" GST_TIME_FORMAT,
   654         update, rate, GST_TIME_ARGS (start),
   588         update, rate, GST_TIME_ARGS (start),
   655         GST_TIME_ARGS (stop), GST_TIME_ARGS (position));
   589         GST_TIME_ARGS (stop), GST_TIME_ARGS (position));
   656   } else {
   590   } else {
   657     GST_CAT_INFO (GST_CAT_EVENT,
   591     GST_CAT_INFO (GST_CAT_EVENT,
   658         "creating newsegment update %d, rate %lf, format %s, "
   592         "creating newsegment update %d, rate %lf, format %d, "
   659         "start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT ", position %"
   593         "start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT ", position %"
   660         G_GINT64_FORMAT, update, rate, gst_format_get_name (format), start,
   594         G_GINT64_FORMAT, update, rate, format, start, stop, position);
   661         stop, position);
       
   662   }
   595   }
   663 
   596 
   664   g_return_val_if_fail (position != -1, NULL);
   597   g_return_val_if_fail (position != -1, NULL);
   665   g_return_val_if_fail (start != -1, NULL);
   598   g_return_val_if_fail (start != -1, NULL);
   666   if (stop != -1)
   599   if (stop != -1)
   667     g_return_val_if_fail (start <= stop, NULL);
   600     g_return_val_if_fail (start <= stop, NULL);
   668 
   601 
   669   structure = gst_structure_id_new (GST_QUARK (EVENT_NEWSEGMENT),
   602   return gst_event_new_custom (GST_EVENT_NEWSEGMENT,
   670       GST_QUARK (UPDATE), G_TYPE_BOOLEAN, update,
   603       gst_structure_new ("GstEventNewsegment",
   671       GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
   604           "update", G_TYPE_BOOLEAN, update,
   672       GST_QUARK (APPLIED_RATE), G_TYPE_DOUBLE, applied_rate,
   605           "rate", G_TYPE_DOUBLE, rate,
   673       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
   606           "applied_rate", G_TYPE_DOUBLE, applied_rate,
   674       GST_QUARK (START), G_TYPE_INT64, start,
   607           "format", GST_TYPE_FORMAT, format,
   675       GST_QUARK (STOP), G_TYPE_INT64, stop,
   608           "start", G_TYPE_INT64, start,
   676       GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
   609           "stop", G_TYPE_INT64, stop,
   677   event = gst_event_new_custom (GST_EVENT_NEWSEGMENT, structure);
   610           "position", G_TYPE_INT64, position, NULL));
   678 
       
   679   return event;
       
   680 }
   611 }
   681 
   612 
   682 /**
   613 /**
   683  * gst_event_parse_new_segment_full:
   614  * gst_event_parse_new_segment_full:
   684  * @event: The event to query
   615  * @event: The event to query
   711   g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT);
   642   g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT);
   712 
   643 
   713   structure = gst_event_get_structure (event);
   644   structure = gst_event_get_structure (event);
   714   if (G_LIKELY (update))
   645   if (G_LIKELY (update))
   715     *update =
   646     *update =
   716         g_value_get_boolean (gst_structure_id_get_value (structure,
   647         g_value_get_boolean (gst_structure_get_value (structure, "update"));
   717             GST_QUARK (UPDATE)));
       
   718   if (G_LIKELY (rate))
   648   if (G_LIKELY (rate))
   719     *rate =
   649     *rate = g_value_get_double (gst_structure_get_value (structure, "rate"));
   720         g_value_get_double (gst_structure_id_get_value (structure,
       
   721             GST_QUARK (RATE)));
       
   722   if (G_LIKELY (applied_rate))
   650   if (G_LIKELY (applied_rate))
   723     *applied_rate =
   651     *applied_rate =
   724         g_value_get_double (gst_structure_id_get_value (structure,
   652         g_value_get_double (gst_structure_get_value (structure,
   725             GST_QUARK (APPLIED_RATE)));
   653             "applied_rate"));
   726   if (G_LIKELY (format))
   654   if (G_LIKELY (format))
   727     *format =
   655     *format = g_value_get_enum (gst_structure_get_value (structure, "format"));
   728         g_value_get_enum (gst_structure_id_get_value (structure,
       
   729             GST_QUARK (FORMAT)));
       
   730   if (G_LIKELY (start))
   656   if (G_LIKELY (start))
   731     *start =
   657     *start = g_value_get_int64 (gst_structure_get_value (structure, "start"));
   732         g_value_get_int64 (gst_structure_id_get_value (structure,
       
   733             GST_QUARK (START)));
       
   734   if (G_LIKELY (stop))
   658   if (G_LIKELY (stop))
   735     *stop =
   659     *stop = g_value_get_int64 (gst_structure_get_value (structure, "stop"));
   736         g_value_get_int64 (gst_structure_id_get_value (structure,
       
   737             GST_QUARK (STOP)));
       
   738   if (G_LIKELY (position))
   660   if (G_LIKELY (position))
   739     *position =
   661     *position =
   740         g_value_get_int64 (gst_structure_id_get_value (structure,
   662         g_value_get_int64 (gst_structure_get_value (structure, "position"));
   741             GST_QUARK (POSITION)));
       
   742 }
   663 }
   743 
   664 
   744 /**
   665 /**
   745  * gst_event_new_tag:
   666  * gst_event_new_tag:
   746  * @taglist: metadata list. The event will take ownership of @taglist.
   667  * @taglist: metadata list
   747  *
   668  *
   748  * Generates a metadata tag event from the given @taglist.
   669  * Generates a metadata tag event from the given @taglist.
   749  *
   670  *
   750  * Returns: a new #GstEvent
   671  * Returns: a new #GstEvent
   751  */
   672  */
   803 
   724 
   804 GstEvent *
   725 GstEvent *
   805 gst_event_new_buffer_size (GstFormat format, gint64 minsize,
   726 gst_event_new_buffer_size (GstFormat format, gint64 minsize,
   806     gint64 maxsize, gboolean async)
   727     gint64 maxsize, gboolean async)
   807 {
   728 {
   808   GstEvent *event;
       
   809   GstStructure *structure;
       
   810 
       
   811   GST_CAT_INFO (GST_CAT_EVENT,
   729   GST_CAT_INFO (GST_CAT_EVENT,
   812       "creating buffersize format %s, minsize %" G_GINT64_FORMAT
   730       "creating buffersize format %d, minsize %" G_GINT64_FORMAT
   813       ", maxsize %" G_GINT64_FORMAT ", async %d", gst_format_get_name (format),
   731       ", maxsize %" G_GINT64_FORMAT ", async %d", format,
   814       minsize, maxsize, async);
   732       minsize, maxsize, async);
   815 
   733 
   816   structure = gst_structure_id_new (GST_QUARK (EVENT_BUFFER_SIZE),
   734   return gst_event_new_custom (GST_EVENT_BUFFERSIZE,
   817       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
   735       gst_structure_new ("GstEventBufferSize",
   818       GST_QUARK (MINSIZE), G_TYPE_INT64, minsize,
   736           "format", GST_TYPE_FORMAT, format,
   819       GST_QUARK (MAXSIZE), G_TYPE_INT64, maxsize,
   737           "minsize", G_TYPE_INT64, minsize,
   820       GST_QUARK (ASYNC), G_TYPE_BOOLEAN, async, NULL);
   738           "maxsize", G_TYPE_INT64, maxsize,
   821   event = gst_event_new_custom (GST_EVENT_BUFFERSIZE, structure);
   739           "async", G_TYPE_BOOLEAN, async, NULL));
   822 
       
   823   return event;
       
   824 }
   740 }
   825 
   741 
   826 /**
   742 /**
   827  * gst_event_parse_buffer_size:
   743  * gst_event_parse_buffer_size:
   828  * @event: The event to query
   744  * @event: The event to query
   846   g_return_if_fail (GST_IS_EVENT (event));
   762   g_return_if_fail (GST_IS_EVENT (event));
   847   g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_BUFFERSIZE);
   763   g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_BUFFERSIZE);
   848 
   764 
   849   structure = gst_event_get_structure (event);
   765   structure = gst_event_get_structure (event);
   850   if (format)
   766   if (format)
   851     *format =
   767     *format = g_value_get_enum (gst_structure_get_value (structure, "format"));
   852         g_value_get_enum (gst_structure_id_get_value (structure,
       
   853             GST_QUARK (FORMAT)));
       
   854   if (minsize)
   768   if (minsize)
   855     *minsize =
   769     *minsize =
   856         g_value_get_int64 (gst_structure_id_get_value (structure,
   770         g_value_get_int64 (gst_structure_get_value (structure, "minsize"));
   857             GST_QUARK (MINSIZE)));
       
   858   if (maxsize)
   771   if (maxsize)
   859     *maxsize =
   772     *maxsize =
   860         g_value_get_int64 (gst_structure_id_get_value (structure,
   773         g_value_get_int64 (gst_structure_get_value (structure, "maxsize"));
   861             GST_QUARK (MAXSIZE)));
       
   862   if (async)
   774   if (async)
   863     *async =
   775     *async = g_value_get_boolean (gst_structure_get_value (structure, "async"));
   864         g_value_get_boolean (gst_structure_id_get_value (structure,
       
   865             GST_QUARK (ASYNC)));
       
   866 }
   776 }
   867 
   777 
   868 /**
   778 /**
   869  * gst_event_new_qos:
   779  * gst_event_new_qos:
   870  * @proportion: the proportion of the qos message
   780  * @proportion: the proportion of the qos message
   897  * increasing value.
   807  * increasing value.
   898  *
   808  *
   899  * The upstream element can use the @diff and @timestamp values to decide
   809  * The upstream element can use the @diff and @timestamp values to decide
   900  * whether to process more buffers. For possitive @diff, all buffers with
   810  * whether to process more buffers. For possitive @diff, all buffers with
   901  * timestamp <= @timestamp + @diff will certainly arrive late in the sink
   811  * timestamp <= @timestamp + @diff will certainly arrive late in the sink
   902  * as well. A (negative) @diff value so that @timestamp + @diff would yield a
   812  * as well. 
   903  * result smaller than 0 is not allowed.
       
   904  *
   813  *
   905  * The application can use general event probes to intercept the QoS
   814  * The application can use general event probes to intercept the QoS
   906  * event and implement custom application specific QoS handling.
   815  * event and implement custom application specific QoS handling.
   907  *
   816  *
   908  * Returns: A new QOS event.
   817  * Returns: A new QOS event.
   913 
   822 
   914 GstEvent *
   823 GstEvent *
   915 gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff,
   824 gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff,
   916     GstClockTime timestamp)
   825     GstClockTime timestamp)
   917 {
   826 {
   918   GstEvent *event;
       
   919   GstStructure *structure;
       
   920 
       
   921   /* diff must be positive or timestamp + diff must be positive */
       
   922   g_return_val_if_fail (diff >= 0 || -diff <= timestamp, NULL);
       
   923 
       
   924   GST_CAT_INFO (GST_CAT_EVENT,
   827   GST_CAT_INFO (GST_CAT_EVENT,
   925       "creating qos proportion %lf, diff %" G_GINT64_FORMAT
   828       "creating qos proportion %lf, diff %" G_GINT64_FORMAT
   926       ", timestamp %" GST_TIME_FORMAT, proportion,
   829       ", timestamp %" GST_TIME_FORMAT, proportion,
   927       diff, GST_TIME_ARGS (timestamp));
   830       diff, GST_TIME_ARGS (timestamp));
   928 
   831 
   929   structure = gst_structure_id_new (GST_QUARK (EVENT_QOS),
   832   return gst_event_new_custom (GST_EVENT_QOS,
   930       GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
   833       gst_structure_new ("GstEventQOS",
   931       GST_QUARK (DIFF), G_TYPE_INT64, diff,
   834           "proportion", G_TYPE_DOUBLE, proportion,
   932       GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp, NULL);
   835           "diff", G_TYPE_INT64, diff,
   933   event = gst_event_new_custom (GST_EVENT_QOS, structure);
   836           "timestamp", G_TYPE_UINT64, timestamp, NULL));
   934 
       
   935   return event;
       
   936 }
   837 }
   937 
   838 
   938 /**
   839 /**
   939  * gst_event_parse_qos:
   840  * gst_event_parse_qos:
   940  * @event: The event to query
   841  * @event: The event to query
   959   g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_QOS);
   860   g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_QOS);
   960 
   861 
   961   structure = gst_event_get_structure (event);
   862   structure = gst_event_get_structure (event);
   962   if (proportion)
   863   if (proportion)
   963     *proportion =
   864     *proportion =
   964         g_value_get_double (gst_structure_id_get_value (structure,
   865         g_value_get_double (gst_structure_get_value (structure, "proportion"));
   965             GST_QUARK (PROPORTION)));
       
   966   if (diff)
   866   if (diff)
   967     *diff =
   867     *diff = g_value_get_int64 (gst_structure_get_value (structure, "diff"));
   968         g_value_get_int64 (gst_structure_id_get_value (structure,
       
   969             GST_QUARK (DIFF)));
       
   970   if (timestamp)
   868   if (timestamp)
   971     *timestamp =
   869     *timestamp =
   972         g_value_get_uint64 (gst_structure_id_get_value (structure,
   870         g_value_get_uint64 (gst_structure_get_value (structure, "timestamp"));
   973             GST_QUARK (TIMESTAMP)));
       
   974 }
   871 }
   975 
   872 
   976 /**
   873 /**
   977  * gst_event_new_seek:
   874  * gst_event_new_seek:
   978  * @rate: The new playback rate
   875  * @rate: The new playback rate
   997  * A pipeline has a default playback segment configured with a start
   894  * A pipeline has a default playback segment configured with a start
   998  * position of 0, a stop position of -1 and a rate of 1.0. The currently
   895  * position of 0, a stop position of -1 and a rate of 1.0. The currently
   999  * configured playback segment can be queried with #GST_QUERY_SEGMENT. 
   896  * configured playback segment can be queried with #GST_QUERY_SEGMENT. 
  1000  *
   897  *
  1001  * @start_type and @stop_type specify how to adjust the currently configured 
   898  * @start_type and @stop_type specify how to adjust the currently configured 
  1002  * start and stop fields in playback segment. Adjustments can be made relative
   899  * start and stop fields in @segment. Adjustments can be made relative or
  1003  * or absolute to the last configured values. A type of #GST_SEEK_TYPE_NONE
   900  * absolute to the last configured values. A type of #GST_SEEK_TYPE_NONE means
  1004  * means that the position should not be updated.
   901  * that the position should not be updated.
  1005  *
   902  *
  1006  * When the rate is positive and @start has been updated, playback will start
   903  * When the rate is positive and @start has been updated, playback will start
  1007  * from the newly configured start position. 
   904  * from the newly configured start position. 
  1008  *
   905  *
  1009  * For negative rates, playback will start from the newly configured stop
   906  * For negative rates, playback will start from the newly configured stop
  1011  * -1 for negative rates.
   908  * -1 for negative rates.
  1012  *
   909  *
  1013  * It is not possible to seek relative to the current playback position, to do
   910  * It is not possible to seek relative to the current playback position, to do
  1014  * this, PAUSE the pipeline, query the current playback position with
   911  * this, PAUSE the pipeline, query the current playback position with
  1015  * #GST_QUERY_POSITION and update the playback segment current position with a
   912  * #GST_QUERY_POSITION and update the playback segment current position with a
  1016  * #GST_SEEK_TYPE_SET to the desired position. 
   913  * #GST_SEEK_TYPE_SET to the desired position.
  1017  *
   914  *
  1018  * Returns: A new seek event.
   915  * Returns: A new seek event.
  1019  */
   916  */
  1020 
   917 #ifdef __SYMBIAN32__
  1021 #ifdef __SYMBIAN32__
   918 EXPORT_C
  1022 EXPORT_C
   919 #endif
  1023 #endif
       
  1024 
       
  1025 GstEvent *
   920 GstEvent *
  1026 gst_event_new_seek (gdouble rate, GstFormat format, GstSeekFlags flags,
   921 gst_event_new_seek (gdouble rate, GstFormat format, GstSeekFlags flags,
  1027     GstSeekType start_type, gint64 start, GstSeekType stop_type, gint64 stop)
   922     GstSeekType start_type, gint64 start, GstSeekType stop_type, gint64 stop)
  1028 {
   923 {
  1029   GstEvent *event;
       
  1030   GstStructure *structure;
       
  1031 
       
  1032   g_return_val_if_fail (rate != 0.0, NULL);
   924   g_return_val_if_fail (rate != 0.0, NULL);
  1033 
   925 
  1034   if (format == GST_FORMAT_TIME) {
   926   if (format == GST_FORMAT_TIME) {
  1035     GST_CAT_INFO (GST_CAT_EVENT,
   927     GST_CAT_INFO (GST_CAT_EVENT,
  1036         "creating seek rate %lf, format TIME, flags %d, "
   928         "creating seek rate %lf, format TIME, flags %d, "
  1038         "stop_type %d, stop %" GST_TIME_FORMAT,
   930         "stop_type %d, stop %" GST_TIME_FORMAT,
  1039         rate, flags, start_type, GST_TIME_ARGS (start),
   931         rate, flags, start_type, GST_TIME_ARGS (start),
  1040         stop_type, GST_TIME_ARGS (stop));
   932         stop_type, GST_TIME_ARGS (stop));
  1041   } else {
   933   } else {
  1042     GST_CAT_INFO (GST_CAT_EVENT,
   934     GST_CAT_INFO (GST_CAT_EVENT,
  1043         "creating seek rate %lf, format %s, flags %d, "
   935         "creating seek rate %lf, format %d, flags %d, "
  1044         "start_type %d, start %" G_GINT64_FORMAT ", "
   936         "start_type %d, start %" G_GINT64_FORMAT ", "
  1045         "stop_type %d, stop %" G_GINT64_FORMAT,
   937         "stop_type %d, stop %" G_GINT64_FORMAT,
  1046         rate, gst_format_get_name (format), flags, start_type, start, stop_type,
   938         rate, format, flags, start_type, start, stop_type, stop);
  1047         stop);
       
  1048   }
   939   }
  1049 
   940 
  1050   structure = gst_structure_id_new (GST_QUARK (EVENT_SEEK),
   941   return gst_event_new_custom (GST_EVENT_SEEK,
  1051       GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
   942       gst_structure_new ("GstEventSeek", "rate", G_TYPE_DOUBLE, rate,
  1052       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
   943           "format", GST_TYPE_FORMAT, format,
  1053       GST_QUARK (FLAGS), GST_TYPE_SEEK_FLAGS, flags,
   944           "flags", GST_TYPE_SEEK_FLAGS, flags,
  1054       GST_QUARK (CUR_TYPE), GST_TYPE_SEEK_TYPE, start_type,
   945           "cur_type", GST_TYPE_SEEK_TYPE, start_type,
  1055       GST_QUARK (CUR), G_TYPE_INT64, start,
   946           "cur", G_TYPE_INT64, start,
  1056       GST_QUARK (STOP_TYPE), GST_TYPE_SEEK_TYPE, stop_type,
   947           "stop_type", GST_TYPE_SEEK_TYPE, stop_type,
  1057       GST_QUARK (STOP), G_TYPE_INT64, stop, NULL);
   948           "stop", G_TYPE_INT64, stop, NULL));
  1058   event = gst_event_new_custom (GST_EVENT_SEEK, structure);
       
  1059 
       
  1060   return event;
       
  1061 }
   949 }
  1062 
   950 
  1063 /**
   951 /**
  1064  * gst_event_parse_seek:
   952  * gst_event_parse_seek:
  1065  * @event: a seek event
   953  * @event: a seek event
  1087   g_return_if_fail (GST_IS_EVENT (event));
   975   g_return_if_fail (GST_IS_EVENT (event));
  1088   g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_SEEK);
   976   g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_SEEK);
  1089 
   977 
  1090   structure = gst_event_get_structure (event);
   978   structure = gst_event_get_structure (event);
  1091   if (rate)
   979   if (rate)
  1092     *rate =
   980     *rate = g_value_get_double (gst_structure_get_value (structure, "rate"));
  1093         g_value_get_double (gst_structure_id_get_value (structure,
       
  1094             GST_QUARK (RATE)));
       
  1095   if (format)
   981   if (format)
  1096     *format =
   982     *format = g_value_get_enum (gst_structure_get_value (structure, "format"));
  1097         g_value_get_enum (gst_structure_id_get_value (structure,
       
  1098             GST_QUARK (FORMAT)));
       
  1099   if (flags)
   983   if (flags)
  1100     *flags =
   984     *flags = g_value_get_flags (gst_structure_get_value (structure, "flags"));
  1101         g_value_get_flags (gst_structure_id_get_value (structure,
       
  1102             GST_QUARK (FLAGS)));
       
  1103   if (start_type)
   985   if (start_type)
  1104     *start_type =
   986     *start_type =
  1105         g_value_get_enum (gst_structure_id_get_value (structure,
   987         g_value_get_enum (gst_structure_get_value (structure, "cur_type"));
  1106             GST_QUARK (CUR_TYPE)));
       
  1107   if (start)
   988   if (start)
  1108     *start =
   989     *start = g_value_get_int64 (gst_structure_get_value (structure, "cur"));
  1109         g_value_get_int64 (gst_structure_id_get_value (structure,
       
  1110             GST_QUARK (CUR)));
       
  1111   if (stop_type)
   990   if (stop_type)
  1112     *stop_type =
   991     *stop_type =
  1113         g_value_get_enum (gst_structure_id_get_value (structure,
   992         g_value_get_enum (gst_structure_get_value (structure, "stop_type"));
  1114             GST_QUARK (STOP_TYPE)));
       
  1115   if (stop)
   993   if (stop)
  1116     *stop =
   994     *stop = g_value_get_int64 (gst_structure_get_value (structure, "stop"));
  1117         g_value_get_int64 (gst_structure_id_get_value (structure,
       
  1118             GST_QUARK (STOP)));
       
  1119 }
   995 }
  1120 
   996 
  1121 /**
   997 /**
  1122  * gst_event_new_navigation:
   998  * gst_event_new_navigation:
  1123  * @structure: description of the event. The event will take ownership of the
   999  * @structure: description of the event
  1124  *     structure.
       
  1125  *
  1000  *
  1126  * Create a new navigation event from the given description.
  1001  * Create a new navigation event from the given description.
  1127  *
  1002  *
  1128  * Returns: a new #GstEvent
  1003  * Returns: a new #GstEvent
  1129  */
  1004  */
  1143  * gst_event_new_latency:
  1018  * gst_event_new_latency:
  1144  * @latency: the new latency value
  1019  * @latency: the new latency value
  1145  *
  1020  *
  1146  * Create a new latency event. The event is sent upstream from the sinks and
  1021  * Create a new latency event. The event is sent upstream from the sinks and
  1147  * notifies elements that they should add an additional @latency to the
  1022  * notifies elements that they should add an additional @latency to the
  1148  * running time before synchronising against the clock.
  1023  * timestamps before synchronising against the clock.
  1149  *
  1024  *
  1150  * The latency is mostly used in live sinks and is always expressed in
  1025  * The latency is mostly used in live sinks and is always expressed in
  1151  * the time format.
  1026  * the time format.
  1152  *
  1027  *
  1153  * Returns: a new #GstEvent
  1028  * Returns: a new #GstEvent
  1159 #endif
  1034 #endif
  1160 
  1035 
  1161 GstEvent *
  1036 GstEvent *
  1162 gst_event_new_latency (GstClockTime latency)
  1037 gst_event_new_latency (GstClockTime latency)
  1163 {
  1038 {
  1164   GstEvent *event;
       
  1165   GstStructure *structure;
       
  1166 
       
  1167   GST_CAT_INFO (GST_CAT_EVENT,
  1039   GST_CAT_INFO (GST_CAT_EVENT,
  1168       "creating latency event %" GST_TIME_FORMAT, GST_TIME_ARGS (latency));
  1040       "creating latency event %" GST_TIME_FORMAT, GST_TIME_ARGS (latency));
  1169 
  1041 
  1170   structure = gst_structure_id_new (GST_QUARK (EVENT_LATENCY),
  1042   return gst_event_new_custom (GST_EVENT_LATENCY,
  1171       GST_QUARK (LATENCY), G_TYPE_UINT64, latency, NULL);
  1043       gst_structure_new ("GstEventLatency",
  1172   event = gst_event_new_custom (GST_EVENT_LATENCY, structure);
  1044           "latency", G_TYPE_UINT64, latency, NULL));
  1173 
       
  1174   return event;
       
  1175 }
  1045 }
  1176 
  1046 
  1177 /**
  1047 /**
  1178  * gst_event_parse_latency:
  1048  * gst_event_parse_latency:
  1179  * @event: The event to query
  1049  * @event: The event to query
  1196   g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_LATENCY);
  1066   g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_LATENCY);
  1197 
  1067 
  1198   structure = gst_event_get_structure (event);
  1068   structure = gst_event_get_structure (event);
  1199   if (latency)
  1069   if (latency)
  1200     *latency =
  1070     *latency =
  1201         g_value_get_uint64 (gst_structure_id_get_value (structure,
  1071         g_value_get_uint64 (gst_structure_get_value (structure, "latency"));
  1202             GST_QUARK (LATENCY)));
  1072 }
  1203 }
       
  1204 
       
  1205 /**
       
  1206  * gst_event_new_step:
       
  1207  * @format: the format of @amount
       
  1208  * @amount: the amount of data to step
       
  1209  * @rate: the step rate
       
  1210  * @flush: flushing steps
       
  1211  * @intermediate: intermediate steps
       
  1212  *
       
  1213  * Create a new step event. The purpose of the step event is to instruct a sink
       
  1214  * to skip @amount (expressed in @format) of media. It can be used to implement
       
  1215  * stepping through the video frame by frame or for doing fast trick modes.
       
  1216  *
       
  1217  * A rate of <= 0.0 is not allowed, pause the pipeline or reverse the playback
       
  1218  * direction of the pipeline to get the same effect.
       
  1219  *
       
  1220  * The @flush flag will clear any pending data in the pipeline before starting
       
  1221  * the step operation.
       
  1222  *
       
  1223  * The @intermediate flag instructs the pipeline that this step operation is
       
  1224  * part of a larger step operation.
       
  1225  *
       
  1226  * Returns: a new #GstEvent
       
  1227  *
       
  1228  * Since: 0.10.24
       
  1229  */
       
  1230 #ifdef __SYMBIAN32__
       
  1231 EXPORT_C
       
  1232 #endif
       
  1233 
       
  1234 GstEvent *
       
  1235 gst_event_new_step (GstFormat format, guint64 amount, gdouble rate,
       
  1236     gboolean flush, gboolean intermediate)
       
  1237 {
       
  1238   GstEvent *event;
       
  1239   GstStructure *structure;
       
  1240 
       
  1241   g_return_val_if_fail (rate > 0.0, NULL);
       
  1242 
       
  1243   GST_CAT_INFO (GST_CAT_EVENT, "creating step event");
       
  1244 
       
  1245   structure = gst_structure_id_new (GST_QUARK (EVENT_STEP),
       
  1246       GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
       
  1247       GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
       
  1248       GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
       
  1249       GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
       
  1250       GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
       
  1251   event = gst_event_new_custom (GST_EVENT_STEP, structure);
       
  1252 
       
  1253   return event;
       
  1254 }
       
  1255 
       
  1256 /**
       
  1257  * gst_event_parse_step:
       
  1258  * @event: The event to query
       
  1259  * @format: A pointer to store the format in.
       
  1260  * @amount: A pointer to store the amount in.
       
  1261  * @rate: A pointer to store the rate in.
       
  1262  * @flush: A pointer to store the flush boolean in.
       
  1263  * @intermediate: A pointer to store the intermediate boolean in.
       
  1264  *
       
  1265  * Parse the step event.
       
  1266  *
       
  1267  * Since: 0.10.24
       
  1268  */
       
  1269 #ifdef __SYMBIAN32__
       
  1270 EXPORT_C
       
  1271 #endif
       
  1272 
       
  1273 void
       
  1274 gst_event_parse_step (GstEvent * event, GstFormat * format, guint64 * amount,
       
  1275     gdouble * rate, gboolean * flush, gboolean * intermediate)
       
  1276 {
       
  1277   const GstStructure *structure;
       
  1278 
       
  1279   g_return_if_fail (GST_IS_EVENT (event));
       
  1280   g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_STEP);
       
  1281 
       
  1282   structure = gst_event_get_structure (event);
       
  1283   if (format)
       
  1284     *format = g_value_get_enum (gst_structure_id_get_value (structure,
       
  1285             GST_QUARK (FORMAT)));
       
  1286   if (amount)
       
  1287     *amount = g_value_get_uint64 (gst_structure_id_get_value (structure,
       
  1288             GST_QUARK (AMOUNT)));
       
  1289   if (rate)
       
  1290     *rate = g_value_get_double (gst_structure_id_get_value (structure,
       
  1291             GST_QUARK (RATE)));
       
  1292   if (flush)
       
  1293     *flush = g_value_get_boolean (gst_structure_id_get_value (structure,
       
  1294             GST_QUARK (FLUSH)));
       
  1295   if (intermediate)
       
  1296     *intermediate = g_value_get_boolean (gst_structure_id_get_value (structure,
       
  1297             GST_QUARK (INTERMEDIATE)));
       
  1298 }