diff --git a/.gitignore b/.gitignore index 3983381664a8bb1981f013c945ca42d9aea65f7a..517bb4f649e845b526aa96c0ec11506eef1468b7 100644 --- a/.gitignore +++ b/.gitignore @@ -94,3 +94,5 @@ docs/swagger _build front/src/translations.json front/locales/en_US/LC_MESSAGES/app.po + +docker/antmedia/ant-media* diff --git a/dev.yml b/dev.yml index 5ac74424cc59eb8b67bf342e3854701ded93e205..e41a0c67dd2ce09a25d2233483be09125a60cf44 100644 --- a/dev.yml +++ b/dev.yml @@ -133,8 +133,17 @@ services: volumes: - "./docs/swagger.yml:/usr/share/nginx/html/swagger.yml" + antmedia: + image: funkwhale/antmedia + ports: + - "5080:5080" + # - "5443:5443" + - "1935:1935" + volumes: + - "/usr/local/antmedia/" + networks: - ? internal + internal: federation: external: name: federation diff --git a/docker/antmedia/.dockerignore b/docker/antmedia/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..c4c4ffc6aa41a89cc618a31d17f6d5924ddf2b10 --- /dev/null +++ b/docker/antmedia/.dockerignore @@ -0,0 +1 @@ +*.zip diff --git a/docker/antmedia/Dockerfile b/docker/antmedia/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4556e0d770b29ff501e01cb6174a5430eeac37f3 --- /dev/null +++ b/docker/antmedia/Dockerfile @@ -0,0 +1,15 @@ +FROM debian:9 + +RUN apt-get update && apt-get install -y libx11-dev wget openjdk-8-jdk jsvc + +RUN useradd -d /usr/local/antmedia/ -s /bin/false -r antmedia +USER antmedia +COPY --chown=antmedia:antmedia ./ant-media-server /usr/local/antmedia +WORKDIR /usr/local/antmedia +RUN mkdir log + +RUN sed -i '/JAVA_HOME="\/usr\/lib\/jvm\/java-8-oracle"/c\JAVA_HOME="\/usr\/lib\/jvm\/java-8-openjdk-amd64"' ./antmedia +COPY ./server.sh ./server.sh + +CMD './server.sh' +EXPOSE 1935 5080 5443 diff --git a/docker/antmedia/README.md b/docker/antmedia/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7bd2b39ece2caff3976eab1aa9802930d27bf078 --- /dev/null +++ b/docker/antmedia/README.md @@ -0,0 +1,7 @@ +# Build antmedia docker image + +``` +wget https://github.com/ant-media/Ant-Media-Server/releases/download/ams-v1.5.2/ant-media-server-community-1.5.2-181116_1126.zip +unzip ant-media-server-community-1.5.2-181116_1126.zip +docker build -t funkwhale/antmedia . +``` diff --git a/docker/antmedia/server.sh b/docker/antmedia/server.sh new file mode 100755 index 0000000000000000000000000000000000000000..3b027cc10622ef200804df1d0d9f9bc905c40a8e --- /dev/null +++ b/docker/antmedia/server.sh @@ -0,0 +1,48 @@ +#!/bin/bash -eux +EXEC="/usr/bin/jsvc" +NAME="antmedia" +# The path to the folder containing daemon jar +FILE_PATH="/usr/local/$NAME" +export RED5_HOME=$FILE_PATH; +echo "Path $FILE_PATH"; +ulimit -n 65536 + +# The path to the folder containing the java runtime +JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64" + +# Our classpath including our jar file and the Apache Commons Daemon library +CLASS_PATH="$FILE_PATH/commons-daemon-1.0.15.jar:$FILE_PATH/ant-media-server-service.jar:$FILE_PATH/conf" + +# The fully qualified name of the class to execute +CLASS="org.red5.daemon.EngineLauncher" + +# Any command line arguments to be passed to the our Java Daemon implementations init() method +ARGS="9999" + +# The file that will contain our process identification number (pid) for other scripts/programs that need to access it. +PID="/tmp/$NAME.pid" + +# System.out writes to this file... +LOG_OUT="$FILE_PATH/log/$NAME-service.log" + +# System.err writes to this file... +LOG_ERR="/dev/stderr" +# LOG_ERR="$FILE_PATH/log/$NAME-error.log" + +LD_LIBRARY_PATH=$FILE_PATH/lib/native +export LD_LIBRARY_PATH +# Native path +NATIVE="-Djava.library.path=$LD_LIBRARY_PATH" +# JAVA options +# You can set JVM additional options here if you want +JVM_OPTS="-Xverify:none -XX:+TieredCompilation -XX:+UseBiasedLocking -XX:InitialCodeCacheSize=8m -XX:ReservedCodeCacheSize=32m -Dorg.terracotta.quartz.skipUpdateCheck=true -XX:+UseG1GC" + +# Set up logging options +LOGGING_OPTS="-Dlogback.ContextSelector=org.red5.logging.LoggingContextSelector -Dcatalina.useNaming=true" +# Set up security options +SECURITY_OPTS="-Djava.security.debug=failure -Djava.security.egd=file:/dev/./urandom" +# Set up tomcat options +TOMCAT_OPTS="-Dcatalina.home=$RED5_HOME" +ADDITIONAL_OPTS="-Djava.library.path=$RED5_HOME/lib/native" +JAVA_OPTS="$LOGGING_OPTS $SECURITY_OPTS $JVM_OPTS $NATIVE $TOMCAT_OPTS $ADDITIONAL_OPTS" +exec $EXEC -nodetach -home $JAVA_HOME -user antmedia -cp $CLASS_PATH -cwd $RED5_HOME $JAVA_OPTS -errfile $LOG_ERR -pidfile $PID $CLASS $ARGS diff --git a/front/src/views/stream/Home.vue b/front/src/views/stream/Home.vue index 0de43d8d4c704f48d0bc59b0d00f7375d54bbbd8..39bcd9d6fcfcef4f5141bc9b674dedbc5dd4faed 100644 --- a/front/src/views/stream/Home.vue +++ b/front/src/views/stream/Home.vue @@ -2,156 +2,35 @@ <div class="main pusher" v-title="labels.title"> <div class="ui vertical aligned stripe segment"> <div> - <h1>Join a video session</h1> + <h1>Stream url</h1> <p> - <label>Session:</label> - <input type="text" v-model="sessionName"> - </p> - <p> - <button @click="joinSession(true)">Join and publish</button> - <button @click="joinSession(false)">Join</button> + <label>Url:</label> + <input type="text" v-model="streamUrl"> </p> </div> + <div v-if="streamUrl"> + HELLO + <audio :src="streamUrl"></audio> - <div id="session"> - <h1 id="session-header"></h1> - <input v-if="session" type="button" @click="session.disconnect()" value="LEAVE"> - <div> - <div id="publisher"><h3>YOU</h3></div> - <div id="subscriber"><h3>OTHERS</h3></div> - </div> </div> </div> </div> </template> <script> -import axios from "axios"; -import "openvidu-browser/static/js/openvidu-browser-2.6.0"; export default { data() { return { - sessionName: "hello2", - session: null, - serverUrl: "https://" + location.hostname + ":4443/api/", - serverSecret: "MY_SECRET" + streamUrl: null, }; }, - created() {}, - destroyed() { - if (this.session) { - this.session.disconnect(); - } - }, computed: { labels() { return { title: this.$gettext("Live streams") }; }, - client() { - let headers = { - Authorization: "Basic " + btoa("OPENVIDUAPP:" + this.serverSecret), - "Content-Type": "application/json" - }; - return axios.create({ - baseURL: this.serverUrl, - timeout: 1000, - headers: headers - }); - } - }, - methods: { - joinSession(publish) { - let OV = new OpenVidu(); - this.session = OV.initSession(); - let session = this.session; - session.on("streamCreated", function(event) { - let subscriber = session.subscribe(event.stream, "subscriber", { - subscribeToAudio: true, - subscribeToVideo: false, - }); - }); - - this.getToken(this.sessionName).then(token => { - session - .connect(token) - .then(() => { - if (publish) { - let publisher = OV.initPublisher("publisher", { - publishAudio: true, - publishVideo: false - }); - session.publish(publisher); - } - }) - .catch(error => { - console.log( - "There was an error connecting to the session:", - error.code, - error.message - ); - }); - }); - }, - getToken(mySessionId) { - let self = this; - return this.createSession(mySessionId).then(sessionId => - self.createToken(sessionId) - ); - }, - createSession(sessionId) { - // See https://openvidu.io/docs/reference-docs/REST-API/#post-apisessions - let self = this; - return new Promise((resolve, reject) => { - self.client - .post(self.serverUrl + "sessions", { customSessionId: sessionId }) - .then( - response => { - resolve(response.data.id); - }, - error => { - if (error.response.status === 409) { - resolve(sessionId); - } else { - console.warn( - "No connection to OpenVidu Server. This may be a certificate error at " + - self.serverUrl - ); - if ( - window.confirm( - 'No connection to OpenVidu Server. This may be a certificate error at "' + - self.serverUrl + - '"\n\nClick OK to navigate and accept it. ' + - 'If no certificate warning is shown, then check that your OpenVidu Server is up and running at "' + - self.serverUrl + - '"' - ) - ) { - location.assign(self.serverUrl + "/accept-certificate"); - } - } - } - ); - }); - }, - createToken(sessionId) { - // See https://openvidu.io/docs/reference-docs/REST-API/#post-apitokens - let self = this; - return new Promise((resolve, reject) => { - self.client - .post(self.serverUrl + "tokens", { session: sessionId }) - .then( - response => { - resolve(response.data.token); - }, - error => { - reject(error); - } - ); - }); - } } }; </script> diff --git a/openvidu-tutorials b/openvidu-tutorials new file mode 160000 index 0000000000000000000000000000000000000000..2e10ab8296292fcbf9dc75e39f89343e4dc555c1 --- /dev/null +++ b/openvidu-tutorials @@ -0,0 +1 @@ +Subproject commit 2e10ab8296292fcbf9dc75e39f89343e4dc555c1 diff --git a/run openvidu b/run openvidu new file mode 100644 index 0000000000000000000000000000000000000000..fbd50306f791ac33856e7e8d422f3056fe129363 --- /dev/null +++ b/run openvidu @@ -0,0 +1 @@ +$ docker run -p 4443:4443 --rm -e openvidu.secret=MY_SECRET openvidu/openvidu-server-kms