Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/org/freedesktop/gstreamer/Bin.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

import com.sun.jna.Pointer;
import java.util.List;
import org.freedesktop.gstreamer.glib.Natives;
import org.freedesktop.gstreamer.lowlevel.GstAPI.GstCallback;
import org.freedesktop.gstreamer.lowlevel.GstTypes;

/**
* Base class and element that can contain other elements.
Expand Down Expand Up @@ -86,7 +86,7 @@ protected Bin(Initializer init) {
* Creates a new Bin with a unique name.
*/
public Bin() {
this(initializer(GSTBIN_API.ptr_gst_bin_new(null), false));
this(Natives.initializer(GSTBIN_API.ptr_gst_bin_new(null), false, true));
}

/**
Expand All @@ -95,7 +95,7 @@ public Bin() {
* @param name The Name to assign to the new Bin
*/
public Bin(String name) {
this(initializer(GSTBIN_API.ptr_gst_bin_new(name), false));
this(Natives.initializer(GSTBIN_API.ptr_gst_bin_new(name), false, true));
}

/**
Expand Down Expand Up @@ -227,16 +227,16 @@ public Element getElementByNameRecurseUp(String name) {
return GSTBIN_API.gst_bin_get_by_name_recurse_up(this, name);
}

/**
* Looks for an element inside the bin that implements the given interface.
* If such an element is found, it returns the element.
*
* @param iface The class of the {@link Element} to search for.
* @return The {@link Element} that implements the interface.
*/
public <T extends Element> T getElementByInterface(Class<T> iface) {
return iface.cast(GSTBIN_API.gst_bin_get_by_interface(this, GstTypes.typeFor(iface)));
}
// /**
// * Looks for an element inside the bin that implements the given interface.
// * If such an element is found, it returns the element.
// *
// * @param iface The class of the {@link Element} to search for.
// * @return The {@link Element} that implements the interface.
// */
// public <T extends Element> T getElementByInterface(Class<T> iface) {
// return iface.cast(GSTBIN_API.gst_bin_get_by_interface(this, GstTypes.typeFor(iface)));
// }

/**
* Calls {@link #debugToDotFile(int, String, boolean)} without timestamping
Expand Down
7 changes: 4 additions & 3 deletions src/org/freedesktop/gstreamer/Buffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.sun.jna.Pointer;
import java.util.EnumSet;
import org.freedesktop.gstreamer.glib.NativeFlags;
import org.freedesktop.gstreamer.glib.Natives;

/**
* Buffers are the basic unit of data transfer in GStreamer. They contain the
Expand All @@ -53,7 +54,7 @@ public class Buffer extends MiniObject {
* Creates a newly allocated buffer without any data.
*/
public Buffer() {
this(initializer(GSTBUFFER_API.ptr_gst_buffer_new()));
this(Natives.initializer(GSTBUFFER_API.ptr_gst_buffer_new()));
}

/**
Expand All @@ -66,13 +67,13 @@ public Buffer() {
* @param size
*/
public Buffer(int size) {
this(initializer(allocBuffer(size)));
this(Natives.initializer(allocBuffer(size)));
}

Buffer(Initializer init) {
super(init);
mapInfo = new MapInfoStruct();
struct = new BufferStruct(handle());
struct = new BufferStruct(getRawPointer());
}

private static Pointer allocBuffer(int size) {
Expand Down
5 changes: 3 additions & 2 deletions src/org/freedesktop/gstreamer/BufferPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.freedesktop.gstreamer.lowlevel.GstBufferPoolAPI;

import com.sun.jna.Pointer;
import org.freedesktop.gstreamer.glib.Natives;

/**
* A BufferPool is an object that can be used to pre-allocate and recycle
Expand All @@ -38,7 +39,7 @@ public class BufferPool extends GstObject {
* Creates a new instance of BufferPool
*/
public BufferPool() {
this(initializer(GstBufferPoolAPI.GSTBUFFERPOOL_API.ptr_gst_buffer_pool_new()));
this(Natives.initializer(GstBufferPoolAPI.GSTBUFFERPOOL_API.ptr_gst_buffer_pool_new()));
}

/**
Expand Down Expand Up @@ -71,7 +72,7 @@ public Caps getCaps() {
Structure config = GstBufferPoolAPI.GSTBUFFERPOOL_API.gst_buffer_pool_get_config(this);
Pointer[] ptr = new Pointer[1];
GstBufferPoolAPI.GSTBUFFERPOOL_API.gst_buffer_pool_config_get_params(config, ptr, null, null, null);
return new Caps(new Initializer(ptr[0], false, true));
return new Caps(Natives.initializer(ptr[0], false, true));
}

}
9 changes: 4 additions & 5 deletions src/org/freedesktop/gstreamer/Bus.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.sun.jna.Callback;
Expand All @@ -36,6 +35,7 @@
import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
import java.util.Locale;
import org.freedesktop.gstreamer.glib.Natives;

import org.freedesktop.gstreamer.lowlevel.GstAPI.GErrorStruct;
import org.freedesktop.gstreamer.lowlevel.GstBusAPI;
Expand All @@ -44,7 +44,6 @@
import static org.freedesktop.gstreamer.lowlevel.GlibAPI.GLIB_API;
import static org.freedesktop.gstreamer.lowlevel.GstBusAPI.GSTBUS_API;
import static org.freedesktop.gstreamer.lowlevel.GstMessageAPI.GSTMESSAGE_API;
import static org.freedesktop.gstreamer.lowlevel.GstMiniObjectAPI.GSTMINIOBJECT_API;

/**
* The {@link Bus} is an object responsible for delivering {@link Message}s in a
Expand Down Expand Up @@ -84,7 +83,6 @@ public class Bus extends GstObject {
public static final String GTYPE_NAME = "GstBus";

private static final Logger LOG = Logger.getLogger(Bus.class.getName());
private static final Level LOG_DEBUG = Level.FINE;

private final Object lock = new Object();
private Map<Class<?>, Map<Object, MessageProxy>> signalListeners;
Expand Down Expand Up @@ -505,7 +503,7 @@ public void connect(final TAG listener) {
public boolean callback(Bus bus, Message msg, Pointer user_data) {
PointerByReference list = new PointerByReference();
GSTMESSAGE_API.gst_message_parse_tag(msg, list);
TagList tl = new TagList(TagList.initializer(list.getValue()));
TagList tl = new TagList(Natives.initializer(list.getValue()));
listener.tagsFound(msg.getSource(), tl);
return true;
}
Expand Down Expand Up @@ -741,7 +739,8 @@ public void run() {
// Unref the message, since we are dropping it.
// (the normal GC will drop other refs to it)
//
GSTMINIOBJECT_API.gst_mini_object_unref(msg);
// GSTMINIOBJECT_API.gst_mini_object_unref(msg);
Natives.unref(msg);
return BusSyncReply.DROP;
}
};
Expand Down
26 changes: 13 additions & 13 deletions src/org/freedesktop/gstreamer/Caps.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/
package org.freedesktop.gstreamer;

import com.sun.jna.Pointer;

import org.freedesktop.gstreamer.glib.Natives;
import static org.freedesktop.gstreamer.lowlevel.GstCapsAPI.GSTCAPS_API;

/**
Expand Down Expand Up @@ -72,7 +72,7 @@ public class Caps extends MiniObject {
* @see #emptyCaps
*/
public Caps() {
this(initializer(GSTCAPS_API.ptr_gst_caps_new_empty()));
this(Natives.initializer(GSTCAPS_API.ptr_gst_caps_new_empty()));
}

/**
Expand All @@ -82,7 +82,7 @@ public Caps() {
* @see #fromString
*/
public Caps(String caps) {
this(initializer(GSTCAPS_API.ptr_gst_caps_from_string(caps)));
this(Natives.initializer(GSTCAPS_API.ptr_gst_caps_from_string(caps)));
}

/**
Expand All @@ -92,7 +92,7 @@ public Caps(String caps) {
* @see #copy
*/
public Caps(Caps caps) {
this(initializer(GSTCAPS_API.ptr_gst_caps_copy(caps)));
this(Natives.initializer(GSTCAPS_API.ptr_gst_caps_copy(caps)));
}

Caps(Initializer init) {
Expand Down Expand Up @@ -282,7 +282,8 @@ public Caps makeWritable() {
* @see Structure
*/
public Caps normalize() {
this.ref(); // gst_caps_normalize copies "this" and drops one reference
// this.ref(); // gst_caps_normalize copies "this" and drops one reference
Natives.ref(this);
return GSTCAPS_API.gst_caps_normalize(this);
}

Expand All @@ -309,7 +310,8 @@ public void setInteger(String field, Integer value) {
* @return The new {@link Caps}
*/
public Caps simplify() {
this.ref(); // gst_caps_simplify copies "this" and drops one reference
// this.ref(); // gst_caps_simplify copies "this" and drops one reference
Natives.ref(this);
return GSTCAPS_API.gst_caps_simplify(this);
}

Expand Down Expand Up @@ -348,7 +350,8 @@ public String toString() {
* @return truncated copy of the Caps
*/
public Caps truncate() {
this.ref();
// this.ref();
Natives.ref(this);
return GSTCAPS_API.gst_caps_truncate(this);
}

Expand All @@ -359,7 +362,7 @@ public Caps truncate() {
* @return The new Caps.
*/
public static Caps anyCaps() {
return new Caps(initializer(GSTCAPS_API.ptr_gst_caps_new_any()));
return new Caps(Natives.initializer(GSTCAPS_API.ptr_gst_caps_new_any()));
}

/**
Expand All @@ -369,7 +372,7 @@ public static Caps anyCaps() {
* @return The new Caps.
*/
public static Caps emptyCaps() {
return new Caps(initializer(GSTCAPS_API.ptr_gst_caps_new_empty()));
return new Caps(Natives.initializer(GSTCAPS_API.ptr_gst_caps_new_empty()));
}

/**
Expand All @@ -383,7 +386,7 @@ public static Caps emptyCaps() {
* @return The new Caps.
*/
public static Caps fromString(String caps) {
return new Caps(initializer(GSTCAPS_API.ptr_gst_caps_from_string(caps)));
return new Caps(Natives.initializer(GSTCAPS_API.ptr_gst_caps_from_string(caps)));
}

/**
Expand All @@ -403,7 +406,4 @@ public static Caps merge(Caps caps1, Caps caps2) {
return GSTCAPS_API.gst_caps_merge(caps1, caps2);
}

protected static Initializer initializer(Pointer ptr) {
return new Initializer(ptr, false, true);
}
}
64 changes: 36 additions & 28 deletions src/org/freedesktop/gstreamer/ClockID.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,61 +16,45 @@
* 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.freedesktop.gstreamer;

import com.sun.jna.Pointer;

import org.freedesktop.gstreamer.lowlevel.RefCountedObject;
import org.freedesktop.gstreamer.glib.RefCountedObject;
import org.freedesktop.gstreamer.lowlevel.GPointer;

import static org.freedesktop.gstreamer.lowlevel.GstClockAPI.GSTCLOCK_API;

/**
* A datatype to hold the handle to an outstanding sync or async clock callback.
*/
public class ClockID extends RefCountedObject implements Comparable<ClockID> {
public ClockID(Initializer init) {
super(init);
}

@Override
protected void disposeNativeHandle(Pointer ptr) {
GSTCLOCK_API.gst_clock_id_unref(ptr);
}

@Override
protected void ref() {
GSTCLOCK_API.gst_clock_id_ref(this);
ClockID(Initializer init) {
super(new Handle(init.ptr, init.ownsHandle), init.needRef);
}

@Override
protected void unref() {
GSTCLOCK_API.gst_clock_id_unref(this);
}

/**
* Cancel an outstanding request. This can either
* be an outstanding async notification or a pending sync notification.
* After this call, @id cannot be used anymore to receive sync or
* async notifications, you need to create a new #GstClockID.
* Cancel an outstanding request. This can either be an outstanding async
* notification or a pending sync notification. After this call, @id cannot
* be used anymore to receive sync or async notifications, you need to
* create a new #GstClockID.
*/
public void unschedule() {
GSTCLOCK_API.gst_clock_id_unschedule(this);
}

/**
* Gets the time of the clock ID
* <p>
* Thread safe.
*
*
* @return The time of this clock id.
*/
public long getTime() {
return GSTCLOCK_API.gst_clock_id_get_time(this);
}

/**
* Compares this ClockID to another.
* Compares this ClockID to another.
*
* @param other The other ClockID to compare to
* @return negative value if a < b; zero if a = b; positive value if a > b
Expand All @@ -79,4 +63,28 @@ public long getTime() {
public int compareTo(ClockID other) {
return GSTCLOCK_API.gst_clock_id_compare_func(this, other);
}

private static final class Handle extends RefCountedObject.Handle {

public Handle(GPointer ptr, boolean ownsHandle) {
super(ptr, ownsHandle);
}

@Override
protected void disposeNativeHandle(GPointer ptr) {
GSTCLOCK_API.gst_clock_id_unref(ptr);
}

@Override
protected void ref() {
GSTCLOCK_API.gst_clock_id_ref(getPointer());
}

@Override
protected void unref() {
GSTCLOCK_API.gst_clock_id_unref(getPointer());
}

}

}
Loading