From a2f8befbcf0da653d1048938b214593aa00e2778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Tue, 7 Oct 2014 14:48:23 +0200 Subject: [PATCH] Add JNI wrapper for linphone_player_get_duration and linphone_player_get_current_position --- coreapi/linphonecore.h | 2 +- coreapi/linphonecore_jni.cc | 8 ++++++++ coreapi/player.c | 2 +- java/common/org/linphone/core/LinphonePlayer.java | 12 ++++++++++++ java/impl/org/linphone/core/LinphonePlayerImpl.java | 12 ++++++++++++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 7b4f7d791..5238173c0 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -593,7 +593,7 @@ int linphone_player_pause(LinphonePlayer *obj); int linphone_player_seek(LinphonePlayer *obj, int time_ms); MSPlayerState linphone_player_get_state(LinphonePlayer *obj); int linphone_player_get_duration(LinphonePlayer *obj); -int linphone_player_get_position(LinphonePlayer *obj); +int linphone_player_get_current_position(LinphonePlayer *obj); void linphone_player_close(LinphonePlayer *obj); /** diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index ceccb5889..7bec3f233 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -5275,6 +5275,14 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphonePlayer_getState(JNIEnv *en return (jint)linphone_player_get_state((LinphonePlayer *)ptr); } +JNIEXPORT jint JNICALL Java_org_linphone_core_LinphonePlayer_getDuration(JNIEnv *env, jobject jobj, jlong ptr) { + return (jint)linphone_player_get_duration((LinphonePlayer *)ptr); +} + +JNIEXPORT jint JNICALL Java_org_linphone_core_LinphonePlayer_getCurrentPosition(JNIEnv *env, jobject jobj, jlong ptr) { + return (jint)linphone_player_get_current_position((LinphonePlayer *)ptr); +} + JNIEXPORT void JNICALL Java_org_linphone_core_LinphonePlayer_close(JNIEnv *env, jobject playerPtr, jlong ptr) { LinphonePlayer *player = (LinphonePlayer *)ptr; if(player->user_data) { diff --git a/coreapi/player.c b/coreapi/player.c index ef5233a34..54573ccb8 100644 --- a/coreapi/player.c +++ b/coreapi/player.c @@ -85,7 +85,7 @@ int linphone_player_get_duration(LinphonePlayer *obj) { * @param obj the player * @return Position of the playback in milliseconds */ -int linphone_player_get_position(LinphonePlayer *obj) { +int linphone_player_get_current_position(LinphonePlayer *obj) { return obj->get_position(obj); } diff --git a/java/common/org/linphone/core/LinphonePlayer.java b/java/common/org/linphone/core/LinphonePlayer.java index c38340af1..9a862d3b3 100644 --- a/java/common/org/linphone/core/LinphonePlayer.java +++ b/java/common/org/linphone/core/LinphonePlayer.java @@ -76,6 +76,18 @@ public interface LinphonePlayer { */ 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 */ diff --git a/java/impl/org/linphone/core/LinphonePlayerImpl.java b/java/impl/org/linphone/core/LinphonePlayerImpl.java index a6c5cb2e5..eb6c18c71 100644 --- a/java/impl/org/linphone/core/LinphonePlayerImpl.java +++ b/java/impl/org/linphone/core/LinphonePlayerImpl.java @@ -44,6 +44,18 @@ public class LinphonePlayerImpl implements LinphonePlayer { 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() {