/* gstreamermm - a C++ wrapper for gstreamer
 *
 * Copyright 2011 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 <glibmm/object.h>
#include <gstreamermm/clock.h>
#include <gst/pbutils/pbutils.h>

_DEFS(gstreamermm,gst)

namespace Gst
{

class DiscovererInfo;

/** Discoverer - Utility for discovering information on URIs.
 * The Discoverer is a utility object which allows to get as much information
 * as possible from one or many URIs.
 *
 * It provides two APIs, allowing usage in blocking or non-blocking mode.
 *
 * The blocking mode just requires calling discover_uri() with the URI one
 * wishes to discover.
 *
 * The non-blocking mode requires a running Glib::MainLoop in the default
 * Glib::MainContext, where one connects to the various signals, appends the
 * URIs to be processed (through discover_uri_async()) and then asks for the
 * discovery to begin (through start()).
 *
 * All the information is returned in a DiscovererInfo structure.
 */
class Discoverer : public Glib::Object 
{
  _CLASS_GOBJECT(Discoverer, GstDiscoverer, GST_DISCOVERER, Glib::Object, GObject)

protected:
  explicit Discoverer(ClockTime timeout);

public:
  _WRAP_METHOD_DOCS_ONLY(gst_discoverer_new, errthrow)
  _WRAP_CREATE(ClockTime timeout)

  _WRAP_METHOD(void start(), gst_discoverer_start)
  _WRAP_METHOD(void stop(), gst_discoverer_stop)
  _WRAP_METHOD(Glib::RefPtr<DiscovererInfo> discover_uri(const Glib::ustring& uri), gst_discoverer_discover_uri, errthrow)
  _WRAP_METHOD(bool discover_uri_async(const Glib::ustring& uri), gst_discoverer_discover_uri_async)

  _WRAP_PROPERTY("timeout", guint64)

#m4 _CONVERSION(`GstDiscovererInfo*', `const Glib::RefPtr<DiscovererInfo>&', `Glib::wrap($3,true)')
#m4 _CONVERSION(`const GError*', `const Glib::Error&', `Glib::Error(const_cast<GError*>($3), true)')
  _WRAP_SIGNAL(void discovered(const Glib::RefPtr<DiscovererInfo>& info, const Glib::Error& error), "discovered")

  _WRAP_SIGNAL(void finished(), "finished")
  _WRAP_SIGNAL(void starting(), "starting")
};

} //namespace Gst
