mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
gst/gstpad.*: Added _CUSTOM error and success GstFlowReturn that can be used be elements internally.
Original commit message from CVS: * gst/gstpad.c: (gst_flow_get_name), (gst_flow_to_quark): * gst/gstpad.h: Added _CUSTOM error and success GstFlowReturn that can be used be elements internally. Added macro to check for SUCCESS flowreturns. API: GST_FLOW_CUSTOM_SUCCESS API: GST_FLOW_CUSTOM_ERROR API: GST_FLOW_IS_SUCCESS * tests/check/gst/gstpad.c: (GST_START_TEST), (gst_pad_suite): Added check for GstFlowReturn sanity.
This commit is contained in:
parent
da7cd3b635
commit
8bec13ec53
4 changed files with 117 additions and 4 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2006-05-23 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* gst/gstpad.c: (gst_flow_get_name), (gst_flow_to_quark):
|
||||
* gst/gstpad.h:
|
||||
Added _CUSTOM error and success GstFlowReturn that can be
|
||||
used be elements internally.
|
||||
Added macro to check for SUCCESS flowreturns.
|
||||
API: GST_FLOW_CUSTOM_SUCCESS
|
||||
API: GST_FLOW_CUSTOM_ERROR
|
||||
API: GST_FLOW_IS_SUCCESS
|
||||
|
||||
* tests/check/gst/gstpad.c: (GST_START_TEST), (gst_pad_suite):
|
||||
Added check for GstFlowReturn sanity.
|
||||
|
||||
2006-05-23 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
Patch by: Mark Nauwelaerts <manauw at skynet dot be>
|
||||
|
|
|
@ -130,6 +130,7 @@ typedef struct
|
|||
} GstFlowQuarks;
|
||||
|
||||
static GstFlowQuarks flow_quarks[] = {
|
||||
{GST_FLOW_CUSTOM_SUCCESS, "custom-success", 0},
|
||||
{GST_FLOW_RESEND, "resend", 0},
|
||||
{GST_FLOW_OK, "ok", 0},
|
||||
{GST_FLOW_NOT_LINKED, "not-linked", 0},
|
||||
|
@ -138,6 +139,7 @@ static GstFlowQuarks flow_quarks[] = {
|
|||
{GST_FLOW_NOT_NEGOTIATED, "not-negotiated", 0},
|
||||
{GST_FLOW_ERROR, "error", 0},
|
||||
{GST_FLOW_NOT_SUPPORTED, "not-supported", 0},
|
||||
{GST_FLOW_CUSTOM_ERROR, "custom-error", 0},
|
||||
|
||||
{0, NULL, 0}
|
||||
};
|
||||
|
@ -148,13 +150,15 @@ static GstFlowQuarks flow_quarks[] = {
|
|||
*
|
||||
* Gets a string representing the given flow return.
|
||||
*
|
||||
* Returns: a string with the name of the flow return.
|
||||
* Returns: a static string with the name of the flow return.
|
||||
*/
|
||||
G_CONST_RETURN gchar *
|
||||
gst_flow_get_name (GstFlowReturn ret)
|
||||
{
|
||||
gint i;
|
||||
|
||||
ret = CLAMP (ret, GST_FLOW_CUSTOM_ERROR, GST_FLOW_CUSTOM_SUCCESS);
|
||||
|
||||
for (i = 0; flow_quarks[i].name; i++) {
|
||||
if (ret == flow_quarks[i].ret)
|
||||
return flow_quarks[i].name;
|
||||
|
@ -176,6 +180,8 @@ gst_flow_to_quark (GstFlowReturn ret)
|
|||
{
|
||||
gint i;
|
||||
|
||||
ret = CLAMP (ret, GST_FLOW_CUSTOM_ERROR, GST_FLOW_CUSTOM_SUCCESS);
|
||||
|
||||
for (i = 0; flow_quarks[i].name; i++) {
|
||||
if (ret == flow_quarks[i].ret)
|
||||
return flow_quarks[i].quark;
|
||||
|
|
36
gst/gstpad.h
36
gst/gstpad.h
|
@ -91,18 +91,32 @@ typedef enum {
|
|||
|
||||
/**
|
||||
* GstFlowReturn:
|
||||
* @GST_FLOW_CUSTOM_SUCCESS: Elements can use values starting from
|
||||
* this to define custom success codes.
|
||||
* Since 0.10.7.
|
||||
* @GST_FLOW_RESEND: Resend buffer, possibly with new caps.
|
||||
* @GST_FLOW_OK: Data passing was ok.
|
||||
* @GST_FLOW_NOT_LINKED: Pad is not linked.
|
||||
* @GST_FLOW_WRONG_STATE: Pad is in wrong state.
|
||||
* @GST_FLOW_UNEXPECTED: Did not expect anything, like after EOS.
|
||||
* @GST_FLOW_NOT_NEGOTIATED: Pad is not negotiated.
|
||||
* @GST_FLOW_ERROR: Some (fatal) error occured.
|
||||
* @GST_FLOW_ERROR: Some (fatal) error occured. Element generating
|
||||
* this error should post an error message with more
|
||||
* details.
|
||||
* @GST_FLOW_NOT_SUPPORTED: This operation is not supported.
|
||||
* @GST_FLOW_CUSTOM_ERROR: Elements can use values starting from
|
||||
* this to define custom error codes. Since 0.10.7.
|
||||
*
|
||||
* The result of passing data to a linked pad.
|
||||
* The result of passing data to a pad.
|
||||
*
|
||||
* Note that the custom return values should not be exposed outside of the
|
||||
* element scope and are available since 0.10.7.
|
||||
*/
|
||||
typedef enum {
|
||||
/* custom success starts here */
|
||||
GST_FLOW_CUSTOM_SUCCESS = 100,
|
||||
|
||||
/* core predefined */
|
||||
GST_FLOW_RESEND = 1,
|
||||
GST_FLOW_OK = 0,
|
||||
/* expected failures */
|
||||
|
@ -112,7 +126,10 @@ typedef enum {
|
|||
GST_FLOW_UNEXPECTED = -3,
|
||||
GST_FLOW_NOT_NEGOTIATED = -4,
|
||||
GST_FLOW_ERROR = -5,
|
||||
GST_FLOW_NOT_SUPPORTED = -6
|
||||
GST_FLOW_NOT_SUPPORTED = -6,
|
||||
|
||||
/* custom error starts here */
|
||||
GST_FLOW_CUSTOM_ERROR = -100
|
||||
} GstFlowReturn;
|
||||
|
||||
/**
|
||||
|
@ -125,6 +142,19 @@ typedef enum {
|
|||
*/
|
||||
#define GST_FLOW_IS_FATAL(ret) ((ret) <= GST_FLOW_UNEXPECTED)
|
||||
|
||||
/**
|
||||
* GST_FLOW_IS_SUCCESS:
|
||||
* @ret: a #GstFlowReturn value
|
||||
*
|
||||
* Macro to test if the given #GstFlowReturn value indicates a
|
||||
* successfull result
|
||||
* This macro is mainly used in elements to decide if the processing
|
||||
* of a buffer was successfull.
|
||||
*
|
||||
* Since: 0.10.7
|
||||
*/
|
||||
#define GST_FLOW_IS_SUCCESS(ret) ((ret) >= GST_FLOW_OK)
|
||||
|
||||
G_CONST_RETURN gchar* gst_flow_get_name (GstFlowReturn ret);
|
||||
GQuark gst_flow_to_quark (GstFlowReturn ret);
|
||||
|
||||
|
|
|
@ -380,6 +380,67 @@ GST_START_TEST (test_push_linked)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_flowreturn)
|
||||
{
|
||||
GstFlowReturn ret;
|
||||
GQuark quark;
|
||||
|
||||
/* test some of the macros */
|
||||
ret = GST_FLOW_UNEXPECTED;
|
||||
fail_unless (GST_FLOW_IS_FATAL (ret));
|
||||
fail_if (GST_FLOW_IS_SUCCESS (ret));
|
||||
fail_if (strcmp (gst_flow_get_name (ret), "unexpected"));
|
||||
quark = gst_flow_to_quark (ret);
|
||||
fail_if (strcmp (g_quark_to_string (quark), "unexpected"));
|
||||
|
||||
ret = GST_FLOW_RESEND;
|
||||
fail_if (GST_FLOW_IS_FATAL (ret));
|
||||
fail_unless (GST_FLOW_IS_SUCCESS (ret));
|
||||
fail_if (strcmp (gst_flow_get_name (ret), "resend"));
|
||||
quark = gst_flow_to_quark (ret);
|
||||
fail_if (strcmp (g_quark_to_string (quark), "resend"));
|
||||
|
||||
/* custom returns */
|
||||
ret = GST_FLOW_CUSTOM_SUCCESS;
|
||||
fail_if (GST_FLOW_IS_FATAL (ret));
|
||||
fail_unless (GST_FLOW_IS_SUCCESS (ret));
|
||||
fail_if (strcmp (gst_flow_get_name (ret), "custom-success"));
|
||||
quark = gst_flow_to_quark (ret);
|
||||
fail_if (strcmp (g_quark_to_string (quark), "custom-success"));
|
||||
|
||||
ret = GST_FLOW_CUSTOM_ERROR;
|
||||
fail_unless (GST_FLOW_IS_FATAL (ret));
|
||||
fail_if (GST_FLOW_IS_SUCCESS (ret));
|
||||
fail_if (strcmp (gst_flow_get_name (ret), "custom-error"));
|
||||
quark = gst_flow_to_quark (ret);
|
||||
fail_if (strcmp (g_quark_to_string (quark), "custom-error"));
|
||||
|
||||
/* custom returns clamping */
|
||||
ret = GST_FLOW_CUSTOM_SUCCESS + 2;
|
||||
fail_if (GST_FLOW_IS_FATAL (ret));
|
||||
fail_unless (GST_FLOW_IS_SUCCESS (ret));
|
||||
fail_if (strcmp (gst_flow_get_name (ret), "custom-success"));
|
||||
quark = gst_flow_to_quark (ret);
|
||||
fail_if (strcmp (g_quark_to_string (quark), "custom-success"));
|
||||
|
||||
ret = GST_FLOW_CUSTOM_ERROR - 2;
|
||||
fail_unless (GST_FLOW_IS_FATAL (ret));
|
||||
fail_if (GST_FLOW_IS_SUCCESS (ret));
|
||||
fail_if (strcmp (gst_flow_get_name (ret), "custom-error"));
|
||||
quark = gst_flow_to_quark (ret);
|
||||
fail_if (strcmp (g_quark_to_string (quark), "custom-error"));
|
||||
|
||||
/* unknown values */
|
||||
ret = GST_FLOW_CUSTOM_ERROR + 2;
|
||||
fail_unless (GST_FLOW_IS_FATAL (ret));
|
||||
fail_if (GST_FLOW_IS_SUCCESS (ret));
|
||||
fail_if (strcmp (gst_flow_get_name (ret), "unknown"));
|
||||
quark = gst_flow_to_quark (ret);
|
||||
fail_unless (quark == 0);
|
||||
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
Suite *
|
||||
gst_pad_suite (void)
|
||||
|
@ -398,6 +459,8 @@ gst_pad_suite (void)
|
|||
tcase_add_test (tc_chain, test_name_is_valid);
|
||||
tcase_add_test (tc_chain, test_push_unlinked);
|
||||
tcase_add_test (tc_chain, test_push_linked);
|
||||
tcase_add_test (tc_chain, test_flowreturn);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue