openvidu-server: openvidu.recording.composed-url property

pull/255/head
pabloFuente 2019-04-15 13:36:25 +02:00
parent 288b05425a
commit c49de8853d
6 changed files with 54 additions and 14 deletions

View File

@ -16,27 +16,27 @@ const appRoutes: Routes = [
component: SessionDetailsComponent component: SessionDetailsComponent
}, },
{ {
path: 'layout-best-fit/:sessionId/:secret', path: 'layout-best-fit/:sessionId/:secret/:port',
component: LayoutBestFitComponent component: LayoutBestFitComponent
}, },
{ {
path: 'layout-best-fit/:sessionId/:secret/:onlyVideo', path: 'layout-best-fit/:sessionId/:secret/:onlyVideo/:port',
component: LayoutBestFitComponent component: LayoutBestFitComponent
}, },
{ {
path: 'layout-vertical-presentation/:sessionId/:secret', path: 'layout-vertical-presentation/:sessionId/:secret/:port',
component: LayoutVerticalPresentationComponent component: LayoutVerticalPresentationComponent
}, },
{ {
path: 'layout-vertical-presentation/:sessionId/:secret/:onlyVideo', path: 'layout-vertical-presentation/:sessionId/:secret/:onlyVideo/:port',
component: LayoutVerticalPresentationComponent component: LayoutVerticalPresentationComponent
}, },
{ {
path: 'layout-horizontal-presentation/:sessionId/:secret', path: 'layout-horizontal-presentation/:sessionId/:secret/:port',
component: LayoutHorizontalPresentationComponent component: LayoutHorizontalPresentationComponent
}, },
{ {
path: 'layout-horizontal-presentation/:sessionId/:secret/:onlyVideo', path: 'layout-horizontal-presentation/:sessionId/:secret/:onlyVideo/:port',
component: LayoutHorizontalPresentationComponent component: LayoutHorizontalPresentationComponent
} }
]; ];

View File

@ -29,6 +29,7 @@ export class LayoutBaseComponent implements OnInit, OnDestroy {
sessionId: string; sessionId: string;
secret: string; secret: string;
onlyVideo = false; onlyVideo = false;
port: number;
session: Session; session: Session;
subscribers: Subscriber[] = []; subscribers: Subscriber[] = [];
@ -46,6 +47,9 @@ export class LayoutBaseComponent implements OnInit, OnDestroy {
if (params.onlyVideo != null) { if (params.onlyVideo != null) {
this.onlyVideo = JSON.parse(params.onlyVideo); this.onlyVideo = JSON.parse(params.onlyVideo);
} }
if (params.port != null) {
this.port = params.port;
}
}); });
} }
@ -101,8 +105,8 @@ export class LayoutBaseComponent implements OnInit, OnDestroy {
this.updateLayout(changeFixedRatio); this.updateLayout(changeFixedRatio);
}); });
const port = !!location.port ? (':' + location.port) : ''; const p = !!this.port ? (':' + this.port) : (!!location.port ? (':' + location.port) : '');
const token = 'wss://' + location.hostname + port + '?sessionId=' + this.sessionId + '&secret=' + this.secret + '&recorder=true'; const token = 'wss://' + location.hostname + p + '?sessionId=' + this.sessionId + '&secret=' + this.secret + '&recorder=true';
this.session.connect(token) this.session.connect(token)
.catch(error => { .catch(error => {
console.error(error); console.error(error);

View File

@ -63,6 +63,9 @@ public class OpenviduConfig {
@Value("${openvidu.recording.autostop-timeout}") @Value("${openvidu.recording.autostop-timeout}")
private int openviduRecordingAutostopTimeout; private int openviduRecordingAutostopTimeout;
@Value("${openvidu.recording.composed-url}")
private String openviduRecordingComposedUrl;
@Value("${openvidu.streams.video.max-recv-bandwidth}") @Value("${openvidu.streams.video.max-recv-bandwidth}")
private int openviduStreamsVideoMaxRecvBandwidth; private int openviduStreamsVideoMaxRecvBandwidth;
@ -193,6 +196,10 @@ public class OpenviduConfig {
return this.openviduRecordingNotification; return this.openviduRecordingNotification;
} }
public String getOpenViduRecordingComposedUrl() {
return this.openviduRecordingComposedUrl;
}
public OpenViduRole[] getRolesFromRecordingNotification() { public OpenViduRole[] getRolesFromRecordingNotification() {
OpenViduRole[] roles; OpenViduRole[] roles;
switch (this.openviduRecordingNotification) { switch (this.openviduRecordingNotification) {

View File

@ -19,6 +19,8 @@ package io.openvidu.server.recording.service;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -417,9 +419,22 @@ public class ComposedRecordingService extends RecordingService {
private String getLayoutUrl(Recording recording, String shortSessionId) { private String getLayoutUrl(Recording recording, String shortSessionId) {
String secret = openviduConfig.getOpenViduSecret(); String secret = openviduConfig.getOpenViduSecret();
String location = OpenViduServer.wsUrl.replaceFirst("wss://", ""); boolean recordingUrlDefined = openviduConfig.getOpenViduRecordingComposedUrl() != null
String layout, finalUrl; && !openviduConfig.getOpenViduRecordingComposedUrl().isEmpty();
String recordingUrl = recordingUrlDefined ? openviduConfig.getOpenViduRecordingComposedUrl()
: OpenViduServer.wsUrl;
recordingUrl = recordingUrl.replaceFirst("wss://", "").replaceFirst("https://", "");
boolean startsWithHttp = recordingUrl.startsWith("http://") || recordingUrl.startsWith("ws://");
if (startsWithHttp) {
recordingUrl = recordingUrl.replaceFirst("http://", "").replaceFirst("ws://", "");
}
if (recordingUrl.endsWith("/")) {
recordingUrl = recordingUrl.substring(0, recordingUrl.length() - 1);
}
String layout, finalUrl;
if (RecordingLayout.CUSTOM.equals(recording.getRecordingLayout())) { if (RecordingLayout.CUSTOM.equals(recording.getRecordingLayout())) {
layout = recording.getCustomLayout(); layout = recording.getCustomLayout();
if (!layout.isEmpty()) { if (!layout.isEmpty()) {
@ -427,12 +442,19 @@ public class ComposedRecordingService extends RecordingService {
layout = layout.endsWith("/") ? layout.substring(0, layout.length() - 1) : layout; layout = layout.endsWith("/") ? layout.substring(0, layout.length() - 1) : layout;
} }
layout += "/index.html"; layout += "/index.html";
finalUrl = "https://OPENVIDUAPP:" + secret + "@" + location + "/layouts/custom" + layout + "?sessionId=" finalUrl = (startsWithHttp ? "http" : "https") + "://OPENVIDUAPP:" + secret + "@" + recordingUrl
+ shortSessionId + "&secret=" + secret; + "/layouts/custom" + layout + "?sessionId=" + shortSessionId + "&secret=" + secret;
} else { } else {
layout = recording.getRecordingLayout().name().toLowerCase().replaceAll("_", "-"); layout = recording.getRecordingLayout().name().toLowerCase().replaceAll("_", "-");
finalUrl = "https://OPENVIDUAPP:" + secret + "@" + location + "/#/layout-" + layout + "/" + shortSessionId Integer port = null;
+ "/" + secret + "/" + !recording.hasAudio(); try {
port = new URL(openviduConfig.getOpenViduPublicUrl()).getPort();
} catch (MalformedURLException e) {
log.error(e.getMessage());
}
finalUrl = (startsWithHttp ? "http" : "https") + "://OPENVIDUAPP:" + secret + "@" + recordingUrl
+ "/#/layout-" + layout + "/" + shortSessionId + "/" + secret + "/" + !recording.hasAudio()
+ ((port != null) ? ("/" + port) : "");
} }
return finalUrl; return finalUrl;

View File

@ -65,6 +65,12 @@
"description": "Timeout in seconds for automatically stopping the recording of a session when last user disconnects or when it starts and no user is publishing (only if RecordingMode.MANUAL)", "description": "Timeout in seconds for automatically stopping the recording of a session when last user disconnects or when it starts and no user is publishing (only if RecordingMode.MANUAL)",
"defaultValue": 120 "defaultValue": 120
}, },
{
"name": "openvidu.recording.composed-url",
"type": "java.lang.String",
"description": "URL where the composed-video recording dockerized Chrome will connect to receive published videos",
"defaultValue": ""
},
{ {
"name": "coturn.sqlite", "name": "coturn.sqlite",
"type": "java.lang.String", "type": "java.lang.String",

View File

@ -21,6 +21,7 @@ openvidu.recording.public-access: false
openvidu.recording.notification: publisher_moderator openvidu.recording.notification: publisher_moderator
openvidu.recording.custom-layout: /opt/openvidu/custom-layout openvidu.recording.custom-layout: /opt/openvidu/custom-layout
openvidu.recording.autostop-timeout: 120 openvidu.recording.autostop-timeout: 120
openvidu.recording.composed-url:
openvidu.streams.video.max-recv-bandwidth: 1000 openvidu.streams.video.max-recv-bandwidth: 1000
openvidu.streams.video.min-recv-bandwidth: 300 openvidu.streams.video.min-recv-bandwidth: 300