// Path: src/org/gstreamer/lowlevel/GstNative.java
// @SuppressWarnings("serial")
// public final class GstNative {
//     // gstreamer library names the files one of libfoo-0.10 and libfoo-1.0
//     private static String[] nameFormats = { /*"%s-0.10",*/ "%s-1.0" };
// 
//     private GstNative() {}
//     
//     private static final Map<String, Object> options = new HashMap<String, Object>() {{
//         put(Library.OPTION_TYPE_MAPPER, new GTypeMapper());
//         put(Library.OPTION_FUNCTION_MAPPER, new GFunctionMapper());
//     }};
// 
//     public static <T extends Library> T load(Class<T> interfaceClass) {
//         return load("gstreamer", interfaceClass);
//     }
// 
//     public static <T extends Library> T load(String libraryName, Class<T> interfaceClass) {
//         for (String format : nameFormats)
//             try {
//                 return GNative.loadLibrary(String.format(format, libraryName), interfaceClass, options);
//             } catch (UnsatisfiedLinkError ex) {
//                 continue;
//             }
//         throw new UnsatisfiedLinkError("Could not load library: " + libraryName);
//     }
// }


import org.gstreamer.Query;
import org.gstreamer.lowlevel.GstNative;
import com.sun.jna.Pointer;
import org.gstreamer.Format;
/* 
 * Copyright (C) 2008 Wayne Meissner
 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
 *                    2000 Wim Taymans <wim.taymans@chello.be>
 *                    2005 Wim Taymans <wim@fluendo.com>
 *
 * This file is part of gstreamer-java.
 *
 * This code is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License version 3 only, as
 * published by the Free Software Foundation.
 *
 * This code 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
 * version 3 for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with this work.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.gstreamer.query;



/**
 * Used to query an element for the current position in the stream.
 */
public class PositionQuery extends Query {
    private static interface API extends com.sun.jna.Library { 
        /* position query */
        Pointer ptr_gst_query_new_position(Format format);
        void gst_query_set_position(Query query, Format format, /* gint64 */ long cur);
        void gst_query_parse_position(Query query, int[] format, /* gint64 * */ long[] cur);
    }
    private static final API gst = GstNative.load(API.class);
    
    public PositionQuery(Initializer init) {
        super(init);
    }
    
    /**
     * Constructs a new query stream position query object. A position query is 
     * used to query the current position of playback in the streams, in some format.
     * 
     * @param format the default {@link Format} for the new query
     */
    public PositionQuery(Format format) {
        super(initializer(gst.ptr_gst_query_new_position(format)));
    }
    
    /**
     * Answers a position query by setting the requested value in the given format.
     * 
     * @param format the requested {@link Format}
     * @param position the position to set in the answer
     */
    public void setPosition(Format format, long position) {
        gst.gst_query_set_position(this, format, position);
    }
    
    /**
     * Gets the {@link Format} of this position query.
     * 
     * @return The format of the query.
     */
    public Format getFormat() {
// Path: src/org/gstreamer/lowlevel/GstNative.java
// @SuppressWarnings("serial")
// public final class GstNative {
//     // gstreamer library names the files one of libfoo-0.10 and libfoo-1.0
//     private static String[] nameFormats = { /*"%s-0.10",*/ "%s-1.0" };
// 
//     private GstNative() {}
//     
//     private static final Map<String, Object> options = new HashMap<String, Object>() {{
//         put(Library.OPTION_TYPE_MAPPER, new GTypeMapper());
//         put(Library.OPTION_FUNCTION_MAPPER, new GFunctionMapper());
//     }};
// 
//     public static <T extends Library> T load(Class<T> interfaceClass) {
//         return load("gstreamer", interfaceClass);
//     }
// 
//     public static <T extends Library> T load(String libraryName, Class<T> interfaceClass) {
//         for (String format : nameFormats)
//             try {
//                 return GNative.loadLibrary(String.format(format, libraryName), interfaceClass, options);
//             } catch (UnsatisfiedLinkError ex) {
//                 continue;
//             }
//         throw new UnsatisfiedLinkError("Could not load library: " + libraryName);
//     }
// }


// Path: src/org/gstreamer/query/PositionQuery.java
import org.gstreamer.Query;
import org.gstreamer.lowlevel.GstNative;
import com.sun.jna.Pointer;
import org.gstreamer.Format;

/* 
 * Copyright (C) 2008 Wayne Meissner
 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
 *                    2000 Wim Taymans <wim.taymans@chello.be>
 *                    2005 Wim Taymans <wim@fluendo.com>
 *
 * This file is part of gstreamer-java.
 *
 * This code is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License version 3 only, as
 * published by the Free Software Foundation.
 *
 * This code 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
 * version 3 for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with this work.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.gstreamer.query;



/**
 * Used to query an element for the current position in the stream.
 */
public class PositionQuery extends Query {
    private static interface API extends com.sun.jna.Library { 
        /* position query */
        Pointer ptr_gst_query_new_position(Format format);
        void gst_query_set_position(Query query, Format format, /* gint64 */ long cur);
        void gst_query_parse_position(Query query, int[] format, /* gint64 * */ long[] cur);
    }
    private static final API gst = GstNative.load(API.class);
    
    public PositionQuery(Initializer init) {
        super(init);
    }
    
    /**
     * Constructs a new query stream position query object. A position query is 
     * used to query the current position of playback in the streams, in some format.
     * 
     * @param format the default {@link Format} for the new query
     */
    public PositionQuery(Format format) {
        super(initializer(gst.ptr_gst_query_new_position(format)));
    }
    
    /**
     * Answers a position query by setting the requested value in the given format.
     * 
     * @param format the requested {@link Format}
     * @param position the position to set in the answer
     */
    public void setPosition(Format format, long position) {
        gst.gst_query_set_position(this, format, position);
    }
    
    /**
     * Gets the {@link Format} of this position query.
     * 
     * @return The format of the query.
     */
    public Format getFormat() {
        int[] fmt = new int[1];