Debian Codegraph @

gstreamer/src/ghostpad.ccg

raw
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 <sstream>
21 #include <gst/gst.h>
22 #include <gstreamermm/padtemplate.h>
23 #include <gstreamermm/handle_error.h>
24
25 _PINCLUDE(gstreamermm/private/pad_p.h)
26
27 namespace Gst
28 {
29
30 GhostPad::GhostPad(const Glib::RefPtr<Gst::Pad>& target,
31 const Glib::ustring& name)
32 : _CONSTRUCT("name", (name.empty() ? static_cast<char*>(0) : name.c_str()),
33 "direction",
34 (target ? ((GstPadDirection) target->get_direction()) : GST_PAD_UNKNOWN))
35 {
36 if(!target)
37 gstreamermm_handle_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
38 " const Glib::RefPtr<Gst::Pad>&): "
39 "Failed to construct ghost pad (name = " + name + ") from null target.");
40
41 if(!gst_ghost_pad_construct(gobj()) ||
42 !gst_ghost_pad_set_target(gobj(), target->gobj()))
43 {
44 gstreamermm_handle_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
45 " const Glib::RefPtr<Gst::Pad>&): "
46 "Unsuccessful construction of ghost pad (name = " + name +
47 ", target = " + target->get_name() + ").");
48 }
49 }
50
51 GhostPad::GhostPad( PadDirection direction, const Glib::ustring& name)
52 : _CONSTRUCT("name", (name.empty() ? static_cast<char*>(0) : name.c_str()),
53 "direction", static_cast<GstPadDirection>(direction))
54 {
55 if(!gst_ghost_pad_construct(gobj()))
56 {
57 std::stringstream int_conv_stream;
58 int_conv_stream << direction;
59
60 gstreamermm_handle_error("Gst::GhostPad::GhostPad(const Glib::ustring&, "
61 "PadDirection): Unsuccessful construction of ghost pad (name = " +
62 name + ", direction = " + int_conv_stream.str() + ").");
63 }
64 }
65
66 GhostPad::GhostPad( const Glib::RefPtr<Gst::Pad>& target,
67 const Glib::RefPtr<Gst::PadTemplate>& templ,
68 const Glib::ustring& name)
69 : _CONSTRUCT("name", (name.empty() ? static_cast<char*>(0) : name.c_str()),
70 "direction",
71 (target ? static_cast<GstPadDirection>(target->get_direction()) : GST_PAD_UNKNOWN),
72 "template", Glib::unwrap(templ))
73 {
74 if(!target || !templ)
75 gstreamermm_handle_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
76 " const Glib::RefPtr<Gst::Pad>&, const Glib::RefPtr<Gst::PadTemplate>&):"
77 " Failed to construct ghost pad (name = " + name + ") from null "
78 "target or template.");
79
80 if(!gst_ghost_pad_construct(gobj()) ||
81 !gst_ghost_pad_set_target(gobj(), target->gobj()))
82 {
83 gstreamermm_handle_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
84 " const Glib::RefPtr<Gst::Pad>&, const Glib::RefPtr<Gst::PadTemplate>&):"
85 " Unsuccessful construction of ghost pad (name = " + name +
86 ", target = " + target->get_name() + ", templ = " +
87 templ->get_name_template() + ").");
88 }
89 }
90
91 GhostPad::GhostPad( const Glib::RefPtr<Gst::PadTemplate>& templ,
92 const Glib::ustring& name)
93 : _CONSTRUCT("name", (name.empty() ? static_cast<char*>(0) : name.c_str()),
94 "direction", (templ ? static_cast<GstPadDirection>(templ->get_direction()) : GST_PAD_UNKNOWN),
95 "template", Glib::unwrap(templ))
96 {
97 if(!templ)
98 gstreamermm_handle_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
99 " const Glib::RefPtr<Gst::PadTemplate>&): "
100 "Failed to construct ghost pad (name = " + name +
101 ") from null template.");
102
103 if(!gst_ghost_pad_construct(gobj()))
104 {
105 gstreamermm_handle_error("Gst::GhostPad::GhostPad(const Glib::ustring&,"
106 " const Glib::RefPtr<Gst::PadTemplate>&): "
107 "Unsuccessful construction of ghost pad (name = " + name +
108 ", templ = " + templ->get_name_template() + ").");
109 }
110 }
111
112 } //namespace Gst