diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-12-08 15:43:44 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-12-08 15:43:44 -0800 |
commit | 6471d5337d542fde05ece58b9337a60b3411fe8b (patch) | |
tree | 64d5b9ccbbca134c9064fcb867a2512002e26374 /src/github/daneren2005 | |
parent | 6e221bf1f4463fb8ca9255d3f02362713d42436f (diff) | |
download | dsub-6471d5337d542fde05ece58b9337a60b3411fe8b.tar.gz dsub-6471d5337d542fde05ece58b9337a60b3411fe8b.tar.bz2 dsub-6471d5337d542fde05ece58b9337a60b3411fe8b.zip |
Upgrade to Cling 2.0.1, up min SDK to 4.0+
Diffstat (limited to 'src/github/daneren2005')
3 files changed, 136 insertions, 48 deletions
diff --git a/src/github/daneren2005/dsub/domain/DLNADevice.java b/src/github/daneren2005/dsub/domain/DLNADevice.java index ba4c2777..2de84013 100644 --- a/src/github/daneren2005/dsub/domain/DLNADevice.java +++ b/src/github/daneren2005/dsub/domain/DLNADevice.java @@ -22,7 +22,7 @@ package github.daneren2005.dsub.domain; import android.os.Parcel;
import android.os.Parcelable;
-import org.teleal.cling.model.meta.Device;
+import org.fourthline.cling.model.meta.Device;
/**
* Created by Scott on 11/1/2014.
diff --git a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java index 44cde0ef..3601e696 100644 --- a/src/github/daneren2005/dsub/provider/DLNARouteProvider.java +++ b/src/github/daneren2005/dsub/provider/DLNARouteProvider.java @@ -33,19 +33,20 @@ import android.support.v7.media.MediaRouteProvider; import android.support.v7.media.MediaRouteProviderDescriptor; import android.util.Log; -import org.teleal.cling.android.AndroidUpnpService; -import org.teleal.cling.android.AndroidUpnpServiceImpl; -import org.teleal.cling.model.action.ActionInvocation; -import org.teleal.cling.model.message.UpnpResponse; -import org.teleal.cling.model.meta.Device; -import org.teleal.cling.model.meta.LocalDevice; -import org.teleal.cling.model.meta.RemoteDevice; -import org.teleal.cling.model.meta.StateVariable; -import org.teleal.cling.model.meta.StateVariableAllowedValueRange; -import org.teleal.cling.model.types.ServiceType; -import org.teleal.cling.registry.Registry; -import org.teleal.cling.registry.RegistryListener; -import org.teleal.cling.support.renderingcontrol.callback.GetVolume; +import org.eclipse.jetty.util.log.Logger; +import org.fourthline.cling.android.AndroidUpnpService; +import org.fourthline.cling.android.AndroidUpnpServiceImpl; +import org.fourthline.cling.model.action.ActionInvocation; +import org.fourthline.cling.model.message.UpnpResponse; +import org.fourthline.cling.model.meta.Device; +import org.fourthline.cling.model.meta.LocalDevice; +import org.fourthline.cling.model.meta.RemoteDevice; +import org.fourthline.cling.model.meta.StateVariable; +import org.fourthline.cling.model.meta.StateVariableAllowedValueRange; +import org.fourthline.cling.model.types.ServiceType; +import org.fourthline.cling.registry.Registry; +import org.fourthline.cling.registry.RegistryListener; +import org.fourthline.cling.support.renderingcontrol.callback.GetVolume; import java.util.ArrayList; import java.util.HashMap; @@ -58,9 +59,6 @@ import github.daneren2005.dsub.service.DLNAController; import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.service.RemoteController; -/** - * Created by Scott on 11/28/13. - */ public class DLNARouteProvider extends MediaRouteProvider { private static final String TAG = DLNARouteProvider.class.getSimpleName(); public static final String CATEGORY_DLNA = "github.daneren2005.dsub.DLNA"; @@ -75,6 +73,10 @@ public class DLNARouteProvider extends MediaRouteProvider { public DLNARouteProvider(Context context) { super(context); + + // Use custom logger + org.eclipse.jetty.util.log.Log.setLog(new JettyAndroidLog()); + this.downloadService = (DownloadService) context; dlnaServiceConnection = new ServiceConnection() { @Override @@ -83,12 +85,12 @@ public class DLNARouteProvider extends MediaRouteProvider { dlnaService.getRegistry().addListener(new RegistryListener() { @Override public void remoteDeviceDiscoveryStarted(Registry registry, RemoteDevice remoteDevice) { - + Log.i(TAG, "Stared DLNA discovery"); } @Override public void remoteDeviceDiscoveryFailed(Registry registry, RemoteDevice remoteDevice, Exception e) { - + Log.w(TAG, "Failed to discover DLNA devices"); } @Override @@ -138,7 +140,10 @@ public class DLNARouteProvider extends MediaRouteProvider { dlnaService = null; } }; - context.bindService(new Intent(context, AndroidUpnpServiceImpl.class), dlnaServiceConnection, Context.BIND_AUTO_CREATE); + + if(!context.getApplicationContext().bindService(new Intent(context, AndroidUpnpServiceImpl.class), dlnaServiceConnection, Context.BIND_AUTO_CREATE)) { + Log.e(TAG, "Failed to bind to DLNA service"); + } } private void broadcastDescriptors() { @@ -189,7 +194,7 @@ public class DLNARouteProvider extends MediaRouteProvider { } private void deviceAdded(final Device device) { - final org.teleal.cling.model.meta.Service renderingControl = device.findService(new ServiceType("schemas-upnp-org", "RenderingControl")); + final org.fourthline.cling.model.meta.Service renderingControl = device.findService(new ServiceType("schemas-upnp-org", "RenderingControl")); if(renderingControl == null) { return; } @@ -235,6 +240,8 @@ public class DLNARouteProvider extends MediaRouteProvider { adding.remove(id); } }); + } else { + adding.remove(id); } } private void deviceRemoved(Device device) { @@ -302,4 +309,86 @@ public class DLNARouteProvider extends MediaRouteProvider { broadcastDescriptors(); } } + + public static class JettyAndroidLog implements Logger { + final private static java.util.logging.Logger log = java.util.logging.Logger.getLogger("Jetty"); + + public static boolean __isIgnoredEnabled = false; + public String _name; + + public JettyAndroidLog() { + this (JettyAndroidLog.class.getName()); + } + + public JettyAndroidLog(String name) { + _name = name; + } + + public String getName () { + return _name; + } + + public void debug(Throwable th) { + // Log.d(TAG, "", th); + } + + public void debug(String msg, Throwable th) { + // Log.d(TAG, msg, th); + } + + public void debug(String msg, Object... args) { + // Log.d(TAG, msg); + } + + public Logger getLogger(String name) { + return new JettyAndroidLog(name); + } + + public void info(String msg, Object... args) { + Log.i(TAG, msg); + } + + public void info(Throwable th) { + Log.i(TAG, "", th); + } + + public void info(String msg, Throwable th) { + Log.i(TAG, msg, th); + } + + public boolean isDebugEnabled() { + return false; + } + + public void warn(Throwable th) { + Log.w(TAG, "", th); + } + + public void warn(String msg, Object... args) { + Log.w(TAG, msg); + } + + public void warn(String msg, Throwable th) { + Log.w(TAG, msg, th); + } + + public boolean isIgnoredEnabled () { + return __isIgnoredEnabled; + } + + + public void ignore(Throwable ignored) { + if (__isIgnoredEnabled) { + warn("IGNORED", ignored); + } + } + + public void setIgnoredEnabled(boolean enabled) { + __isIgnoredEnabled = enabled; + } + + public void setDebugEnabled(boolean enabled) { + + } + } } diff --git a/src/github/daneren2005/dsub/service/DLNAController.java b/src/github/daneren2005/dsub/service/DLNAController.java index 2448b088..522bf586 100644 --- a/src/github/daneren2005/dsub/service/DLNAController.java +++ b/src/github/daneren2005/dsub/service/DLNAController.java @@ -19,31 +19,30 @@ import android.content.SharedPreferences; import android.os.Looper;
import android.util.Log;
-import org.teleal.cling.controlpoint.ControlPoint;
-import org.teleal.cling.controlpoint.SubscriptionCallback;
-import org.teleal.cling.model.action.ActionInvocation;
-import org.teleal.cling.model.gena.CancelReason;
-import org.teleal.cling.model.gena.GENASubscription;
-import org.teleal.cling.model.message.UpnpResponse;
-import org.teleal.cling.model.meta.Device;
-import org.teleal.cling.model.meta.StateVariable;
-import org.teleal.cling.model.state.StateVariableValue;
-import org.teleal.cling.model.types.ServiceType;
-import org.teleal.cling.support.avtransport.callback.Pause;
-import org.teleal.cling.support.avtransport.callback.Play;
-import org.teleal.cling.support.avtransport.callback.Seek;
-import org.teleal.cling.support.avtransport.callback.SetAVTransportURI;
-import org.teleal.cling.support.avtransport.callback.Stop;
-import org.teleal.cling.support.avtransport.lastchange.AVTransportLastChangeParser;
-import org.teleal.cling.support.avtransport.lastchange.AVTransportVariable;
-import org.teleal.cling.support.contentdirectory.DIDLParser;
-import org.teleal.cling.support.lastchange.LastChange;
-import org.teleal.cling.support.model.DIDLContent;
-import org.teleal.cling.support.model.SeekMode;
-import org.teleal.cling.support.model.item.Item;
-import org.teleal.cling.support.model.item.MusicTrack;
-import org.teleal.cling.support.model.item.VideoItem;
-import org.teleal.cling.support.renderingcontrol.callback.SetVolume;
+import org.fourthline.cling.controlpoint.ControlPoint;
+import org.fourthline.cling.controlpoint.SubscriptionCallback;
+import org.fourthline.cling.model.action.ActionInvocation;
+import org.fourthline.cling.model.gena.CancelReason;
+import org.fourthline.cling.model.gena.GENASubscription;
+import org.fourthline.cling.model.message.UpnpResponse;
+import org.fourthline.cling.model.meta.Device;
+import org.fourthline.cling.model.state.StateVariableValue;
+import org.fourthline.cling.model.types.ServiceType;
+import org.fourthline.cling.support.avtransport.callback.Pause;
+import org.fourthline.cling.support.avtransport.callback.Play;
+import org.fourthline.cling.support.avtransport.callback.Seek;
+import org.fourthline.cling.support.avtransport.callback.SetAVTransportURI;
+import org.fourthline.cling.support.avtransport.callback.Stop;
+import org.fourthline.cling.support.avtransport.lastchange.AVTransportLastChangeParser;
+import org.fourthline.cling.support.avtransport.lastchange.AVTransportVariable;
+import org.fourthline.cling.support.contentdirectory.DIDLParser;
+import org.fourthline.cling.support.lastchange.LastChange;
+import org.fourthline.cling.support.model.DIDLContent;
+import org.fourthline.cling.support.model.SeekMode;
+import org.fourthline.cling.support.model.item.Item;
+import org.fourthline.cling.support.model.item.MusicTrack;
+import org.fourthline.cling.support.model.item.VideoItem;
+import org.fourthline.cling.support.renderingcontrol.callback.SetVolume;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -120,7 +119,7 @@ public class DLNAController extends RemoteController { boolean failed = false;
for(StateVariableValue val: m.values()) {
if(val.toString().indexOf("TransportStatus val=\"ERROR_OCCURRED\"") != -1) {
- Log.w(TAG, "Failed to load with event: val.toString()");
+ Log.w(TAG, "Failed to load with event: " + val.toString());
failed = true;
}
}
@@ -195,7 +194,7 @@ public class DLNAController extends RemoteController { public void shutdown() {
controlPoint.execute(new Stop(device.renderer.findService(new ServiceType("schemas-upnp-org", "AVTransport"))) {
@Override
- public void failure(ActionInvocation invocation, org.teleal.cling.model.message.UpnpResponse operation, String defaultMessage) {
+ public void failure(ActionInvocation invocation, org.fourthline.cling.model.message.UpnpResponse operation, String defaultMessage) {
Log.w(TAG, "Stop failed: " + defaultMessage);
}
});
|