Debian Codegraph @

gstreamer/gstreamermm/urihandler.h

raw symbols SCIP
1 // Generated by gmmproc 2.50.1 -- DO NOT MODIFY!
2 #ifndef _GSTREAMERMM_URIHANDLER_H
3 #define _GSTREAMERMM_URIHANDLER_H
4
5
6 #include <glibmm/ustring.h>
7 #include <sigc++/sigc++.h>
8
9 /* gstreamermm - a C++ wrapper for gstreamer
10 *
11 * Copyright 2008-2016 The gstreamermm Development Team
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free
25 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */
27
28 #include <gst/gst.h>
29 #include <glibmm/interface.h>
30 #include <gstreamermm/enums.h>
31 #include <glibmm/arrayhandle.h>
32 #include <cstdio>
33
34
35 #ifndef DOXYGEN_SHOULD_SKIP_THIS
36 using GstURIHandler = struct _GstURIHandler;
37 using GstURIHandlerClass = struct _GstURIHandlerClass;
38 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
39
40
41 #ifndef DOXYGEN_SHOULD_SKIP_THIS
42 namespace Gst
43 { class URIHandler_Class; } // namespace Gst
44 #endif // DOXYGEN_SHOULD_SKIP_THIS
45
46 namespace Gst
47 {
48
49 class Element;
50
51 /** @addtogroup gstreamermmEnums gstreamermm Enums and Flags */
52
53 /**
54 * @var URIType URI_UNKNOWN
55 * The URI direction is unknown.
56 *
57 * @var URIType URI_SINK
58 * The URI is a consumer.
59 *
60 * @var URIType URI_SRC
61 * The URI is a producer.
62 *
63 * @enum URIType
64 *
65 * The different types of URI direction.
66 *
67 * @ingroup gstreamermmEnums
68 */
69 enum URIType
70 {
71 URI_UNKNOWN,
72 URI_SINK,
73 URI_SRC
74 };
75
76 } // namespace Gst
77
78 #ifndef DOXYGEN_SHOULD_SKIP_THIS
79 namespace Glib
80 {
81
82 template <>
83 class Value<Gst::URIType> : public Glib::Value_Enum<Gst::URIType>
84 {
85 public:
86 static GType value_type() G_GNUC_CONST;
87 };
88
89 } // namespace Glib
90 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
91
92 namespace Gst
93 {
94
95 /**
96 * @var URIError URI_ERROR_UNSUPPORTED_PROTOCOL
97 * The protocol is not supported.
98 *
99 * @var URIError URI_ERROR_BAD_URI
100 * There was a problem with the URI.
101 *
102 * @var URIError URI_ERROR_BAD_STATE
103 * Could not set or change the URI because the
104 * URI handler was in a state where that is not possible or not permitted.
105 *
106 * @var URIError URI_ERROR_BAD_REFERENCE
107 * There was a problem with the entity that
108 * the URI references.
109 *
110 * @enum URIError
111 *
112 * Different URI-related errors that can occur.
113 *
114 * @ingroup gstreamermmEnums
115 */
116 enum URIError
117 {
118 URI_ERROR_UNSUPPORTED_PROTOCOL,
119 URI_ERROR_BAD_URI,
120 URI_ERROR_BAD_STATE,
121 URI_ERROR_BAD_REFERENCE
122 };
123
124 } // namespace Gst
125
126 #ifndef DOXYGEN_SHOULD_SKIP_THIS
127 namespace Glib
128 {
129
130 template <>
131 class Value<Gst::URIError> : public Glib::Value_Enum<Gst::URIError>
132 {
133 public:
134 static GType value_type() G_GNUC_CONST;
135 };
136
137 } // namespace Glib
138 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
139
140 namespace Gst
141 {
142
143
144 /** An interface to ease URI handling in plugins.
145 * The Gst::URIHandler is an interface that is implemented by Source and Sink
146 * Gst::Element to simplify then handling of URI.
147 *
148 * An application can use the following functions to quickly get an element
149 * that handles the given URI for reading or writing (make_element_from_uri()).
150 *
151 * Source and Sink plugins should implement this interface when possible.
152 *
153 * Last reviewed on 2016-08-27 (1.8.0)
154 * @ingroup GstInterfaces
155 */
156
157 class URIHandler : public Glib::Interface
158 {
159
160 #ifndef DOXYGEN_SHOULD_SKIP_THIS
161
162 public:
163 using CppObjectType = URIHandler;
164 using CppClassType = URIHandler_Class;
165 using BaseObjectType = GstURIHandler;
166 using BaseClassType = GstURIHandlerInterface;
167
168 // noncopyable
169 URIHandler(const URIHandler&) = delete;
170 URIHandler& operator=(const URIHandler&) = delete;
171
172 private:
173 friend class URIHandler_Class;
174 static CppClassType urihandler_class_;
175
176 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
177 protected:
178 /**
179 * You should derive from this class to use it.
180 */
181 URIHandler();
182
183 #ifndef DOXYGEN_SHOULD_SKIP_THIS
184 /** Called by constructors of derived classes. Provide the result of
185 * the Class init() function to ensure that it is properly
186 * initialized.
187 *
188 * @param interface_class The Class object for the derived type.
189 */
190 explicit URIHandler(const Glib::Interface_Class& interface_class);
191
192 public:
193 // This is public so that C++ wrapper instances can be
194 // created for C instances of unwrapped types.
195 // For instance, if an unexpected C type implements the C interface.
196 explicit URIHandler(GstURIHandler* castitem);
197
198 protected:
199 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
200
201 public:
202
203 URIHandler(URIHandler&& src) noexcept;
204 URIHandler& operator=(URIHandler&& src) noexcept;
205
206 ~URIHandler() noexcept override;
207
208 static void add_interface(GType gtype_implementer);
209
210 /** Get the GType for this class, for use with the underlying GObject type system.
211 */
212 static GType get_type() G_GNUC_CONST;
213
214 #ifndef DOXYGEN_SHOULD_SKIP_THIS
215 static GType get_base_type() G_GNUC_CONST;
216 #endif
217
218 ///Provides access to the underlying C GObject.
219 GstURIHandler* gobj() { return reinterpret_cast<GstURIHandler*>(gobject_); }
220
221 ///Provides access to the underlying C GObject.
222 const GstURIHandler* gobj() const { return reinterpret_cast<GstURIHandler*>(gobject_); }
223
224 private:
225
226
227 public:
228
229 /** Tests if the given string is a valid protocol identifier. Protocols
230 * must consist of alphanumeric characters, '+', '-' and '.' and must
231 * start with a alphabetic character. See RFC 3986 Section 3.1.
232 *
233 * @param protocol A string.
234 * @return <tt>true</tt> if the string is a valid protocol identifier, <tt>false</tt> otherwise.
235 */
236 static bool protocol_is_valid(const Glib::ustring& protocol);
237
238 /** Checks if an element exists that supports the given URI protocol. Note
239 * that a positive return value does not imply that a subsequent call to
240 * Gst::Element::make_from_uri() is guaranteed to work.
241 *
242 * @param type Whether to check for a source or a sink.
243 * @param protocol Protocol that should be checked for (e.g. "http" or "smb").
244 * @return <tt>true</tt>.
245 */
246 static bool protocol_is_supported(const Gst::URIType type, const Glib::ustring& protocol);
247
248 /** Tests if the given string is a valid URI identifier. URIs start with a valid
249 * scheme followed by ":" and maybe a string identifying the location.
250 *
251 * @param uri A URI string.
252 * @return <tt>true</tt> if the string is a valid URI.
253 */
254 static bool uri_is_valid(const Glib::ustring& uri);
255
256 /** Checks if the protocol of a given valid URI matches @a protocol.
257 *
258 * @param uri A URI string.
259 * @param protocol A protocol string (e.g. "http").
260 * @return <tt>true</tt> if the protocol matches.
261 */
262 static bool uri_has_protocol(const Glib::ustring& uri, const Glib::ustring& protocol);
263
264 /** Extracts the protocol out of a given valid URI.
265 *
266 * @param uri A URI string.
267 * @return The protocol for this URI.
268 */
269 static Glib::ustring get_protocol(const Glib::ustring& uri);
270
271 /** Extracts the location out of a given valid URI, ie. the protocol and "://"
272 * are stripped from the URI, which means that the location returned includes
273 * the hostname if one is specified.
274 *
275 * Free-function: g_free
276 *
277 * @param uri A URI string.
278 * @return The location for this URI. Returns <tt>nullptr</tt> if the
279 * URI isn't valid. If the URI does not contain a location, an empty
280 * string is returned.
281 */
282 static Glib::ustring get_location(const Glib::ustring& uri);
283
284 /** Constructs a URI for a given valid protocol and location.
285 *
286 * @param protocol Protocol for URI.
287 * @param location Location for URI.
288 * @return A new string for this URI. Returns <tt>nullptr</tt> if the
289 * given URI protocol is not valid, or the given location is <tt>nullptr</tt>.
290 */
291 static Glib::ustring construct_uri(const Glib::ustring& protocol, const Glib::ustring& location);
292
293 /** Similar to Glib::filename_to_uri(), but attempts to handle relative file paths
294 * as well. Before converting @a filename into an URI, it will be prefixed by
295 * the current working directory if it is a relative path, and then the path
296 * will be canonicalised so that it doesn't contain any './' or '../' segments.
297 *
298 * On Windows #filename should be in UTF-8 encoding.
299 *
300 * @param filename Absolute or relative file name path.
301 * @return Newly-allocated URI string, or <tt>nullptr</tt> on error.
302 */
303 static Glib::ustring filename_to_uri(const Glib::ustring& filename);
304
305 /** Creates an element for handling the given URI.
306 *
307 * @param type Whether to create a source or a sink.
308 * @param uri URI to create an element for.
309 * @param name Name of created element, can be <tt>nullptr</tt>.
310 * @return A new element or <tt>nullptr</tt> if none could be created.
311 */
312 static Glib::RefPtr<Gst::Element> make_element_from_uri(const Gst::URIType type, const Glib::ustring& uri, const Glib::ustring& name);
313
314
315 /** Gets the type of the given URI handler
316 *
317 * @return The Gst::URIType of the URI handler.
318 * Returns Gst::URI_UNKNOWN if the @a handler isn't implemented correctly.
319 */
320 URIType get_uri_type() const;
321
322
323 /** Gets the list of protocols supported by @a handler. This list may not be
324 * modified.
325 *
326 * @return The
327 * supported protocols. Returns <tt>nullptr</tt> if the @a handler isn't
328 * implemented properly, or the @a handler doesn't support any
329 * protocols.
330 */
331 std::vector<Glib::ustring> get_protocols() const;
332
333
334 /** Gets the currently handled URI.
335 *
336 * @return The URI currently handled by
337 * the @a handler. Returns <tt>nullptr</tt> if there are no URI currently
338 * handled.
339 */
340 Glib::ustring get_uri() const;
341
342 /** Tries to set the URI of the given handler.
343 *
344 * @param uri URI to set.
345 * @return <tt>true</tt> if the URI was set successfully, else <tt>false</tt>.
346 */
347 bool set_uri(const Glib::ustring& uri);
348
349
350 /** Virtual method which should be implemented to return the URI currently
351 * handled by the element.
352 */
353 virtual Glib::ustring get_uri_vfunc() const;
354
355
356 /** Virtual method which should be implemented to set a new URI.
357 */
358 virtual bool set_uri_vfunc(const Glib::ustring& uri, GError** error);
359
360
361 /**
362 * Method to return the list of protocols handled by the element.
363 */
364 virtual const gchar * const * get_protocols_vfunc() const;
365
366 /**
367 * Method to tell whether the element handles source or sink URI.
368 */
369 virtual URIType get_type_vfunc();
370
371
372 protected:
373
374
375 public:
376
377 public:
378 //C++ methods used to invoke GTK+ virtual functions:
379
380 protected:
381 //GTK+ Virtual Functions (override these to change behaviour):
382
383 //Default Signal Handlers::
384
385
386 };
387
388 } // namespace Gst
389
390
391 namespace Glib
392 {
393 /** A Glib::wrap() method for this object.
394 *
395 * @param object The C instance.
396 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
397 * @result A C++ instance that wraps this C instance.
398 *
399 * @relates Gst::URIHandler
400 */
401 Glib::RefPtr<Gst::URIHandler> wrap(GstURIHandler* object, bool take_copy = false);
402
403 } // namespace Glib
404
405
406 #endif /* _GSTREAMERMM_URIHANDLER_H */
407