Merge pull request #540 from naevatec/rtsp_network_cache_param

Added network cache param to IP cameras
pull/546/head
Pablo Fuente Pérez 2020-09-18 13:41:44 +02:00 committed by GitHub
commit d0ed5e5345
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) { if (kMediaOptions.rtspUri != null) {
json.addProperty("rtspUri", kMediaOptions.rtspUri); json.addProperty("rtspUri", kMediaOptions.rtspUri);
json.addProperty("adaptativeBitrate", kMediaOptions.adaptativeBitrate); json.addProperty("adaptativeBitrate", kMediaOptions.adaptativeBitrate);
json.addProperty("networkCache", kMediaOptions.networkCache);
json.addProperty("onlyPlayWithSubscribers", kMediaOptions.onlyPlayWithSubscribers); json.addProperty("onlyPlayWithSubscribers", kMediaOptions.onlyPlayWithSubscribers);
} }
} }

View File

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

View File

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

View File

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