Added network cache param to IP cameras

pull/540/head
Saul Pablo Labajo Izquierdo 2020-09-12 09:57:33 +02:00
parent 6f976246b4
commit 0fdbcaac90
4 changed files with 19 additions and 2 deletions

View File

@ -69,6 +69,7 @@ public class CDREventWebrtcConnection extends CDREventEnd implements Comparable<
if (kMediaOptions.rtspUri != null) {
json.addProperty("rtspUri", kMediaOptions.rtspUri);
json.addProperty("adaptativeBitrate", kMediaOptions.adaptativeBitrate);
json.addProperty("networkCache", kMediaOptions.network_cache);
json.addProperty("onlyPlayWithSubscribers", kMediaOptions.onlyPlayWithSubscribers);
}
}

View File

@ -32,6 +32,7 @@ public class KurentoMediaOptions extends MediaOptions {
public String rtspUri;
public Boolean adaptativeBitrate;
public Boolean onlyPlayWithSubscribers;
public Integer network_cache;
public KurentoMediaOptions(boolean isOffer, String sdpOffer, Boolean hasAudio, Boolean hasVideo,
Boolean audioActive, Boolean videoActive, String typeOfVideo, Integer frameRate, String videoDimensions,
@ -45,7 +46,7 @@ public class KurentoMediaOptions extends MediaOptions {
public KurentoMediaOptions(boolean isOffer, String sdpOffer, Boolean hasAudio, Boolean hasVideo,
Boolean audioActive, Boolean videoActive, String typeOfVideo, Integer frameRate, String videoDimensions,
KurentoFilter filter, boolean doLoopback, String rtspUri, Boolean adaptativeBitrate,
Boolean onlyPlayWithSubscribers) {
Boolean onlyPlayWithSubscribers, Integer network_cache) {
super(hasAudio, hasVideo, audioActive, videoActive, typeOfVideo, frameRate, videoDimensions, filter);
this.isOffer = isOffer;
this.sdpOffer = sdpOffer;
@ -53,6 +54,7 @@ public class KurentoMediaOptions extends MediaOptions {
this.rtspUri = rtspUri;
this.adaptativeBitrate = adaptativeBitrate;
this.onlyPlayWithSubscribers = onlyPlayWithSubscribers;
this.network_cache = network_cache;
}
public KurentoMediaOptions(Boolean hasAudio, Boolean hasVideo, Boolean audioActive, Boolean videoActive,
@ -65,6 +67,7 @@ public class KurentoMediaOptions extends MediaOptions {
this.rtspUri = streamProperties.rtspUri;
this.adaptativeBitrate = streamProperties.adaptativeBitrate;
this.onlyPlayWithSubscribers = streamProperties.onlyPlayWithSubscribers;
this.network_cache = streamProperties.network_cache;
}
@Override
@ -76,6 +79,9 @@ public class KurentoMediaOptions extends MediaOptions {
if (onlyPlayWithSubscribers != null) {
json.addProperty("onlyPlayWithSubscribers", onlyPlayWithSubscribers);
}
if (network_cache != null) {
json.addProperty("networkCache", network_cache);
}
return json;
}

View File

@ -364,6 +364,9 @@ public abstract class MediaEndpoint {
if (!mediaOptions.adaptativeBitrate) {
playerBuilder = playerBuilder.useEncodedMedia();
}
if (mediaOptions.network_cache != null) {
playerBuilder = playerBuilder.withNetworkCache(mediaOptions.network_cache);
}
playerBuilder.buildAsync(new Continuation<PlayerEndpoint>() {

View File

@ -755,12 +755,19 @@ public class SessionRestController {
String rtspUri;
Boolean adaptativeBitrate;
Boolean onlyPlayWithSubscribers;
String network_cache_str;
Integer network_cache;
String data;
try {
type = (String) params.get("type");
rtspUri = (String) params.get("rtspUri");
adaptativeBitrate = (Boolean) params.get("adaptativeBitrate");
onlyPlayWithSubscribers = (Boolean) params.get("onlyPlayWithSubscribers");
network_cache_str = (String) params.get("networkCache");
if (network_cache_str != null)
network_cache = Integer.parseInt(network_cache_str);
else
network_cache = null;
data = (String) params.get("data");
} catch (ClassCastException e) {
return this.generateErrorResponse("Type error in some parameter",
@ -785,7 +792,7 @@ public class SessionRestController {
String videoDimensions = null;
KurentoMediaOptions mediaOptions = new KurentoMediaOptions(true, null, hasAudio, hasVideo, audioActive,
videoActive, typeOfVideo, frameRate, videoDimensions, null, false, rtspUri, adaptativeBitrate,
onlyPlayWithSubscribers);
onlyPlayWithSubscribers, network_cache);
// While closing a session IP cameras can't be published
if (session.closingLock.readLock().tryLock()) {