mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
gst/gstelement.c: Handle INFO messages from the GST_ELEMENT_INFO macro as well.
Original commit message from CVS: * gst/gstelement.c: (gst_element_message_full), (gst_element_set_locked_state), (gst_element_get_state_func), (gst_element_change_state): Handle INFO messages from the GST_ELEMENT_INFO macro as well. Documentation updates. Small code cleanups. * gst/gstmessage.c: (gst_message_new_info), (gst_message_parse_info): * gst/gstmessage.h: API: gst_message_new_info() API: gst_message_parse_info() Add INFO message create and parse code.
This commit is contained in:
parent
05cf4d83c3
commit
31be175723
4 changed files with 122 additions and 27 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
||||||
|
2007-02-28 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* gst/gstelement.c: (gst_element_message_full),
|
||||||
|
(gst_element_set_locked_state), (gst_element_get_state_func),
|
||||||
|
(gst_element_change_state):
|
||||||
|
Handle INFO messages from the GST_ELEMENT_INFO macro as well.
|
||||||
|
Documentation updates.
|
||||||
|
Small code cleanups.
|
||||||
|
|
||||||
|
* gst/gstmessage.c: (gst_message_new_info),
|
||||||
|
(gst_message_parse_info):
|
||||||
|
* gst/gstmessage.h:
|
||||||
|
API: gst_message_new_info()
|
||||||
|
API: gst_message_parse_info()
|
||||||
|
Add INFO message create and parse code.
|
||||||
|
|
||||||
2007-02-28 Wim Taymans <wim@fluendo.com>
|
2007-02-28 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/gstbin.c: (bin_query_min_max_init), (bin_query_latency_fold),
|
* gst/gstbin.c: (bin_query_min_max_init), (bin_query_latency_fold),
|
||||||
|
|
|
@ -1556,7 +1556,7 @@ void gst_element_message_full
|
||||||
GST_DEBUG_OBJECT (element, "start");
|
GST_DEBUG_OBJECT (element, "start");
|
||||||
g_return_if_fail (GST_IS_ELEMENT (element));
|
g_return_if_fail (GST_IS_ELEMENT (element));
|
||||||
g_return_if_fail ((type == GST_MESSAGE_ERROR) ||
|
g_return_if_fail ((type == GST_MESSAGE_ERROR) ||
|
||||||
(type == GST_MESSAGE_WARNING));
|
(type == GST_MESSAGE_WARNING) || (type == GST_MESSAGE_INFO));
|
||||||
|
|
||||||
/* check if we send the given text or the default error text */
|
/* check if we send the given text or the default error text */
|
||||||
if ((text == NULL) || (text[0] == 0)) {
|
if ((text == NULL) || (text[0] == 0)) {
|
||||||
|
@ -1587,14 +1587,22 @@ void gst_element_message_full
|
||||||
sent_text);
|
sent_text);
|
||||||
gerror = g_error_new_literal (domain, code, sent_text);
|
gerror = g_error_new_literal (domain, code, sent_text);
|
||||||
|
|
||||||
if (type == GST_MESSAGE_ERROR) {
|
switch (type) {
|
||||||
|
case GST_MESSAGE_ERROR:
|
||||||
message =
|
message =
|
||||||
gst_message_new_error (GST_OBJECT_CAST (element), gerror, sent_debug);
|
gst_message_new_error (GST_OBJECT_CAST (element), gerror, sent_debug);
|
||||||
} else if (type == GST_MESSAGE_WARNING) {
|
break;
|
||||||
|
case GST_MESSAGE_WARNING:
|
||||||
message = gst_message_new_warning (GST_OBJECT_CAST (element), gerror,
|
message = gst_message_new_warning (GST_OBJECT_CAST (element), gerror,
|
||||||
sent_debug);
|
sent_debug);
|
||||||
} else {
|
break;
|
||||||
|
case GST_MESSAGE_INFO:
|
||||||
|
message = gst_message_new_info (GST_OBJECT_CAST (element), gerror,
|
||||||
|
sent_debug);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
gst_element_post_message (element, message);
|
gst_element_post_message (element, message);
|
||||||
|
|
||||||
|
@ -1645,7 +1653,7 @@ gst_element_is_locked_state (GstElement * element)
|
||||||
*
|
*
|
||||||
* MT safe.
|
* MT safe.
|
||||||
*
|
*
|
||||||
* Returns: TRUE if the state was changed, FALSE if bad parameterss were given
|
* Returns: TRUE if the state was changed, FALSE if bad parameters were given
|
||||||
* or the elements state-locking needed no change.
|
* or the elements state-locking needed no change.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -1675,11 +1683,13 @@ gst_element_set_locked_state (GstElement * element, gboolean locked_state)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
was_ok:
|
was_ok:
|
||||||
|
{
|
||||||
GST_CAT_DEBUG (GST_CAT_STATES, "elements %s was in locked state %d",
|
GST_CAT_DEBUG (GST_CAT_STATES, "elements %s was in locked state %d",
|
||||||
GST_ELEMENT_NAME (element), old);
|
GST_ELEMENT_NAME (element), old);
|
||||||
GST_OBJECT_UNLOCK (element);
|
GST_OBJECT_UNLOCK (element);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1741,10 +1751,13 @@ gst_element_get_state_func (GstElement * element,
|
||||||
GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
|
GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE;
|
||||||
GstState old_pending;
|
GstState old_pending;
|
||||||
|
|
||||||
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, "getting state");
|
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, "getting state, timeout %"
|
||||||
|
GST_TIME_FORMAT, GST_TIME_ARGS (timeout));
|
||||||
|
|
||||||
GST_OBJECT_LOCK (element);
|
GST_OBJECT_LOCK (element);
|
||||||
ret = GST_STATE_RETURN (element);
|
ret = GST_STATE_RETURN (element);
|
||||||
|
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, "RETURN is %s",
|
||||||
|
gst_element_state_change_return_get_name (ret));
|
||||||
|
|
||||||
/* we got an error, report immediatly */
|
/* we got an error, report immediatly */
|
||||||
if (ret == GST_STATE_CHANGE_FAILURE)
|
if (ret == GST_STATE_CHANGE_FAILURE)
|
||||||
|
@ -1860,13 +1873,12 @@ interrupted:
|
||||||
*
|
*
|
||||||
* This function returns %GST_STATE_CHANGE_NO_PREROLL if the element
|
* This function returns %GST_STATE_CHANGE_NO_PREROLL if the element
|
||||||
* successfully changed its state but is not able to provide data yet.
|
* successfully changed its state but is not able to provide data yet.
|
||||||
* This mostly
|
* This mostly happens for live sources that only produce data in the PLAYING
|
||||||
* happens for live sources that only produce data in the PLAYING state.
|
* state. While the state change return is equivalent to
|
||||||
* While the state change return is equivalent to %GST_STATE_CHANGE_SUCCESS, it
|
* %GST_STATE_CHANGE_SUCCESS, it is returned to the application to signal that
|
||||||
* is returned to the application to signal that some sink elements might not
|
* some sink elements might not be able to complete their state change because
|
||||||
* be able to complete their state change because an element is not producing
|
* an element is not producing data to complete the preroll. When setting the
|
||||||
* data to complete the preroll. When setting the element to playing,
|
* element to playing, the preroll will complete and playback will start.
|
||||||
* the preroll will complete and playback will start.
|
|
||||||
*
|
*
|
||||||
* Returns: %GST_STATE_CHANGE_SUCCESS if the element has no more pending state
|
* Returns: %GST_STATE_CHANGE_SUCCESS if the element has no more pending state
|
||||||
* and the last state change succeeded, %GST_STATE_CHANGE_ASYNC if the
|
* and the last state change succeeded, %GST_STATE_CHANGE_ASYNC if the
|
||||||
|
@ -1955,13 +1967,13 @@ nothing_aborted:
|
||||||
* by elements that do asynchronous state changes.
|
* by elements that do asynchronous state changes.
|
||||||
* The core will normally call this method automatically when an
|
* The core will normally call this method automatically when an
|
||||||
* element returned %GST_STATE_CHANGE_SUCCESS from the state change function.
|
* element returned %GST_STATE_CHANGE_SUCCESS from the state change function.
|
||||||
* Elements that return %GST_STATE_CHANGE_ASYNC from the change_state function
|
|
||||||
* should eventually call this method from the streaming thread to signal
|
|
||||||
* successfull state change completion.
|
|
||||||
*
|
*
|
||||||
* If after calling this method the element still has not reached
|
* If after calling this method the element still has not reached
|
||||||
* the pending state, the next state change is performed.
|
* the pending state, the next state change is performed.
|
||||||
*
|
*
|
||||||
|
* This method is used internally and should normally not be called by plugins
|
||||||
|
* or applications.
|
||||||
|
*
|
||||||
* Returns: The result of the commit state change.
|
* Returns: The result of the commit state change.
|
||||||
*
|
*
|
||||||
* MT safe.
|
* MT safe.
|
||||||
|
@ -2067,7 +2079,8 @@ complete:
|
||||||
* This function can only be called when the element is currently
|
* This function can only be called when the element is currently
|
||||||
* not in error or an async state change.
|
* not in error or an async state change.
|
||||||
*
|
*
|
||||||
* This function can only be called with the STATE_LOCK held.
|
* This function is used internally and should normally not be called from
|
||||||
|
* plugins or applications.
|
||||||
*
|
*
|
||||||
* MT safe.
|
* MT safe.
|
||||||
*/
|
*/
|
||||||
|
@ -2336,6 +2349,7 @@ invalid_return:
|
||||||
g_critical ("%s: unknown return value %d from a state change function",
|
g_critical ("%s: unknown return value %d from a state change function",
|
||||||
GST_ELEMENT_NAME (element), ret);
|
GST_ELEMENT_NAME (element), ret);
|
||||||
|
|
||||||
|
/* we are in error now */
|
||||||
ret = GST_STATE_CHANGE_FAILURE;
|
ret = GST_STATE_CHANGE_FAILURE;
|
||||||
GST_STATE_RETURN (element) = ret;
|
GST_STATE_RETURN (element) = ret;
|
||||||
GST_OBJECT_UNLOCK (element);
|
GST_OBJECT_UNLOCK (element);
|
||||||
|
|
|
@ -373,6 +373,33 @@ gst_message_new_warning (GstObject * src, GError * error, gchar * debug)
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_message_new_info:
|
||||||
|
* @src: The object originating the message.
|
||||||
|
* @error: The GError for this message.
|
||||||
|
* @debug: A debugging string for something or other.
|
||||||
|
*
|
||||||
|
* Create a new info message. The message will make copies of @error and
|
||||||
|
* @debug.
|
||||||
|
*
|
||||||
|
* Returns: The new info message.
|
||||||
|
*
|
||||||
|
* Since: 0.10.12
|
||||||
|
*
|
||||||
|
* MT safe.
|
||||||
|
*/
|
||||||
|
GstMessage *
|
||||||
|
gst_message_new_info (GstObject * src, GError * error, gchar * debug)
|
||||||
|
{
|
||||||
|
GstMessage *message;
|
||||||
|
|
||||||
|
message = gst_message_new_custom (GST_MESSAGE_INFO, src,
|
||||||
|
gst_structure_new ("GstMessageInfo", "gerror", GST_TYPE_G_ERROR, error,
|
||||||
|
"debug", G_TYPE_STRING, debug, NULL));
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_message_new_tag:
|
* gst_message_new_tag:
|
||||||
* @src: The object originating the message.
|
* @src: The object originating the message.
|
||||||
|
@ -962,6 +989,42 @@ gst_message_parse_warning (GstMessage * message, GError ** gerror,
|
||||||
*debug = g_strdup (gst_structure_get_string (message->structure, "debug"));
|
*debug = g_strdup (gst_structure_get_string (message->structure, "debug"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_message_parse_info:
|
||||||
|
* @message: A valid #GstMessage of type GST_MESSAGE_INFO.
|
||||||
|
* @gerror: Location for the GError
|
||||||
|
* @debug: Location for the debug message, or NULL
|
||||||
|
*
|
||||||
|
* Extracts the GError and debug string from the GstMessage. The values returned
|
||||||
|
* in the output arguments are copies; the caller must free them when done.
|
||||||
|
*
|
||||||
|
* MT safe.
|
||||||
|
*
|
||||||
|
* Since: 0.10.12
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
|
||||||
|
{
|
||||||
|
const GValue *error_gvalue;
|
||||||
|
GError *error_val;
|
||||||
|
|
||||||
|
g_return_if_fail (GST_IS_MESSAGE (message));
|
||||||
|
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
|
||||||
|
|
||||||
|
error_gvalue = gst_structure_get_value (message->structure, "gerror");
|
||||||
|
g_return_if_fail (error_gvalue != NULL);
|
||||||
|
g_return_if_fail (G_VALUE_TYPE (error_gvalue) == GST_TYPE_G_ERROR);
|
||||||
|
|
||||||
|
error_val = (GError *) g_value_get_boxed (error_gvalue);
|
||||||
|
if (error_val)
|
||||||
|
*gerror = g_error_copy (error_val);
|
||||||
|
else
|
||||||
|
*gerror = NULL;
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
*debug = g_strdup (gst_structure_get_string (message->structure, "debug"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_message_parse_segment_start:
|
* gst_message_parse_segment_start:
|
||||||
* @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
|
* @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
|
||||||
|
|
|
@ -249,6 +249,7 @@ gst_message_ref (GstMessage * msg)
|
||||||
GstMessage * gst_message_new_eos (GstObject * src);
|
GstMessage * gst_message_new_eos (GstObject * src);
|
||||||
GstMessage * gst_message_new_error (GstObject * src, GError * error, gchar * debug);
|
GstMessage * gst_message_new_error (GstObject * src, GError * error, gchar * debug);
|
||||||
GstMessage * gst_message_new_warning (GstObject * src, GError * error, gchar * debug);
|
GstMessage * gst_message_new_warning (GstObject * src, GError * error, gchar * debug);
|
||||||
|
GstMessage * gst_message_new_info (GstObject * src, GError * error, gchar * debug);
|
||||||
GstMessage * gst_message_new_tag (GstObject * src, GstTagList * tag_list);
|
GstMessage * gst_message_new_tag (GstObject * src, GstTagList * tag_list);
|
||||||
GstMessage * gst_message_new_buffering (GstObject * src, gint percent);
|
GstMessage * gst_message_new_buffering (GstObject * src, gint percent);
|
||||||
GstMessage * gst_message_new_state_changed (GstObject * src, GstState oldstate,
|
GstMessage * gst_message_new_state_changed (GstObject * src, GstState oldstate,
|
||||||
|
@ -269,6 +270,7 @@ GstMessage * gst_message_new_custom (GstMessageType type,
|
||||||
|
|
||||||
void gst_message_parse_error (GstMessage *message, GError **gerror, gchar **debug);
|
void gst_message_parse_error (GstMessage *message, GError **gerror, gchar **debug);
|
||||||
void gst_message_parse_warning (GstMessage *message, GError **gerror, gchar **debug);
|
void gst_message_parse_warning (GstMessage *message, GError **gerror, gchar **debug);
|
||||||
|
void gst_message_parse_info (GstMessage *message, GError **gerror, gchar **debug);
|
||||||
void gst_message_parse_tag (GstMessage *message, GstTagList **tag_list);
|
void gst_message_parse_tag (GstMessage *message, GstTagList **tag_list);
|
||||||
void gst_message_parse_buffering (GstMessage *message, gint *percent);
|
void gst_message_parse_buffering (GstMessage *message, gint *percent);
|
||||||
void gst_message_parse_state_changed (GstMessage *message, GstState *oldstate,
|
void gst_message_parse_state_changed (GstMessage *message, GstState *oldstate,
|
||||||
|
|
Loading…
Reference in a new issue