aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-02-22 11:08:49 -0800
committerScott Jackson <daneren2005@gmail.com>2015-02-22 11:08:49 -0800
commite239b215a067e2d1de7201f0b9182cdcf59d818b (patch)
treee35d29bba39f511e1d1642565452f4e87801b71d /src
parent43cbeb065de81f18b63331b8e98f325e79fda3ef (diff)
downloaddsub-e239b215a067e2d1de7201f0b9182cdcf59d818b.tar.gz
dsub-e239b215a067e2d1de7201f0b9182cdcf59d818b.tar.bz2
dsub-e239b215a067e2d1de7201f0b9182cdcf59d818b.zip
#320 Start of option to pass traffic while casting through device proxy
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/DLNAController.java29
-rw-r--r--src/github/daneren2005/dsub/util/Constants.java1
-rw-r--r--src/github/daneren2005/dsub/util/Util.java5
3 files changed, 32 insertions, 3 deletions
diff --git a/src/github/daneren2005/dsub/service/DLNAController.java b/src/github/daneren2005/dsub/service/DLNAController.java
index cdff990b..a2894a23 100644
--- a/src/github/daneren2005/dsub/service/DLNAController.java
+++ b/src/github/daneren2005/dsub/service/DLNAController.java
@@ -67,6 +67,8 @@ import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.serverproxy.FileProxy;
+import github.daneren2005.serverproxy.ServerProxy;
+import github.daneren2005.serverproxy.WebProxy;
public class DLNAController extends RemoteController {
private static final String TAG = DLNAController.class.getSimpleName();
@@ -77,7 +79,7 @@ public class DLNAController extends RemoteController {
SubscriptionCallback callback;
boolean supportsSeek = false;
- private FileProxy proxy;
+ private ServerProxy proxy;
String rootLocation = "";
boolean error = false;
@@ -388,7 +390,18 @@ public class DLNAController extends RemoteController {
url = proxy.getPublicAddress(currentPlaying.getCompleteFile().getPath());
}
} else {
- if(proxy != null) {
+ // Check if we want a proxy going still
+ if(Util.isCastProxy(downloadService)) {
+ if(proxy instanceof FileProxy) {
+ proxy.stop();
+ proxy = null;
+ }
+
+ if(proxy == null) {
+ proxy = new WebProxy(downloadService);
+ proxy.start();
+ }
+ } else if(proxy != null) {
proxy.stop();
proxy = null;
}
@@ -398,6 +411,11 @@ public class DLNAController extends RemoteController {
} else {
url = musicService.getMusicUrl(downloadService, song, currentPlaying.getBitRate());
}
+
+ // If proxy is going, it is a WebProxy
+ if(proxy != null) {
+ url = proxy.getPublicAddress(url);
+ }
}
// Create metadata for entry
@@ -434,8 +452,13 @@ public class DLNAController extends RemoteController {
if(song.getCoverArt() != null) {
String coverArt = null;
- if(proxy == null) {
+ if(proxy == null || proxy instanceof WebProxy) {
coverArt = musicService.getCoverArtUrl(downloadService, song);
+
+ // If proxy is going, it is a web proxy
+ if(proxy != null) {
+ coverArt = proxy.getPublicAddress(coverArt);
+ }
} else {
File coverArtFile = FileUtil.getAlbumArtFile(downloadService, song);
if(coverArtFile != null && coverArtFile.exists()) {
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java
index d97fe8d0..b0bbfe31 100644
--- a/src/github/daneren2005/dsub/util/Constants.java
+++ b/src/github/daneren2005/dsub/util/Constants.java
@@ -152,6 +152,7 @@ public final class Constants {
public static final String PREFERENCES_KEY_REPLAY_GAIN_UNTAGGED = "replayGainUntagged2";
public static final String PREFERENCES_KEY_REPLAY_GAIN_TYPE= "replayGainType";
public static final String PREFERENCES_KEY_ALBUMS_PER_FOLDER = "albumsPerFolder";
+ public static final String PREFERENCES_KEY_CAST_PROXY = "castProxy";
public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount";
public static final String OFFLINE_SCROBBLE_ID = "scrobbleID";
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java
index 01588bf2..1eaf71f8 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -560,6 +560,11 @@ public final class Util {
return Math.max(0, Constants.FREE_TRIAL_DAYS - daysSinceInstall);
}
+ public static boolean isCastProxy(Context context) {
+ SharedPreferences prefs = getPreferences(context);
+ return prefs.getBoolean(Constants.PREFERENCES_KEY_CAST_PROXY, false);
+ }
+
/**
* Get the contents of an <code>InputStream</code> as a <code>byte[]</code>.
* <p/>