/* gstreamermm - a C++ wrapper for gstreamer
 *
 * Copyright 2008-2016 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/gst.h>

namespace Gst
{

const ClockTime CLOCK_TIME_NONE = GST_CLOCK_TIME_NONE;
const ClockTime SECOND = GST_SECOND;
const ClockTime MILLI_SECOND = GST_MSECOND;
const ClockTime MICRO_SECOND = GST_USECOND;
const ClockTime NANO_SECOND = GST_NSECOND;


guint get_hours(ClockTime time)
{
  return GST_CLOCK_TIME_IS_VALID (time) ? time / (GST_SECOND * 60 * 60) : 99;
}

guint get_minutes(ClockTime time)
{
  return GST_CLOCK_TIME_IS_VALID (time) ? (time / (GST_SECOND * 60)) % 60 : 99;
}

guint get_seconds(ClockTime time)
{
  return GST_CLOCK_TIME_IS_VALID (time) ? (time / GST_SECOND) % 60 : 99;
}

guint get_milliseconds(ClockTime time)
{
  return GST_CLOCK_TIME_IS_VALID (time) ? (time / GST_MSECOND) % 1000 : 999;
}

guint get_microseconds(ClockTime time)
{
  return GST_CLOCK_TIME_IS_VALID (time) ? (time / GST_USECOND) % 1000 : 999;
}

guint get_nanoseconds(ClockTime time)
{
  return GST_CLOCK_TIME_IS_VALID (time) ?  (time / GST_NSECOND) % 1000 : 999;
}

guint get_fractional_seconds(ClockTime time)
{
  return GST_CLOCK_TIME_IS_VALID (time) ? time % GST_SECOND : 999999999;
}

} //namespace Gst
