message: add progress message functions

This commit is contained in:
Wim Taymans 2011-01-05 13:41:08 +01:00
parent 6382a6813d
commit f5b175972c
6 changed files with 111 additions and 2 deletions

View file

@ -1248,6 +1248,10 @@ gst_message_parse_stream_status
gst_message_set_stream_status_object
gst_message_get_stream_status_object
GstProgressType
gst_message_new_progress
gst_message_parse_progress
<SUBSECTION Standard>
GstMessageClass
GST_MESSAGE
@ -1260,11 +1264,13 @@ GST_MESSAGE_GET_CLASS
GST_TYPE_MESSAGE_TYPE
GST_TYPE_STRUCTURE_CHANGE_TYPE
GST_TYPE_STREAM_STATUS_TYPE
GST_TYPE_PROGRESS_TYPE
<SUBSECTION Private>
gst_message_get_type
gst_message_type_get_type
gst_structure_change_type_get_type
gst_stream_status_type_get_type
gst_progress_type_get_type
GST_MESSAGE_COND
GST_MESSAGE_GET_LOCK
GST_MESSAGE_LOCK

View file

@ -2079,3 +2079,68 @@ gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
}
/**
* gst_message_new_progress:
* @src: The object originating the message.
* @type: a #GstProgressType
* @category: a progress category
* @text: free, user visible text describing the progress
*
* Progress messages are posted by elements when they use an asynchronous task
* to perform actions triggered by a state change.
*
* @category contains a well defined string describing the action.
* @test should contain a user visible string detailing the current action.
*
* Returns: (transfer full): The new qos message.
*
* Since: 0.10.33
*/
GstMessage *
gst_message_new_progress (GstObject * src, GstProgressType type,
const gchar * category, const gchar * text)
{
GstMessage *message;
GstStructure *structure;
gint percent = 100;
g_return_val_if_fail (category != NULL, NULL);
g_return_val_if_fail (text != NULL, NULL);
if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
percent = 0;
structure = gst_structure_id_new (GST_QUARK (MESSAGE_PROGRESS),
GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
GST_QUARK (CATEGORY), G_TYPE_STRING, category,
GST_QUARK (TEXT), G_TYPE_STRING, text,
GST_QUARK (PERCENT), G_TYPE_INT, percent, NULL);
message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
return message;
}
/**
* gst_message_parse_progress:
* @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
* @type: (out) (allow-none): location for the type
* @category: (out) (allow-none) (transfer full): location for the category
* @text: (out) (allow-none) (transfer full): location for the text
*
* Parses the progress @type, @category and @text.
*
* Since: 0.10.33
*/
void
gst_message_parse_progress (GstMessage * message, GstProgressType * type,
gchar ** category, gchar ** text)
{
g_return_if_fail (GST_IS_MESSAGE (message));
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
gst_structure_id_get (message->structure,
GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
GST_QUARK (CATEGORY), G_TYPE_STRING, category,
GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
}

View file

@ -88,6 +88,7 @@ typedef struct _GstMessageClass GstMessageClass;
* @GST_MESSAGE_STEP_START: A stepping operation was started. Since: 0.10.24
* @GST_MESSAGE_QOS: A buffer was dropped or an element changed its processing
* strategy for Quality of Service reasons. Since: 0.10.29
* @GST_MESSAGE_PROGRESS: A progress message. Since: 0.10.33
* @GST_MESSAGE_ANY: mask for all of the above messages.
*
* The different message types that are available.
@ -123,6 +124,7 @@ typedef enum
GST_MESSAGE_REQUEST_STATE = (1 << 22),
GST_MESSAGE_STEP_START = (1 << 23),
GST_MESSAGE_QOS = (1 << 24),
GST_MESSAGE_PROGRESS = (1 << 25),
GST_MESSAGE_ANY = ~0
} GstMessageType;
@ -240,6 +242,28 @@ typedef enum {
GST_STREAM_STATUS_TYPE_STOP = 10
} GstStreamStatusType;
/**
* GstProgressType:
* @GST_PROGRESS_TYPE_START: A new task started.
* @GST_PROGRESS_TYPE_CONTINUE: A task completed and a new one continues.
* @GST_PROGRESS_TYPE_COMPLETE: A task completed.
* @GST_PROGRESS_TYPE_CANCELED: A task was canceled.
* @GST_PROGRESS_TYPE_ERROR: A task caused an error. An error message is also
* posted on the bus.
*
* The type of a %GST_MESSAGE_PROGRESS. The progress messages inform the
* application of the status of assynchronous tasks.
*
* Since: 0.10.33
*/
typedef enum {
GST_PROGRESS_TYPE_START = 0,
GST_PROGRESS_TYPE_CONTINUE = 1,
GST_PROGRESS_TYPE_COMPLETE = 2,
GST_PROGRESS_TYPE_CANCELED = 3,
GST_PROGRESS_TYPE_ERROR = 4,
} GstProgressType;
/**
* GstMessage:
* @mini_object: the parent structure
@ -492,6 +516,12 @@ void gst_message_parse_qos_values (GstMessage * message, gint64 *
gint * quality);
void gst_message_parse_qos_stats (GstMessage * message, GstFormat * format, guint64 * processed,
guint64 * dropped);
/* PROGRESS */
GstMessage * gst_message_new_progress (GstObject * src, GstProgressType type, const gchar *category,
const gchar *text);
void gst_message_parse_progress (GstMessage * message, GstProgressType * type, gchar ** category,
gchar ** text);
/* custom messages */
GstMessage * gst_message_new_custom (GstMessageType type,

View file

@ -49,7 +49,8 @@ static const gchar *_quark_strings[] = {
"GstQueryURI", "GstEventStep", "GstMessageStepDone", "amount", "flush",
"intermediate", "GstMessageStepStart", "active", "eos", "sink-message",
"message", "GstMessageQOS", "running-time", "stream-time", "jitter",
"quality", "processed", "dropped", "buffering-ranges"
"quality", "processed", "dropped", "buffering-ranges", "GstMessageProgress",
"category", "text", "percent"
};
GQuark _priv_gst_quark_table[GST_QUARK_MAX];

View file

@ -127,8 +127,12 @@ typedef enum _GstQuarkId
GST_QUARK_PROCESSED = 98,
GST_QUARK_DROPPED = 99,
GST_QUARK_BUFFERING_RANGES = 100,
GST_QUARK_MESSAGE_PROGRESS = 101,
GST_QUARK_CATEGORY = 102,
GST_QUARK_TEXT = 103,
GST_QUARK_PERCENT = 104,
GST_QUARK_MAX = 101
GST_QUARK_MAX = 105
} GstQuarkId;
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];

View file

@ -531,6 +531,7 @@ EXPORTS
gst_message_new_info
gst_message_new_latency
gst_message_new_new_clock
gst_message_new_progress
gst_message_new_qos
gst_message_new_request_state
gst_message_new_segment_done
@ -553,6 +554,7 @@ EXPORTS
gst_message_parse_error
gst_message_parse_info
gst_message_parse_new_clock
gst_message_parse_progress
gst_message_parse_qos
gst_message_parse_qos_stats
gst_message_parse_qos_values
@ -813,6 +815,7 @@ EXPORTS
gst_preset_set_meta
gst_print_element_args
gst_print_pad_caps
gst_progress_type_get_type
gst_proxy_pad_get_type
gst_qos_type_get_type
gst_query_add_buffering_range