| 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 <gstreamermm/bus.h> |
| 22 |
#include <gstreamermm/caps.h> |
| 23 |
#include <gstreamermm/elementfactory.h> |
| 24 |
#include <gstreamermm/event.h> |
| 25 |
#include <gstreamermm/pad.h> |
| 26 |
#include <gstreamermm/padtemplate.h> |
| 27 |
#include <gstreamermm/query.h> |
| 28 |
#include <gstreamermm/iterator.h> |
| 29 |
#include <gstreamermm/handle_error.h> |
| 30 |
|
| 31 |
_PINCLUDE(gstreamermm/private/object_p.h) |
| 32 |
|
| 33 |
namespace Gst |
| 34 |
{ |
| 35 |
|
| 36 |
namespace Enums |
| 37 |
{ |
| 38 |
|
| 39 |
Glib::ustring get_name(State s) |
| 40 |
{ |
| 41 |
return gst_element_state_get_name(GstState(s)); |
| 42 |
} |
| 43 |
|
| 44 |
Glib::ustring get_name(StateChangeReturn s) |
| 45 |
{ |
| 46 |
return gst_element_state_change_return_get_name(GstStateChangeReturn(s)); |
| 47 |
} |
| 48 |
|
| 49 |
} //namespace Enums |
| 50 |
|
| 51 |
Glib::RefPtr<Gst::Element> Element::link(const Glib::RefPtr<Gst::Element>& dest) |
| 52 |
{ |
| 53 |
if(!dest) |
| 54 |
gstreamermm_handle_error("Failed to link null element."); |
| 55 |
|
| 56 |
const bool result = gst_element_link(gobj(), Glib::unwrap(dest)); |
| 57 |
|
| 58 |
if(result) |
| 59 |
return dest; |
| 60 |
else |
| 61 |
{ |
| 62 |
gstreamermm_handle_error("failed to link: " + get_name() + "->" + |
| 63 |
dest->get_name()); |
| 64 |
return Glib::RefPtr<Gst::Element>(); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
Glib::RefPtr<Gst::Element> Element::link(const Glib::RefPtr<Gst::Element>& dest, const Glib::RefPtr<Gst::Caps>& filter) |
| 69 |
{ |
| 70 |
if(!dest) |
| 71 |
gstreamermm_handle_error("Failed to link null element."); |
| 72 |
|
| 73 |
const bool result = gst_element_link_filtered(gobj(), Glib::unwrap(dest), |
| 74 |
Glib::unwrap(filter)); |
| 75 |
|
| 76 |
if(result) |
| 77 |
return dest; |
| 78 |
else |
| 79 |
{ |
| 80 |
gstreamermm_handle_error("failed to link: " + get_name() + "->" + |
| 81 |
dest->get_name()); |
| 82 |
return Glib::RefPtr<Gst::Element>(); |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
void Element::post_message(int code, int line, MessageType type, |
| 87 |
const Glib::QueryQuark& domain, const Glib::ustring& text, |
| 88 |
const Glib::ustring& debug, const Glib::ustring& file, |
| 89 |
const Glib::ustring& function) |
| 90 |
{ |
| 91 |
gchar* gst_text = g_strdup(text.c_str()); |
| 92 |
gchar* gst_debug = g_strdup(debug.c_str()); |
| 93 |
|
| 94 |
gst_element_message_full(gobj(), static_cast<GstMessageType>(type), |
| 95 |
domain, code, gst_text, gst_debug, file.c_str(), function.c_str(), line); |
| 96 |
} |
| 97 |
|
| 98 |
bool Element::send_event(const Glib::RefPtr<Gst::Event>& event) |
| 99 |
{ |
| 100 |
event->reference(); |
| 101 |
return gst_element_send_event(gobj(), Glib::unwrap(event)); |
| 102 |
} |
| 103 |
|
| 104 |
Glib::RefPtr<Gst::PadTemplate> Gst::Element::get_pad_template(const Glib::ustring &factory_name) const |
| 105 |
{ |
| 106 |
return Glib::wrap(gst_element_class_get_pad_template(GST_ELEMENT_GET_CLASS(gobject_), factory_name.c_str()), true); |
| 107 |
} |
| 108 |
|
| 109 |
} //namespace Gst |