mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-07 14:18:25 +00:00
Fix LinphonePlayer method in JNI
This commit is contained in:
parent
9d1bb6b6a8
commit
68f5085d84
3 changed files with 27 additions and 47 deletions
|
|
@ -7484,16 +7484,9 @@ static void _eof_callback(LinphonePlayer *player, void *user_data) {
|
|||
env->CallVoidMethod(player_data->mListener, player_data->mEndOfFileMethodID, player_data->mJLinphonePlayer);
|
||||
}
|
||||
|
||||
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_open(JNIEnv *env, jobject jPlayer, jlong ptr, jstring filename, jobject listener) {
|
||||
LinphonePlayerData *data = NULL;
|
||||
LinphonePlayerEofCallback cb = NULL;
|
||||
extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_open(JNIEnv *env, jobject jPlayer, jlong ptr, jstring filename) {
|
||||
const char *cfilename = GetStringUTFChars(env, filename);
|
||||
if(listener) {
|
||||
data = new LinphonePlayerData(env, listener, jPlayer);
|
||||
cb = _eof_callback;
|
||||
}
|
||||
if(linphone_player_open((LinphonePlayer *)ptr, cfilename, cb, data) == -1) {
|
||||
if(data) delete data;
|
||||
if(linphone_player_open((LinphonePlayer *)ptr, cfilename) == -1) {
|
||||
ReleaseStringUTFChars(env, filename, cfilename);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -7546,7 +7539,7 @@ extern "C" void Java_org_linphone_core_LinphonePlayerImpl_destroy(JNIEnv *env, j
|
|||
}
|
||||
jobject window_id = (jobject)ms_media_player_get_window_id((MSMediaPlayer *)player->impl);
|
||||
if(window_id) env->DeleteGlobalRef(window_id);
|
||||
linphone_player_destroy(player);
|
||||
_linphone_player_destroy(player);
|
||||
}
|
||||
|
||||
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createLocalPlayer(JNIEnv *env, jobject jobj, jlong ptr, jobject window) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public interface LinphonePlayer {
|
|||
closed, /*< No file is open */
|
||||
paused, /*< A file is open and playback is not running */
|
||||
playing; /*< A file is open and playback is running */
|
||||
|
||||
|
||||
public static State fromValue(int value) {
|
||||
if(value == 0) {
|
||||
return closed;
|
||||
|
|
@ -30,64 +30,51 @@ public interface LinphonePlayer {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Listener for Linphone players
|
||||
* @author François Grisez
|
||||
*
|
||||
*/
|
||||
public interface Listener {
|
||||
/**
|
||||
* Method called when a player reaches the end of a file
|
||||
* @param player The player which called the method
|
||||
*/
|
||||
public void endOfFile(LinphonePlayer player);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param filename Name of the file to open
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
public int open(String filename, Listener listener);
|
||||
|
||||
public int open(String filename);
|
||||
|
||||
/**
|
||||
* Start playback
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
public int start();
|
||||
|
||||
|
||||
/**
|
||||
* Get playback paused
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
public int pause();
|
||||
|
||||
|
||||
/**
|
||||
* Go to a specific position in the timeline
|
||||
* @param timeMs Time in milliseconds
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
public int seek(int timeMs);
|
||||
|
||||
|
||||
/**
|
||||
* Get the state of the player
|
||||
* @return See State enumeration
|
||||
*/
|
||||
public State getState();
|
||||
|
||||
|
||||
/**
|
||||
* Get the duration of the media
|
||||
* @return The duration in milliseconds
|
||||
*/
|
||||
public int getDuration();
|
||||
|
||||
|
||||
/**
|
||||
* Get the position of the playback
|
||||
* @return The position in milliseconds
|
||||
*/
|
||||
public int getCurrentPosition();
|
||||
|
||||
|
||||
/**
|
||||
* Close a file
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.linphone.core;
|
||||
|
||||
|
|
@ -9,59 +9,59 @@ package org.linphone.core;
|
|||
*/
|
||||
public class LinphonePlayerImpl implements LinphonePlayer {
|
||||
private long nativePtr = 0;
|
||||
|
||||
|
||||
LinphonePlayerImpl(long nativePtr) {
|
||||
this.nativePtr = nativePtr;
|
||||
}
|
||||
|
||||
private native int open(long nativePtr, String filename, Listener listener);
|
||||
|
||||
private native int open(long nativePtr, String filename);
|
||||
@Override
|
||||
public synchronized int open(String filename, Listener listener) {
|
||||
return open(nativePtr, filename, listener);
|
||||
public synchronized int open(String filename) {
|
||||
return open(nativePtr, filename);
|
||||
}
|
||||
|
||||
|
||||
private native int start(long nativePtr);
|
||||
@Override
|
||||
public synchronized int start() {
|
||||
return start(nativePtr);
|
||||
}
|
||||
|
||||
|
||||
private native int pause(long nativePtr);
|
||||
@Override
|
||||
public synchronized int pause() {
|
||||
return pause(nativePtr);
|
||||
}
|
||||
|
||||
|
||||
private native int seek(long nativePtr, int timeMs);
|
||||
@Override
|
||||
public synchronized int seek(int timeMs) {
|
||||
return seek(nativePtr, timeMs);
|
||||
}
|
||||
|
||||
|
||||
private native int getState(long nativePtr);
|
||||
@Override
|
||||
public synchronized State getState() {
|
||||
return LinphonePlayer.State.fromValue(getState(nativePtr));
|
||||
}
|
||||
|
||||
|
||||
private native int getDuration(long nativePtr);
|
||||
@Override
|
||||
public synchronized int getDuration() {
|
||||
return getDuration(nativePtr);
|
||||
}
|
||||
|
||||
|
||||
private native int getCurrentPosition(long nativePtr);
|
||||
@Override
|
||||
public synchronized int getCurrentPosition() {
|
||||
return getCurrentPosition(nativePtr);
|
||||
}
|
||||
|
||||
|
||||
private native void close(long nativePtr);
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
close(nativePtr);
|
||||
}
|
||||
|
||||
|
||||
private native void destroy(long nativePtr);
|
||||
@Override
|
||||
protected void finalize() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue