From: Stefan Sauer Date: Thu, 2 Jan 2014 21:30:11 +0000 (+0100) Subject: toc: expand GstTocEntry with loop fields X-Git-Tag: 1.3.1~97 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0fb6a15a6556fcbe01f69324a6c5c773187fb1e5;p=platform%2Fupstream%2Fgstreamer.git toc: expand GstTocEntry with loop fields Add loop_type and repeat_count fields to GstTocEntry plus setters and getters. This allows to represent edit-lists in a toc as well as loops in instruemnts (wav, xi). API: gst_toc_entry_set_loop API: gst_toc_entry_get_loop --- diff --git a/docs/design/part-toc.txt b/docs/design/part-toc.txt index cc0d11b..8f14f5d 100644 --- a/docs/design/part-toc.txt +++ b/docs/design/part-toc.txt @@ -54,8 +54,9 @@ item respectively. Field 'tags' is a list of tags related to the item. And field So, a little more about managing GstToc. Use gst_toc_new() and gst_toc_unref() to create/free it. GstTocEntry can be created using gst_toc_entry_new(). -While building GstToc you can set start and stop -timestamps for each item using gst_toc_entry_set_start_stop(). +While building GstToc you can set start and stop timestamps for each item using +gst_toc_entry_set_start_stop() and loop_type and repeat_count using +gst_toc_entry_set_loop(). The best way to process already created GstToc is to recursively go through the 'entries' and 'subentries' fields. diff --git a/gst/gsttoc.c b/gst/gsttoc.c index 6da7ad8..0d3d025 100644 --- a/gst/gsttoc.c +++ b/gst/gsttoc.c @@ -96,6 +96,8 @@ struct _GstTocEntry GstClockTime start, stop; GList *subentries; GstTagList *tags; + GstTocLoopType loop_type; + gint repeat_count; }; struct _GstToc @@ -487,20 +489,19 @@ gst_toc_entry_set_start_stop_times (GstTocEntry * entry, gint64 start, /** * gst_toc_entry_get_start_stop_times: * @entry: #GstTocEntry to get values from. - * @start: (out): the storage for the start value, leave #NULL if not need. - * @stop: (out): the storage for the stop value, leave #NULL if not need. + * @start: (out): the storage for the start value, leave %NULL if not need. + * @stop: (out): the storage for the stop value, leave %NULL if not need. * - * Get start and stop values from the @entry and write them into appropriate storages. + * Get @start and @stop values from the @entry and write them into appropriate + * storages. * - * Returns: TRUE if all non-NULL storage pointers were filled with appropriate values, - * FALSE otherwise. + * Returns: %TRUE if all non-%NULL storage pointers were filled with appropriate + * values, %FALSE otherwise. */ gboolean gst_toc_entry_get_start_stop_times (const GstTocEntry * entry, gint64 * start, gint64 * stop) { - gboolean ret = TRUE; - g_return_val_if_fail (entry != NULL, FALSE); if (start != NULL) @@ -508,10 +509,63 @@ gst_toc_entry_get_start_stop_times (const GstTocEntry * entry, gint64 * start, if (stop != NULL) *stop = entry->stop; - return ret; + return TRUE; +} + +/** + * gst_toc_entry_set_loop: + * @entry: #GstTocEntry to set values. + * @loop_type: loop_type value to set. + * @repeat_count: repeat_count value to set. + * + * Set @loop_type and @repeat_count values for the @entry. + * + * Since: 1.4 + */ +void +gst_toc_entry_set_loop (GstTocEntry * entry, GstTocLoopType loop_type, + gint repeat_count) +{ + g_return_if_fail (entry != NULL); + + entry->loop_type = loop_type; + entry->repeat_count = repeat_count; } /** + * gst_toc_entry_get_loop: + * @entry: #GstTocEntry to get values from. + * @loop_type: (out): the storage for the loop_type value, leave %NULL if not + * need. + * @repeat_count: (out): the storage for the repeat_count value, leave %NULL if + * not need. + * + * Get @loop_type and @repeat_count values from the @entry and write them into + * appropriate storages. Loops are e.g. used by sampled instruments. GStreamer + * is not automatically applying the loop. The application can process this + * meta data and use it e.g. to send a seek-event to loop a section. + * + * Returns: %TRUE if all non-%NULL storage pointers were filled with appropriate + * values, %FALSE otherwise. + * + * Since: 1.4 + */ +gboolean +gst_toc_entry_get_loop (const GstTocEntry * entry, GstTocLoopType * loop_type, + gint * repeat_count) +{ + g_return_val_if_fail (entry != NULL, FALSE); + + if (loop_type != NULL) + *loop_type = entry->loop_type; + if (repeat_count != NULL) + *repeat_count = entry->repeat_count; + + return TRUE; +} + + +/** * gst_toc_entry_type_get_nick: * @type: a #GstTocEntryType. * diff --git a/gst/gsttoc.h b/gst/gsttoc.h index 632435a..a9815d8 100644 --- a/gst/gsttoc.h +++ b/gst/gsttoc.h @@ -81,6 +81,35 @@ typedef enum { #define GST_TOC_ENTRY_TYPE_IS_ALTERNATIVE(entry_type) (entry_type < 0) #define GST_TOC_ENTRY_TYPE_IS_SEQUENCE(entry_type) (entry_type > 0) +/** + * GstTocLoopType: + * @GST_TOC_LOOP_NONE: single forward playback + * @GST_TOC_LOOP_FORWARD: repeat forward + * @GST_TOC_LOOP_REVERSE: repeat backward + * @GST_TOC_LOOP_PING_PONG: repeat forward and backward + * + * How a #GstTocEntry should be repeated. By default, entries are played a + * single time. + * + * Since: 1.4 + */ +typedef enum { + GST_TOC_LOOP_NONE = 0, + GST_TOC_LOOP_FORWARD, + GST_TOC_LOOP_REVERSE, + GST_TOC_LOOP_PING_PONG +} GstTocLoopType; + +/** + * GST_TOC_REPEAT_COUNT_INFINITE: + * + * Special value for the repeat_count set in gst_toc_entry_set_loop() or + * returned by gst_toc_entry_set_loop() to indicate infinite looping. + * + * Since: 1.4 + */ +#define GST_TOC_REPEAT_COUNT_INFINITE (-1) + /* functions to return type structures */ GType gst_toc_get_type (void); GType gst_toc_entry_get_type (void); @@ -130,6 +159,9 @@ gboolean gst_toc_entry_is_sequence (const GstTocEntry *ent void gst_toc_entry_set_start_stop_times (GstTocEntry *entry, gint64 start, gint64 stop); gboolean gst_toc_entry_get_start_stop_times (const GstTocEntry *entry, gint64 *start, gint64 *stop); +void gst_toc_entry_set_loop (GstTocEntry *entry, GstTocLoopType loop_type, gint repeat_count); +gboolean gst_toc_entry_get_loop (const GstTocEntry *entry, GstTocLoopType *loop_type, gint *repeat_count); + GstToc * gst_toc_entry_get_toc (GstTocEntry *entry); GstTocEntry * gst_toc_entry_get_parent (GstTocEntry *entry);