[libbluray-devel] SIElementFilter: rewrite

hpi1 git at videolan.org
Wed Apr 6 10:38:16 CEST 2016


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Apr  5 13:06:48 2016 +0300| [eb09c83e29832e83e6b5a4268f90d8da8d3b8fd1] | committer: hpi1

SIElementFilter: rewrite

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

 .../tv/service/navigation/SIElementFilter.java     |   59 +++++++++++++++++++-
 .../bdj/java/org/bluray/ti/PlayItemImpl.java       |    8 +++
 2 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/src/libbluray/bdj/java/javax/tv/service/navigation/SIElementFilter.java b/src/libbluray/bdj/java/javax/tv/service/navigation/SIElementFilter.java
index f0dc97c..2b9249a 100644
--- a/src/libbluray/bdj/java/javax/tv/service/navigation/SIElementFilter.java
+++ b/src/libbluray/bdj/java/javax/tv/service/navigation/SIElementFilter.java
@@ -1,7 +1,7 @@
 /*
  * This file is part of libbluray
  * Copyright (C) 2010  William Hahne
- * Copyright (C) 2015  Petri Hintukainen
+ * Copyright (C) 2015-2016  Petri Hintukainen
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -28,11 +28,19 @@ import javax.tv.service.SIRequestorImpl;
 
 import org.bluray.net.BDLocator;
 
+import org.bluray.ti.PlayItem;
+import org.bluray.ti.PlayItemImpl;
+import org.bluray.ti.PlayList;
+import org.bluray.ti.PlayListImpl;
+import org.bluray.ti.TitleImpl;
+
 public final class SIElementFilter extends ServiceFilter
 {
     public SIElementFilter(SIElement element) throws FilterNotSupportedException {
-        if (element == null)
+        if (element == null) {
+            System.err.println("null element");
             throw new NullPointerException();
+        }
 
         try {
             new BDLocator(element.getLocator().toExternalForm());
@@ -49,6 +57,52 @@ public final class SIElementFilter extends ServiceFilter
     }
 
     public boolean accept(Service service) {
+
+        if (service == null) {
+            System.err.println("null service");
+            throw new NullPointerException();
+        }
+
+        if (!(service instanceof TitleImpl))
+            return false;
+        TitleImpl title = (TitleImpl)service;
+
+        if (element instanceof PlayListImpl) {
+            int id = ((PlayListImpl)element).getId();
+            PlayList[] pls = title.getPlayLists();
+            for (int i = 0; i < pls.length; i++) {
+                if (id == pls[i].getId()) {
+                    return true;
+                }
+            }
+            return false;
+
+        } else if (element instanceof PlayItemImpl) {
+
+            int piId = ((PlayItemImpl)element).getPlayItemId();
+            int plId = ((PlayItemImpl)element).getPlayListId();
+
+            PlayList[] pls = title.getPlayLists();
+            for (int i = 0; i < pls.length; i++) {
+                if (plId == pls[i].getId()) {
+
+                    PlayItem pis[] = pls[i].getPlayItems();
+                    for (int j = 0; j < pis.length; j++) {
+                        if (piId == ((PlayItemImpl)pis[j]).getPlayItemId()) {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+
+        } else if (element instanceof ServiceDetails) {
+            return element.getLocator() == service.getLocator();
+        }
+
+        System.err.println("Unsupported SI element");
+        return false;
+        /*
         SIRequestorImpl requestor = new SIRequestorImpl();
 
         SIRequest req = service.retrieveDetails(requestor);
@@ -81,6 +135,7 @@ public final class SIElementFilter extends ServiceFilter
         }
 
         return false;
+        */
     }
 
     SIElement element;
diff --git a/src/libbluray/bdj/java/org/bluray/ti/PlayItemImpl.java b/src/libbluray/bdj/java/org/bluray/ti/PlayItemImpl.java
index cde7c5e..7ffbf67 100644
--- a/src/libbluray/bdj/java/org/bluray/ti/PlayItemImpl.java
+++ b/src/libbluray/bdj/java/org/bluray/ti/PlayItemImpl.java
@@ -41,6 +41,14 @@ public class PlayItemImpl implements PlayItem {
         this.service = service;
     }
 
+    public int getPlayItemId() {
+        return playitemId;
+    }
+
+    public int getPlayListId() {
+        return playlistId;
+    }
+
     public Locator getLocator()
     {
         int title = Libbluray.getCurrentTitle();



More information about the libbluray-devel mailing list