| 1 |
/* gstreamermm - a C++ wrapper for gstreamer |
| 2 |
* |
| 3 |
* Copyright 2008-2016 The gstreamermm Development Team |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the Free |
| 17 |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <gst/gst.h> |
| 21 |
#include <glibmm/interface.h> |
| 22 |
#include <gstreamermm/enums.h> |
| 23 |
#include <glibmm/arrayhandle.h> |
| 24 |
#include <cstdio> |
| 25 |
_DEFS(gstreamermm,gst) |
| 26 |
|
| 27 |
namespace Gst |
| 28 |
{ |
| 29 |
|
| 30 |
class Element; |
| 31 |
|
| 32 |
_WRAP_ENUM(URIType, GstURIType) |
| 33 |
_WRAP_ENUM(URIError, GstURIError) |
| 34 |
|
| 35 |
/** An interface to ease URI handling in plugins. |
| 36 |
* The Gst::URIHandler is an interface that is implemented by Source and Sink |
| 37 |
* Gst::Element to simplify then handling of URI. |
| 38 |
* |
| 39 |
* An application can use the following functions to quickly get an element |
| 40 |
* that handles the given URI for reading or writing (make_element_from_uri()). |
| 41 |
* |
| 42 |
* Source and Sink plugins should implement this interface when possible. |
| 43 |
* |
| 44 |
* Last reviewed on 2016-08-27 (1.8.0) |
| 45 |
* @ingroup GstInterfaces |
| 46 |
*/ |
| 47 |
class URIHandler : public Glib::Interface |
| 48 |
{ |
| 49 |
_CLASS_INTERFACE(URIHandler, GstURIHandler, GST_URI_HANDLER, GstURIHandlerInterface) |
| 50 |
|
| 51 |
public: |
| 52 |
_WRAP_METHOD(static bool protocol_is_valid(const Glib::ustring& protocol), gst_uri_protocol_is_valid) |
| 53 |
_WRAP_METHOD(static bool protocol_is_supported(const Gst::URIType type, const Glib::ustring& protocol), gst_uri_protocol_is_supported) |
| 54 |
_WRAP_METHOD(static bool uri_is_valid(const Glib::ustring& uri), gst_uri_is_valid) |
| 55 |
_WRAP_METHOD(static bool uri_has_protocol(const Glib::ustring& uri, const Glib::ustring& protocol), gst_uri_has_protocol) |
| 56 |
_WRAP_METHOD(static Glib::ustring get_protocol(const Glib::ustring& uri), gst_uri_get_protocol) |
| 57 |
_WRAP_METHOD(static Glib::ustring get_location(const Glib::ustring& uri), gst_uri_get_location) |
| 58 |
_WRAP_METHOD(static Glib::ustring construct_uri(const Glib::ustring& protocol, const Glib::ustring& location), gst_uri_construct) |
| 59 |
_WRAP_METHOD(static Glib::ustring filename_to_uri(const Glib::ustring& filename), gst_filename_to_uri, errthrow) |
| 60 |
_WRAP_METHOD(static Glib::RefPtr<Gst::Element> make_element_from_uri(const Gst::URIType type, const Glib::ustring& uri, const Glib::ustring& name), gst_element_make_from_uri, errthrow) |
| 61 |
|
| 62 |
_WRAP_METHOD(URIType get_uri_type() const, gst_uri_handler_get_uri_type) |
| 63 |
|
| 64 |
#m4 _CONVERSION(`const gchar* const*',`std::vector<Glib::ustring>',`Glib::ArrayHandler<Glib::ustring>::array_to_vector($3, Glib::OWNERSHIP_NONE)') |
| 65 |
_WRAP_METHOD(std::vector<Glib::ustring> get_protocols() const, gst_uri_handler_get_protocols) |
| 66 |
|
| 67 |
_WRAP_METHOD(Glib::ustring get_uri() const, gst_uri_handler_get_uri) |
| 68 |
_WRAP_METHOD(bool set_uri(const Glib::ustring& uri), gst_uri_handler_set_uri, errthrow) |
| 69 |
|
| 70 |
#m4 _CONVERSION(`Glib::ustring', `const gchar*', `($3).c_str()') |
| 71 |
|
| 72 |
/** Virtual method which should be implemented to return the URI currently |
| 73 |
* handled by the element. |
| 74 |
*/ |
| 75 |
_WRAP_VFUNC(Glib::ustring get_uri() const, "get_uri") |
| 76 |
|
| 77 |
/** Virtual method which should be implemented to set a new URI. |
| 78 |
*/ |
| 79 |
_WRAP_VFUNC(bool set_uri(const Glib::ustring& uri, GError** error), "set_uri") |
| 80 |
|
| 81 |
/** |
| 82 |
* Method to return the list of protocols handled by the element. |
| 83 |
*/ |
| 84 |
virtual const gchar * const * get_protocols_vfunc() const; |
| 85 |
|
| 86 |
/** |
| 87 |
* Method to tell whether the element handles source or sink URI. |
| 88 |
*/ |
| 89 |
virtual URIType get_type_vfunc(); |
| 90 |
|
| 91 |
|
| 92 |
protected: |
| 93 |
#m4begin |
| 94 |
_PUSH(SECTION_PCC_CLASS_INIT_VFUNCS) |
| 95 |
klass->get_type = &get_type_vfunc_callback; |
| 96 |
klass->get_protocols = &get_protocols_vfunc_callback; |
| 97 |
_SECTION(SECTION_PH_VFUNCS) |
| 98 |
static GstURIType get_type_vfunc_callback(GType type); |
| 99 |
static const gchar * const * get_protocols_vfunc_callback(GType type); |
| 100 |
_POP() |
| 101 |
#m4end |
| 102 |
}; |
| 103 |
|
| 104 |
} // namespace Gst |