Removed openvidu-call from tutorials
@ -1 +0,0 @@
|
||||
**/node_modules
|
||||
53
openvidu-call/.gitignore
vendored
@ -1,53 +0,0 @@
|
||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# compiled output
|
||||
*.angular
|
||||
*/dist
|
||||
/tmp
|
||||
/out-tsc
|
||||
|
||||
# Only exists if Bazel was run
|
||||
/bazel-out
|
||||
|
||||
# dependencies
|
||||
*/node_modules
|
||||
|
||||
# profiling files
|
||||
chrome-profiler-events*.json
|
||||
speed-measure-plugin*.json
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# IDE - VSCode
|
||||
*.vscode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.history/*
|
||||
|
||||
# misc
|
||||
/.sass-cache
|
||||
/connect.lock
|
||||
/coverage
|
||||
/libpeerconnection.log
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
testem.log
|
||||
/typings
|
||||
|
||||
# System Files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
.editorconfig
|
||||
*.browserslistrc
|
||||
.git/*
|
||||
@ -1,16 +0,0 @@
|
||||
[](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
[](https://github.com/OpenVidu/openvidu/actions/workflows/openvidu-ce-test.yml)
|
||||
[](https://docs.openvidu.io/en/stable/?badge=stable)
|
||||
[](https://hub.docker.com/r/openvidu/openvidu-call/)
|
||||
[](https://openvidu.discourse.group/)
|
||||
|
||||
[![][OpenViduLogo]](http://openvidu.io)
|
||||
|
||||
openvidu-call
|
||||
===
|
||||
|
||||
Visit [openvidu.io/demos](http://openvidu.io/demos#3)
|
||||
|
||||
[OpenViduLogo]: https://secure.gravatar.com/avatar/5daba1d43042f2e4e85849733c8e5702?s=120
|
||||
|
||||
[Documentation](https://docs.openvidu.io/en/latest/demos/openvidu-call/)
|
||||
@ -1,5 +0,0 @@
|
||||
FROM openvidu/openvidu-dev-node:10.x
|
||||
|
||||
COPY run.sh /run.sh
|
||||
|
||||
ENTRYPOINT [ "/run.sh" ]
|
||||
@ -1,7 +0,0 @@
|
||||
#!/bin/bash -x
|
||||
set -eu -o pipefail
|
||||
|
||||
git clone https://github.com/openvidu/openvidu-call
|
||||
cd openvidu-call/front/openvidu-call/
|
||||
npm install
|
||||
./node_modules/protractor/bin/protractor ./e2e/protractor.conf.js --baseUrl=${APP_URL}
|
||||
@ -1,35 +0,0 @@
|
||||
# Build OpenVidu Call for production
|
||||
FROM node:lts-alpine3.16 as openvidu-call-build
|
||||
|
||||
WORKDIR /openvidu-call
|
||||
|
||||
ARG BASE_HREF=/
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npm install --location=global npm
|
||||
|
||||
# Build OpenVidu Call frontend
|
||||
RUN rm openvidu-call-front/package-lock.json && \
|
||||
# Install frontend dependencies and build it for production
|
||||
cd openvidu-call-front && npm install && \
|
||||
npm run prod:build-java ${BASE_HREF} && \
|
||||
cd ../ && rm -rf openvidu-call-front
|
||||
|
||||
FROM maven
|
||||
|
||||
WORKDIR /opt/openvidu-call
|
||||
|
||||
COPY --from=openvidu-call-build /openvidu-call/openvidu-call-back-java .
|
||||
|
||||
# Install backend dependencies and build it for production
|
||||
RUN mvn clean install package
|
||||
|
||||
# Entrypoint
|
||||
COPY docker/java-entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN cat /usr/local/bin/entrypoint.sh
|
||||
RUN apt-get install curl && \
|
||||
chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
CMD ["/usr/local/bin/entrypoint.sh"]
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
# Build OpenVidu Call for production
|
||||
FROM node:16-alpine3.16 as openvidu-call-build
|
||||
|
||||
WORKDIR /openvidu-call
|
||||
|
||||
ARG BASE_HREF=/
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npm install --location=global npm
|
||||
|
||||
# Build OpenVidu Call frontend
|
||||
RUN rm openvidu-call-front/package-lock.json && \
|
||||
# Install frontend dependencies and build it for production
|
||||
cd openvidu-call-front && npm install && \
|
||||
npm run prod:build ${BASE_HREF} && \
|
||||
cd ../ && rm -rf openvidu-call-front
|
||||
|
||||
FROM node:16-alpine3.16
|
||||
|
||||
WORKDIR /opt/openvidu-call
|
||||
|
||||
COPY --from=openvidu-call-build /openvidu-call/openvidu-call-back .
|
||||
|
||||
RUN npm install --location=global npm
|
||||
|
||||
# Install backend dependencies and build it for production
|
||||
RUN npm install && \
|
||||
npm run build
|
||||
|
||||
# Move frontend build to dist
|
||||
RUN mv public dist/
|
||||
|
||||
# Entrypoint
|
||||
COPY docker/node-entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN apk add curl && \
|
||||
chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
CMD ["/usr/local/bin/entrypoint.sh"]
|
||||
@ -1,7 +0,0 @@
|
||||
## OpenVidu Call docker
|
||||
|
||||
To build the Docker image:
|
||||
|
||||
```
|
||||
docker build -f Dockerfile -t <your-tag-name> --build-arg RELEASE_VERSION=<your-release-version> .
|
||||
```
|
||||
@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
[[ -z "${OPENVIDU_URL}" ]] && export OPENVIDU_URL=$(curl -s ifconfig.co)
|
||||
[[ -z "${OPENVIDU_SECRET}" ]] && export OPENVIDU_SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||
|
||||
cd /opt/openvidu-call
|
||||
|
||||
[ ! -z "${OPENVIDU_URL}" ] && JAVA_PROPERTIES=" -DOPENVIDU_URL=${OPENVIDU_URL}"
|
||||
[ ! -z "${OPENVIDU_SECRET}" ] && JAVA_PROPERTIES=" ${JAVA_PROPERTIES} -DOPENVIDU_SECRET=${OPENVIDU_SECRET}"
|
||||
[ ! -z "${SERVER_PORT}" ] && JAVA_PROPERTIES=" ${JAVA_PROPERTIES} -Dserver.port=${SERVER_PORT}"
|
||||
[ ! -z "${ADMIN_SECRET}" ] && JAVA_PROPERTIES=" ${JAVA_PROPERTIES} -DADMIN_SECRET=${ADMIN_SECRET}"
|
||||
[ ! -z "${RECORDING}" ] && JAVA_PROPERTIES=" ${JAVA_PROPERTIES} -DRECORDING=${RECORDING}"
|
||||
[ ! -z "${SERVER_PORT}" ] && JAVA_PROPERTIES=" ${JAVA_PROPERTIES} -Dserver.port=${SERVER_PORT}"
|
||||
|
||||
java ${JAVA_PROPERTIES} -jar target/openvidu-call-back-java.jar
|
||||
@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
[[ -z "${OPENVIDU_URL}" ]] && export OPENVIDU_URL=$(curl -s ifconfig.co)
|
||||
[[ -z "${OPENVIDU_SECRET}" ]] && export OPENVIDU_SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||
|
||||
# openvidu-call configuration
|
||||
cat>/opt/openvidu-call/.env<<EOF
|
||||
SERVER_PORT=${SERVER_PORT}
|
||||
OPENVIDU_URL=${OPENVIDU_URL}
|
||||
OPENVIDU_SECRET=${OPENVIDU_SECRET}
|
||||
ADMIN_SECRET=${ADMIN_SECRET}
|
||||
RECORDING=${RECORDING}
|
||||
CALL_OPENVIDU_CERTTYPE=${CALL_OPENVIDU_CERTTYPE}
|
||||
EOF
|
||||
|
||||
cd /opt/openvidu-call
|
||||
node dist/app.js
|
||||
24
openvidu-call/openvidu-call-back-java/.gitignore
vendored
@ -1,24 +0,0 @@
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
target/
|
||||
@ -1,25 +0,0 @@
|
||||
# openvidu-call-back-java
|
||||
|
||||
This is a fully functional OpenVidu Call server application sample built for Java with Spring Boot. Visit [OpenVidu Call](https://docs.openvidu.io/en/stable//components/openvidu-call/) documentation for further context.
|
||||
|
||||
It internally uses [openvidu-java-client SDK](https://docs.openvidu.io/en/stable/reference-docs/openvidu-java-client/).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Java (>=11)](https://www.java.com/en/download/manual.jsp)
|
||||
- [Maven](https://maven.apache.org)
|
||||
|
||||
## Run
|
||||
|
||||
Download repository
|
||||
|
||||
```
|
||||
git clone git@github.com:OpenVidu/openvidu-tutorials.git
|
||||
cd openvidu-tutorials/openvidu-call/openvidu-call-back-java
|
||||
```
|
||||
|
||||
Run the application
|
||||
|
||||
```
|
||||
mvn spring-boot:run
|
||||
```
|
||||
@ -1,57 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>io.openvidu</groupId>
|
||||
<artifactId>openvidu-call-back-java</artifactId>
|
||||
<version>2.22.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>openvidu-call-back-java</name>
|
||||
<url>https://github.com/OpenVidu/openvidu-tutorials/tree/master/openvidu-call/openvidu-call-back-java</url>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>11</java.version>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<start-class>io.openvidu.call.java.App</start-class>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.openvidu</groupId>
|
||||
<artifactId>openvidu-java-client</artifactId>
|
||||
<version>2.22.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>openvidu-call-back-java</finalName>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -1,13 +0,0 @@
|
||||
package io.openvidu.call.java;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(App.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,104 +0,0 @@
|
||||
package io.openvidu.call.java.controllers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CookieValue;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.openvidu.call.java.services.OpenViduService;
|
||||
import io.openvidu.java.client.OpenViduHttpException;
|
||||
import io.openvidu.java.client.OpenViduJavaClientException;
|
||||
import io.openvidu.java.client.Recording;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@RestController
|
||||
@RequestMapping("admin")
|
||||
public class AdminController {
|
||||
|
||||
@Value("${ADMIN_SECRET}")
|
||||
private String ADMIN_SECRET;
|
||||
|
||||
@Autowired
|
||||
private OpenViduService openviduService;
|
||||
|
||||
@PostMapping("/login")
|
||||
public ResponseEntity<?> login(@RequestBody(required = false) Map<String, String> params,
|
||||
@CookieValue(name = OpenViduService.RECORDING_TOKEN_NAME, defaultValue = "") String recordingToken, HttpServletResponse res) {
|
||||
|
||||
String message = "";
|
||||
Map<String, Object> response = new HashMap<String, Object>();
|
||||
|
||||
String password = params.get("password");
|
||||
String sessionToken = this.openviduService.getSessionIdFromCookie(recordingToken);
|
||||
boolean isAdminTokenValid = this.openviduService.adminTokens.contains(sessionToken);
|
||||
|
||||
boolean isAuthValid = password.equals(ADMIN_SECRET) || isAdminTokenValid;
|
||||
if (isAuthValid) {
|
||||
try {
|
||||
if (sessionToken.isEmpty() || !openviduService.adminTokens.contains(sessionToken)) {
|
||||
// Save session token
|
||||
String token = UUID.randomUUID().toString();
|
||||
|
||||
Cookie cookie = new Cookie(OpenViduService.ADMIN_TOKEN_NAME, token);
|
||||
cookie.setPath("/");
|
||||
res.addCookie(cookie);
|
||||
|
||||
cookie = new Cookie("session", token);
|
||||
cookie.setPath("/");
|
||||
res.addCookie(cookie);
|
||||
|
||||
openviduService.adminTokens.add(token);
|
||||
}
|
||||
List<Recording> recordings = openviduService.listAllRecordings();
|
||||
System.out.println("Login succeeded");
|
||||
System.out.println(recordings.size() + " Recordings found");
|
||||
response.put("recordings", recordings);
|
||||
|
||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||
} catch (OpenViduJavaClientException | OpenViduHttpException error) {
|
||||
|
||||
if(Integer.parseInt(error.getMessage()) == 501) {
|
||||
System.err.println(error.getMessage() + ". OpenVidu Server recording module is disabled.");
|
||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||
} else {
|
||||
message = error.getMessage() + " Unexpected error getting recordings";
|
||||
error.printStackTrace();
|
||||
System.err.println(message);
|
||||
return new ResponseEntity<>(message, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
message = "Permissions denied";
|
||||
System.err.println(message);
|
||||
return new ResponseEntity<>(null, HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/logout")
|
||||
public ResponseEntity<Void> logout(@RequestBody(required = false) Map<String, String> params,
|
||||
@CookieValue(name = "session", defaultValue = "") String sessionToken,
|
||||
HttpServletResponse res) {
|
||||
this.openviduService.adminTokens.remove(sessionToken);
|
||||
Cookie cookie = new Cookie("session", null);
|
||||
res.addCookie(cookie);
|
||||
return new ResponseEntity<>(null, HttpStatus.OK);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,233 +0,0 @@
|
||||
package io.openvidu.call.java.controllers;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CookieValue;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.openvidu.call.java.services.OpenViduService;
|
||||
import io.openvidu.call.java.services.ProxyService;
|
||||
import io.openvidu.java.client.OpenViduHttpException;
|
||||
import io.openvidu.java.client.OpenViduJavaClientException;
|
||||
import io.openvidu.java.client.Recording;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@RestController
|
||||
@RequestMapping("/recordings")
|
||||
public class RecordingController {
|
||||
|
||||
@Value("${RECORDING}")
|
||||
private String RECORDING;
|
||||
|
||||
@Autowired
|
||||
private OpenViduService openviduService;
|
||||
|
||||
@Autowired
|
||||
private ProxyService proxyService;
|
||||
|
||||
@GetMapping("")
|
||||
public ResponseEntity<?> getRecordings(
|
||||
@CookieValue(name = OpenViduService.RECORDING_TOKEN_NAME, defaultValue = "") String recordingToken) {
|
||||
try {
|
||||
List<Recording> recordings = new ArrayList<Recording>();
|
||||
boolean IS_RECORDING_ENABLED = RECORDING.toUpperCase().equals("ENABLED");
|
||||
String sessionId = openviduService.getSessionIdFromCookie(recordingToken);
|
||||
boolean isAdminDashboard = openviduService.adminTokens.contains(sessionId);
|
||||
|
||||
if ((!sessionId.isEmpty() && IS_RECORDING_ENABLED
|
||||
&& openviduService.isValidToken(sessionId, recordingToken)) || isAdminDashboard) {
|
||||
if (isAdminDashboard) {
|
||||
recordings = this.openviduService.listAllRecordings();
|
||||
} else {
|
||||
long date = openviduService.getDateFromCookie(recordingToken);
|
||||
recordings = openviduService.listRecordingsBySessionIdAndDate(sessionId, date);
|
||||
}
|
||||
return new ResponseEntity<>(recordings, HttpStatus.OK);
|
||||
} else {
|
||||
String message = IS_RECORDING_ENABLED ? "Permissions denied to drive recording"
|
||||
: "Recording is disabled";
|
||||
System.err.println(message);
|
||||
return new ResponseEntity<>(message, HttpStatus.FORBIDDEN);
|
||||
|
||||
}
|
||||
} catch (OpenViduJavaClientException | OpenViduHttpException error) {
|
||||
error.printStackTrace();
|
||||
int code = Integer.parseInt(error.getMessage());
|
||||
String message = "Unexpected error getting all recordings";
|
||||
if (code == 404) {
|
||||
message = "No recording exist for the session";
|
||||
}
|
||||
System.err.println(message);
|
||||
return new ResponseEntity<>(message, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/start")
|
||||
public ResponseEntity<?> startRecording(@RequestBody(required = false) Map<String, String> params,
|
||||
@CookieValue(name = OpenViduService.RECORDING_TOKEN_NAME, defaultValue = "") String recordingToken) {
|
||||
|
||||
try {
|
||||
String sessionId = params.get("sessionId");
|
||||
if (openviduService.isValidToken(sessionId, recordingToken)) {
|
||||
Recording startingRecording = openviduService.startRecording(sessionId);
|
||||
openviduService.recordingMap.get(sessionId).setRecordingId(startingRecording.getId());
|
||||
System.out.println("Starting recording in " + sessionId);
|
||||
return new ResponseEntity<>(startingRecording, HttpStatus.OK);
|
||||
|
||||
} else {
|
||||
String message = "Permissions denied for starting recording in session " + sessionId;
|
||||
System.out.println(message);
|
||||
return new ResponseEntity<>(message, HttpStatus.FORBIDDEN);
|
||||
}
|
||||
} catch (OpenViduJavaClientException | OpenViduHttpException error) {
|
||||
error.printStackTrace();
|
||||
int code = Integer.parseInt(error.getMessage());
|
||||
String message = "Unexpected error starting recording";
|
||||
if (code == 409) {
|
||||
message = "The session is already being recorded.";
|
||||
} else if (code == 501) {
|
||||
message = "OpenVidu Server recording module is disabled";
|
||||
} else if (code == 406) {
|
||||
message = "The session has no connected participants";
|
||||
}
|
||||
System.err.println(message);
|
||||
return new ResponseEntity<>(message, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/stop")
|
||||
public ResponseEntity<?> stopRecording(@RequestBody(required = false) Map<String, String> params,
|
||||
@CookieValue(name = OpenViduService.RECORDING_TOKEN_NAME, defaultValue = "") String recordingToken) {
|
||||
try {
|
||||
String sessionId = params.get("sessionId");
|
||||
if (openviduService.isValidToken(sessionId, recordingToken)) {
|
||||
String recordingId = openviduService.recordingMap.get(sessionId).getRecordingId();
|
||||
|
||||
if (!recordingId.isEmpty()) {
|
||||
System.out.println("Stopping recording in " + sessionId);
|
||||
openviduService.stopRecording(recordingId);
|
||||
long date = openviduService.getDateFromCookie(recordingToken);
|
||||
List<Recording> recordingList = openviduService.listRecordingsBySessionIdAndDate(sessionId, date);
|
||||
openviduService.recordingMap.get(sessionId).setRecordingId("");
|
||||
return new ResponseEntity<>(recordingList, HttpStatus.OK);
|
||||
} else {
|
||||
String message = "Session was not being recorded";
|
||||
System.err.println(message);
|
||||
return new ResponseEntity<>(message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
} else {
|
||||
String message = "Permissions denied to drive recording";
|
||||
System.err.println(message);
|
||||
return new ResponseEntity<>(message, HttpStatus.FORBIDDEN);
|
||||
}
|
||||
} catch (OpenViduJavaClientException | OpenViduHttpException error) {
|
||||
error.printStackTrace();
|
||||
int code = Integer.parseInt(error.getMessage());
|
||||
String message = "Unexpected error stopping recording";
|
||||
if (code == 501) {
|
||||
message = "OpenVidu Server recording module is disabled";
|
||||
} else if (code == 406) {
|
||||
message = "Recording has STARTING status. Wait until STARTED status before stopping the recording";
|
||||
}
|
||||
System.err.println(message);
|
||||
return new ResponseEntity<>(message, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{recordingId}")
|
||||
public ResponseEntity<?> deleteRecording(@PathVariable String recordingId,
|
||||
@CookieValue(name = OpenViduService.RECORDING_TOKEN_NAME, defaultValue = "") String recordingToken,
|
||||
@CookieValue(name = "session", defaultValue = "") String sessionToken) {
|
||||
try {
|
||||
List<Recording> recordings = new ArrayList<Recording>();
|
||||
String sessionId = openviduService.getSessionIdFromCookie(recordingToken);
|
||||
boolean isAdminDashboard = openviduService.adminTokens.contains(sessionToken);
|
||||
|
||||
if ((!sessionId.isEmpty() && openviduService.isValidToken(sessionId, recordingToken)) || isAdminDashboard) {
|
||||
if (recordingId.isEmpty()) {
|
||||
String message = "Missing recording id parameter.";
|
||||
System.err.println(message);
|
||||
return new ResponseEntity<>(message, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
System.out.println("Deleting recording " + recordingId);
|
||||
openviduService.deleteRecording(recordingId);
|
||||
if (isAdminDashboard && !sessionToken.isEmpty()) {
|
||||
recordings = openviduService.listAllRecordings();
|
||||
} else {
|
||||
long date = openviduService.getDateFromCookie(recordingToken);
|
||||
recordings = openviduService.listRecordingsBySessionIdAndDate(sessionId, date);
|
||||
}
|
||||
return new ResponseEntity<>(recordings, HttpStatus.OK);
|
||||
|
||||
} else {
|
||||
String message = "Permissions denied to drive recording";
|
||||
System.err.println(message);
|
||||
return new ResponseEntity<>(message, HttpStatus.FORBIDDEN);
|
||||
}
|
||||
} catch (OpenViduJavaClientException | OpenViduHttpException error) {
|
||||
error.printStackTrace();
|
||||
int code = Integer.parseInt(error.getMessage());
|
||||
String message = "Unexpected error deleting the recording";
|
||||
if (code == 409) {
|
||||
message = "The recording has STARTED status. Stop it before deletion.";
|
||||
} else if (code == 501) {
|
||||
message = "OpenVidu Server recording module is disabled";
|
||||
} else if (code == 409) {
|
||||
message = "No recording exists for the session";
|
||||
}
|
||||
System.err.println(message);
|
||||
return new ResponseEntity<>(message, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/{recordingId}/{extension}")
|
||||
public ResponseEntity<?> getRecording(@PathVariable String recordingId, @PathVariable String extension,
|
||||
@CookieValue(name = OpenViduService.RECORDING_TOKEN_NAME, defaultValue = "") String recordingToken,
|
||||
@CookieValue(name = "session", defaultValue = "") String sessionToken, HttpServletRequest req, HttpServletResponse res) {
|
||||
|
||||
boolean isAdminDashboard = openviduService.adminTokens.contains(sessionToken);
|
||||
String sessionId = this.openviduService.getSessionIdFromCookie(recordingToken);
|
||||
if ((!sessionId.isEmpty() && openviduService.isValidToken(sessionId, recordingToken)) || isAdminDashboard) {
|
||||
if (recordingId.isEmpty()) {
|
||||
String message = "Missing recording id parameter.";
|
||||
System.err.println(message);
|
||||
return new ResponseEntity<>(message, HttpStatus.BAD_REQUEST);
|
||||
} else {
|
||||
try {
|
||||
return proxyService.processProxyRequest(req, res);
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
} else {
|
||||
String message = "Permissions denied to drive recording";
|
||||
System.err.println(message);
|
||||
return new ResponseEntity<>(message, HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,130 +0,0 @@
|
||||
package io.openvidu.call.java.controllers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CookieValue;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.openvidu.call.java.models.RecordingData;
|
||||
import io.openvidu.call.java.services.OpenViduService;
|
||||
import io.openvidu.java.client.Connection;
|
||||
import io.openvidu.java.client.OpenViduHttpException;
|
||||
import io.openvidu.java.client.OpenViduJavaClientException;
|
||||
import io.openvidu.java.client.OpenViduRole;
|
||||
import io.openvidu.java.client.Recording;
|
||||
import io.openvidu.java.client.Session;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@RestController
|
||||
public class SessionController {
|
||||
|
||||
@Value("${RECORDING}")
|
||||
private String RECORDING;
|
||||
|
||||
@Autowired
|
||||
private OpenViduService openviduService;
|
||||
|
||||
@PostMapping("/sessions")
|
||||
public ResponseEntity<Map<String, Object>> createConnection(
|
||||
@RequestBody(required = false) Map<String, Object> params,
|
||||
@CookieValue(name = OpenViduService.RECORDING_TOKEN_NAME, defaultValue = "") String recordingTokenCookie,
|
||||
HttpServletResponse res) {
|
||||
|
||||
Map<String, Object> response = new HashMap<String, Object>();
|
||||
try {
|
||||
long date = -1;
|
||||
String nickname = "";
|
||||
|
||||
String sessionId = params.get("sessionId").toString();
|
||||
if (params.containsKey("nickname")) {
|
||||
nickname = params.get("nickname").toString();
|
||||
}
|
||||
|
||||
Session sessionCreated = this.openviduService.createSession(sessionId);
|
||||
boolean IS_RECORDING_ENABLED = RECORDING.toUpperCase().equals("ENABLED");
|
||||
|
||||
boolean hasValidToken = this.openviduService.isValidToken(sessionId, recordingTokenCookie);
|
||||
boolean isSessionCreator = hasValidToken || sessionCreated.getActiveConnections().size() == 0;
|
||||
|
||||
OpenViduRole role = isSessionCreator && IS_RECORDING_ENABLED ? OpenViduRole.MODERATOR
|
||||
: OpenViduRole.PUBLISHER;
|
||||
|
||||
response.put("recordingEnabled", IS_RECORDING_ENABLED);
|
||||
response.put("recordings", new ArrayList<Recording>());
|
||||
|
||||
Connection cameraConnection = this.openviduService.createConnection(sessionCreated, nickname, role);
|
||||
Connection screenConnection = this.openviduService.createConnection(sessionCreated, nickname, role);
|
||||
|
||||
response.put("cameraToken", cameraConnection.getToken());
|
||||
response.put("screenToken", screenConnection.getToken());
|
||||
|
||||
if (IS_RECORDING_ENABLED && isSessionCreator && !hasValidToken) {
|
||||
/**
|
||||
* ! *********** WARN *********** !
|
||||
*
|
||||
* To identify who is able to manage session recording, the code sends a cookie
|
||||
* with a token to the session creator. The relation between cookies and
|
||||
* sessions are stored in backend memory.
|
||||
*
|
||||
* This authentication & authorization system is pretty basic and it is not for
|
||||
* production. We highly recommend IMPLEMENT YOUR OWN USER MANAGEMENT with
|
||||
* persistence for a properly and secure recording feature.
|
||||
*
|
||||
* ! *********** WARN *********** !
|
||||
**/
|
||||
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
date = System.currentTimeMillis();
|
||||
String recordingToken = cameraConnection.getToken() + "&" + OpenViduService.RECORDING_TOKEN_NAME + "="
|
||||
+ uuid + "&createdAt=" + date;
|
||||
|
||||
Cookie cookie = new Cookie(OpenViduService.RECORDING_TOKEN_NAME, recordingToken);
|
||||
res.addCookie(cookie);
|
||||
|
||||
RecordingData recData = new RecordingData(recordingToken, "");
|
||||
this.openviduService.recordingMap.put(sessionId, recData);
|
||||
}
|
||||
|
||||
if (IS_RECORDING_ENABLED) {
|
||||
if (date == -1) {
|
||||
date = openviduService.getDateFromCookie(recordingTokenCookie);
|
||||
}
|
||||
List<Recording> recordings = openviduService.listRecordingsBySessionIdAndDate(sessionId, date);
|
||||
response.put("recordings", recordings);
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||
|
||||
} catch (OpenViduJavaClientException | OpenViduHttpException e) {
|
||||
|
||||
if (e.getMessage() != null && Integer.parseInt(e.getMessage()) == 501) {
|
||||
System.err.println("OpenVidu Server recording module is disabled");
|
||||
response.put("recordingEnabled", false);
|
||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||
} else if (e.getMessage() != null && Integer.parseInt(e.getMessage()) == 401) {
|
||||
System.err.println("OpenVidu credentials are wrong.");
|
||||
return new ResponseEntity<>(null, HttpStatus.UNAUTHORIZED);
|
||||
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
System.err.println(e.getMessage());
|
||||
return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package io.openvidu.call.java.models;
|
||||
|
||||
public class RecordingData {
|
||||
|
||||
String token;
|
||||
String recordingId;
|
||||
public RecordingData(String token, String recordingId) {
|
||||
this.token = token;
|
||||
this.recordingId = recordingId;
|
||||
}
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
public String getRecordingId() {
|
||||
return recordingId;
|
||||
}
|
||||
public void setRecordingId(String recordingId) {
|
||||
this.recordingId = recordingId;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,174 +0,0 @@
|
||||
package io.openvidu.call.java.services;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import io.openvidu.call.java.models.RecordingData;
|
||||
import io.openvidu.java.client.Connection;
|
||||
import io.openvidu.java.client.ConnectionProperties;
|
||||
import io.openvidu.java.client.OpenVidu;
|
||||
import io.openvidu.java.client.OpenViduHttpException;
|
||||
import io.openvidu.java.client.OpenViduJavaClientException;
|
||||
import io.openvidu.java.client.OpenViduRole;
|
||||
import io.openvidu.java.client.Recording;
|
||||
import io.openvidu.java.client.Session;
|
||||
import io.openvidu.java.client.SessionProperties;
|
||||
|
||||
@Service
|
||||
public class OpenViduService {
|
||||
|
||||
public static final String RECORDING_TOKEN_NAME = "ovCallRecordingToken";
|
||||
public static final String ADMIN_TOKEN_NAME = "ovCallAdminToken";
|
||||
public Map<String, RecordingData> recordingMap = new HashMap<String, RecordingData>();
|
||||
public List<String> adminTokens = new ArrayList<String>();
|
||||
|
||||
@Value("${OPENVIDU_URL}")
|
||||
public String OPENVIDU_URL;
|
||||
|
||||
@Value("${OPENVIDU_SECRET}")
|
||||
private String OPENVIDU_SECRET;
|
||||
|
||||
private OpenVidu openvidu;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.openvidu = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);
|
||||
}
|
||||
|
||||
public String getBasicAuth() {
|
||||
String stringToEncode = "OPENVIDUAPP:" + OPENVIDU_SECRET;
|
||||
byte[] encodedString = Base64.encodeBase64(stringToEncode.getBytes());
|
||||
return "Basic " + new String(encodedString);
|
||||
}
|
||||
|
||||
public long getDateFromCookie(String recordingToken) {
|
||||
try {
|
||||
if (!recordingToken.isEmpty()) {
|
||||
MultiValueMap<String, String> cookieTokenParams = UriComponentsBuilder.fromUriString(recordingToken).build()
|
||||
.getQueryParams();
|
||||
String date = cookieTokenParams.get("createdAt").get(0);
|
||||
return Long.parseLong(date);
|
||||
} else {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
} catch(Exception e) {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
public String getSessionIdFromCookie(String cookie) {
|
||||
try {
|
||||
|
||||
if (!cookie.isEmpty()) {
|
||||
MultiValueMap<String, String> cookieTokenParams = UriComponentsBuilder.fromUriString(cookie)
|
||||
.build().getQueryParams();
|
||||
return cookieTokenParams.get("sessionId").get(0);
|
||||
}
|
||||
|
||||
} catch (Exception error) {
|
||||
System.out.println("Recording cookie not found");
|
||||
System.err.println(error);
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
public boolean isValidToken(String sessionId, String recordingToken) {
|
||||
try {
|
||||
|
||||
if (!recordingToken.isEmpty()) {
|
||||
MultiValueMap<String, String> storedTokenParams = null;
|
||||
|
||||
if(this.recordingMap.containsKey(sessionId)) {
|
||||
storedTokenParams = UriComponentsBuilder
|
||||
.fromUriString(this.recordingMap.get(sessionId).getToken()).build().getQueryParams();
|
||||
}
|
||||
|
||||
MultiValueMap<String, String> cookieTokenParams = UriComponentsBuilder
|
||||
.fromUriString(recordingToken).build().getQueryParams();
|
||||
|
||||
if (!cookieTokenParams.isEmpty() && storedTokenParams != null) {
|
||||
String cookieSessionId = cookieTokenParams.get("sessionId").get(0);
|
||||
String cookieToken = cookieTokenParams.get(RECORDING_TOKEN_NAME).get(0);
|
||||
String cookieDate = cookieTokenParams.get("createdAt").get(0);
|
||||
|
||||
String storedToken = storedTokenParams.get(RECORDING_TOKEN_NAME).get(0);
|
||||
String storedDate = storedTokenParams.get("createdAt").get(0);
|
||||
|
||||
return sessionId.equals(cookieSessionId) && cookieToken.equals(storedToken) && cookieDate.equals(storedDate);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Session createSession(String sessionId) throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("customSessionId", sessionId);
|
||||
SessionProperties properties = SessionProperties.fromJson(params).build();
|
||||
Session session = openvidu.createSession(properties);
|
||||
session.fetch();
|
||||
return session;
|
||||
}
|
||||
|
||||
public Connection createConnection(Session session, String nickname, OpenViduRole role)
|
||||
throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String, Object> connectionData = new HashMap<String, Object>();
|
||||
|
||||
if (!nickname.isEmpty()) {
|
||||
connectionData.put("openviduCustomConnectionId", nickname);
|
||||
}
|
||||
params.put("role", role.name());
|
||||
params.put("data", connectionData.toString());
|
||||
ConnectionProperties properties = ConnectionProperties.fromJson(params).build();
|
||||
return session.createConnection(properties);
|
||||
|
||||
}
|
||||
|
||||
public Recording startRecording(String sessionId) throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
return this.openvidu.startRecording(sessionId);
|
||||
}
|
||||
|
||||
public Recording stopRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
return this.openvidu.stopRecording(recordingId);
|
||||
}
|
||||
|
||||
public void deleteRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
this.openvidu.deleteRecording(recordingId);
|
||||
}
|
||||
|
||||
public Recording getRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
return this.openvidu.getRecording(recordingId);
|
||||
}
|
||||
|
||||
public List<Recording> listAllRecordings() throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
return this.openvidu.listRecordings();
|
||||
}
|
||||
|
||||
public List<Recording> listRecordingsBySessionIdAndDate(String sessionId, long date)
|
||||
throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
List<Recording> recordings = this.listAllRecordings();
|
||||
List<Recording> recordingsAux = new ArrayList<Recording>();
|
||||
for (Recording recording : recordings) {
|
||||
if (recording.getSessionId().equals(sessionId) && date <= recording.getCreatedAt()) {
|
||||
recordingsAux.add(recording);
|
||||
}
|
||||
}
|
||||
return recordingsAux;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,71 +0,0 @@
|
||||
package io.openvidu.call.java.services;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.client.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.HttpStatusCodeException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
@Service
|
||||
public class ProxyService {
|
||||
|
||||
@Value("${OPENVIDU_URL}")
|
||||
public String OPENVIDU_URL;
|
||||
|
||||
@Autowired
|
||||
private OpenViduService openviduService;
|
||||
|
||||
public ResponseEntity<?> processProxyRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws URISyntaxException {
|
||||
|
||||
String requestUrl = request.getRequestURI();
|
||||
|
||||
URI uri = UriComponentsBuilder.fromUriString(OPENVIDU_URL).path(requestUrl).query(request.getQueryString()).build(true).toUri();
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
|
||||
while (headerNames.hasMoreElements()) {
|
||||
String headerName = headerNames.nextElement();
|
||||
headers.set(headerName, request.getHeader(headerName));
|
||||
}
|
||||
|
||||
headers.add("Authorization", this.openviduService.getBasicAuth());
|
||||
headers.remove("Cookie");
|
||||
headers.remove(HttpHeaders.ACCEPT_ENCODING);
|
||||
|
||||
HttpEntity<String> httpEntity = new HttpEntity<>(null, headers);
|
||||
ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory());
|
||||
RestTemplate restTemplate = new RestTemplate(factory);
|
||||
|
||||
restTemplate.setInterceptors(Arrays.asList((requestIntercept, body, execution) -> {
|
||||
ClientHttpResponse responseIntercept = execution.execute(requestIntercept, body);
|
||||
responseIntercept.getHeaders().remove("set-cookie");
|
||||
return responseIntercept;
|
||||
}));
|
||||
|
||||
try {
|
||||
|
||||
return restTemplate.exchange(uri, HttpMethod.GET, httpEntity, byte[].class);
|
||||
|
||||
} catch (HttpStatusCodeException e) {
|
||||
System.err.println(e.getMessage());
|
||||
System.err.println(e.getRawStatusCode());
|
||||
return ResponseEntity.status(e.getRawStatusCode()).headers(e.getResponseHeaders())
|
||||
.body(e.getResponseBodyAsString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
server.port: 5000
|
||||
server.ssl.enabled: false
|
||||
|
||||
OPENVIDU_URL: https://localhost:4443
|
||||
OPENVIDU_SECRET: MY_SECRET
|
||||
|
||||
RECORDING: ENABLED
|
||||
ADMIN_SECRET: MY_SECRET
|
||||
@ -1,13 +0,0 @@
|
||||
package io.openvidu.call.java;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class AppTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"printWidth": 140,
|
||||
"trailingComma": "none",
|
||||
"semi": true,
|
||||
"bracketSpacing": true,
|
||||
"useTabs": true,
|
||||
"jsxSingleQuote": true,
|
||||
"tabWidth": 4
|
||||
}
|
||||
12329
openvidu-call/openvidu-call-back/package-lock.json
generated
@ -1,56 +0,0 @@
|
||||
{
|
||||
"author": "OpenVidu",
|
||||
"bugs": {
|
||||
"url": "https://github.com/OpenVidu/openvidu-call/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"btoa": "1.2.1",
|
||||
"cookie-parser": "1.4.6",
|
||||
"cookie-session": "^2.0.0",
|
||||
"dotenv": "16.0.0",
|
||||
"express": "4.18.1",
|
||||
"http-proxy-middleware": "2.0.6",
|
||||
"openvidu-node-client": "2.23.0"
|
||||
},
|
||||
"description": "OpenVidu Call Server",
|
||||
"devDependencies": {
|
||||
"@types/btoa": "1.2.3",
|
||||
"@types/cookie-parser": "1.4.3",
|
||||
"@types/express": "4.17.13",
|
||||
"@types/jest": "27.4.0",
|
||||
"@types/node": "17.0.10",
|
||||
"cross-env": "7.0.3",
|
||||
"dotenv-webpack": "7.0.3",
|
||||
"jest": "27.4.7",
|
||||
"nodemon": "2.0.15",
|
||||
"supertest": "6.2.2",
|
||||
"ts-loader": "9.2.6",
|
||||
"ts-node": "10.4.0",
|
||||
"typescript": "4.4.4"
|
||||
},
|
||||
"homepage": "https://github.com/OpenVidu/openvidu-call#readme",
|
||||
"jest": {
|
||||
"coveragePathIgnorePatterns": [
|
||||
"/node_modules/"
|
||||
],
|
||||
"testEnvironment": "node"
|
||||
},
|
||||
"keywords": [
|
||||
"openvidu",
|
||||
"webrtc",
|
||||
"openvidu-call"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"main": "app.ts",
|
||||
"name": "openvidu-call-server",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/OpenVidu/openvidu-call.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"start": "cross-env CALL_OPENVIDU_CERTTYPE=selfsigned nodemon src/app.ts",
|
||||
"test": "jest"
|
||||
},
|
||||
"version": "2.23.0"
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
import * as express from 'express';
|
||||
import { SERVER_PORT, OPENVIDU_URL, OPENVIDU_SECRET, CALL_OPENVIDU_CERTTYPE, ADMIN_SECRET, RECORDING } from './config';
|
||||
import { app as sessionController } from './controllers/SessionController';
|
||||
import { app as adminController } from './controllers/AdminController';
|
||||
import { app as recordingController, proxyGETRecording } from './controllers/RecordingController';
|
||||
|
||||
import * as dotenv from 'dotenv';
|
||||
import * as cookieParser from 'cookie-parser';
|
||||
import * as cookieSession from 'cookie-session';
|
||||
|
||||
dotenv.config();
|
||||
const app = express();
|
||||
|
||||
app.use(express.static(__dirname + '/public'));
|
||||
app.use(express.json());
|
||||
app.use(cookieParser());
|
||||
app.use(
|
||||
cookieSession({
|
||||
name: 'session',
|
||||
keys: [ADMIN_SECRET],
|
||||
maxAge: 24 * 60 * 60 * 1000 // 24 hours
|
||||
})
|
||||
);
|
||||
|
||||
app.use('/sessions', sessionController);
|
||||
app.use('/recordings', recordingController);
|
||||
app.use('/recordings/:recordingId', proxyGETRecording);
|
||||
app.use('/admin', adminController);
|
||||
|
||||
// Accept selfsigned certificates if CALL_OPENVIDU_CERTTYPE=selfsigned
|
||||
if (CALL_OPENVIDU_CERTTYPE === 'selfsigned') {
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
||||
}
|
||||
app.listen(SERVER_PORT, () => {
|
||||
console.log('---------------------------------------------------------');
|
||||
console.log(' ');
|
||||
console.log(`OPENVIDU URL: ${OPENVIDU_URL}`);
|
||||
console.log(`OPENVIDU SECRET: ${OPENVIDU_SECRET}`);
|
||||
console.log(`CALL OPENVIDU CERTTYPE: ${CALL_OPENVIDU_CERTTYPE}`);
|
||||
console.log(`CALL RECORDING: ${RECORDING}`);
|
||||
console.log(`CALL ADMIN PASSWORD: ${ADMIN_SECRET}`);
|
||||
console.log(`OpenVidu Call Server is listening on port ${SERVER_PORT}`);
|
||||
console.log(' ');
|
||||
console.log('---------------------------------------------------------');
|
||||
});
|
||||
@ -1,6 +0,0 @@
|
||||
export const SERVER_PORT = process.env.SERVER_PORT || 5000;
|
||||
export const OPENVIDU_URL = process.env.OPENVIDU_URL || 'http://localhost:4443';
|
||||
export const OPENVIDU_SECRET = process.env.OPENVIDU_SECRET || 'MY_SECRET';
|
||||
export const CALL_OPENVIDU_CERTTYPE = process.env.CALL_OPENVIDU_CERTTYPE || 'selfsigned';
|
||||
export const ADMIN_SECRET = process.env.ADMIN_SECRET || OPENVIDU_SECRET;
|
||||
export const RECORDING = process.env.RECORDING || 'ENABLED';
|
||||
@ -1,48 +0,0 @@
|
||||
import * as express from 'express';
|
||||
import * as crypto from 'crypto';
|
||||
import { Request, Response } from 'express';
|
||||
|
||||
import { OpenViduService } from '../services/OpenViduService';
|
||||
import { ADMIN_SECRET } from '../config';
|
||||
|
||||
export const app = express.Router({
|
||||
strict: true
|
||||
});
|
||||
|
||||
const openviduService = OpenViduService.getInstance();
|
||||
|
||||
app.post('/login', async (req: Request, res: Response) => {
|
||||
const password = req.body.password;
|
||||
const isAdminTokenValid = openviduService.adminTokens.includes(req['session']?.token);
|
||||
const isAuthValid = password === ADMIN_SECRET || isAdminTokenValid;
|
||||
if (isAuthValid) {
|
||||
try {
|
||||
if (!req['session']?.token || !openviduService.adminTokens.includes(req['session']?.token)) {
|
||||
// Save session token
|
||||
const token = crypto.randomBytes(32).toString('hex');
|
||||
res.cookie(openviduService.ADMIN_TOKEN_NAME, token);
|
||||
req['session'] = { token };
|
||||
openviduService.adminTokens.push(token);
|
||||
}
|
||||
const recordings = await openviduService.listAllRecordings();
|
||||
console.log(`${recordings.length} recordings found`);
|
||||
res.status(200).send(JSON.stringify({ recordings }));
|
||||
} catch (error) {
|
||||
const code = Number(error?.message);
|
||||
if(code === 501){
|
||||
console.log('501. OpenVidu Server recording module is disabled.');
|
||||
res.status(200).send();
|
||||
} else {
|
||||
console.error(error);
|
||||
res.status(500).send('Unexpected error getting recordings');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res.status(403).send('Permissions denied');
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/logout', async (req: Request, res: Response) => {
|
||||
openviduService.adminTokens = openviduService.adminTokens.filter((token) => token !== req['session'].token);
|
||||
req['session'] = {};
|
||||
});
|
||||
@ -1,172 +0,0 @@
|
||||
import { CALL_OPENVIDU_CERTTYPE, OPENVIDU_URL, RECORDING } from '../config';
|
||||
|
||||
import * as express from 'express';
|
||||
import { Request, Response } from 'express';
|
||||
import { Recording } from 'openvidu-node-client';
|
||||
import { OpenViduService } from '../services/OpenViduService';
|
||||
import { createProxyMiddleware } from 'http-proxy-middleware';
|
||||
export const app = express.Router({
|
||||
strict: true
|
||||
});
|
||||
|
||||
const openviduService = OpenViduService.getInstance();
|
||||
|
||||
app.get('/', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const IS_RECORDING_ENABLED = RECORDING.toUpperCase() === 'ENABLED';
|
||||
const sessionId = openviduService.getSessionIdFromCookie(req.cookies);
|
||||
const isAdminDashboard = openviduService.adminTokens.includes(req['session'].token);
|
||||
let recordings = [];
|
||||
if ((!!sessionId && IS_RECORDING_ENABLED && openviduService.isValidToken(sessionId, req.cookies)) || isAdminDashboard) {
|
||||
if (isAdminDashboard) {
|
||||
recordings = await openviduService.listAllRecordings();
|
||||
} else {
|
||||
const date = openviduService.getDateFromCookie(req.cookies);
|
||||
recordings = await openviduService.listRecordingsBySessionIdAndDate(sessionId, date);
|
||||
}
|
||||
res.status(200).send(JSON.stringify(recordings));
|
||||
} else {
|
||||
const message = IS_RECORDING_ENABLED ? 'Permissions denied to drive recording' : 'Recording is disabled';
|
||||
res.status(403).send(JSON.stringify({ message }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
const code = Number(error?.message);
|
||||
let message = 'Unexpected error getting all recordings';
|
||||
if (code === 404) {
|
||||
message = 'No recording exist for the session';
|
||||
}
|
||||
return res.status(Number(code) || 500).send(JSON.stringify({ message }));
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/start', async (req: Request, res: Response) => {
|
||||
try {
|
||||
let sessionId: string = req.body.sessionId;
|
||||
if (openviduService.isValidToken(sessionId, req.cookies)) {
|
||||
let startingRecording: Recording = null;
|
||||
console.log(`Starting recording in ${sessionId}`);
|
||||
startingRecording = await openviduService.startRecording(sessionId);
|
||||
openviduService.recordingMap.get(sessionId).recordingId = startingRecording.id;
|
||||
res.status(200).send(JSON.stringify(startingRecording));
|
||||
} else {
|
||||
console.log(`Permissions denied for starting recording in session ${sessionId}`);
|
||||
res.status(403).send(JSON.stringify({ message: 'Permissions denied to drive recording' }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
const code = Number(error?.message);
|
||||
let message = `Unexpected error starting recording`;
|
||||
if (code === 409) {
|
||||
message = 'The session is already being recorded.';
|
||||
} else if (code === 501) {
|
||||
message = 'OpenVidu Server recording module is disabled';
|
||||
} else if (code === 406) {
|
||||
message = 'The session has no connected participants';
|
||||
}
|
||||
return res.status(code || 500).send(JSON.stringify({ message }));
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/stop', async (req: Request, res: Response) => {
|
||||
try {
|
||||
let sessionId: string = req.body.sessionId;
|
||||
if (openviduService.isValidToken(sessionId, req.cookies)) {
|
||||
const recordingId = openviduService.recordingMap.get(sessionId)?.recordingId;
|
||||
|
||||
if (!!recordingId) {
|
||||
console.log(`Stopping recording in ${sessionId}`);
|
||||
await openviduService.stopRecording(recordingId);
|
||||
const date = openviduService.getDateFromCookie(req.cookies);
|
||||
const recordingList = await openviduService.listRecordingsBySessionIdAndDate(sessionId, date);
|
||||
openviduService.recordingMap.get(sessionId).recordingId = '';
|
||||
res.status(200).send(JSON.stringify(recordingList));
|
||||
} else {
|
||||
res.status(404).send(JSON.stringify({ message: 'Session was not being recorded' }));
|
||||
}
|
||||
} else {
|
||||
res.status(403).send(JSON.stringify({ message: 'Permissions denied to drive recording' }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
const code = Number(error?.message);
|
||||
let message = `Unexpected error stopping recording`;
|
||||
if (code === 501) {
|
||||
message = 'OpenVidu Server recording module is disabled';
|
||||
} else if (code === 406) {
|
||||
message = 'Recording has STARTING status. Wait until STARTED status before stopping the recording';
|
||||
}
|
||||
return res.status(code || 500).send(JSON.stringify({ message }));
|
||||
}
|
||||
});
|
||||
|
||||
app.delete('/delete/:recordingId', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const sessionId = openviduService.getSessionIdFromCookie(req.cookies);
|
||||
const isAdminDashboard = openviduService.adminTokens.includes(req['session'].token);
|
||||
let recordings = [];
|
||||
if ((!!sessionId && openviduService.isValidToken(sessionId, req.cookies)) || isAdminDashboard) {
|
||||
const recordingId: string = req.params.recordingId;
|
||||
if (!recordingId) {
|
||||
return res.status(400).send('Missing recording id parameter.');
|
||||
}
|
||||
console.log(`Deleting recording ${recordingId}`);
|
||||
await openviduService.deleteRecording(recordingId);
|
||||
if (isAdminDashboard && !!req['session']) {
|
||||
recordings = await openviduService.listAllRecordings();
|
||||
} else {
|
||||
const date = openviduService.getDateFromCookie(req.cookies);
|
||||
recordings = await openviduService.listRecordingsBySessionIdAndDate(sessionId, date);
|
||||
}
|
||||
res.status(200).send(JSON.stringify(recordings));
|
||||
} else {
|
||||
res.status(403).send(JSON.stringify({ message: 'Permissions denied to drive recording' }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
const code = Number(error?.message);
|
||||
let message = `Unexpected error deleting the recording`;
|
||||
if (code === 409) {
|
||||
message = 'The recording has STARTED status. Stop it before deletion.';
|
||||
} else if (code === 501) {
|
||||
message = 'OpenVidu Server recording module is disabled';
|
||||
} else if (code === 409) {
|
||||
message = 'No recording exists for the session';
|
||||
}
|
||||
return res.status(code).send(JSON.stringify({ message }));
|
||||
}
|
||||
});
|
||||
|
||||
export const proxyGETRecording = createProxyMiddleware({
|
||||
target: `${OPENVIDU_URL}/openvidu/`,
|
||||
secure: CALL_OPENVIDU_CERTTYPE !== 'selfsigned',
|
||||
onProxyReq: (proxyReq, req: Request, res: Response) => {
|
||||
const isAdminDashboard = openviduService.adminTokens.includes(req['session'].token);
|
||||
const sessionId = openviduService.getSessionIdFromCookie(req.cookies);
|
||||
proxyReq.removeHeader('Cookie');
|
||||
if ((!!sessionId && openviduService.isValidToken(sessionId, req.cookies)) || isAdminDashboard) {
|
||||
const recordingId: string = req.params.recordingId;
|
||||
if (!recordingId) {
|
||||
return res.status(400).send(JSON.stringify({ message: 'Missing recording id parameter.' }));
|
||||
} else {
|
||||
proxyReq.setHeader('Connection', 'keep-alive');
|
||||
proxyReq.setHeader('Authorization', openviduService.getBasicAuth());
|
||||
}
|
||||
} else {
|
||||
return res.status(403).send(JSON.stringify({ message: 'Permissions denied to drive recording' }));
|
||||
}
|
||||
},
|
||||
onProxyRes: (proxyRes, req: Request, res: Response) => {
|
||||
proxyRes.headers['set-cookie'] = null;
|
||||
},
|
||||
onError: (error, req: Request, res: Response) => {
|
||||
console.log(error);
|
||||
const code = Number(error?.message);
|
||||
let message = 'Unexpected error downloading the recording';
|
||||
if (code === 404) {
|
||||
message = 'No recording exist for the session';
|
||||
}
|
||||
res.status(Number(code) || 500).send(JSON.stringify({ message }));
|
||||
return res.end();
|
||||
}
|
||||
});
|
||||
@ -1,80 +0,0 @@
|
||||
import * as express from 'express';
|
||||
import * as crypto from 'crypto';
|
||||
import { Request, Response } from 'express';
|
||||
import { OpenViduRole, Session } from 'openvidu-node-client';
|
||||
import { OpenViduService } from '../services/OpenViduService';
|
||||
import { RECORDING } from '../config';
|
||||
|
||||
export const app = express.Router({
|
||||
strict: true
|
||||
});
|
||||
|
||||
const openviduService = OpenViduService.getInstance();
|
||||
|
||||
app.post('/', async (req: Request, res: Response) => {
|
||||
try {
|
||||
console.log('Session ID received', req.body.sessionId);
|
||||
|
||||
let sessionId: string = req.body.sessionId;
|
||||
let nickname: string = req.body.nickname;
|
||||
let date = null;
|
||||
let sessionCreated: Session = await openviduService.createSession(sessionId);
|
||||
const RECORDING_TOKEN_NAME = openviduService.RECORDING_TOKEN_NAME;
|
||||
const IS_RECORDING_ENABLED = RECORDING.toUpperCase() === 'ENABLED';
|
||||
const hasValidToken = openviduService.isValidToken(sessionId, req.cookies);
|
||||
const isSessionCreator = hasValidToken || sessionCreated.activeConnections.length === 0;
|
||||
const role: OpenViduRole = isSessionCreator && IS_RECORDING_ENABLED ? OpenViduRole.MODERATOR : OpenViduRole.PUBLISHER;
|
||||
const response = { cameraToken: '', screenToken: '', recordingEnabled: IS_RECORDING_ENABLED, recordings: [] };
|
||||
const cameraConnection = await openviduService.createConnection(sessionCreated, nickname, role);
|
||||
const screenConnection = await openviduService.createConnection(sessionCreated, nickname, role);
|
||||
response.cameraToken = cameraConnection.token;
|
||||
response.screenToken = screenConnection.token;
|
||||
|
||||
if (IS_RECORDING_ENABLED && isSessionCreator && !hasValidToken) {
|
||||
/**
|
||||
* ! *********** WARN *********** !
|
||||
*
|
||||
* To identify who is able to manage session recording, the code sends a cookie with a token to the session creator.
|
||||
* The relation between cookies and sessions are stored in backend memory.
|
||||
*
|
||||
* This authentication & authorization system is pretty basic and it is not for production.
|
||||
* We highly recommend IMPLEMENT YOUR OWN USER MANAGEMENT with persistence for a properly and secure recording feature.
|
||||
*
|
||||
* ! *********** WARN *********** !
|
||||
**/
|
||||
const uuid = crypto.randomBytes(32).toString('hex');
|
||||
date = Date.now();
|
||||
const recordingToken = `${response.cameraToken}&${RECORDING_TOKEN_NAME}=${uuid}&createdAt=${date}`;
|
||||
res.cookie(RECORDING_TOKEN_NAME, recordingToken);
|
||||
openviduService.recordingMap.set(sessionId, { token: recordingToken, recordingId: '' });
|
||||
}
|
||||
|
||||
if (IS_RECORDING_ENABLED) {
|
||||
date = date || openviduService.getDateFromCookie(req.cookies);
|
||||
try {
|
||||
response.recordings = await openviduService.listRecordingsBySessionIdAndDate(sessionId, date);
|
||||
} catch (error) {
|
||||
if (error.message === '501') {
|
||||
console.log('Recording is diasbled in OpenVidu Server. Disabling it in OpenVidu Call');
|
||||
response.recordings = [];
|
||||
response.recordingEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res.status(200).send(JSON.stringify(response));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
let message = 'Cannot connect with OpenVidu Server';
|
||||
let code = Number(error?.message);
|
||||
if (error.message === 500) {
|
||||
message = 'Unexpected error when creating the Connection object.';
|
||||
} else if (error.message === 404) {
|
||||
message = 'No session exists';
|
||||
}
|
||||
if (typeof code !== 'number') {
|
||||
code = 503;
|
||||
}
|
||||
res.status(code).send({ message });
|
||||
}
|
||||
});
|
||||
@ -1,117 +0,0 @@
|
||||
import { Connection, ConnectionProperties, OpenVidu, OpenViduRole, Recording, Session, SessionProperties } from 'openvidu-node-client';
|
||||
import { OPENVIDU_URL, OPENVIDU_SECRET } from '../config';
|
||||
|
||||
export class OpenViduService {
|
||||
RECORDING_TOKEN_NAME = 'ovCallRecordingToken';
|
||||
ADMIN_TOKEN_NAME = 'ovCallAdminToken';
|
||||
recordingMap: Map<string, { token: string; recordingId: string }> = new Map<string, { token: string; recordingId: string }>();
|
||||
adminTokens: string[] = [];
|
||||
protected static instance: OpenViduService;
|
||||
private openvidu: OpenVidu;
|
||||
|
||||
private constructor() {
|
||||
this.openvidu = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);
|
||||
}
|
||||
|
||||
static getInstance() {
|
||||
if (!OpenViduService.instance) {
|
||||
OpenViduService.instance = new OpenViduService();
|
||||
}
|
||||
return OpenViduService.instance;
|
||||
}
|
||||
|
||||
getBasicAuth(): string {
|
||||
return this.openvidu.basicAuth;
|
||||
}
|
||||
|
||||
getDateFromCookie(cookies: any): number {
|
||||
try {
|
||||
const cookieToken = cookies[this.RECORDING_TOKEN_NAME];
|
||||
if (!!cookieToken) {
|
||||
const cookieTokenUrl = new URL(cookieToken);
|
||||
const date = cookieTokenUrl?.searchParams.get('createdAt');
|
||||
return Number(date);
|
||||
} else {
|
||||
return Date.now();
|
||||
}
|
||||
} catch (error) {
|
||||
return Date.now();
|
||||
}
|
||||
}
|
||||
|
||||
getSessionIdFromCookie(cookies: any): string {
|
||||
try {
|
||||
const cookieTokenUrl = new URL(cookies[this.RECORDING_TOKEN_NAME]);
|
||||
return cookieTokenUrl?.searchParams.get('sessionId');
|
||||
} catch (error) {
|
||||
console.log('Recording cookie not found');
|
||||
console.error(error);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
isValidToken(sessionId: string, cookies: any): boolean {
|
||||
try {
|
||||
const storedTokenUrl = new URL(this.recordingMap.get(sessionId)?.token);
|
||||
const cookieTokenUrl = new URL(cookies[this.RECORDING_TOKEN_NAME]);
|
||||
if (!!cookieTokenUrl && !!storedTokenUrl) {
|
||||
const cookieSessionId = cookieTokenUrl.searchParams.get('sessionId');
|
||||
const cookieToken = cookieTokenUrl.searchParams.get(this.RECORDING_TOKEN_NAME);
|
||||
const cookieDate = cookieTokenUrl.searchParams.get('createdAt');
|
||||
|
||||
const storedToken = storedTokenUrl.searchParams.get(this.RECORDING_TOKEN_NAME);
|
||||
const storedDate = storedTokenUrl.searchParams.get('createdAt');
|
||||
|
||||
return sessionId === cookieSessionId && cookieToken === storedToken && cookieDate === storedDate;
|
||||
}
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async createSession(sessionId: string): Promise<Session> {
|
||||
console.log('Creating session: ', sessionId);
|
||||
let sessionProperties: SessionProperties = { customSessionId: sessionId };
|
||||
const session = await this.openvidu.createSession(sessionProperties);
|
||||
await session.fetch();
|
||||
return session;
|
||||
}
|
||||
|
||||
public createConnection(session: Session, nickname: string, role: OpenViduRole): Promise<Connection> {
|
||||
console.log(`Requesting token for session ${session.sessionId}`);
|
||||
let connectionProperties: ConnectionProperties = { role };
|
||||
if (!!nickname) {
|
||||
connectionProperties.data = JSON.stringify({
|
||||
openviduCustomConnectionId: nickname
|
||||
});
|
||||
}
|
||||
console.log('Connection Properties:', connectionProperties);
|
||||
return session.createConnection(connectionProperties);
|
||||
}
|
||||
|
||||
public async startRecording(sessionId: string): Promise<Recording> {
|
||||
return this.openvidu.startRecording(sessionId);
|
||||
}
|
||||
|
||||
public stopRecording(recordingId: string): Promise<Recording> {
|
||||
return this.openvidu.stopRecording(recordingId);
|
||||
}
|
||||
|
||||
public deleteRecording(recordingId: string): Promise<Error> {
|
||||
return this.openvidu.deleteRecording(recordingId);
|
||||
}
|
||||
public getRecording(recordingId: string): Promise<Recording> {
|
||||
return this.openvidu.getRecording(recordingId);
|
||||
}
|
||||
|
||||
public async listAllRecordings(): Promise<Recording[]> {
|
||||
return await this.openvidu.listRecordings();
|
||||
}
|
||||
|
||||
public async listRecordingsBySessionIdAndDate(sessionId: string, date: number) {
|
||||
const recordingList: Recording[] = await this.listAllRecordings();
|
||||
return recordingList.filter((recording) => recording.sessionId === sessionId && date <= recording.createdAt);
|
||||
}
|
||||
}
|
||||
@ -1,66 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
// "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
||||
// "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
"sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"outDir": "./dist", /* Redirect output structure to the directory. */
|
||||
// "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
// "composite": true, /* Enable project compilation */
|
||||
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||
// "removeComments": true, /* Do not emit comments to output. */
|
||||
// "noEmit": true, /* Do not emit outputs. */
|
||||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
|
||||
/* Strict Type-Checking Options */
|
||||
// "strict": true, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
||||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
||||
|
||||
/* Additional Checks */
|
||||
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||
|
||||
/* Module Resolution Options */
|
||||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
// "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||
|
||||
/* Source Map Options */
|
||||
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||
|
||||
/* Experimental Options */
|
||||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
|
||||
/* Advanced Options */
|
||||
// "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"noUnusedLocals": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"exclude": ["**/*.test.ts", "*.test.tsx"]
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"printWidth": 140,
|
||||
"trailingComma": "none",
|
||||
"semi": true,
|
||||
"bracketSpacing": true,
|
||||
"useTabs": true,
|
||||
"jsxSingleQuote": true,
|
||||
"tabWidth": 4
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
# OpenviduCall
|
||||
|
||||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.1.
|
||||
|
||||
## Development server
|
||||
|
||||
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
|
||||
|
||||
## Code scaffolding
|
||||
|
||||
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
||||
|
||||
## Build
|
||||
|
||||
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
|
||||
|
||||
Use the `--configuration` flag for a set the environment file.
|
||||
|
||||
For example: `--configuration=production`. Moreover, inside of `environment.production.ts` should exist the `openvidu_url` and `openvidu_secret` fields. Where `openvidu_url` will be the url where openvidu exist and its port. For example `https://call.openvidu.io:4443`
|
||||
## Running unit tests
|
||||
|
||||
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
||||
|
||||
## Running end-to-end tests
|
||||
|
||||
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
|
||||
|
||||
## Further help
|
||||
|
||||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
|
||||
@ -1,172 +0,0 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"openvidu-call": {
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"projectType": "application",
|
||||
"prefix": "app",
|
||||
"schematics": {},
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"aot": true,
|
||||
"outputPath": "dist/openvidu-call",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "src/tsconfig.app.json",
|
||||
"assets": [
|
||||
"src/favicon.ico",
|
||||
"src/assets"
|
||||
],
|
||||
"styles": [
|
||||
"src/styles.scss"
|
||||
],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"development": {
|
||||
"optimization": false,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": true,
|
||||
"namedChunks": false,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": false
|
||||
},
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "2mb",
|
||||
"maximumError": "5mb"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "6kb",
|
||||
"maximumError": "10kb"
|
||||
}
|
||||
],
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.prod.ts"
|
||||
}
|
||||
],
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
"namedChunks": false,
|
||||
"aot": true,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": true
|
||||
},
|
||||
"ci": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "6kb"
|
||||
}
|
||||
],
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.ci.ts"
|
||||
}
|
||||
],
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
"namedChunks": false,
|
||||
"aot": true,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"options": {
|
||||
"browserTarget": "openvidu-call:build",
|
||||
"proxyConfig": "src/proxy.conf.json"
|
||||
},
|
||||
"configurations": {
|
||||
"development": {
|
||||
"browserTarget": "openvidu-call:build:development"
|
||||
},
|
||||
"production": {
|
||||
"browserTarget": "openvidu-call:build:production"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "openvidu-call:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"main": "src/test.ts",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "src/tsconfig.spec.json",
|
||||
"karmaConfig": "src/karma.conf.js",
|
||||
"codeCoverage": true,
|
||||
"styles": [],
|
||||
"scripts": [],
|
||||
"assets": [
|
||||
"src/favicon.ico",
|
||||
"src/assets"
|
||||
],
|
||||
"codeCoverageExclude": [
|
||||
"/**/*mock*.ts",
|
||||
"/**/openvidu-layout.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": [
|
||||
"src/tsconfig.app.json",
|
||||
"src/tsconfig.spec.json"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"openvidu-call-e2e": {
|
||||
"root": "e2e/",
|
||||
"projectType": "application",
|
||||
"architect": {
|
||||
"e2e": {
|
||||
"builder": "@angular-devkit/build-angular:protractor",
|
||||
"options": {
|
||||
"protractorConfig": "e2e/protractor.conf.js",
|
||||
"devServerTarget": "openvidu-call:serve"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-devkit/build-angular:tslint",
|
||||
"options": {
|
||||
"tsConfig": "e2e/tsconfig.e2e.json",
|
||||
"exclude": [
|
||||
"**/node_modules/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultProject": "openvidu-call"
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
// Protractor configuration file, see link for more information
|
||||
// https://github.com/angular/protractor/blob/master/lib/config.ts
|
||||
|
||||
const { SpecReporter } = require('jasmine-spec-reporter');
|
||||
|
||||
exports.config = {
|
||||
allScriptsTimeout: 30000,
|
||||
specs: ['./src/**/*.e2e-spec.ts'],
|
||||
|
||||
multiCapabilities: [
|
||||
{
|
||||
browserName: 'chrome',
|
||||
chromeOptions: {
|
||||
args: ['use-fake-ui-for-media-stream', 'use-fake-device-for-media-stream'],
|
||||
},
|
||||
acceptInsecureCerts : true
|
||||
},
|
||||
// {
|
||||
// browserName: 'firefox',
|
||||
// 'moz:firefoxOptions': {
|
||||
// 'prefs': {
|
||||
// 'media.navigator.streams.fake': true,
|
||||
// 'media.navigator.permission.disabled': true
|
||||
// }
|
||||
// },
|
||||
// acceptInsecureCerts : true
|
||||
// }
|
||||
],
|
||||
restartBrowserBetweenTests: true,
|
||||
directConnect: !process.env.SELENIUM_URL,
|
||||
seleniumAddress: process.env.SELENIUM_URL,
|
||||
baseUrl: (process.env.APP_URL || 'http://localhost:4200/'),
|
||||
framework: 'jasmine',
|
||||
jasmineNodeOpts: {
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: 30000,
|
||||
print: function() {},
|
||||
},
|
||||
onPrepare() {
|
||||
require('ts-node').register({
|
||||
project: require('path').join(__dirname, './tsconfig.e2e.json'),
|
||||
}
|
||||
);
|
||||
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
|
||||
},
|
||||
};
|
||||
@ -1,552 +0,0 @@
|
||||
import { OpenViduCall } from './call.po';
|
||||
import { browser, by, ProtractorBrowser, Key, WebElement } from 'protractor';
|
||||
import { protractor } from 'protractor/built/ptor';
|
||||
|
||||
describe('Connect to the room', () => {
|
||||
const OVC = new OpenViduCall();
|
||||
|
||||
beforeEach(() => {
|
||||
browser.waitForAngularEnabled(false);
|
||||
browser.get('#/');
|
||||
});
|
||||
|
||||
it('should navigate to OpenVidu room', () => {
|
||||
const input = OVC.getRoomInput(browser);
|
||||
input.clear();
|
||||
input.sendKeys('OpenVidu');
|
||||
OVC.getRoomJoinButton(browser).click();
|
||||
expect(browser.getCurrentUrl()).toMatch('#/OpenVidu');
|
||||
});
|
||||
|
||||
it('should show a short room name error', () => {
|
||||
const input = OVC.getRoomInput(browser);
|
||||
input.clear();
|
||||
input.sendKeys('OV');
|
||||
const shortError = OVC.getShortRoomNameError(browser);
|
||||
expect(shortError.isDisplayed()).toBeTruthy();
|
||||
OVC.getRoomJoinButton(browser).click();
|
||||
expect(browser.getCurrentUrl()).toMatch('#/');
|
||||
});
|
||||
|
||||
it('should show a required name room error', async () => {
|
||||
const input = OVC.getRoomInput(browser);
|
||||
await input.sendKeys(Key.CONTROL, 'a');
|
||||
await input.sendKeys(Key.DELETE);
|
||||
expect(OVC.getRequiredRoomNameError(browser).isDisplayed()).toBeTruthy();
|
||||
OVC.getRoomJoinButton(browser).click();
|
||||
expect(browser.getCurrentUrl()).toMatch('#/');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Testing config card', () => {
|
||||
const OVC = new OpenViduCall();
|
||||
const EC = protractor.ExpectedConditions;
|
||||
|
||||
beforeEach(() => {
|
||||
browser.waitForAngularEnabled(false);
|
||||
browser.get('#/OpenVidu');
|
||||
});
|
||||
|
||||
it('should show the config card', () => {
|
||||
const configCard = OVC.getConfigCard(browser);
|
||||
browser.wait(EC.visibilityOf(configCard), 3000);
|
||||
expect(configCard.isDisplayed()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should close the config card and go to home', () => {
|
||||
browser.wait(EC.visibilityOf(OVC.getConfigCard(browser)), 3000);
|
||||
expect(OVC.getConfigCard(browser).isDisplayed()).toBeTruthy();
|
||||
|
||||
browser.wait(EC.elementToBeClickable(OVC.getCloseButtonConfigCard(browser)), 5000);
|
||||
OVC.getCloseButtonConfigCard(browser).click();
|
||||
expect(browser.getCurrentUrl()).toMatch('#/');
|
||||
|
||||
// browser.wait(EC.elementToBeClickable(OVC.getCamButton(browser)), 5000);
|
||||
// OVC.getCamButton(browser).click();
|
||||
// browser.wait(EC.visibilityOf(OVC.getCamIcon(browser)), 5000);
|
||||
// expect(OVC.getCamIcon(browser).isDisplayed()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should be able to mute the camera', async () => {
|
||||
let isVideoEnabled: boolean;
|
||||
const videoEnableScript =
|
||||
'const videoTrack = document.getElementsByTagName("video")[0].srcObject.getVideoTracks()[0]; return videoTrack.enabled;';
|
||||
|
||||
browser.wait(EC.elementToBeClickable(OVC.getConfigCardCameraButton(browser)), 5000);
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
isVideoEnabled = await browser.executeScript(videoEnableScript);
|
||||
expect(isVideoEnabled).toBe(true);
|
||||
|
||||
OVC.getConfigCardCameraButton(browser).click();
|
||||
isVideoEnabled = await browser.executeScript(videoEnableScript);
|
||||
expect(isVideoEnabled).toBe(false);
|
||||
});
|
||||
|
||||
it('should be able to mute the microphone', async () => {
|
||||
let isAudioEnabled: boolean;
|
||||
const audioEnableScript =
|
||||
'const audioTrack = document.getElementsByTagName("video")[0].srcObject.getAudioTracks()[0]; return audioTrack.enabled;';
|
||||
|
||||
browser.wait(EC.elementToBeClickable(OVC.getConfigCardMicrophoneButton(browser)), 5000);
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
isAudioEnabled = await browser.executeScript(audioEnableScript);
|
||||
expect(isAudioEnabled).toBe(true);
|
||||
|
||||
OVC.getConfigCardMicrophoneButton(browser).click();
|
||||
isAudioEnabled = await browser.executeScript(audioEnableScript);
|
||||
expect(isAudioEnabled).toBe(false);
|
||||
});
|
||||
|
||||
it('should be able to share the screen', async () => {
|
||||
browser.wait(EC.elementToBeClickable(OVC.getConfigCardScreenShareButton(browser)), 5000);
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getConfigCardScreenShareButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to share the screen and remove the camera video if it is muted', () => {
|
||||
browser.wait(EC.elementToBeClickable(OVC.getConfigCardScreenShareButton(browser)), 5000);
|
||||
browser.wait(EC.elementToBeClickable(OVC.getConfigCardCameraButton(browser)), 5000);
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getConfigCardCameraButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getConfigCardScreenShareButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to add the camera video when the screen is active clicking on camera button', () => {
|
||||
browser.wait(EC.elementToBeClickable(OVC.getConfigCardScreenShareButton(browser)), 5000);
|
||||
browser.wait(EC.elementToBeClickable(OVC.getConfigCardCameraButton(browser)), 5000);
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getConfigCardCameraButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getConfigCardScreenShareButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getConfigCardCameraButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to add the camera video disabling screen share', () => {
|
||||
browser.wait(EC.elementToBeClickable(OVC.getConfigCardScreenShareButton(browser)), 5000);
|
||||
browser.wait(EC.elementToBeClickable(OVC.getConfigCardCameraButton(browser)), 5000);
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getConfigCardCameraButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
OVC.getConfigCardScreenShareButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getConfigCardScreenShareButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to join to room', async () => {
|
||||
browser.wait(EC.elementToBeClickable(OVC.getRoomJoinButton(browser)), 5000);
|
||||
OVC.getRoomJoinButton(browser).click();
|
||||
expect(OVC.getRoomContainer(browser).isDisplayed()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Testing room', () => {
|
||||
const OVC = new OpenViduCall();
|
||||
const EC = protractor.ExpectedConditions;
|
||||
|
||||
beforeEach(() => {
|
||||
browser.waitForAngularEnabled(false);
|
||||
browser.get('#/');
|
||||
browser.wait(EC.elementToBeClickable(OVC.getRoomJoinButton(browser)), 5000);
|
||||
OVC.getRoomJoinButton(browser).click();
|
||||
browser.sleep(1000);
|
||||
|
||||
browser.wait(EC.elementToBeClickable(OVC.getRoomJoinButton(browser)), 5000);
|
||||
OVC.getRoomJoinButton(browser).click();
|
||||
browser.sleep(1000);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
browser.wait(EC.elementToBeClickable(OVC.getLeaveButton(browser)), 5000);
|
||||
OVC.getLeaveButton(browser).click();
|
||||
expect(expect(browser.getCurrentUrl()).toMatch('#/'));
|
||||
});
|
||||
|
||||
it('should be able to mute the camera', async () => {
|
||||
let isVideoEnabled: boolean;
|
||||
const videoEnableScript =
|
||||
'const videoTrack = document.getElementsByTagName("video")[0].srcObject.getVideoTracks()[0]; return videoTrack.enabled;';
|
||||
|
||||
browser.wait(EC.elementToBeClickable(OVC.getRoomCameraButton(browser)), 5000);
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
isVideoEnabled = await browser.executeScript(videoEnableScript);
|
||||
expect(isVideoEnabled).toBe(true);
|
||||
|
||||
OVC.getRoomCameraButton(browser).click();
|
||||
isVideoEnabled = await browser.executeScript(videoEnableScript);
|
||||
|
||||
expect(isVideoEnabled).toBe(false);
|
||||
|
||||
// Uncomment when muted video is shown
|
||||
// expect(OVC.getCameraStatusDisabled(browser).isDisplayed()).toBe(true);
|
||||
});
|
||||
|
||||
it('should be able to mute the microphone', async () => {
|
||||
let isAudioEnabled: boolean;
|
||||
const audioEnableScript =
|
||||
'const audioTrack = document.getElementsByTagName("video")[0].srcObject.getAudioTracks()[0]; return audioTrack.enabled;';
|
||||
|
||||
browser.wait(EC.elementToBeClickable(OVC.getRoomMicrophoneButton(browser)), 5000);
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
isAudioEnabled = await browser.executeScript(audioEnableScript);
|
||||
expect(isAudioEnabled).toBe(true);
|
||||
|
||||
OVC.getRoomMicrophoneButton(browser).click();
|
||||
isAudioEnabled = await browser.executeScript(audioEnableScript);
|
||||
expect(isAudioEnabled).toBe(false);
|
||||
expect(OVC.getMicrophoneStatusDisabled(browser).isDisplayed()).toBe(true);
|
||||
});
|
||||
|
||||
it('should be able to share the screen', () => {
|
||||
browser.wait(EC.elementToBeClickable(OVC.getRoomScreenButton(browser)), 5000);
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
browser.sleep(3000);
|
||||
OVC.getRoomScreenButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to share the screen and remove the camera video if it is muted', () => {
|
||||
browser.wait(EC.elementToBeClickable(OVC.getRoomScreenButton(browser)), 5000);
|
||||
browser.wait(EC.elementToBeClickable(OVC.getRoomCameraButton(browser)), 5000);
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getRoomCameraButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getRoomScreenButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to add the camera video when the screen is active clicking on camera button', () => {
|
||||
browser.wait(EC.elementToBeClickable(OVC.getRoomScreenButton(browser)), 5000);
|
||||
browser.wait(EC.elementToBeClickable(OVC.getRoomCameraButton(browser)), 5000);
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getRoomCameraButton(browser).click();
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getRoomScreenButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
browser.sleep(5000);
|
||||
OVC.getRoomCameraButton(browser).click();
|
||||
browser.sleep(1000);
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to add the camera video disabling screen share', () => {
|
||||
browser.wait(EC.elementToBeClickable(OVC.getRoomScreenButton(browser)), 5000);
|
||||
browser.wait(EC.elementToBeClickable(OVC.getRoomCameraButton(browser)), 5000);
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getRoomCameraButton(browser).click();
|
||||
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getRoomScreenButton(browser).click();
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
|
||||
OVC.getRoomScreenButton(browser).click();
|
||||
OVC.getAllVideos(browser).then((videos) => {
|
||||
expect(videos.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should enable and disable fullscreen', () => {
|
||||
browser.wait(EC.elementToBeClickable(OVC.getFullscreenButton(browser)), 5000);
|
||||
const button = OVC.getFullscreenButton(browser);
|
||||
button.click();
|
||||
browser.sleep(1000);
|
||||
browser.driver
|
||||
.manage()
|
||||
.window()
|
||||
.getSize()
|
||||
.then((value) => {
|
||||
expect(value.width === OVC.getVideo(browser).width && value.height === OVC.getVideo(browser).height);
|
||||
button.click();
|
||||
browser.driver
|
||||
.manage()
|
||||
.window()
|
||||
.getSize()
|
||||
.then((value2) => {
|
||||
expect(value2.width !== OVC.getVideo(browser).width && value2.height !== OVC.getVideo(browser).height);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// describe('Test room ', () => {
|
||||
// const OVC = new OpenViduCall();
|
||||
// const EC = protractor.ExpectedConditions;
|
||||
|
||||
// beforeEach(() => {
|
||||
// browser.waitForAngularEnabled(false);
|
||||
// browser.get('#/codeURJC');
|
||||
// });
|
||||
|
||||
// it('should set disabled the webcam and show the icon', () => {
|
||||
// browser.sleep(3000);
|
||||
// browser.wait(EC.elementToBeClickable(OVC.getCamButton(browser)), 5000);
|
||||
// OVC.getCamButton(browser).click();
|
||||
// browser.wait(EC.visibilityOf(OVC.getCamIcon(browser)), 5000);
|
||||
// expect(OVC.getCamIcon(browser).isDisplayed()).toBeTruthy();
|
||||
// });
|
||||
|
||||
// it('should set disabled the microphone and show the icon', () => {
|
||||
// browser.sleep(3000);
|
||||
// browser.wait(EC.elementToBeClickable(OVC.getMicButton(browser)), 5000);
|
||||
// OVC.getMicButton(browser).click();
|
||||
// browser.wait(EC.visibilityOf(OVC.getMicIcon(browser)), 5000);
|
||||
// expect(OVC.getMicIcon(browser).isDisplayed()).toBeTruthy();
|
||||
// });
|
||||
|
||||
// it('should show the screen share dialog', () => {
|
||||
// browser.wait(EC.elementToBeClickable(OVC.getShareScreenButton(browser)), 5000);
|
||||
// OVC.getShareScreenButton(browser).click();
|
||||
// browser.wait(EC.presenceOf(OVC.getDialogExtension(browser)), 5000);
|
||||
// expect(OVC.getDialogExtension(browser).isDisplayed()).toBeTruthy();
|
||||
// const button = OVC.getDialogCancelButton(browser);
|
||||
// button.click();
|
||||
// });
|
||||
|
||||
// it('should change the username', () => {
|
||||
// browser.wait(EC.elementToBeClickable(OVC.getLocalNickname(browser)), 5000);
|
||||
// OVC.getLocalNickname(browser).click();
|
||||
// expect(OVC.getDialogNickname(browser).isDisplayed()).toBeTruthy();
|
||||
// const inputDialog = OVC.getDialogNickname(browser).element(by.css('input'));
|
||||
// inputDialog.clear();
|
||||
// OVC.typeWithDelay(inputDialog, 'C');
|
||||
// OVC.pressEnter(browser);
|
||||
// browser.sleep(1000);
|
||||
// expect(OVC.getLocalNickname(browser).getText()).toBe('C');
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('Chat component', () => {
|
||||
// const OVC = new OpenViduCall();
|
||||
// const EC = protractor.ExpectedConditions;
|
||||
|
||||
// beforeEach(() => {
|
||||
// browser.waitForAngularEnabled(false);
|
||||
// return browser.get('#/codeURJC');
|
||||
// });
|
||||
|
||||
// it('should send a message', () => {
|
||||
// browser.wait(EC.elementToBeClickable(OVC.getChatButton(browser)), 5000);
|
||||
// OVC.getChatButton(browser).click();
|
||||
// browser.sleep(1500);
|
||||
// OVC.getChatInput(browser).sendKeys('Message 1');
|
||||
// browser.actions().sendKeys(protractor.Key.ENTER).perform();
|
||||
// expect(OVC.getMessageList(browser).count()).toEqual(1);
|
||||
// OVC.getChatButton(browser).click();
|
||||
// });
|
||||
// });
|
||||
|
||||
// describe('Two browsers: ', () => {
|
||||
// const OVC = new OpenViduCall();
|
||||
// const EC = protractor.ExpectedConditions;
|
||||
// let browser2: ProtractorBrowser;
|
||||
|
||||
// beforeEach(() => {
|
||||
// browser.waitForAngularEnabled(false);
|
||||
// browser.get('#/codeURJC');
|
||||
// });
|
||||
|
||||
// it('should connect a new user', () => {
|
||||
// browser2 = OVC.openNewBrowserInTheSameRoom(browser);
|
||||
|
||||
// // avoid timeout waiting angular
|
||||
// browser2.waitForAngularEnabled(false);
|
||||
|
||||
// browser.sleep(4000);
|
||||
// expect(OVC.getVideoList(browser).count()).toEqual(2);
|
||||
// OVC.closeSession(browser2);
|
||||
// });
|
||||
|
||||
// it('a user should disconnect his WEBCAM and to be identified by other ', () => {
|
||||
// browser2 = OVC.openNewBrowserInTheSameRoom(browser);
|
||||
|
||||
// // avoid timeout waiting angular
|
||||
// browser2.ignoreSynchronization = true;
|
||||
// browser.wait(EC.elementToBeClickable(OVC.getCamButton(browser)), 10000);
|
||||
// OVC.getCamButton(browser).click();
|
||||
// expect(OVC.getCamIcon(browser).isDisplayed()).toBeTruthy();
|
||||
// expect(OVC.getCamIcon(browser2).isDisplayed()).toBeTruthy();
|
||||
// OVC.closeSession(browser2);
|
||||
// });
|
||||
|
||||
// it('a user should disconnect his MICROPHONE and to be identified by other ', () => {
|
||||
// browser2 = OVC.openNewBrowserInTheSameRoom(browser);
|
||||
|
||||
// // avoid timeout waiting angular
|
||||
// browser2.waitForAngularEnabled(false);
|
||||
|
||||
// browser.wait(EC.elementToBeClickable(OVC.getMicButton(browser)), 5000);
|
||||
// OVC.getMicButton(browser).click();
|
||||
// expect(OVC.getMicIcon(browser).isDisplayed()).toBeTruthy();
|
||||
// expect(OVC.getMicIcon(browser2).isDisplayed()).toBeTruthy();
|
||||
// OVC.closeSession(browser2);
|
||||
// });
|
||||
|
||||
// it('a user should send a MESSAGE and to be identified by other ', () => {
|
||||
// browser2 = OVC.openNewBrowserInTheSameRoom(browser);
|
||||
// // avoid timeout waiting angular
|
||||
// browser2.waitForAngularEnabled(false);
|
||||
|
||||
// browser.sleep(3000);
|
||||
// browser.wait(EC.elementToBeClickable(OVC.getChatButton(browser)), 5000);
|
||||
// OVC.getChatButton(browser).click();
|
||||
// browser.wait(EC.visibilityOf(OVC.getChatContent(browser)), 5000);
|
||||
// expect(OVC.getChatContent(browser).isDisplayed).toBeTruthy();
|
||||
// browser.sleep(5000);
|
||||
// OVC.getChatInput(browser).click();
|
||||
// OVC.getChatInput(browser).sendKeys('New Message');
|
||||
// OVC.pressEnter(browser);
|
||||
// OVC.getChatButton(browser).click();
|
||||
// expect(OVC.getNewMessagePoint(browser2).getText()).toBe('1');
|
||||
// OVC.closeSession(browser2);
|
||||
// });
|
||||
|
||||
// it('both users should can type messages and reveive its', () => {
|
||||
// browser2 = OVC.openNewBrowserInTheSameRoom(browser);
|
||||
|
||||
// browser2.waitForAngularEnabled(false);
|
||||
|
||||
// OVC.getChatButton(browser).click();
|
||||
// const input = OVC.getChatInput(browser);
|
||||
// browser.sleep(2000);
|
||||
// input.click();
|
||||
// input.sendKeys('New Message User 1');
|
||||
// OVC.pressEnter(browser);
|
||||
// // OVC.getChatButton(browser).click();
|
||||
// OVC.getChatButton(browser2).click();
|
||||
|
||||
// expect(OVC.getMessageList(browser2).count()).toEqual(1);
|
||||
// const input2 = OVC.getChatInput(browser2);
|
||||
// browser2.sleep(2000);
|
||||
// input2.click();
|
||||
// input2.sendKeys('Message User 2');
|
||||
// OVC.pressEnter(browser2);
|
||||
// expect(OVC.getMessageList(browser).count()).toEqual(4);
|
||||
// OVC.closeSession(browser2);
|
||||
// });
|
||||
|
||||
// it('user should can change his nickname and to be checked by other', () => {
|
||||
// browser2 = OVC.openNewBrowserInTheSameRoom(browser);
|
||||
|
||||
// browser2.waitForAngularEnabled(false);
|
||||
// browser.sleep(4000);
|
||||
// OVC.getLocalNickname(browser).click();
|
||||
// expect(OVC.getDialogNickname(browser).isDisplayed()).toBeTruthy();
|
||||
// const inputDialog = OVC.getDialogNickname(browser).element(by.css('input'));
|
||||
// inputDialog.click();
|
||||
// inputDialog.clear();
|
||||
// OVC.typeWithDelay(inputDialog, 'C');
|
||||
// OVC.pressEnter(browser);
|
||||
// browser.sleep(2000);
|
||||
// expect(OVC.getRemoteNickname(browser2).getText()).toBe('C');
|
||||
// OVC.closeSession(browser2);
|
||||
// });
|
||||
// });
|
||||
@ -1,142 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
import { by, element, protractor, ElementFinder, ProtractorBrowser, WebElement, ElementArrayFinder } from 'protractor';
|
||||
|
||||
export class OpenViduCall {
|
||||
constructor() {}
|
||||
|
||||
getRoomInput(browser: ProtractorBrowser) {
|
||||
return this.getElementById(browser, 'roomInput');
|
||||
}
|
||||
|
||||
getRoomJoinButton(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'joinButton');
|
||||
}
|
||||
|
||||
getShortRoomNameError(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'shortNameError');
|
||||
}
|
||||
|
||||
getRequiredRoomNameError(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'requiredNameError');
|
||||
}
|
||||
|
||||
getConfigCard(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'roomConfig');
|
||||
}
|
||||
|
||||
getConfigCardScreenShareButton(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'configCardScreenButton');
|
||||
}
|
||||
|
||||
getConfigCardCameraButton(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'configCardCameraButton');
|
||||
}
|
||||
|
||||
getConfigCardMicrophoneButton(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'configCardMicrophoneButton');
|
||||
}
|
||||
|
||||
getRoomContainer(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'room-container');
|
||||
}
|
||||
|
||||
getCloseButtonConfigCard(browser: ProtractorBrowser): ElementFinder {
|
||||
return browser.element(by.id('closeButton'));
|
||||
}
|
||||
|
||||
|
||||
getAllVideos(browser: ProtractorBrowser){
|
||||
return browser.element.all(by.tagName('video'));
|
||||
}
|
||||
|
||||
getLeaveButton(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'navLeaveButton');
|
||||
}
|
||||
|
||||
getRoomCameraButton(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'navCameraButton');
|
||||
}
|
||||
|
||||
getCameraStatusDisabled(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'statusCam');
|
||||
}
|
||||
|
||||
getFullscreenButton(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'fullscreenButton');
|
||||
}
|
||||
|
||||
getRoomMicrophoneButton(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'navMicrophoneButton');
|
||||
}
|
||||
|
||||
getMicrophoneStatusDisabled(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'statusMic');
|
||||
}
|
||||
|
||||
getRoomScreenButton(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getElementById(browser, 'navScreenButton');
|
||||
}
|
||||
|
||||
openNewBrowserInTheSameRoom(browser: ProtractorBrowser): ProtractorBrowser {
|
||||
return browser.forkNewDriverInstance(true);
|
||||
}
|
||||
|
||||
getLocalNickname(browser: ProtractorBrowser): ElementFinder {
|
||||
return browser.element(by.css('#localUser #nickname'));
|
||||
}
|
||||
getRemoteNickname(browser: ProtractorBrowser): ElementFinder {
|
||||
return browser.element(by.css('#remoteUsers #nickname'));
|
||||
}
|
||||
|
||||
getDialogNickname(browser: ProtractorBrowser): ElementFinder {
|
||||
return browser.element(by.css('#dialogNickname'));
|
||||
}
|
||||
|
||||
getChatButton(browser: ProtractorBrowser): ElementFinder {
|
||||
return browser.element(by.css('#navChatButton'));
|
||||
}
|
||||
|
||||
getVideo(browser: ProtractorBrowser): ElementFinder {
|
||||
return this.getChatContent(browser).element(by.css('video'));
|
||||
}
|
||||
|
||||
|
||||
getRemoteVideoList(browser): ElementFinder {
|
||||
return browser.element.all(by.css('#remoteUsers video'));
|
||||
}
|
||||
|
||||
getChatContent(browser: ProtractorBrowser): ElementFinder {
|
||||
return browser.element(by.css('#chatComponent'));
|
||||
}
|
||||
|
||||
getChatInput(browser: ProtractorBrowser): ElementFinder {
|
||||
return browser.element(by.id('chatInput'));
|
||||
}
|
||||
|
||||
getNewMessagePoint(browser: ProtractorBrowser): ElementFinder {
|
||||
return browser.element(by.css('#mat-badge-content-0'));
|
||||
}
|
||||
|
||||
pressEnter(browser: ProtractorBrowser) {
|
||||
browser.actions().sendKeys(protractor.Key.ENTER).perform();
|
||||
}
|
||||
|
||||
getMessageList(browser: ProtractorBrowser) {
|
||||
return browser.element.all(by.css('#chatComponent .message-wrap .message .msg-detail'));
|
||||
}
|
||||
|
||||
closeSession(browser: ProtractorBrowser) {
|
||||
const leaveButton = this.getLeaveButton(browser);
|
||||
leaveButton.click();
|
||||
browser.quit();
|
||||
}
|
||||
|
||||
typeWithDelay(input, keys: string) {
|
||||
keys.split('').forEach((c) => input.sendKeys(c));
|
||||
}
|
||||
|
||||
private getElementById(browser: ProtractorBrowser, id: string) {
|
||||
return browser.element(by.id(id));
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/app",
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"types": [
|
||||
"jasmine",
|
||||
"jasminewd2",
|
||||
"node"
|
||||
]
|
||||
}
|
||||
}
|
||||
23810
openvidu-call/openvidu-call-front/package-lock.json
generated
@ -1,50 +0,0 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@angular/animations": "13.3.0",
|
||||
"@angular/cdk": "13.3.0",
|
||||
"@angular/common": "13.3.0",
|
||||
"@angular/compiler": "13.3.0",
|
||||
"@angular/core": "13.3.0",
|
||||
"@angular/forms": "13.3.0",
|
||||
"@angular/material": "13.3.0",
|
||||
"@angular/platform-browser": "13.3.0",
|
||||
"@angular/platform-browser-dynamic": "13.3.0",
|
||||
"@angular/router": "13.3.0",
|
||||
"openvidu-angular": "2.23.1",
|
||||
"rxjs": "7.5.5",
|
||||
"unique-names-generator": "4.7.1",
|
||||
"zone.js": "0.11.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "13.3.0",
|
||||
"@angular/cli": "13.3.0",
|
||||
"@angular/compiler-cli": "13.3.0",
|
||||
"@angular/language-service": "13.3.0",
|
||||
"@types/jasmine": "3.10.3",
|
||||
"@types/node": "16.11.9",
|
||||
"codelyzer": "6.0.1",
|
||||
"fs-extra": "9.0.1",
|
||||
"jasmine-core": "3.10.1",
|
||||
"karma": "6.3.9",
|
||||
"ng-packagr": "13.3.0",
|
||||
"protractor": "7.0.0",
|
||||
"ts-node": "10.4.0",
|
||||
"tslib": "2.3.1",
|
||||
"tslint": "6.1.3",
|
||||
"typedoc": "0.22.11",
|
||||
"typescript": "4.4.4"
|
||||
},
|
||||
"name": "openvidu-call",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev:start": "ng serve --ssl --configuration development",
|
||||
"dev:build": "./node_modules/@angular/cli/bin/ng.js build --output-path ../openvidu-call-back/public/",
|
||||
"prod:build": "func() { ./node_modules/@angular/cli/bin/ng.js build --output-path ../openvidu-call-back/public/ --configuration production --base-href=\"${1:-/}\"; }; func",
|
||||
"dev:build-java": "./node_modules/@angular/cli/bin/ng.js build --output-path ../openvidu-call-back-java/src/main/resources/static/",
|
||||
"prod:build-java": "func() { ./node_modules/@angular/cli/bin/ng.js build --output-path ../openvidu-call-back-java/src/main/resources/static/ --configuration production --base-href=\"${1:-/}\"; }; func",
|
||||
"e2e": "ng e2e",
|
||||
"lint": "ng lint",
|
||||
"test": "ng test openvidu-call --watch=false --code-coverage"
|
||||
},
|
||||
"version": "2.23.0"
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { AdminDashboardComponent } from './components/admin-dashboard/admin-dashboard.component';
|
||||
import { CallComponent } from './components/call/call.component';
|
||||
import { HomeComponent } from './components/home/home.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', component: HomeComponent },
|
||||
{ path: 'admin', component: AdminDashboardComponent },
|
||||
{ path: ':roomName', component: CallComponent }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(routes, { useHash: true })],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class AppRoutingModule {}
|
||||
@ -1,2 +0,0 @@
|
||||
<!--The content below is only a placeholder and can be replaced.-->
|
||||
<router-outlet></router-outlet>
|
||||
@ -1,15 +0,0 @@
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [AppComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
it('should create the app', async(() => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.debugElement.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
}));
|
||||
|
||||
});
|
||||
@ -1,10 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.css']
|
||||
})
|
||||
export class AppComponent {
|
||||
title = 'OpenVidu Call';
|
||||
}
|
||||
@ -1,44 +0,0 @@
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
import { environment } from 'src/environments/environment';
|
||||
|
||||
// Material
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
|
||||
// Application Components
|
||||
import { AppComponent } from './app.component';
|
||||
import { CallComponent } from './components/call/call.component';
|
||||
import { HomeComponent } from './components/home/home.component';
|
||||
|
||||
// OpenVidu Angular
|
||||
import { OpenViduAngularConfig, OpenViduAngularModule } from 'openvidu-angular';
|
||||
import { AdminDashboardComponent } from './components/admin-dashboard/admin-dashboard.component';
|
||||
|
||||
// Services
|
||||
|
||||
const config: OpenViduAngularConfig = {
|
||||
production: environment.production
|
||||
};
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [AppComponent, HomeComponent, CallComponent, AdminDashboardComponent],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
BrowserAnimationsModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
MatToolbarModule,
|
||||
OpenViduAngularModule.forRoot(config),
|
||||
AppRoutingModule // Order is important, AppRoutingModule must be the last import for useHash working
|
||||
],
|
||||
providers: [],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule {
|
||||
ngDoBootstrap() {}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
<ov-admin-login *ngIf="!logged" [error]="error" (onLoginButtonClicked)="onLoginClicked($event)"></ov-admin-login>
|
||||
|
||||
<ov-admin-dashboard
|
||||
*ngIf="logged"
|
||||
[recordingsList]="recordings"
|
||||
(onLogoutClicked)="onLogoutClicked()"
|
||||
(onRefreshRecordingsClicked)="onRefreshRecordingsClicked()"
|
||||
(onDeleteRecordingClicked)="onDeleteRecordingClicked($event)"
|
||||
></ov-admin-dashboard>
|
||||
@ -1,25 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AdminDashboardComponent } from './admin-dashboard.component';
|
||||
|
||||
describe('AdminDashboardComponent', () => {
|
||||
let component: AdminDashboardComponent;
|
||||
let fixture: ComponentFixture<AdminDashboardComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ AdminDashboardComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(AdminDashboardComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -1,52 +0,0 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { RecordingService } from 'openvidu-angular';
|
||||
import { RestService } from 'src/app/services/rest.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-admin-dashboard',
|
||||
templateUrl: './admin-dashboard.component.html',
|
||||
styleUrls: ['./admin-dashboard.component.css']
|
||||
})
|
||||
export class AdminDashboardComponent implements OnInit {
|
||||
recordings = [];
|
||||
logged: boolean;
|
||||
error: any;
|
||||
constructor(private restService: RestService, private recordingService: RecordingService) {}
|
||||
|
||||
ngOnInit(): void {}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onLogoutClicked();
|
||||
}
|
||||
|
||||
async onLoginClicked(pass: string) {
|
||||
try {
|
||||
const resp: any = await this.restService.login(pass);
|
||||
this.logged = true;
|
||||
this.recordings = resp.recordings;
|
||||
} catch (error) {
|
||||
this.error = error;
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
async onLogoutClicked() {
|
||||
this.logged = false;
|
||||
await this.restService.logout();
|
||||
}
|
||||
|
||||
async onRefreshRecordingsClicked() {
|
||||
try {
|
||||
this.recordings = await this.restService.getRecordings();
|
||||
} catch (error) {
|
||||
this.onLogoutClicked();
|
||||
}
|
||||
}
|
||||
|
||||
async onDeleteRecordingClicked(recordingId: string) {
|
||||
try {
|
||||
this.recordings = await this.restService.deleteRecording(recordingId);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
<ov-videoconference
|
||||
[tokens]="tokens"
|
||||
[recordingActivityRecordingsList]="recordingList"
|
||||
[recordingActivityRecordingError]="recordingError"
|
||||
(onToolbarLeaveButtonClicked)="onLeaveButtonClicked()"
|
||||
(onToolbarStartRecordingClicked)="onStartRecordingClicked()"
|
||||
(onActivitiesPanelStartRecordingClicked)="onStartRecordingClicked()"
|
||||
(onToolbarStopRecordingClicked)="onStopRecordingClicked()"
|
||||
(onActivitiesPanelStopRecordingClicked)="onStopRecordingClicked()"
|
||||
(onActivitiesPanelDeleteRecordingClicked)="onDeleteRecordingClicked($event)"
|
||||
[activitiesPanelRecordingActivity]="recordingEnabled"
|
||||
[toolbarRecordingButton]="recordingEnabled"
|
||||
>
|
||||
</ov-videoconference>
|
||||
@ -1,25 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CallComponent } from './call.component';
|
||||
|
||||
describe('CallComponent', () => {
|
||||
let component: CallComponent;
|
||||
let fixture: ComponentFixture<CallComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ CallComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(CallComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -1,80 +0,0 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||
import { ParticipantService, RecordingInfo, RecordingService, TokenModel } from 'openvidu-angular';
|
||||
|
||||
import { RestService } from '../../services/rest.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-call',
|
||||
templateUrl: './call.component.html',
|
||||
styleUrls: ['./call.component.css']
|
||||
})
|
||||
export class CallComponent implements OnInit {
|
||||
sessionId = '';
|
||||
tokens: TokenModel;
|
||||
joinSessionClicked: boolean = false;
|
||||
closeClicked: boolean = false;
|
||||
isSessionAlive: boolean = false;
|
||||
recordingEnabled: boolean = true;
|
||||
recordingList: RecordingInfo[] = [];
|
||||
recordingError: any;
|
||||
|
||||
constructor(
|
||||
private restService: RestService,
|
||||
private participantService: ParticipantService,
|
||||
private recordingService: RecordingService,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
this.route.params.subscribe((params: Params) => {
|
||||
this.sessionId = params.roomName;
|
||||
});
|
||||
|
||||
let nickname: string = '';
|
||||
// Just for debugging purposes
|
||||
const regex = /^UNSAFE_DEBUG_USE_CUSTOM_IDS_/gm;
|
||||
const match = regex.exec(this.sessionId);
|
||||
if (match && match.length > 0) {
|
||||
console.warn('DEBUGGING SESSION');
|
||||
nickname = this.participantService.getLocalParticipant().getNickname();
|
||||
}
|
||||
|
||||
const response = await this.restService.getTokens(this.sessionId, nickname);
|
||||
this.recordingEnabled = response.recordingEnabled;
|
||||
this.recordingList = response.recordings;
|
||||
this.tokens = {
|
||||
webcam: response.cameraToken,
|
||||
screen: response.screenToken
|
||||
};
|
||||
}
|
||||
onLeaveButtonClicked() {
|
||||
this.isSessionAlive = false;
|
||||
this.closeClicked = true;
|
||||
this.router.navigate([`/`]);
|
||||
}
|
||||
async onStartRecordingClicked() {
|
||||
try {
|
||||
await this.restService.startRecording(this.sessionId);
|
||||
} catch (error) {
|
||||
this.recordingError = error;
|
||||
}
|
||||
}
|
||||
|
||||
async onStopRecordingClicked() {
|
||||
try {
|
||||
this.recordingList = await this.restService.stopRecording(this.sessionId);
|
||||
} catch (error) {
|
||||
this.recordingError = error;
|
||||
}
|
||||
}
|
||||
|
||||
async onDeleteRecordingClicked(recordingId: string) {
|
||||
try {
|
||||
this.recordingList = await this.restService.deleteRecording(recordingId);
|
||||
} catch (error) {
|
||||
this.recordingError = error;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,179 +0,0 @@
|
||||
.section1 {
|
||||
background: url('../../../assets/images/bg.webp') top center no-repeat;
|
||||
background-size: cover;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#header, .footer {
|
||||
background-color: transparent;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.roomError{
|
||||
font-size: 16px;
|
||||
color: #c01515;
|
||||
}
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
font-size: 9px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.footer a {
|
||||
color: #ffffff;
|
||||
|
||||
}
|
||||
#header_img {
|
||||
max-width: 150px;
|
||||
margin-right: 10px;
|
||||
margin-top: 10px;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.ovVersion {
|
||||
position: absolute;
|
||||
right: 15px;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.ovLogo {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#card_content {
|
||||
height: 50%;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 25px;
|
||||
font-weight: 500;
|
||||
color: #fff;
|
||||
position: relative;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
#room_card {
|
||||
color: #303030;
|
||||
position: inherit;
|
||||
max-width: 700px;
|
||||
width: 75%;
|
||||
margin: auto;
|
||||
background: rgba(221, 221, 221, 0.856);
|
||||
}
|
||||
|
||||
#room_card mat-form-field {
|
||||
margin: auto;
|
||||
padding: 0px 5px;
|
||||
}
|
||||
|
||||
/* Extra small devices (phones, 600px and down) */
|
||||
@media only screen and (max-width: 600px) {
|
||||
#header_img, .ovVersion, .footer {
|
||||
display: none;
|
||||
}
|
||||
.joinForm, .ovLogo {
|
||||
max-width: 80%;
|
||||
}
|
||||
.inputForm, h4 {
|
||||
font-size: 16px ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding: 100px 0;
|
||||
position: absolute;
|
||||
top: 40%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.formContainer {
|
||||
font-size: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
.joinForm {
|
||||
min-width: 300px;
|
||||
margin: 10px auto;
|
||||
max-width: 50%;
|
||||
background: #fff;
|
||||
padding: 6px 10px;
|
||||
position: relative;
|
||||
border-radius: 10px 5px 10px 0px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.inputForm {
|
||||
border: 0;
|
||||
padding: 4px 8px;
|
||||
font-size: 17px;
|
||||
width: calc(100% - 90px);
|
||||
outline: none;
|
||||
caret-color: #000000;
|
||||
color: #303030;
|
||||
}
|
||||
|
||||
.joinButton {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: -2px;
|
||||
bottom: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
padding: 0 20px;
|
||||
background: #00ad4e;
|
||||
color: #fff;
|
||||
border-radius: 0px 5px 10px 0px;
|
||||
transition: 0.3s;
|
||||
box-shadow: 0px 2px 15px rgba(0, 0, 0, 0.1);
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.joinButton:hover {
|
||||
background: #009242;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Small devices (portrait tablets and large phones, 600px and up) */
|
||||
@media only screen and (min-width: 600px) {
|
||||
.ovLogo {
|
||||
max-width: 75%;
|
||||
}
|
||||
}
|
||||
|
||||
/* Medium devices (landscape tablets, 768px and up) */
|
||||
@media only screen and (min-width: 768px) {
|
||||
|
||||
}
|
||||
|
||||
/* Large devices (laptops/desktops, 992px and up) */
|
||||
@media only screen and (min-width: 992px) {
|
||||
.ovLogo {
|
||||
max-width: 60%;
|
||||
}
|
||||
.inputForm {
|
||||
font-size: 20px !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Extra large devices (large laptops and desktops, 1200px and up) */
|
||||
@media only screen and (min-width: 1200px) {
|
||||
.section1 {
|
||||
background-attachment: fixed;
|
||||
}
|
||||
.ovLogo {
|
||||
max-width: 50%;
|
||||
}
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
<div class="section1">
|
||||
<mat-toolbar id="header">
|
||||
<a href="https://openvidu.io/" target="_blank">
|
||||
<img id="header_img" alt="OpenVidu Logo" src="assets/images/openvidu_logo.png" />
|
||||
</a>
|
||||
<div class="ovVersion">
|
||||
<span>{{ version }}</span>
|
||||
</div>
|
||||
</mat-toolbar>
|
||||
<div class="container">
|
||||
<div class="ovInfo">
|
||||
<img class="ovLogo" alt="OpenVidu Logo" src="assets/images/openvidu_logo.png" />
|
||||
<h4>Videoconference rooms in one click</h4>
|
||||
</div>
|
||||
<div class="formContainer">
|
||||
<div class="roomError" id="requiredNameError" *ngIf="roomForm.hasError('required')">
|
||||
Room name is <strong>required</strong>
|
||||
</div>
|
||||
<div class="roomError" id="shortNameError" *ngIf="roomForm.hasError('minlength')">
|
||||
Room name is <strong>too short!</strong>
|
||||
</div>
|
||||
<form [formGroup]="roomForm" novalidate (ngSubmit)="goToVideoCall()">
|
||||
<div class="joinForm">
|
||||
<input matInput class="inputForm" type="text" [formControl]="roomForm" autocomplete="off" id="roomInput" />
|
||||
<button type="submit" class="joinButton" id="joinButton" >JOIN</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<mat-toolbar class="footer">
|
||||
<span>
|
||||
Photo by
|
||||
<a
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
href="https://unsplash.com/@danielleone?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText"
|
||||
>
|
||||
Daniel Leone
|
||||
</a>
|
||||
on
|
||||
<a
|
||||
href="https://unsplash.com/s/photos/mountain?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText"
|
||||
target="_blank"
|
||||
>
|
||||
Unsplash
|
||||
</a></span
|
||||
>
|
||||
</mat-toolbar>
|
||||
</div>
|
||||
@ -1,28 +0,0 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
import { HomeComponent } from './home.component';
|
||||
import { FormBuilder } from '@angular/forms';
|
||||
|
||||
describe('HomeComponent', () => {
|
||||
let component: HomeComponent;
|
||||
let fixture: ComponentFixture<HomeComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [HomeComponent],
|
||||
providers: [FormBuilder],
|
||||
imports: [RouterTestingModule.withRoutes([])]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(HomeComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -1,31 +0,0 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormBuilder, Validators, FormControl } from '@angular/forms';
|
||||
import { Router } from '@angular/router';
|
||||
import { uniqueNamesGenerator, adjectives, colors, animals } from 'unique-names-generator';
|
||||
import packageInfo from '../../../../package.json';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
templateUrl: './home.component.html',
|
||||
styleUrls: ['./home.component.css']
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
public roomForm: FormControl;
|
||||
public version: string;
|
||||
|
||||
constructor(private router: Router, public formBuilder: FormBuilder) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.version = packageInfo.version;
|
||||
const randomName = uniqueNamesGenerator({ dictionaries: [adjectives, colors, animals], separator: '-', });
|
||||
this.roomForm = new FormControl(randomName, [Validators.minLength(4), Validators.required]);
|
||||
}
|
||||
|
||||
public goToVideoCall() {
|
||||
if (this.roomForm.valid) {
|
||||
const roomName = this.roomForm.value.replace(/ /g, '-'); // replace white spaces by -
|
||||
this.roomForm.setValue(roomName);
|
||||
this.router.navigate(['/', roomName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { RestService } from './rest.service';
|
||||
|
||||
describe('RestService', () => {
|
||||
let service: RestService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(RestService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -1,81 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { catchError, lastValueFrom, Observable } from 'rxjs';
|
||||
import { RecordingInfo } from 'openvidu-angular';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class RestService {
|
||||
private baseHref: string;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
this.baseHref = '/' + (!!window.location.pathname.split('/')[1] ? window.location.pathname.split('/')[1] + '/' : '');
|
||||
}
|
||||
async getTokens(
|
||||
sessionId: string,
|
||||
nickname?: string
|
||||
): Promise<{ cameraToken: string, screenToken: string, recordingEnabled: boolean, recordings?: RecordingInfo[] }> {
|
||||
return this.postRequest('sessions', { sessionId, nickname });
|
||||
}
|
||||
login(password: string): Promise<any[]> {
|
||||
return this.postRequest('admin/login', { password });
|
||||
}
|
||||
logout(): Promise<void> {
|
||||
return this.postRequest('admin/logout', {});
|
||||
}
|
||||
|
||||
getRecordings() {
|
||||
return this.getRequest(`recordings/`);
|
||||
}
|
||||
|
||||
startRecording(sessionId: string) {
|
||||
return this.postRequest('recordings/start', { sessionId });
|
||||
}
|
||||
|
||||
stopRecording(sessionId: string) {
|
||||
return this.postRequest('recordings/stop', { sessionId });
|
||||
}
|
||||
|
||||
deleteRecording(recordingId: string): Promise<RecordingInfo[]> {
|
||||
return this.deleteRequest(`recordings/delete/${recordingId}`);
|
||||
}
|
||||
|
||||
private postRequest(path: string, body: any): any {
|
||||
try {
|
||||
return lastValueFrom(this.http.post<any>(this.baseHref + path, body));
|
||||
} catch (error) {
|
||||
if (error.status === 404) {
|
||||
throw { status: error.status, message: 'Cannot connect with backend. ' + error.url + ' not found' };
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private getRequest(path: string, responseType?: string): any {
|
||||
try {
|
||||
const options = {};
|
||||
if (responseType) {
|
||||
options['responseType'] = responseType;
|
||||
}
|
||||
return lastValueFrom(this.http.get(`${this.baseHref}${path}`, options));
|
||||
} catch (error) {
|
||||
if (error.status === 404) {
|
||||
throw { status: error.status, message: 'Cannot connect with backend. ' + error.url + ' not found' };
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private deleteRequest(path: string) {
|
||||
try {
|
||||
return lastValueFrom(this.http.delete<any>(`${this.baseHref}${path}`));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
if (error.status === 404) {
|
||||
throw { status: error.status, message: 'Cannot connect with backend. ' + error.url + ' not found' };
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 258 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 294 KiB |
|
Before Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 183 KiB |
|
Before Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 207 KiB |
|
Before Width: | Height: | Size: 194 KiB |
|
Before Width: | Height: | Size: 268 KiB |
|
Before Width: | Height: | Size: 120 KiB |
|
Before Width: | Height: | Size: 228 KiB |
|
Before Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 328 KiB |
|
Before Width: | Height: | Size: 587 B |
|
Before Width: | Height: | Size: 621 B |
|
Before Width: | Height: | Size: 481 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 901 B |
|
Before Width: | Height: | Size: 943 B |
|
Before Width: | Height: | Size: 813 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |