/*
 *  This file is part of the WebKit open source project.
 *  This file has been generated by generate-bindings.pl. DO NOT MODIFY!
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 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
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public License
 *  along with this library; see the file COPYING.LIB.  If not, write to
 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 *  Boston, MA 02110-1301, USA.
 */

#include "config.h"
#include "WebKitDOMVideoPlaybackQuality.h"

#include "CSSImportRule.h"
#include "DOMObjectCache.h"
#include "Document.h"
#include "ExceptionCode.h"
#include "JSMainThreadExecState.h"
#include "WebKitDOMPrivate.h"
#include "WebKitDOMVideoPlaybackQualityPrivate.h"
#include "gobject/ConvertToUTF8String.h"
#include <wtf/GetPtr.h>
#include <wtf/RefPtr.h>

#define WEBKIT_DOM_VIDEO_PLAYBACK_QUALITY_GET_PRIVATE(obj) G_TYPE_INSTANCE_GET_PRIVATE(obj, WEBKIT_TYPE_DOM_VIDEO_PLAYBACK_QUALITY, WebKitDOMVideoPlaybackQualityPrivate)

typedef struct _WebKitDOMVideoPlaybackQualityPrivate {
#if ENABLE(MEDIA_SOURCE)
    RefPtr<WebCore::VideoPlaybackQuality> coreObject;
#endif // ENABLE(MEDIA_SOURCE)
} WebKitDOMVideoPlaybackQualityPrivate;

#if ENABLE(MEDIA_SOURCE)

namespace WebKit {

WebKitDOMVideoPlaybackQuality* kit(WebCore::VideoPlaybackQuality* obj)
{
    if (!obj)
        return 0;

    if (gpointer ret = DOMObjectCache::get(obj))
        return WEBKIT_DOM_VIDEO_PLAYBACK_QUALITY(ret);

    return wrapVideoPlaybackQuality(obj);
}

WebCore::VideoPlaybackQuality* core(WebKitDOMVideoPlaybackQuality* request)
{
    return request ? static_cast<WebCore::VideoPlaybackQuality*>(WEBKIT_DOM_OBJECT(request)->coreObject) : 0;
}

WebKitDOMVideoPlaybackQuality* wrapVideoPlaybackQuality(WebCore::VideoPlaybackQuality* coreObject)
{
    ASSERT(coreObject);
    return WEBKIT_DOM_VIDEO_PLAYBACK_QUALITY(g_object_new(WEBKIT_TYPE_DOM_VIDEO_PLAYBACK_QUALITY, "core-object", coreObject, NULL));
}

} // namespace WebKit

#endif // ENABLE(MEDIA_SOURCE)

G_DEFINE_TYPE(WebKitDOMVideoPlaybackQuality, webkit_dom_video_playback_quality, WEBKIT_TYPE_DOM_OBJECT)

enum {
    PROP_0,
    PROP_CREATION_TIME,
    PROP_TOTAL_VIDEO_FRAMES,
    PROP_DROPPED_VIDEO_FRAMES,
    PROP_CORRUPTED_VIDEO_FRAMES,
    PROP_TOTAL_FRAME_DELAY,
};

static void webkit_dom_video_playback_quality_finalize(GObject* object)
{
    WebKitDOMVideoPlaybackQualityPrivate* priv = WEBKIT_DOM_VIDEO_PLAYBACK_QUALITY_GET_PRIVATE(object);
#if ENABLE(MEDIA_SOURCE)
    WebKit::DOMObjectCache::forget(priv->coreObject.get());
#endif // ENABLE(MEDIA_SOURCE)
    priv->~WebKitDOMVideoPlaybackQualityPrivate();
    G_OBJECT_CLASS(webkit_dom_video_playback_quality_parent_class)->finalize(object);
}

static void webkit_dom_video_playback_quality_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec)
{
    WebCore::JSMainThreadNullState state;
#if ENABLE(MEDIA_SOURCE)
    WebKitDOMVideoPlaybackQuality* self = WEBKIT_DOM_VIDEO_PLAYBACK_QUALITY(object);
    WebCore::VideoPlaybackQuality* coreSelf = WebKit::core(self);
#endif // ENABLE(MEDIA_SOURCE)
    switch (propertyId) {
    case PROP_CREATION_TIME: {
#if ENABLE(MEDIA_SOURCE)
        g_value_set_double(value, coreSelf->creationTime());
#else
        WEBKIT_WARN_FEATURE_NOT_PRESENT("Media Source")
#endif /* ENABLE(MEDIA_SOURCE) */
        break;
    }
    case PROP_TOTAL_VIDEO_FRAMES: {
#if ENABLE(MEDIA_SOURCE)
        g_value_set_ulong(value, coreSelf->totalVideoFrames());
#else
        WEBKIT_WARN_FEATURE_NOT_PRESENT("Media Source")
#endif /* ENABLE(MEDIA_SOURCE) */
        break;
    }
    case PROP_DROPPED_VIDEO_FRAMES: {
#if ENABLE(MEDIA_SOURCE)
        g_value_set_ulong(value, coreSelf->droppedVideoFrames());
#else
        WEBKIT_WARN_FEATURE_NOT_PRESENT("Media Source")
#endif /* ENABLE(MEDIA_SOURCE) */
        break;
    }
    case PROP_CORRUPTED_VIDEO_FRAMES: {
#if ENABLE(MEDIA_SOURCE)
        g_value_set_ulong(value, coreSelf->corruptedVideoFrames());
#else
        WEBKIT_WARN_FEATURE_NOT_PRESENT("Media Source")
#endif /* ENABLE(MEDIA_SOURCE) */
        break;
    }
    case PROP_TOTAL_FRAME_DELAY: {
#if ENABLE(MEDIA_SOURCE)
        g_value_set_double(value, coreSelf->totalFrameDelay());
#else
        WEBKIT_WARN_FEATURE_NOT_PRESENT("Media Source")
#endif /* ENABLE(MEDIA_SOURCE) */
        break;
    }
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
        break;
    }
}

static GObject* webkit_dom_video_playback_quality_constructor(GType type, guint constructPropertiesCount, GObjectConstructParam* constructProperties)
{
    GObject* object = G_OBJECT_CLASS(webkit_dom_video_playback_quality_parent_class)->constructor(type, constructPropertiesCount, constructProperties);
#if ENABLE(MEDIA_SOURCE)
    WebKitDOMVideoPlaybackQualityPrivate* priv = WEBKIT_DOM_VIDEO_PLAYBACK_QUALITY_GET_PRIVATE(object);
    priv->coreObject = static_cast<WebCore::VideoPlaybackQuality*>(WEBKIT_DOM_OBJECT(object)->coreObject);
    WebKit::DOMObjectCache::put(priv->coreObject.get(), object);
#endif // ENABLE(MEDIA_SOURCE)
    return object;
}

static void webkit_dom_video_playback_quality_class_init(WebKitDOMVideoPlaybackQualityClass* requestClass)
{
    GObjectClass* gobjectClass = G_OBJECT_CLASS(requestClass);
    g_type_class_add_private(gobjectClass, sizeof(WebKitDOMVideoPlaybackQualityPrivate));
    gobjectClass->constructor = webkit_dom_video_playback_quality_constructor;
    gobjectClass->finalize = webkit_dom_video_playback_quality_finalize;
    gobjectClass->get_property = webkit_dom_video_playback_quality_get_property;

    g_object_class_install_property(
        gobjectClass,
        PROP_CREATION_TIME,
        g_param_spec_double(
            "creation-time",
            "VideoPlaybackQuality:creation-time",
            "read-only gdouble VideoPlaybackQuality:creation-time",
            -G_MAXDOUBLE, G_MAXDOUBLE, 0,
            WEBKIT_PARAM_READABLE));

    g_object_class_install_property(
        gobjectClass,
        PROP_TOTAL_VIDEO_FRAMES,
        g_param_spec_ulong(
            "total-video-frames",
            "VideoPlaybackQuality:total-video-frames",
            "read-only gulong VideoPlaybackQuality:total-video-frames",
            0, G_MAXULONG, 0,
            WEBKIT_PARAM_READABLE));

    g_object_class_install_property(
        gobjectClass,
        PROP_DROPPED_VIDEO_FRAMES,
        g_param_spec_ulong(
            "dropped-video-frames",
            "VideoPlaybackQuality:dropped-video-frames",
            "read-only gulong VideoPlaybackQuality:dropped-video-frames",
            0, G_MAXULONG, 0,
            WEBKIT_PARAM_READABLE));

    g_object_class_install_property(
        gobjectClass,
        PROP_CORRUPTED_VIDEO_FRAMES,
        g_param_spec_ulong(
            "corrupted-video-frames",
            "VideoPlaybackQuality:corrupted-video-frames",
            "read-only gulong VideoPlaybackQuality:corrupted-video-frames",
            0, G_MAXULONG, 0,
            WEBKIT_PARAM_READABLE));

    g_object_class_install_property(
        gobjectClass,
        PROP_TOTAL_FRAME_DELAY,
        g_param_spec_double(
            "total-frame-delay",
            "VideoPlaybackQuality:total-frame-delay",
            "read-only gdouble VideoPlaybackQuality:total-frame-delay",
            -G_MAXDOUBLE, G_MAXDOUBLE, 0,
            WEBKIT_PARAM_READABLE));

}

static void webkit_dom_video_playback_quality_init(WebKitDOMVideoPlaybackQuality* request)
{
    WebKitDOMVideoPlaybackQualityPrivate* priv = WEBKIT_DOM_VIDEO_PLAYBACK_QUALITY_GET_PRIVATE(request);
    new (priv) WebKitDOMVideoPlaybackQualityPrivate();
}

gdouble webkit_dom_video_playback_quality_get_creation_time(WebKitDOMVideoPlaybackQuality* self)
{
#if ENABLE(MEDIA_SOURCE)
    WebCore::JSMainThreadNullState state;
    g_return_val_if_fail(WEBKIT_DOM_IS_VIDEO_PLAYBACK_QUALITY(self), 0);
    WebCore::VideoPlaybackQuality* item = WebKit::core(self);
    gdouble result = item->creationTime();
    return result;
#else
    WEBKIT_WARN_FEATURE_NOT_PRESENT("Media Source")
    return static_cast<gdouble>(0);
#endif /* ENABLE(MEDIA_SOURCE) */
}

gulong webkit_dom_video_playback_quality_get_total_video_frames(WebKitDOMVideoPlaybackQuality* self)
{
#if ENABLE(MEDIA_SOURCE)
    WebCore::JSMainThreadNullState state;
    g_return_val_if_fail(WEBKIT_DOM_IS_VIDEO_PLAYBACK_QUALITY(self), 0);
    WebCore::VideoPlaybackQuality* item = WebKit::core(self);
    gulong result = item->totalVideoFrames();
    return result;
#else
    WEBKIT_WARN_FEATURE_NOT_PRESENT("Media Source")
    return static_cast<gulong>(0);
#endif /* ENABLE(MEDIA_SOURCE) */
}

gulong webkit_dom_video_playback_quality_get_dropped_video_frames(WebKitDOMVideoPlaybackQuality* self)
{
#if ENABLE(MEDIA_SOURCE)
    WebCore::JSMainThreadNullState state;
    g_return_val_if_fail(WEBKIT_DOM_IS_VIDEO_PLAYBACK_QUALITY(self), 0);
    WebCore::VideoPlaybackQuality* item = WebKit::core(self);
    gulong result = item->droppedVideoFrames();
    return result;
#else
    WEBKIT_WARN_FEATURE_NOT_PRESENT("Media Source")
    return static_cast<gulong>(0);
#endif /* ENABLE(MEDIA_SOURCE) */
}

gulong webkit_dom_video_playback_quality_get_corrupted_video_frames(WebKitDOMVideoPlaybackQuality* self)
{
#if ENABLE(MEDIA_SOURCE)
    WebCore::JSMainThreadNullState state;
    g_return_val_if_fail(WEBKIT_DOM_IS_VIDEO_PLAYBACK_QUALITY(self), 0);
    WebCore::VideoPlaybackQuality* item = WebKit::core(self);
    gulong result = item->corruptedVideoFrames();
    return result;
#else
    WEBKIT_WARN_FEATURE_NOT_PRESENT("Media Source")
    return static_cast<gulong>(0);
#endif /* ENABLE(MEDIA_SOURCE) */
}

gdouble webkit_dom_video_playback_quality_get_total_frame_delay(WebKitDOMVideoPlaybackQuality* self)
{
#if ENABLE(MEDIA_SOURCE)
    WebCore::JSMainThreadNullState state;
    g_return_val_if_fail(WEBKIT_DOM_IS_VIDEO_PLAYBACK_QUALITY(self), 0);
    WebCore::VideoPlaybackQuality* item = WebKit::core(self);
    gdouble result = item->totalFrameDelay();
    return result;
#else
    WEBKIT_WARN_FEATURE_NOT_PRESENT("Media Source")
    return static_cast<gdouble>(0);
#endif /* ENABLE(MEDIA_SOURCE) */
}

