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
8 changes: 7 additions & 1 deletion src/org/freedesktop/gstreamer/Gst.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2018 Antonio Morales
* Copyright (c) 2018 Neil C Smith
* Copyright (c) 2007 Wayne Meissner
*
Expand Down Expand Up @@ -44,6 +45,7 @@
import org.freedesktop.gstreamer.elements.DecodeBin;
import org.freedesktop.gstreamer.elements.PlayBin;
import org.freedesktop.gstreamer.elements.URIDecodeBin;
import org.freedesktop.gstreamer.elements.WebRTCBin;
import org.freedesktop.gstreamer.glib.GDate;
import org.freedesktop.gstreamer.glib.GInetAddress;
import org.freedesktop.gstreamer.glib.GSocketAddress;
Expand Down Expand Up @@ -619,9 +621,12 @@ private static synchronized void loadAllClasses() {
PadTemplate.class,
Plugin.class,
PluginFeature.class,
Promise.class,
Query.class,
Registry.class,
SDPMessage.class,
Sample.class,
WebRTCSessionDescription.class,
// ----------- Elements -------------
AppSink.class,
AppSrc.class,
Expand All @@ -632,6 +637,7 @@ private static synchronized void loadAllClasses() {
DecodeBin.class,
Pipeline.class,
PlayBin.class,
URIDecodeBin.class
URIDecodeBin.class,
WebRTCBin.class
);
}
12 changes: 11 additions & 1 deletion src/org/freedesktop/gstreamer/Pad.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/*
* Copyright (C) 2018 Antonio Morales
* Copyright (C) 2014 Tom Greenwood <tgreenwood@cafex.com>
* Copyright (C) 2009 Tamas Korodi <kotyo@zamba.fm>
* Copyright (C) 2007 Wayne Meissner
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
*
* This file is part of gstreamer-java.
*
* This code is free software: you can redistribute it and/or modify it under
Expand Down Expand Up @@ -689,4 +690,13 @@ public PadTemplate getTemplate() {
return GSTPAD_API.gst_pad_get_pad_template(this);
}


/**
* Check if the pad has caps set on it with a GST_EVENT_CAPS events
*
* @return true if the pad has caps set
*/
public boolean hasCurrentCaps() {
return GSTPAD_API.gst_pad_has_current_caps(this);
}
}
123 changes: 123 additions & 0 deletions src/org/freedesktop/gstreamer/Promise.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Copyright (c) 2018 Vinicius Tona
* Copyright (c) 2018 Antonio Morales
*
* 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.freedesktop.gstreamer;

import static org.freedesktop.gstreamer.lowlevel.GstPromiseAPI.GSTPROMISE_API;

import org.freedesktop.gstreamer.lowlevel.GstAPI.GstCallback;

import com.sun.jna.Pointer;

public class Promise extends MiniObject {
public static final String GTYPE_NAME = "GstPromise";

public static interface PROMISE_CHANGE {
/**
* Called whenever the state of the promise is changed from PENDING to any other {@link PromiseResult}
*
* @param promise the original promise that had the callback attached to
*/
public void onChange(Promise promise);
}

/**
* Creates a new instance of Promise. This constructor is used internally.
*
* @param init internal initialization data.
*/
public Promise(final Initializer init) {
super(init);
}

/**
* Creates a new instance of promise
*/
public Promise() {
this(initializer(GSTPROMISE_API.ptr_gst_promise_new()));
}

/**
* Creates a new instance of promise with a callback attached.
*
* @param listerner Listener to be called whenever the state of a {@link Promise} is changed
*/
public Promise(final PROMISE_CHANGE listener) {
this(new Initializer(GSTPROMISE_API.ptr_gst_promise_new_with_change_func(new GstCallback() {
@SuppressWarnings("unused")
public void callback(Promise promise, Pointer userData) {
listener.onChange(promise);
}
}), false, false));
}

protected static Initializer initializer(final Pointer ptr) {
return new Initializer(ptr, false, true);
}

/**
* Wait for the promise to move out of the PENDING {@link PromiseResult} state.
* If the promise is not in PENDING then it will immediately return.
*
* @return the {@link PromiseResult} of the promise.
*/
public PromiseResult waitResult() {
return GSTPROMISE_API.gst_promise_wait(this);
}

/**
* Set a reply on the promise.
*
* Will wake up any waiters on the promise with the REPLIED {@link PromiseResult} state.
* If the promise has already been interrupted than the replied will not be visible to any waiters
*
* @param structure the {@link Structure} to reply the promise with
*/
public void reply(final Structure structure) {
GSTPROMISE_API.gst_promise_reply(this, structure);
}

/**
* Interrupt waiting for the result of the prommise.
*
* Any waiters on the promise will receive the INTERRUPTED {@link PromiseResult} state.
*/
public void interrupt() {
GSTPROMISE_API.gst_promise_interrupt(this);
}

/**
* Expire a promise.
*
* Any waiters on the promise will recieved the EXPIRED {@link PromiseResult} state.
*/
public void expire() {
GSTPROMISE_API.gst_promise_expire(this);
}

/**
* Retrieve the reply set on the promise.
*
* The state of the promise must be in the REPLIED {@link PromiseResult} state.
* The return structure is owned by the promise and thus cannot be modified.
*
* @return the {@link Structure} set on the promise reply.
*/
public Structure getReply() {
return Structure.objectFor(GSTPROMISE_API.ptr_gst_promise_get_reply(this), false, false);
}
}
36 changes: 36 additions & 0 deletions src/org/freedesktop/gstreamer/PromiseResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2018 Antonio Morales
*
* 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.freedesktop.gstreamer;

import org.freedesktop.gstreamer.lowlevel.annotations.DefaultEnumValue;

/**
* The result of a {@link Promise}
* Available since GStreamer 1.14
*/
public enum PromiseResult {
/** The initial state of a promise */
PENDING,
/** The promise was interrupted */
INTERRUPTED,
/** The promise has been resolved and it has a value */
REPLIED,
/** The promise is expired and won't return a result */
EXPIRED,
/** Unknown result */
@DefaultEnumValue UNKNOWN;
}
93 changes: 93 additions & 0 deletions src/org/freedesktop/gstreamer/SDPMessage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (c) 2018 Antonio Morales
*
* 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.freedesktop.gstreamer;

import java.nio.charset.StandardCharsets;

import static org.freedesktop.gstreamer.lowlevel.GstSDPMessageAPI.GSTSDPMESSAGE_API;

import org.freedesktop.gstreamer.lowlevel.NativeObject;

import com.sun.jna.Pointer;

public class SDPMessage extends NativeObject {
public static final String GTYPE_NAME = "GstSDPMessage";

/**
* Internally used constructor. Do not use.
*
* @param init internal initialization data
*/
public SDPMessage(Initializer init) {
super(init);
}

/**
* Creates a new instance of SDPMessage
*/
public SDPMessage() {
this(initializer());
}

/**
* A SDP formatted string representation of SDPMessage.
*
* Used for offer/answer exchanges for real time communicationse
*
* @return the SDP string representation of SDPMessage.
*/
public String toString() {
return GSTSDPMESSAGE_API.gst_sdp_message_as_text(this);
}

/**
* Takes a SDP string and parses it and fills in all fields for SDPMessage.
*
* Look at https://tools.ietf.org/html/rfc4566 for more information on SDP
*
* @param sdpString the sdp string
*/
public void parseBuffer(String sdpString) {
byte[] data = sdpString.getBytes(StandardCharsets.US_ASCII);
int length = sdpString.length();
GSTSDPMESSAGE_API.gst_sdp_message_parse_buffer(data, length, this);
}

/**
* Creates a copy of this SDPMessage.
*
* @return a copy of SDPMessage.
*/
public SDPMessage copy(boolean shouldInvalidateOriginal) {
Pointer[] ptr = new Pointer[1];
GSTSDPMESSAGE_API.gst_sdp_message_copy(this, ptr);
if (shouldInvalidateOriginal) {
this.invalidate();
}
return new SDPMessage(initializer(ptr[0]));
}

private static Initializer initializer() {
Pointer[] ptr = new Pointer[1];
GSTSDPMESSAGE_API.gst_sdp_message_new(ptr);
return initializer(ptr[0]);
}

protected void disposeNativeHandle(Pointer ptr) {
GSTSDPMESSAGE_API.gst_sdp_message_free(ptr);
}
}
47 changes: 47 additions & 0 deletions src/org/freedesktop/gstreamer/SDPResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2018 Antonio Morales
*
* 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.freedesktop.gstreamer;

import org.freedesktop.gstreamer.lowlevel.IntegerEnum;
import org.freedesktop.gstreamer.lowlevel.annotations.DefaultEnumValue;

/**
* The possible results for {@link SDPMessage} functions
*/
public enum SDPResult implements IntegerEnum {
/** A successful return value*/
OK(0),
/** A function to SDPMessage was given invalid paramters */
EINVAL(-1),
/** An unknown result */
@DefaultEnumValue
__UNKNWON_NATIVE_VALUE(~0);

SDPResult(int value) {
this.value = value;
}

/**
* Gets the integer value of the enum
* @return the integer value for this enum.
*/
public int intValue() {
return value;
}

private int value;
}
9 changes: 9 additions & 0 deletions src/org/freedesktop/gstreamer/Structure.java
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,15 @@ public String getName(int i) {
return GSTSTRUCTURE_API.gst_structure_nth_field_name(this, i);
}

/**
* Checks that two structures are equal
* @param structure the stucture to check if it's equal to this structure
* @return true if both structures are equal
*/
public boolean isEqual(Structure structure) {
return GSTSTRUCTURE_API.gst_structure_is_equal(this, structure);
}

@Override
public String toString() {
return GSTSTRUCTURE_API.gst_structure_to_string(this);
Expand Down
Loading