|
Packit |
5e46da |
/*
|
|
Packit |
5e46da |
* This file is part of libbluray
|
|
Packit |
5e46da |
* Copyright (C) 2010 William Hahne
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* This library is free software; you can redistribute it and/or
|
|
Packit |
5e46da |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
5e46da |
* License as published by the Free Software Foundation; either
|
|
Packit |
5e46da |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
5e46da |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
5e46da |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
5e46da |
* Lesser General Public License for more details.
|
|
Packit |
5e46da |
*
|
|
Packit |
5e46da |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
5e46da |
* License along with this library. If not, see
|
|
Packit |
5e46da |
* <http://www.gnu.org/licenses/>.
|
|
Packit |
5e46da |
*/
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
package javax.tv.service;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
import java.util.LinkedList;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
import javax.tv.locator.InvalidLocatorException;
|
|
Packit |
5e46da |
import javax.tv.locator.Locator;
|
|
Packit |
5e46da |
import javax.tv.service.navigation.ServiceFilter;
|
|
Packit |
5e46da |
import javax.tv.service.navigation.ServiceList;
|
|
Packit |
5e46da |
import javax.tv.service.navigation.ServiceListImpl;
|
|
Packit |
5e46da |
import javax.tv.service.transport.Transport;
|
|
Packit |
5e46da |
import javax.tv.service.transport.TransportImpl;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
import org.bluray.net.BDLocator;
|
|
Packit |
5e46da |
import org.bluray.ti.TitleImpl;
|
|
Packit |
5e46da |
import org.videolan.Libbluray;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public class SIManagerImpl extends SIManager {
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
private static final Object instanceLock = new Object();
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public static SIManager createInstance() {
|
|
Packit |
5e46da |
synchronized (instanceLock) {
|
|
Packit |
5e46da |
if (instance == null)
|
|
Packit |
5e46da |
instance = new SIManagerImpl();
|
|
Packit |
5e46da |
return instance;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public static void shutdown() {
|
|
Packit |
5e46da |
synchronized (instanceLock) {
|
|
Packit |
5e46da |
instance = null;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
protected SIManagerImpl() {
|
|
Packit |
5e46da |
int ntitles = Libbluray.numTitles();
|
|
Packit |
5e46da |
LinkedList list = new LinkedList();
|
|
Packit |
5e46da |
for (int i = 0; i <= ntitles; i++) {
|
|
Packit |
5e46da |
try {
|
|
Packit |
5e46da |
list.add(new TitleImpl(i));
|
|
Packit |
5e46da |
} catch (Exception t) {
|
|
Packit |
5e46da |
org.videolan.Logger.getLogger("SIManagerImpl").error("Failed initializing title " + i + ": " + t);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
try {
|
|
Packit |
5e46da |
list.add(new TitleImpl(65535));
|
|
Packit |
5e46da |
} catch (Exception t) {
|
|
Packit |
5e46da |
org.videolan.Logger.getLogger("SIManagerImpl").error("Failed initializing title FirstPlay: " + t);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
titles = new ServiceListImpl(list);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public ServiceList filterServices(ServiceFilter filter) {
|
|
Packit |
5e46da |
return titles.filterServices(filter);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public String getPreferredLanguage() {
|
|
Packit |
5e46da |
return language;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public RatingDimension getRatingDimension(String name) throws SIException {
|
|
Packit |
5e46da |
if (!name.equals(RatingDimensionImpl.dimensionName))
|
|
Packit |
5e46da |
throw new SIException();
|
|
Packit |
5e46da |
return new RatingDimensionImpl();
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public Service getService(Locator locator) throws InvalidLocatorException, SecurityException {
|
|
Packit |
5e46da |
try {
|
|
Packit |
5e46da |
new BDLocator(locator.toExternalForm());
|
|
Packit |
5e46da |
} catch (org.davic.net.InvalidLocatorException e) {
|
|
Packit |
5e46da |
System.err.println("invalid locator: " + locator.toExternalForm() + "\n" + org.videolan.Logger.dumpStack(e));
|
|
Packit |
5e46da |
throw new javax.tv.locator.InvalidLocatorException(locator);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
return titles.findService(locator);
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public String[] getSupportedDimensions() {
|
|
Packit |
5e46da |
String[] dimensions = new String[1];
|
|
Packit |
5e46da |
dimensions[0] = RatingDimensionImpl.dimensionName;
|
|
Packit |
5e46da |
return dimensions;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public Transport[] getTransports() {
|
|
Packit |
5e46da |
Transport[] transports = new Transport[1];
|
|
Packit |
5e46da |
transports[0] = new TransportImpl();
|
|
Packit |
5e46da |
return transports;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public void registerInterest(Locator locator, boolean active)
|
|
Packit |
5e46da |
throws InvalidLocatorException, SecurityException {
|
|
Packit |
5e46da |
org.videolan.Logger.unimplemented(SIManagerImpl.class.getName(), "registerInterest");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public SIRequest retrieveProgramEvent(Locator locator, SIRequestor requestor)
|
|
Packit |
5e46da |
throws InvalidLocatorException, SecurityException {
|
|
Packit |
5e46da |
org.videolan.Logger.unimplemented(SIManagerImpl.class.getName(), "retrieveProgramEvent");
|
|
Packit |
5e46da |
throw new Error("Not implemented");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public SIRequest retrieveSIElement(Locator locator, SIRequestor requestor)
|
|
Packit |
5e46da |
throws InvalidLocatorException, SecurityException {
|
|
Packit |
5e46da |
org.videolan.Logger.unimplemented(SIManagerImpl.class.getName(), "retrieveSIElement");
|
|
Packit |
5e46da |
throw new Error("Not implemented");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public SIRequest retrieveServiceDetails(Locator locator, SIRequestor requestor)
|
|
Packit |
5e46da |
throws InvalidLocatorException, SecurityException {
|
|
Packit |
5e46da |
org.videolan.Logger.unimplemented(SIManagerImpl.class.getName(), "retrieveServiceDetails");
|
|
Packit |
5e46da |
throw new Error("Not implemented");
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
public void setPreferredLanguage(String language) {
|
|
Packit |
5e46da |
this.language = language;
|
|
Packit |
5e46da |
}
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
private ServiceListImpl titles;
|
|
Packit |
5e46da |
private String language = null;
|
|
Packit |
5e46da |
|
|
Packit |
5e46da |
private static SIManagerImpl instance = null;
|
|
Packit |
5e46da |
}
|