[libbluray-devel] Split bd_bdj_seek() from _play_playlist_at()

hpi1 git at videolan.org
Mon Dec 1 09:27:46 CET 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Nov 24 11:36:41 2014 +0200| [11aade99d74129affffc446d492296109b6a0b33] | committer: hpi1

Split bd_bdj_seek() from  _play_playlist_at()

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=11aade99d74129affffc446d492296109b6a0b33
---

 src/libbluray/bdj/java/org/videolan/Libbluray.java |   10 ++---
 src/libbluray/bdj/native/org_videolan_Libbluray.c  |   42 ++++----------------
 src/libbluray/bdj/native/org_videolan_Libbluray.h  |   24 ++---------
 src/libbluray/bluray.c                             |   29 +++++++++-----
 src/libbluray/bluray_internal.h                    |    1 +
 5 files changed, 36 insertions(+), 70 deletions(-)

diff --git a/src/libbluray/bdj/java/org/videolan/Libbluray.java b/src/libbluray/bdj/java/org/videolan/Libbluray.java
index e068275..b50f67f 100644
--- a/src/libbluray/bdj/java/org/videolan/Libbluray.java
+++ b/src/libbluray/bdj/java/org/videolan/Libbluray.java
@@ -175,14 +175,14 @@ public class Libbluray {
     }
 
     public static long seekTime(long tick) {
-        return seekTimeN(nativePointer, tick);
+        return seekN(nativePointer, -1, -1, tick);
     }
 
     public static long seekMark(int mark) {
         if (mark < 0)
             throw new IllegalArgumentException("Mark cannot be negative");
 
-        long result = seekMarkN(nativePointer, mark);
+        long result = seekN(nativePointer, -1, mark, -1);
         if (result == -1)
             throw new IllegalArgumentException("Seek error");
         return result;
@@ -192,7 +192,7 @@ public class Libbluray {
         if (clip < 0)
             throw new IllegalArgumentException("Mark cannot be negative");
 
-        long result = seekPlayItemN(nativePointer, clip);
+        long result = seekN(nativePointer, clip, -1, -1);
         if (result == -1)
             throw new IllegalArgumentException("Seek error");
         return result;
@@ -498,9 +498,7 @@ public class Libbluray {
     private static native TitleInfo getTitleInfoN(long np, int title);
     private static native PlaylistInfo getPlaylistInfoN(long np, int playlist);
     private static native int getTitlesN(long np);
-    private static native long seekTimeN(long np, long tick);
-    private static native long seekMarkN(long np, int mark);
-    private static native long seekPlayItemN(long np, int clip);
+    private static native long seekN(long np, int playitem, int playmark, long time);
     private static native int selectPlaylistN(long np, int playlist, int playitem, int playmark, long time);
     private static native int selectTitleN(long np, int title);
     private static native int selectAngleN(long np, int angle);
diff --git a/src/libbluray/bdj/native/org_videolan_Libbluray.c b/src/libbluray/bdj/native/org_videolan_Libbluray.c
index 0f30a0e..828f944 100644
--- a/src/libbluray/bdj/native/org_videolan_Libbluray.c
+++ b/src/libbluray/bdj/native/org_videolan_Libbluray.c
@@ -212,31 +212,13 @@ JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_getTitlesN(JNIEnv * env,
     return disc_info->num_titles;
 }
 
-JNIEXPORT jlong JNICALL Java_org_videolan_Libbluray_seekTimeN(JNIEnv * env,
-        jclass cls, jlong np, jlong tick) {
+JNIEXPORT jlong JNICALL Java_org_videolan_Libbluray_seekN(JNIEnv * env,
+        jclass cls, jlong np, jint playitem, jint playmark, jlong tick) {
     BLURAY* bd = (BLURAY*)(intptr_t)np;
 
-    BD_DEBUG(DBG_JNI, "seekTimeN(%"PRId64")\n", (int64_t)tick);
+    BD_DEBUG(DBG_JNI, "seekN(tick=%"PRId64", mark=%d, playitem=%d)\n", (int64_t)tick, (int)playmark, (int)playitem);
 
-    return bd_seek_time(bd, tick);
-}
-
-JNIEXPORT jlong JNICALL Java_org_videolan_Libbluray_seekMarkN(JNIEnv * env,
-        jclass cls, jlong np, jint mark) {
-    BLURAY* bd = (BLURAY*)(intptr_t)np;
-
-    BD_DEBUG(DBG_JNI, "seekMarkN(%d)\n", (int)mark);
-
-    return bd_seek_mark(bd, mark);
-}
-
-JNIEXPORT jlong JNICALL Java_org_videolan_Libbluray_seekPlayItemN(JNIEnv * env,
-        jclass cls, jlong np, jint clip) {
-    BLURAY* bd = (BLURAY*)(intptr_t)np;
-
-    BD_DEBUG(DBG_JNI, "seekPlayItemN(%d)\n", (int)clip);
-
-    return bd_seek_playitem(bd, clip);
+    return bd_bdj_seek(bd, playitem, playmark, tick);
 }
 
 JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_selectPlaylistN(
@@ -517,19 +499,9 @@ Java_org_videolan_Libbluray_methods[] =
         VC(Java_org_videolan_Libbluray_getTitlesN),
     },
     {
-        CC("seekTimeN"),
-        CC("(JJ)J"),
-        VC(Java_org_videolan_Libbluray_seekTimeN),
-    },
-    {
-        CC("seekMarkN"),
-        CC("(JI)J"),
-        VC(Java_org_videolan_Libbluray_seekMarkN),
-    },
-    {
-        CC("seekPlayItemN"),
-        CC("(JI)J"),
-        VC(Java_org_videolan_Libbluray_seekPlayItemN),
+        CC("seekN"),
+        CC("(JIIJ)J"),
+        VC(Java_org_videolan_Libbluray_seekN),
     },
     {
         CC("selectPlaylistN"),
diff --git a/src/libbluray/bdj/native/org_videolan_Libbluray.h b/src/libbluray/bdj/native/org_videolan_Libbluray.h
index 40c8e8c..6d403f4 100644
--- a/src/libbluray/bdj/native/org_videolan_Libbluray.h
+++ b/src/libbluray/bdj/native/org_videolan_Libbluray.h
@@ -142,27 +142,11 @@ JNIEXPORT jint JNICALL Java_org_videolan_Libbluray_getTitlesN
 
 /*
  * Class:     org_videolan_Libbluray
- * Method:    seekTimeN
- * Signature: (JJ)J
+ * Method:    seekN
+ * Signature: (JIIJ)J
  */
-JNIEXPORT jlong JNICALL Java_org_videolan_Libbluray_seekTimeN
-  (JNIEnv *, jclass, jlong, jlong);
-
-/*
- * Class:     org_videolan_Libbluray
- * Method:    seekMarkN
- * Signature: (JI)J
- */
-JNIEXPORT jlong JNICALL Java_org_videolan_Libbluray_seekMarkN
-  (JNIEnv *, jclass, jlong, jint);
-
-/*
- * Class:     org_videolan_Libbluray
- * Method:    seekPlayItemN
- * Signature: (JI)J
- */
-JNIEXPORT jlong JNICALL Java_org_videolan_Libbluray_seekPlayItemN
-  (JNIEnv *, jclass, jlong, jint);
+JNIEXPORT jlong JNICALL Java_org_videolan_Libbluray_seekN
+  (JNIEnv *, jclass, jlong, jint, jint, jlong);
 
 /*
  * Class:     org_videolan_Libbluray
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index db6a3a5..2b23781 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -2194,6 +2194,25 @@ int bd_select_playlist(BLURAY *bd, uint32_t playlist)
 }
 
 #ifdef USING_BDJAVA
+int bd_bdj_seek(BLURAY *bd, int playitem, int playmark, int64_t time)
+{
+    bd_mutex_lock(&bd->mutex);
+
+    if (playitem > 0) {
+        bd_seek_playitem(bd, playitem);
+    }
+    if (playmark >= 0) {
+        bd_seek_mark(bd, playmark);
+    }
+    if (time >= 0) {
+        bd_seek_time(bd, time);
+    }
+
+    bd_mutex_unlock(&bd->mutex);
+
+    return 1;
+}
+
 static int _play_playlist_at(BLURAY *bd, int playlist, int playitem, int playmark, int64_t time)
 {
     if (playlist < 0) {
@@ -2207,15 +2226,7 @@ static int _play_playlist_at(BLURAY *bd, int playlist, int playitem, int playmar
 
     bd->bdj_wait_start = 1;  /* playback is triggered by bd_select_rate() */
 
-    if (playitem > 0) {
-        bd_seek_playitem(bd, playitem);
-    }
-    if (playmark >= 0) {
-        bd_seek_mark(bd, playmark);
-    }
-    if (time >= 0) {
-        bd_seek_time(bd, time);
-    }
+    bd_bdj_seek(bd, playitem, playmark, time);
 
     return 1;
 }
diff --git a/src/libbluray/bluray_internal.h b/src/libbluray/bluray_internal.h
index 54623a7..92d3568 100644
--- a/src/libbluray/bluray_internal.h
+++ b/src/libbluray/bluray_internal.h
@@ -63,6 +63,7 @@ enum bd_select_rate_reason {
 
 BD_PRIVATE int      bd_play_playlist_at(struct bluray *bd, int playlist, int playitem, int playmark, int64_t time);
 BD_PRIVATE void     bd_select_rate(struct bluray *bd, float rate, int reason);
+BD_PRIVATE int      bd_bdj_seek(struct bluray *bd, int playitem, int playmark, int64_t time);
 
 /*
  * BD-J overlay



More information about the libbluray-devel mailing list