flesh out error descriptions
[platform/upstream/gstreamer.git] / gst / gsterror.h
1 /* GStreamer
2  * Copyright (C) 2004 Thomas Vander Stichele <thomas at apestaart dot org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __GST_ERROR_H__
21 #define __GST_ERROR_H__
22
23 #include <glib.h>
24 #include <glib-object.h>
25 #include <errno.h>
26
27 G_BEGIN_DECLS
28 /*
29  * we define FIXME error domains:
30  * GST_CORE_ERROR
31  * GST_LIBRARY_ERROR
32  * GST_RESOURCE_ERROR
33  * GST_STREAM_ERROR
34  *
35  * Check GError API docs for rationale for naming.
36  */
37 /**
38  * GstCoreError:
39  * @GST_CORE_ERROR_FAILED: a general error which doesn't fit in any other
40  * category.  Make sure you add a custom message to the error call.
41  * @GST_CORE_ERROR_TOO_LAZY: do not use this except as a placeholder for
42  * deciding where to go while developing code.
43  * @GST_CORE_ERROR_NOT_IMPLEMENTED: use this when you do not want to implement
44  * this functionality yet.
45  * @GST_CORE_ERROR_STATE_CHANGE: used for state change errors.
46  * @GST_CORE_ERROR_PAD: used for pad-related errors.
47  * @GST_CORE_ERROR_THREAD: used for thread-related errors.
48  * @GST_CORE_ERROR_SCHEDULER: used for scheduler-related errors.
49  * @GST_CORE_ERROR_NEGOTIATION: used for negotiation-related errors.
50  * @GST_CORE_ERROR_EVENT: used for event-related errors.
51  * @GST_CORE_ERROR_SEEK: used for seek-related errors.
52  * @GST_CORE_ERROR_CAPS: used for caps-related errors.
53  * @GST_CORE_ERROR_TAG: used for negotiation-related errors.
54  * @GST_CORE_ERROR_NUM_ERRORS: the number of core error types.
55  *
56  * Core errors are errors inside the core GStreamer library.
57  * the core GStreamer library
58  */
59 /* FIXME: should we divide in numerical blocks so we can easily add
60           for example PAD errors later ? */
61 typedef enum
62 {
63   GST_CORE_ERROR_FAILED = 1,
64   GST_CORE_ERROR_TOO_LAZY,
65   GST_CORE_ERROR_NOT_IMPLEMENTED,
66   GST_CORE_ERROR_STATE_CHANGE,
67   GST_CORE_ERROR_PAD,
68   GST_CORE_ERROR_THREAD,
69   GST_CORE_ERROR_SCHEDULER,
70   GST_CORE_ERROR_NEGOTIATION,
71   GST_CORE_ERROR_EVENT,
72   GST_CORE_ERROR_SEEK,
73   GST_CORE_ERROR_CAPS,
74   GST_CORE_ERROR_TAG,
75   GST_CORE_ERROR_NUM_ERRORS
76 } GstCoreError;
77
78 /**
79  * GstLibraryError:
80  * @GST_LIBRARY_ERROR_FAILED: a general error which doesn't fit in any other
81  * category.  Make sure you add a custom message to the error call.
82  * @GST_LIBRARY_ERROR_TOO_LAZY: do not use this except as a placeholder for
83  * deciding where to go while developing code.
84  * @GST_LIBRARY_ERROR_INIT: used when the library could not be opened.
85  * @GST_LIBRARY_ERROR_SHUTDOWN: used when the library could not be closed.
86  * @GST_LIBRARY_ERROR_SETTINGS: used when the library doesn't accept settings.
87  * @GST_LIBRARY_ERROR_ENCODE: used when the library generated an encoding error.
88  * @GST_LIBRARY_ERROR_NUM_ERRORS: the number of library error types.
89  *
90  * Library errors are for errors from the library being used by elements
91  * (initializing, finalizing, settings, ...)
92  */
93 typedef enum
94 {
95   GST_LIBRARY_ERROR_FAILED = 1,
96   GST_LIBRARY_ERROR_TOO_LAZY,
97   GST_LIBRARY_ERROR_INIT,
98   GST_LIBRARY_ERROR_SHUTDOWN,
99   GST_LIBRARY_ERROR_SETTINGS,
100   GST_LIBRARY_ERROR_ENCODE,
101   GST_LIBRARY_ERROR_NUM_ERRORS
102 } GstLibraryError;
103
104 /**
105  * GstResourceError:
106  * @GST_RESOURCE_ERROR_FAILED: a general error which doesn't fit in any other
107  * category.  Make sure you add a custom message to the error call.
108  * @GST_RESOURCE_ERROR_TOO_LAZY: do not use this except as a placeholder for
109  * deciding where to go while developing code.
110  * @GST_RESOURCE_ERROR_NOT_FOUND: used when the resource could not be found.
111  * @GST_RESOURCE_ERROR_BUSY: used when resource is busy.
112  * @GST_RESOURCE_ERROR_OPEN_READ: used when resource fails to open for reading.
113  * @GST_RESOURCE_ERROR_OPEN_WRITE: used when resource fails to open for writing.
114  * @GST_RESOURCE_ERROR_OPEN_READ_WRITE: used when resource cannot be opened for
115  * both reading and writing, or either (but unspecified which).
116  * @GST_RESOURCE_ERROR_CLOSE: used when the resource can't be closed.
117  * @GST_RESOURCE_ERROR_READ: used when the resource can't be read from.
118  * @GST_RESOURCE_ERROR_WRITE: used when the resource can't be written to.
119  * @GST_RESOURCE_ERROR_SEEK: used when a seek on the resource fails.
120  * @GST_RESOURCE_ERROR_SYNC: used when a synchronize on the resource fails.
121  * @GST_RESOURCE_ERROR_SETTINGS: used when settings can't be manipulated on
122  * @GST_RESOURCE_ERROR_NUM_ERRORS: the number of library error types.
123  *
124  * Resource errors are for any resource used by an element:
125  * memory, files, network connections, process space, ...
126  * They're typically used by source and sink elements.
127  */
128 typedef enum
129 {
130   GST_RESOURCE_ERROR_FAILED = 1,
131   GST_RESOURCE_ERROR_TOO_LAZY,
132   GST_RESOURCE_ERROR_NOT_FOUND,
133   GST_RESOURCE_ERROR_BUSY,
134   GST_RESOURCE_ERROR_OPEN_READ,
135   GST_RESOURCE_ERROR_OPEN_WRITE,
136   GST_RESOURCE_ERROR_OPEN_READ_WRITE,
137   GST_RESOURCE_ERROR_CLOSE,
138   GST_RESOURCE_ERROR_READ,
139   GST_RESOURCE_ERROR_WRITE,
140   GST_RESOURCE_ERROR_SEEK,
141   GST_RESOURCE_ERROR_SYNC,
142   GST_RESOURCE_ERROR_SETTINGS,
143   GST_RESOURCE_ERROR_NUM_ERRORS
144 } GstResourceError;
145
146 /**
147  * GstStreamError:
148  * @GST_STREAM_ERROR_FAILED: a general error which doesn't fit in any other
149  * category.  Make sure you add a custom message to the error call.
150  * @GST_STREAM_ERROR_TOO_LAZY: do not use this except as a placeholder for
151  * deciding where to go while developing code.
152  * @GST_STREAM_ERROR_NOT_IMPLEMENTED: use this when you do not want to implement
153  * this functionality yet.
154  * @GST_STREAM_ERROR_TYPE_NOT_FOUND: used when the element doesn't know the
155  * stream's type.
156  * @GST_STREAM_ERROR_WRONG_TYPE: used when the element doesn't handle this type
157  * of stream.
158  * @GST_STREAM_ERROR_CODEC_NOT_FOUND: used when there's no codec to handle the
159  * stream's type.
160  * @GST_STREAM_ERROR_DECODE: used when decoding fails.
161  * @GST_STREAM_ERROR_ENCODE: used when encoding fails.
162  * @GST_STREAM_ERROR_DEMUX: used when demuxing fails.
163  * @GST_STREAM_ERROR_MUX: used when muxing fails.
164  * @GST_STREAM_ERROR_FORMAT: used when the stream is of the wrong format
165  * (for example, wrong caps).
166  * @GST_STREAM_ERROR_NUM_ERRORS: the number of library error types.
167  *
168  * Stream errors are for anything related to the stream being processed:
169  * format errors, media type errors, ...
170  * They're typically used by decoders, demuxers, converters, ...
171  */
172 typedef enum
173 {
174   GST_STREAM_ERROR_FAILED = 1,
175   GST_STREAM_ERROR_TOO_LAZY,
176   GST_STREAM_ERROR_NOT_IMPLEMENTED,
177   GST_STREAM_ERROR_TYPE_NOT_FOUND,
178   GST_STREAM_ERROR_WRONG_TYPE,
179   GST_STREAM_ERROR_CODEC_NOT_FOUND,
180   GST_STREAM_ERROR_DECODE,
181   GST_STREAM_ERROR_ENCODE,
182   GST_STREAM_ERROR_DEMUX,
183   GST_STREAM_ERROR_MUX,
184   GST_STREAM_ERROR_FORMAT,
185   GST_STREAM_ERROR_NUM_ERRORS
186 } GstStreamError;
187
188 /* This should go away once we convinced glib people to register GError */
189 #define GST_TYPE_G_ERROR    (gst_g_error_get_type ())
190
191 #define GST_LIBRARY_ERROR   gst_library_error_quark ()
192 #define GST_RESOURCE_ERROR  gst_resource_error_quark ()
193 #define GST_CORE_ERROR      gst_core_error_quark ()
194 #define GST_STREAM_ERROR    gst_stream_error_quark ()
195
196 #define GST_ERROR_SYSTEM    ("system error: %s", g_strerror (errno))
197
198 GType gst_g_error_get_type (void);
199 gchar *gst_error_get_message (GQuark domain, gint code);
200 GQuark gst_stream_error_quark (void);
201 GQuark gst_core_error_quark (void);
202 GQuark gst_resource_error_quark (void);
203 GQuark gst_library_error_quark (void);
204
205 G_END_DECLS
206 #endif /* __GST_ERROR_H__ */