gst/gsterror.*: document
[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_NEGOTIATION: used for negotiation-related errors.
49  * @GST_CORE_ERROR_EVENT: used for event-related errors.
50  * @GST_CORE_ERROR_SEEK: used for seek-related errors.
51  * @GST_CORE_ERROR_CAPS: used for caps-related errors.
52  * @GST_CORE_ERROR_TAG: used for negotiation-related errors.
53  * @GST_CORE_ERROR_NUM_ERRORS: the number of core error types.
54  *
55  * Core errors are errors inside the core GStreamer library.
56  */
57 /* FIXME: should we divide in numerical blocks so we can easily add
58           for example PAD errors later ? */
59 typedef enum
60 {
61   GST_CORE_ERROR_FAILED = 1,
62   GST_CORE_ERROR_TOO_LAZY,
63   GST_CORE_ERROR_NOT_IMPLEMENTED,
64   GST_CORE_ERROR_STATE_CHANGE,
65   GST_CORE_ERROR_PAD,
66   GST_CORE_ERROR_THREAD,
67   GST_CORE_ERROR_NEGOTIATION,
68   GST_CORE_ERROR_EVENT,
69   GST_CORE_ERROR_SEEK,
70   GST_CORE_ERROR_CAPS,
71   GST_CORE_ERROR_TAG,
72   GST_CORE_ERROR_NUM_ERRORS
73 } GstCoreError;
74
75 /**
76  * GstLibraryError:
77  * @GST_LIBRARY_ERROR_FAILED: a general error which doesn't fit in any other
78  * category.  Make sure you add a custom message to the error call.
79  * @GST_LIBRARY_ERROR_TOO_LAZY: do not use this except as a placeholder for
80  * deciding where to go while developing code.
81  * @GST_LIBRARY_ERROR_INIT: used when the library could not be opened.
82  * @GST_LIBRARY_ERROR_SHUTDOWN: used when the library could not be closed.
83  * @GST_LIBRARY_ERROR_SETTINGS: used when the library doesn't accept settings.
84  * @GST_LIBRARY_ERROR_ENCODE: used when the library generated an encoding error.
85  * @GST_LIBRARY_ERROR_NUM_ERRORS: the number of library error types.
86  *
87  * Library errors are for errors from the library being used by elements
88  * (initializing, finalizing, settings, ...)
89  */
90 typedef enum
91 {
92   GST_LIBRARY_ERROR_FAILED = 1,
93   GST_LIBRARY_ERROR_TOO_LAZY,
94   GST_LIBRARY_ERROR_INIT,
95   GST_LIBRARY_ERROR_SHUTDOWN,
96   GST_LIBRARY_ERROR_SETTINGS,
97   GST_LIBRARY_ERROR_ENCODE,
98   GST_LIBRARY_ERROR_NUM_ERRORS
99 } GstLibraryError;
100
101 /**
102  * GstResourceError:
103  * @GST_RESOURCE_ERROR_FAILED: a general error which doesn't fit in any other
104  * category.  Make sure you add a custom message to the error call.
105  * @GST_RESOURCE_ERROR_TOO_LAZY: do not use this except as a placeholder for
106  * deciding where to go while developing code.
107  * @GST_RESOURCE_ERROR_NOT_FOUND: used when the resource could not be found.
108  * @GST_RESOURCE_ERROR_BUSY: used when resource is busy.
109  * @GST_RESOURCE_ERROR_OPEN_READ: used when resource fails to open for reading.
110  * @GST_RESOURCE_ERROR_OPEN_WRITE: used when resource fails to open for writing.
111  * @GST_RESOURCE_ERROR_OPEN_READ_WRITE: used when resource cannot be opened for
112  * both reading and writing, or either (but unspecified which).
113  * @GST_RESOURCE_ERROR_CLOSE: used when the resource can't be closed.
114  * @GST_RESOURCE_ERROR_READ: used when the resource can't be read from.
115  * @GST_RESOURCE_ERROR_WRITE: used when the resource can't be written to.
116  * @GST_RESOURCE_ERROR_SEEK: used when a seek on the resource fails.
117  * @GST_RESOURCE_ERROR_SYNC: used when a synchronize on the resource fails.
118  * @GST_RESOURCE_ERROR_SETTINGS: used when settings can't be manipulated on
119  * @GST_RESOURCE_ERROR_NUM_ERRORS: the number of library error types.
120  *
121  * Resource errors are for any resource used by an element:
122  * memory, files, network connections, process space, ...
123  * They're typically used by source and sink elements.
124  */
125 typedef enum
126 {
127   GST_RESOURCE_ERROR_FAILED = 1,
128   GST_RESOURCE_ERROR_TOO_LAZY,
129   GST_RESOURCE_ERROR_NOT_FOUND,
130   GST_RESOURCE_ERROR_BUSY,
131   GST_RESOURCE_ERROR_OPEN_READ,
132   GST_RESOURCE_ERROR_OPEN_WRITE,
133   GST_RESOURCE_ERROR_OPEN_READ_WRITE,
134   GST_RESOURCE_ERROR_CLOSE,
135   GST_RESOURCE_ERROR_READ,
136   GST_RESOURCE_ERROR_WRITE,
137   GST_RESOURCE_ERROR_SEEK,
138   GST_RESOURCE_ERROR_SYNC,
139   GST_RESOURCE_ERROR_SETTINGS,
140   GST_RESOURCE_ERROR_NUM_ERRORS
141 } GstResourceError;
142
143 /**
144  * GstStreamError:
145  * @GST_STREAM_ERROR_FAILED: a general error which doesn't fit in any other
146  * category.  Make sure you add a custom message to the error call.
147  * @GST_STREAM_ERROR_TOO_LAZY: do not use this except as a placeholder for
148  * deciding where to go while developing code.
149  * @GST_STREAM_ERROR_NOT_IMPLEMENTED: use this when you do not want to implement
150  * this functionality yet.
151  * @GST_STREAM_ERROR_TYPE_NOT_FOUND: used when the element doesn't know the
152  * stream's type.
153  * @GST_STREAM_ERROR_WRONG_TYPE: used when the element doesn't handle this type
154  * of stream.
155  * @GST_STREAM_ERROR_CODEC_NOT_FOUND: used when there's no codec to handle the
156  * stream's type.
157  * @GST_STREAM_ERROR_DECODE: used when decoding fails.
158  * @GST_STREAM_ERROR_ENCODE: used when encoding fails.
159  * @GST_STREAM_ERROR_DEMUX: used when demuxing fails.
160  * @GST_STREAM_ERROR_MUX: used when muxing fails.
161  * @GST_STREAM_ERROR_FORMAT: used when the stream is of the wrong format
162  * (for example, wrong caps).
163  * @GST_STREAM_ERROR_NUM_ERRORS: the number of library error types.
164  *
165  * Stream errors are for anything related to the stream being processed:
166  * format errors, media type errors, ...
167  * They're typically used by decoders, demuxers, converters, ...
168  */
169 typedef enum
170 {
171   GST_STREAM_ERROR_FAILED = 1,
172   GST_STREAM_ERROR_TOO_LAZY,
173   GST_STREAM_ERROR_NOT_IMPLEMENTED,
174   GST_STREAM_ERROR_TYPE_NOT_FOUND,
175   GST_STREAM_ERROR_WRONG_TYPE,
176   GST_STREAM_ERROR_CODEC_NOT_FOUND,
177   GST_STREAM_ERROR_DECODE,
178   GST_STREAM_ERROR_ENCODE,
179   GST_STREAM_ERROR_DEMUX,
180   GST_STREAM_ERROR_MUX,
181   GST_STREAM_ERROR_FORMAT,
182   GST_STREAM_ERROR_NUM_ERRORS
183 } GstStreamError;
184
185 #define GST_TYPE_G_ERROR    (gst_g_error_get_type ())
186
187 /**
188  * GST_LIBRARY_ERROR:
189  *
190  * Error domain for library loading. Errors in this domain will
191  * be from the #GstLibraryError enumeration.
192  * See #GError for information on error domains.
193  */
194 #define GST_LIBRARY_ERROR   gst_library_error_quark ()
195 /**
196  * GST_RESOURCE_ERROR:
197  *
198  * Error domain for resource handling. Errors in this domain will
199  * be from the #GstResourceError enumeration.
200  * See #GError for information on error domains.
201  */
202 #define GST_RESOURCE_ERROR  gst_resource_error_quark ()
203 /**
204  * GST_CORE_ERROR:
205  *
206  * Error domain for core system. Errors in this domain will
207  * be from the #GstCoreError enumeration.
208  * See #GError for information on error domains.
209  */
210 #define GST_CORE_ERROR      gst_core_error_quark ()
211 /**
212  * GST_STREAM_ERROR:
213  *
214  * Error domain for media stream processing. Errors in this domain will
215  * be from the #GstStreamError enumeration.
216  * See #GError for information on error domains.
217  */
218 #define GST_STREAM_ERROR    gst_stream_error_quark ()
219
220 /**
221  * GST_ERROR_SYSTEM:
222  *
223  * Returns a string using errno describing the previously failed system
224  * call.  To be used as the debug argument in #GST_ELEMENT_ERROR.
225  */
226 #define GST_ERROR_SYSTEM    ("system error: %s", g_strerror (errno))
227
228 GType gst_g_error_get_type (void);
229 gchar *gst_error_get_message (GQuark domain, gint code);
230 GQuark gst_stream_error_quark (void);
231 GQuark gst_core_error_quark (void);
232 GQuark gst_resource_error_quark (void);
233 GQuark gst_library_error_quark (void);
234
235 G_END_DECLS
236 #endif /* __GST_ERROR_H__ */