/* gstreamermm - a C++ wrapper for gstreamer
 *
 * Copyright 2008 The gstreamermm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <gst/gstghostpad.h>
#include <gstreamermm/padtemplate.h>

_PINCLUDE(gstreamermm/private/pad_p.h)

namespace Gst
{

GhostPad::GhostPad(const Glib::ustring& name,
  const Glib::RefPtr<Gst::Pad>& target)
  : _CONSTRUCT("name", name.c_str(),
    "direction", (GstPadDirection) target->get_direction())
{
  if (!gst_ghost_pad_construct(gobj()) ||
    !gst_ghost_pad_set_target(gobj(), target->gobj()))
  {
    g_warning("Gst::GhostPad::GhostPad(const Glib::ustring&,"
      " const Glib::RefPtr<Gst::Pad>&): "
      "Unsuccessful construction of ghost pad (name = %s, target = %s).",
      name.c_str(), target->get_name().c_str());
  }
}

GhostPad::GhostPad(const Glib::ustring& name, PadDirection direction)
  : _CONSTRUCT("name", name.c_str(), "direction", (GstPadDirection) direction)
{
  if (!gst_ghost_pad_construct(gobj()))
  {
    g_warning("Gst::GhostPad::GhostPad(const Glib::ustring&, PadDirection):"
    " Unsuccessful construction of ghost pad (name = %s, direction = %d).",
    name.c_str(), direction);
  }
}

GhostPad::GhostPad(const Glib::ustring& name,
  const Glib::RefPtr<Gst::Pad>& target,
  const Glib::RefPtr<Gst::PadTemplate>& templ)
  : _CONSTRUCT("name", name.c_str(), "direction",
    (GstPadDirection) target->get_direction(), "template", templ->gobj())
{
  if (!gst_ghost_pad_construct(gobj()) ||
    !gst_ghost_pad_set_target(gobj(), target->gobj()))
  {
    g_warning("Gst::GhostPad::GhostPad(const Glib::ustring&,"
      " const Glib::RefPtr<Gst::Pad>&, const Glib::RefPtr<Gst::PadTemplate>&):"
        " Unsuccessful construction of ghost pad "
        "(name = %s, target = %s, templ = %s).",
        name.c_str(), target->get_name().c_str(),
        templ->get_name_template().c_str());
  }
}

GhostPad::GhostPad(const Glib::ustring& name,
  const Glib::RefPtr<Gst::PadTemplate>& templ)
  : _CONSTRUCT("name", name.c_str(), "direction", 
    (GstPadDirection) templ->get_direction(), "template", templ->gobj())
{
  if (!gst_ghost_pad_construct(gobj()))
  {
    g_warning("Gst::GhostPad::GhostPad(const Glib::ustring&,"
      " const Glib::RefPtr<Gst::PadTemplate>&): "
      "Unsuccessful construction of ghost pad (name = %s, templ = %s).",
      name.c_str(), templ->get_name_template().c_str());
  }
}

} //namespace Gst
