Remove resolution cache
Resolutions are cached by ThumbCell
This commit is contained in:
parent
28fee0b2e6
commit
a7b0b3f374
|
@ -6,14 +6,11 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
|
||||||
import com.google.common.cache.CacheBuilder;
|
|
||||||
import com.iheartradio.m3u8.Encoding;
|
import com.iheartradio.m3u8.Encoding;
|
||||||
import com.iheartradio.m3u8.Format;
|
import com.iheartradio.m3u8.Format;
|
||||||
import com.iheartradio.m3u8.ParseException;
|
import com.iheartradio.m3u8.ParseException;
|
||||||
|
@ -41,12 +38,7 @@ public class CamsodaModel extends AbstractModel {
|
||||||
private List<StreamSource> streamSources = null;
|
private List<StreamSource> streamSources = null;
|
||||||
private String status = "n/a";
|
private String status = "n/a";
|
||||||
private float sortOrder = 0;
|
private float sortOrder = 0;
|
||||||
|
int[] resolution = new int[2];
|
||||||
private static Cache<String, int[]> streamResolutionCache = CacheBuilder.newBuilder()
|
|
||||||
.initialCapacity(10_000)
|
|
||||||
.maximumSize(10_000)
|
|
||||||
.expireAfterWrite(30, TimeUnit.MINUTES)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
public String getStreamUrl() throws IOException {
|
public String getStreamUrl() throws IOException {
|
||||||
if(streamUrl == null) {
|
if(streamUrl == null) {
|
||||||
|
@ -139,13 +131,11 @@ public class CamsodaModel extends AbstractModel {
|
||||||
@Override
|
@Override
|
||||||
public void invalidateCacheEntries() {
|
public void invalidateCacheEntries() {
|
||||||
streamSources = null;
|
streamSources = null;
|
||||||
streamResolutionCache.invalidate(getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getStreamResolution(boolean failFast) throws ExecutionException {
|
public int[] getStreamResolution(boolean failFast) throws ExecutionException {
|
||||||
int[] resolution = streamResolutionCache.getIfPresent(getName());
|
if(failFast) {
|
||||||
if(resolution != null) {
|
|
||||||
return resolution;
|
return resolution;
|
||||||
} else {
|
} else {
|
||||||
if(failFast) {
|
if(failFast) {
|
||||||
|
@ -158,7 +148,6 @@ public class CamsodaModel extends AbstractModel {
|
||||||
} else {
|
} else {
|
||||||
StreamSource src = streamSources.get(0);
|
StreamSource src = streamSources.get(0);
|
||||||
resolution = new int[] {src.width, src.height};
|
resolution = new int[] {src.width, src.height};
|
||||||
streamResolutionCache.put(getName(), resolution);
|
|
||||||
return resolution;
|
return resolution;
|
||||||
}
|
}
|
||||||
} catch (IOException | ParseException | PlaylistException e) {
|
} catch (IOException | ParseException | PlaylistException e) {
|
||||||
|
|
Loading…
Reference in New Issue