openvidu-testapp Docker container

pull/32/head
pabloFuente 2018-03-02 11:36:12 +01:00
parent c2b3c46969
commit bb05d019bc
7 changed files with 132 additions and 37 deletions

View File

@ -0,0 +1,28 @@
FROM ubuntu:16.04
MAINTAINER openvidu@gmail.com
# Install Kurento Media Server (KMS)
RUN echo "deb http://ubuntu.kurento.org xenial kms6" | tee /etc/apt/sources.list.d/kurento.list \
&& apt-key adv --keyserver keyserver.ubuntu.com --recv 2F819BC0 \
&& apt-get update \
&& apt-get -y dist-upgrade \
&& apt-get -y install kurento-media-server-6.0 \
&& rm -rf /var/lib/apt/lists/*
# Install Java
RUN apt-get update && apt-get install -y openjdk-8-jdk && rm -rf /var/lib/apt/lists/*
# Configure Supervisor
RUN mkdir -p /var/log/supervisor
RUN apt-get update && apt-get install -y supervisor && rm -rf /var/lib/apt/lists/*
# Copy all files
COPY kms.sh /kms.sh
COPY web /web/
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY openvidu-server.jar openvidu-server.jar
EXPOSE 8443
# Exec supervisord
CMD ["/usr/bin/supervisord"]

View File

@ -0,0 +1,19 @@
# Copy compiled openvidu-server.jar
cp ../../openvidu-server/target/openvidu-server-"$1".jar ./openvidu-server.jar
# Build and copy openvidu-testapp static files
cd ../
ng build
cp -a dist/. ./docker/web/
cd docker
# Modify WebSocket protocol in app.js for allowing both ngrok and localhost connections
sed -i 's/OV\.initSession("wss:\/\/"/OV\.initSession("ws:\/\/"/g' ./web/app.js
# Build docker image
docker build -t openvidu/testapp .
# Delete unwanted files
rm -rf ./web
rm -rf ./openvidu-server
rm openvidu-server.jar

View File

@ -0,0 +1,19 @@
#!/bin/bash -x
set -e
if [ -n "$KMS_TURN_URL" ]; then
echo "turnURL=$KMS_TURN_URL" > /etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini
fi
if [ -n "$KMS_STUN_IP" -a -n "$KMS_STUN_PORT" ]; then
# Generate WebRtcEndpoint configuration
echo "stunServerAddress=$KMS_STUN_IP" > /etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini
echo "stunServerPort=$KMS_STUN_PORT" >> /etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini
fi
# Remove ipv6 local loop until ipv6 is supported
cat /etc/hosts | sed '/::1/d' | tee /etc/hosts > /dev/null
export GST_DEBUG=Kurento*:5
exec /usr/bin/kurento-media-server "$@"

View File

@ -0,0 +1,13 @@
[supervisord]
nodaemon=true
logfile=/var/log/supervisor/supervisord.log;
pidfile=/var/run/supervisord.pid;
loglevel=debug
[program:kms]
command=/bin/bash /kms.sh
redirect_stderr=true
[program:openvidu-server]
command=/bin/bash -c "java -Dserver.port=8443 -Dsecurity.ignored=/** -Dspring.resources.static-locations=file:///web/ -jar /openvidu-server.jar"
redirect_stderr=true

View File

@ -247,6 +247,14 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
private leaveSession(): void { private leaveSession(): void {
if (!!this.publisherRecorder) {
this.restartPublisherRecord();
}
Object.keys(this.subscribers).forEach((key) => {
if (!!this.subscribers[key].recorder) {
this.restartSubscriberRecord(key);
}
});
if (this.session) { if (this.session) {
this.session.disconnect(); this.session.disconnect();
} }
@ -446,13 +454,12 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
this.afterOpenPreview(this.publisherRecorder); this.afterOpenPreview(this.publisherRecorder);
}); });
dialogRef.afterClosed().subscribe(() => { dialogRef.afterClosed().subscribe(() => {
this.afterClosePreview(this.publisherRecorder); this.afterClosePreview();
}); });
}) })
.catch((error) => { .catch((error) => {
console.error('Error stopping LocalRecorder: ' + error); console.error('Error stopping LocalRecorder: ' + error);
}); });
this.restartPublisherRecord();
} }
} }
@ -492,13 +499,12 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
this.afterOpenPreview(this.subscribers[connectionId].recorder); this.afterOpenPreview(this.subscribers[connectionId].recorder);
}); });
dialogRef.afterClosed().subscribe(() => { dialogRef.afterClosed().subscribe(() => {
this.afterClosePreview(this.subscribers[connectionId].recorder); this.afterClosePreview(connectionId);
}); });
}) })
.catch((error) => { .catch((error) => {
console.error('Error stopping LocalRecorder: ' + error); console.error('Error stopping LocalRecorder: ' + error);
}); });
this.restartSubscriberRecord(connectionId);
} }
} }
@ -519,9 +525,6 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
if (this.unpublished) { if (this.unpublished) {
this.session.publish(this.publisher); this.session.publish(this.publisher);
} else { } else {
if (!!this.publisherRecorder && this.publisherRecording) {
this.publisherRecorder.clean();
}
this.session.unpublish(this.publisher); this.session.unpublish(this.publisher);
this.removeUserData(this.session.connection.connectionId); this.removeUserData(this.session.connection.connectionId);
this.restartPublisherRecord(); this.restartPublisherRecord();
@ -535,6 +538,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
if (!this.unpublished) { if (!this.unpublished) {
this.session.unpublish(this.publisher); this.session.unpublish(this.publisher);
this.removeUserData(this.session.connection.connectionId); this.removeUserData(this.session.connection.connectionId);
this.restartPublisherRecord();
} }
let screenChange; let screenChange;
@ -600,9 +604,6 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
subUnsubFromSubscriber(connectionId: string) { subUnsubFromSubscriber(connectionId: string) {
let subscriber: Subscriber = this.subscribers[connectionId].subscriber; let subscriber: Subscriber = this.subscribers[connectionId].subscriber;
if (this.subscribers[connectionId].subbed) { if (this.subscribers[connectionId].subbed) {
if (!!this.subscribers[connectionId].recorder && this.subscribers[connectionId].recording) {
this.subscribers[connectionId].recorder.clean();
}
this.session.unsubscribe(subscriber); this.session.unsubscribe(subscriber);
this.restartSubscriberRecord(connectionId); this.restartSubscriberRecord(connectionId);
document.getElementById('data-' + this.session.connection.connectionId + '-' + connectionId).style.marginLeft = '0'; document.getElementById('data-' + this.session.connection.connectionId + '-' + connectionId).style.marginLeft = '0';
@ -738,46 +739,61 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
private afterOpenPreview(recorder: LocalRecorder): void { private afterOpenPreview(recorder: LocalRecorder): void {
this.muteSubscribersService.updateMuted(true); this.muteSubscribersService.updateMuted(true);
recorder.preview('local-recorder-preview').controls = true; recorder.preview('recorder-preview').controls = true;
} }
private afterClosePreview(recorder: LocalRecorder): void { private afterClosePreview(connectionId?: string): void {
this.muteSubscribersService.updateMuted(false); this.muteSubscribersService.updateMuted(false);
recorder.clean(); if (!!connectionId) {
this.restartSubscriberRecord(connectionId);
} else {
this.restartPublisherRecord();
}
} }
private restartPublisherRecord(): void { private restartPublisherRecord(): void {
let el: HTMLElement = document.getElementById('local-record-icon-' + this.session.connection.connectionId); if (!!this.session) {
if (!!el) { let el: HTMLElement = document.getElementById('local-record-icon-' + this.session.connection.connectionId);
el.innerHTML = 'fiber_manual_record'; if (!!el) {
} el.innerHTML = 'fiber_manual_record';
el = document.getElementById('local-pause-icon-' + this.session.connection.connectionId); }
if (!!el) { el = document.getElementById('local-pause-icon-' + this.session.connection.connectionId);
el.innerHTML = 'pause'; if (!!el) {
} el.innerHTML = 'pause';
el = document.getElementById('local-pause-btn-' + this.session.connection.connectionId); }
if (!!el) { el = document.getElementById('local-pause-btn-' + this.session.connection.connectionId);
el.style.display = 'none'; if (!!el) {
el.style.display = 'none';
}
} }
this.publisherPaused = false; this.publisherPaused = false;
this.publisherRecording = false; this.publisherRecording = false;
if (!!this.publisherRecorder) {
this.publisherRecorder.clean();
}
} }
private restartSubscriberRecord(connectionId: string): void { private restartSubscriberRecord(connectionId: string): void {
let el: HTMLElement = document.getElementById('record-icon-' + this.session.connection.connectionId + '-' + connectionId); if (!!this.session) {
if (!!el) { let el: HTMLElement = document.getElementById('record-icon-' + this.session.connection.connectionId + '-' + connectionId);
el.innerHTML = 'fiber_manual_record'; if (!!el) {
} el.innerHTML = 'fiber_manual_record';
el = document.getElementById('pause-icon-' + this.session.connection.connectionId + '-' + connectionId); }
if (!!el) { el = document.getElementById('pause-icon-' + this.session.connection.connectionId + '-' + connectionId);
el.innerHTML = 'pause'; if (!!el) {
} el.innerHTML = 'pause';
el = document.getElementById('pause-btn-' + this.session.connection.connectionId + '-' + connectionId); }
if (!!el) { el = document.getElementById('pause-btn-' + this.session.connection.connectionId + '-' + connectionId);
el.style.display = 'none'; if (!!el) {
el.style.display = 'none';
}
} }
this.subscribers[connectionId].recording = false; this.subscribers[connectionId].recording = false;
this.subscribers[connectionId].paused = false; this.subscribers[connectionId].paused = false;
if (!!this.subscribers[connectionId].recorder) {
this.subscribers[connectionId].recorder.clean();
}
} }
} }

View File

@ -6,7 +6,7 @@ import { LocalRecorder } from 'openvidu-browser';
selector: 'app-local-recording-dialog', selector: 'app-local-recording-dialog',
template: ` template: `
<div mat-dialog-content> <div mat-dialog-content>
<div id="local-recorder-preview"></div> <div id="recorder-preview"></div>
</div> </div>
<div mat-dialog-actions> <div mat-dialog-actions>
<button mat-button mat-dialog-close>Close</button> <button mat-button mat-dialog-close>Close</button>

View File

@ -122,7 +122,7 @@ button {
margin: 3px 0 !important; margin: 3px 0 !important;
} }
#local-recorder-preview video { #recorder-preview video {
width: 500px; width: 500px;
height: inherit; height: inherit;
} }