[DEV] test streaming for communication ==> proto to keep

This commit is contained in:
Edouard DUPIN 2022-03-08 16:14:10 +01:00
parent 9399ffe3b6
commit a0b55f6b96
20 changed files with 965 additions and 58 deletions

63
back/karideo_back.iml Normal file
View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_14">
<output url="file://$MODULE_DIR$/out/maven/classes" />
<output-test url="file://$MODULE_DIR$/out/maven/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/classes" />
<excludeFolder url="file://$MODULE_DIR$/${project.build.directory}/test-classes" />
<excludeFolder url="file://$MODULE_DIR$/${project.basedir}/out/maven" />
<excludeFolder url="file://$MODULE_DIR$/out/maven" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.media:jersey-media-multipart:2.32" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-common:2.32" level="project" />
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.hk2:osgi-resource-locator:1.0.3" level="project" />
<orderEntry type="library" name="Maven: com.sun.activation:jakarta.activation:1.2.2" level="project" />
<orderEntry type="library" name="Maven: org.jvnet.mimepull:mimepull:1.9.13" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.inject:jersey-hk2:2.32" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-locator:2.6.1" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.hk2.external:aopalliance-repackaged:2.6.1" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-api:2.6.1" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-utils:2.6.1" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.25.0-GA" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.32" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.hk2.external:jakarta.inject:2.6.1" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.grizzly:grizzly-http-server:2.4.4" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.grizzly:grizzly-http:2.4.4" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.grizzly:grizzly-framework:2.4.4" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-server:2.32" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-client:2.32" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.media:jersey-media-jaxb:2.32" level="project" />
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
<orderEntry type="library" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:2.3.3" level="project" />
<orderEntry type="library" name="Maven: jakarta.ws.rs:jakarta.ws.rs-api:2.1.6" level="project" />
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" />
<orderEntry type="library" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" />
<orderEntry type="library" name="Maven: javax.ws.rs:javax.ws.rs-api:2.1.1" level="project" />
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.3.1" level="project" />
<orderEntry type="library" name="Maven: com.sun.istack:istack-commons-runtime:3.0.7" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:2.32" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: jakarta.servlet:jakarta.servlet-api:4.0.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.jersey.test-framework:jersey-test-framework-core:2.32" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.jersey.containers:jersey-container-servlet-core:2.32" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.jersey.containers:jersey-container-grizzly2-servlet:2.32" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.jersey.containers:jersey-container-servlet:2.32" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.glassfish.grizzly:grizzly-http-servlet:2.4.4" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.45" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.media:jersey-media-json-jackson:2.32" level="project" />
<orderEntry type="library" name="Maven: org.glassfish.jersey.ext:jersey-entity-filtering:2.32" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.10.1" level="project" />
<orderEntry type="library" name="Maven: jakarta.activation:jakarta.activation-api:1.2.1" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.10" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.10" level="project" />
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.0.1" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains:annotations:20.1.0" level="project" />
</component>
</module>

View File

@ -55,6 +55,11 @@
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-sse</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
@ -97,6 +102,58 @@
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.tyrus</groupId>
<artifactId>tyrus-server</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.tyrus</groupId>
<artifactId>tyrus-container-grizzly-server</artifactId>
<version>2.0.0</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.glassfish.grizzly</groupId> -->
<!-- <artifactId>grizzly-websockets</artifactId> -->
<!-- <version>3.0.0</version> -->
<!-- </dependency><dependency> -->
<!-- <groupId>org.glassfish.grizzly</groupId> -->
<!-- <artifactId>grizzly-http-all</artifactId> -->
<!-- <version>2.1.2</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.glassfish.grizzly</groupId> -->
<!-- <artifactId>grizzly-http-servlet</artifactId> -->
<!-- <version>2.2.16</version> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>javax.servlet</groupId> -->
<!-- <artifactId>javax.servlet-api</artifactId> -->
<!-- <version>3.0.1</version> -->
<!-- </dependency> -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.glassfish.tyrus</groupId> -->
<!-- <artifactId>websocket-impl</artifactId> -->
<!-- <version>${websocket-version}</version> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
</dependencies>
<build>
@ -119,7 +176,7 @@
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<mainClass>io.scenarium.oauth.WebLauncher</mainClass>
<mainClass>org.kar.karideo.WebLauncher</mainClass>
</configuration>
</plugin>
<!-- Create the source bundle -->

View File

@ -70,6 +70,7 @@ public class ConfigVariable {
String out = System.getenv("org.kar.karideo.address");
if (out == null) {
return "http://0.0.0.0:18080/karideo/api/";
//return "http://0.0.0.0:18080";
}
return out;
}

View File

@ -1,20 +1,27 @@
package org.kar.karideo;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.grizzly.http.server.NetworkListener;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.kar.karideo.api.*;
import org.kar.karideo.db.DBConfig;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.logging.LoggingFeature;
import javax.ws.rs.core.UriBuilder;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.System.Logger.Level;
import java.net.URI;
import java.util.Properties;
import org.glassfish.tyrus.server.Server;
public class WebLauncher {
public static DBConfig dbConfig;
@ -53,7 +60,7 @@ public class WebLauncher {
// add jackson to be discovenr when we are ins standalone server
rc.register(JacksonFeature.class);
// enable this to show low level request
//rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName());
rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.INFO.getName());
System.out.println("Connect on the BDD:");
System.out.println(" getDBHost: '" + ConfigVariable.getDBHost() + "'");
@ -68,7 +75,12 @@ public class WebLauncher {
ConfigVariable.getDBName());
System.out.println(" ==> " + dbConfig);
System.out.println("OAuth service " + ConfigVariable.getRestOAuthServer());
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc, false);
//HttpServer server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), false);
//startWsServer();
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
@ -88,4 +100,20 @@ public class WebLauncher {
e.printStackTrace();
}
}
public static void startWsServer() {
Server server = new Server("localhost", 8080, "/echo", null, WebSocketResource.class);
try {
server.start();
//BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//System.out.print("Please press a key to stop the server.");
//reader.readLine();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
//server.stop();
}
}
}

View File

@ -0,0 +1,124 @@
package org.kar.karideo.api;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.CountDownLatch;
import java.util.logging.Logger;
import javax.websocket.ClientEndpoint;
import javax.websocket.CloseReason;
import javax.websocket.DeploymentException;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import org.glassfish.tyrus.client.ClientManager;
@ServerEndpoint(value = "/echooo")
public class WebSocketResource {
private Logger logger = Logger.getLogger(this.getClass().getName());
@OnOpen
public void onOpen(Session session) {
logger.info("Connected ... " + session.getId());
try {
session.getBasicRemote().sendText("start");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@OnMessage
public String onMessage(String message, Session session) {
BufferedReader bufferRead = new BufferedReader(new InputStreamReader(System.in));
try {
logger.info("Received ...." + message);
String userInput = bufferRead.readLine();
return userInput;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@OnClose
public void onClose(Session session, CloseReason closeReason) {
logger.info(String.format("Session %s close because of %s", session.getId(), closeReason));
}
}
//
//import java.io.IOException;
//
//import javax.websocket.OnClose;
//import javax.websocket.OnError;
//import javax.websocket.OnMessage;
//import javax.websocket.OnOpen;
//import javax.websocket.Session;
//import javax.websocket.server.ServerEndpoint;
//
//import org.glassfish.grizzly.http.HttpRequestPacket;
//import org.glassfish.grizzly.websockets.ProtocolHandler;
//import org.glassfish.grizzly.websockets.WebSocket;
//import org.glassfish.grizzly.websockets.WebSocketApplication;
//import org.glassfish.grizzly.websockets.WebSocketListener;
//import org.glassfish.grizzly.websockets.DataFrame;
//import org.kar.karideo.applicationWS.IndicationWebSocket;
//import org.kar.karideo.internal.Log;
//
//
//
//
//public class WebSocketResource extends WebSocketApplication {
//
// public void onMessage(WebSocket websocket, String frame) {
// Log.error("onMessage called.....with " + frame);
// websocket.send("server send : " + frame + "received");
// try {
// Thread.sleep(2000L);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// websocket.send("server send : " + frame + "received again");
// }
//
// @Override
// public WebSocket createSocket(ProtocolHandler handler,
// HttpRequestPacket requestPacket, WebSocketListener... listeners) {
// Log.error("createWebSocket called.....");
// return new IndicationWebSocket(handler, requestPacket, listeners);
// }
//
//// @Override
//// protected IndicationWebSocket createWebSocket(Connection connection,
//// ServerWebSocketMeta meta) {
//// Log.error("createWebSocket called.....");
//// return new IndicationWebSocket(connection, meta, null);
//// }
//
// @Override
// public boolean isApplicationRequest(HttpRequestPacket arg0) {
// Log.error("isApplicationRequest called.....");
// return true;
// }
//
// @Override
// public void onConnect(WebSocket socket) {
// Log.error("onConnect called.....");
// }
//
// @Override
// public void onClose(WebSocket websocket, DataFrame frame) {
// Log.error("onClose called.....");
// }
//}
//

View File

@ -0,0 +1,23 @@
package org.kar.karideo.applicationWS;
//
//import org.glassfish.grizzly.http.HttpRequestPacket;
//import org.glassfish.grizzly.websockets.DefaultWebSocket;
//import org.glassfish.grizzly.websockets.ProtocolHandler;
//import org.glassfish.grizzly.websockets.WebSocketListener;
//
//public class IndicationWebSocket extends DefaultWebSocket {
//
// public IndicationWebSocket(ProtocolHandler handler,
// HttpRequestPacket requestPacket, WebSocketListener... listeners) {
// super(handler, requestPacket, listeners);
// }
//
//
//// public IndicationWebSocket(Connection connection, WebSocketMeta meta,
//// WebSocketHandler<? extends WebSocketBase> handler) {
//// super(connection, meta, handler);
//// }
//
//
//}
//

View File

@ -1,60 +1,63 @@
package org.kar.karideo.internal;
import io.scenarium.logger.LogLevel;
import io.scenarium.logger.Logger;
//import io.scenarium.logger.LogLevel;
//import io.scenarium.logger.Logger;
public class Log {
// private static final String LIB_NAME = "logger";
// private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
// private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
// private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
// private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
// private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
// private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
// private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
// private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
// private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
//
// private Log() {}
//
// public static void print(String data) {
// if (PRINT_PRINT)
// Logger.print(LIB_NAME_DRAW, data);
// }
//
// public static void todo(String data) {
// if (PRINT_TODO)
// Logger.todo(LIB_NAME_DRAW, data);
// }
//
// public static void critical(String data) {
// if (PRINT_CRITICAL)
// Logger.critical(LIB_NAME_DRAW, data);
// }
//
// public static void error(String data) {
// if (PRINT_ERROR)
// Logger.error(LIB_NAME_DRAW, data);
// }
//
// public static void warning(String data) {
// if (PRINT_WARNING)
// Logger.warning(LIB_NAME_DRAW, data);
// }
//
// public static void info(String data) {
// if (PRINT_INFO)
// Logger.info(LIB_NAME_DRAW, data);
// }
//
// public static void debug(String data) {
// if (PRINT_DEBUG)
// Logger.debug(LIB_NAME_DRAW, data);
// }
//
// public static void verbose(String data) {
// if (PRINT_VERBOSE)
// Logger.verbose(LIB_NAME_DRAW, data);
// }
private static final String LIB_NAME = "logger";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
private Log() {}
public static void print(String data) {
if (PRINT_PRINT)
Logger.print(LIB_NAME_DRAW, data);
}
public static void todo(String data) {
if (PRINT_TODO)
Logger.todo(LIB_NAME_DRAW, data);
}
public static void critical(String data) {
if (PRINT_CRITICAL)
Logger.critical(LIB_NAME_DRAW, data);
}
public static void error(String data) {
if (PRINT_ERROR)
Logger.error(LIB_NAME_DRAW, data);
}
public static void warning(String data) {
if (PRINT_WARNING)
Logger.warning(LIB_NAME_DRAW, data);
}
public static void info(String data) {
if (PRINT_INFO)
Logger.info(LIB_NAME_DRAW, data);
}
public static void debug(String data) {
if (PRINT_DEBUG)
Logger.debug(LIB_NAME_DRAW, data);
}
public static void verbose(String data) {
if (PRINT_VERBOSE)
Logger.verbose(LIB_NAME_DRAW, data);
}
}

View File

@ -7,6 +7,7 @@ import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; // CLI imports router
import { ModuleWithProviders } from '@angular/core';
import { ConferenceComponent } from './scene/conference/conference';
import { HomeScene } from './scene/home/home';
import { TypeScene } from './scene/type/type';
import { UniverseScene } from './scene/universe/universe';
@ -30,6 +31,7 @@ const routes: Routes = [
{ path: 'home', component: HomeScene },
{ path: 'upload', component: UploadScene },
{ path: 'type/:universe_id/:type_id/:series_id/:season_id/:video_id', component: TypeScene },
{ path: 'conference', component: ConferenceComponent },
{ path: 'universe/:universe_id/:type_id/:series_id/:season_id/:video_id', component: UniverseScene },

View File

@ -12,6 +12,8 @@ import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; // this is needed for dynamic selection of the select
import { AppRoutingModule } from './app-routing.module';
import { WebRtcStreamInComponent } from './component/webrtc-stream-in/webrtc-stream-in';
import { WebRtcStreamOutComponent } from './component/webrtc-stream-out/webrtc-stream-out';
import { UploadFileComponent } from './component/upload-file/upload-file';
import { TopMenuComponent } from './component/top-menu/top-menu';
import { ElementTypeComponent } from './component/element-type/element-type';
@ -24,6 +26,7 @@ import { PopInCreateType } from './popin/create-type/create-type';
import { PopInUploadProgress } from './popin/upload-progress/upload-progress';
import { PopInDeleteConfirm } from './popin/delete-confirm/delete-confirm';
import { ConferenceComponent } from './scene/conference/conference';
import { HelpScene } from './scene/help/help';
import { LoginScene } from './scene/login/login';
import { SignUpScene } from './scene/sign-up/sign-up';
@ -91,7 +94,10 @@ import { AppComponent } from './app.component';
VideoEditScene,
SeasonEditScene,
SeriesEditScene,
UploadScene
WebRtcStreamInComponent,
WebRtcStreamOutComponent,
UploadScene,
ConferenceComponent,
],
imports: [
BrowserModule,

View File

@ -0,0 +1,6 @@
<div>
<div class="borders" >
WebRtc Stream In
<video #videoElement autoplay playsinline disablePictureInPicture></video>
</div>
</div>

View File

@ -0,0 +1,12 @@
.borders {
height: 300px;
width: 400px;
margin: 20px auto;
border: 2px dashed #00F;
border-radius: 10px;
}
.borders:hover {
cursor: pointer;
border: 2px dashed #0FF;
}

View File

@ -0,0 +1,79 @@
import { Component, OnInit, ViewChild} from '@angular/core';
import { Router } from "@angular/router";
@Component({
selector: 'webrtc-stream-in',
templateUrl: './webrtc-stream-in.html',
styleUrls: ['./webrtc-stream-in.less']
})
export class WebRtcStreamInComponent implements OnInit {
@ViewChild('videoElement') videoElement: any;
private videoElementNative = null;
private startTime;
constructor(private router: Router) {
}
ngOnInit() {
}
ngAfterViewInit() {
this.videoElementNative = this.videoElement.nativeElement;
this.videoElementNative.disablePictureInPicture = true;
}
offerOptions = {
offerToReceiveAudio: 1,
offerToReceiveVideo: 1
};
/*
call():void {
console.log('Starting call');
startTime = window.performance.now();
var videoTracks = localStream.getVideoTracks();
var audioTracks = localStream.getAudioTracks();
if (videoTracks.length > 0) {
trace('Using video device: ' + videoTracks[0].label);
}
if (audioTracks.length > 0) {
console.log('Using audio device: ' + audioTracks[0].label);
}
var servers = null;
pc1 = new RTCPeerConnection(servers);
trace('Created local peer connection object pc1');
pc1.onicecandidate = function(e) {
onIceCandidate(pc1, e);
};
pc2 = new RTCPeerConnection(servers);
trace('Created remote peer connection object pc2');
pc2.onicecandidate = function(e) {
onIceCandidate(pc2, e);
};
pc1.oniceconnectionstatechange = function(e) {
onIceStateChange(pc1, e);
};
pc2.oniceconnectionstatechange = function(e) {
onIceStateChange(pc2, e);
};
pc2.onaddstream = gotRemoteStream;
pc1.addStream(localStream);
trace('Added local stream to pc1');
trace('pc1 createOffer start');
pc1.createOffer(
offerOptions
).then(
onCreateOfferSuccess,
onCreateSessionDescriptionError
);
}
*/
}

View File

@ -0,0 +1,7 @@
<div>
<div class="borders" >
WebRtc Stream out
<video #videoElement autoplay muted playsinline disablePictureInPicture></video>
<!--<video #videoElement id="videoElement" src="{{sourceVideoStream}}" autoplay muted playsinline></video>-->
</div>
</div>

View File

@ -0,0 +1,17 @@
.borders {
height: 350px;
width: 450px;
margin: 20px auto;
border: 2px dashed #F00;
border-radius: 10px;
}
.borders:hover {
cursor: pointer;
border: 2px dashed #0F0;
}
video {
height: 300px;
width: 400px;
border: 2px solid #F00;
}

View File

@ -0,0 +1,116 @@
import { Component, OnInit,Input, ViewChild, SimpleChanges} from '@angular/core';
import { Router } from "@angular/router";
@Component({
selector: 'webrtc-stream-out',
templateUrl: './webrtc-stream-out.html',
styleUrls: ['./webrtc-stream-out.less']
})
export class WebRtcStreamOutComponent implements OnInit {
@ViewChild('videoElement') videoElement: any;
@Input() streamData: boolean;
private videoElementNative = null;
private startTime;
public sourceVideoStream = null;
public stream = null;
private rtcPearConnection;
offerOptions = {
offerToReceiveAudio: 1,
offerToReceiveVideo: 1
};
constructor(private router: Router) {
}
ngOnInit() {
this.startLocalStream();
}
ngAfterViewInit() {
this.videoElementNative = this.videoElement.nativeElement;
this.videoElementNative.disablePictureInPicture = true;
}
ngOnChanges(changes: SimpleChanges) {
console.log("change input: " + JSON.stringify(changes));
if (changes["streamData"]["previousValue"] != changes["streamData"]["currentValue"]) {
console.log(" streamData ==>" + changes["streamData"]["currentValue"]);
if (changes["streamData"]["currentValue"] == true) {
this.call();
}
}
// You can also use categoryId.previousValue and
// categoryId.firstChange for comparing old and new values
}
startLocalStream():void {
console.log('Requesting local stream');
let self = this;
navigator.mediaDevices.getUserMedia({
audio: true,
video: true
}).then(function(stream) {
console.log('Received local stream');
self.videoElementNative.srcObject = stream;
self.stream = stream;
})
.catch(function(e) {
alert('getUserMedia() error: ' + e.name);
});
}
/*
onIceCandidate(pc, event):void {
getOtherPc(pc).addIceCandidate(event.candidate)
.then(
function() {
onAddIceCandidateSuccess(pc);
},
function(err) {
onAddIceCandidateError(pc, err);
}
);
console.log(getName(pc) + ' ICE candidate: \n' + (event.candidate ?
event.candidate.candidate : '(null)'));
}
*/
call():void {
console.log('Starting call');
this.startTime = window.performance.now();
if (this.stream == null){
console.log("local stream is disable");
return;
}
var videoTracks = this.stream.getVideoTracks();
var audioTracks = this.stream.getAudioTracks();
if (videoTracks.length > 0) {
console.log('Using video device: ' + videoTracks[0].label);
}
if (audioTracks.length > 0) {
console.log('Using audio device: ' + audioTracks[0].label);
}
var servers = null;
this.rtcPearConnection = new RTCPeerConnection(servers);
console.log('Created local peer connection object pc1');
this.rtcPearConnection.onicecandidate = function(e) {
console.log("onicecandidate " + e);
};
this.rtcPearConnection.oniceconnectionstatechange = function(e) {
console.log("oniceconnectionstatechange " + e);
};
console.log('Added local stream [START]');
this.rtcPearConnection.addStream(this.stream);
console.log('Added local stream [ END ]');
console.log('pc1 createOffer start');
this.rtcPearConnection.createOffer(
this.offerOptions
).then( function(e) {
console.log("create offer error " + JSON.stringify(e));
}
);
}
}

View File

@ -0,0 +1,16 @@
<div class="generic-page">
<div class="title">
Conference
</div>
<webrtc-stream-out [streamData]="streamOutRequested"></webrtc-stream-out>
<webrtc-stream-in ></webrtc-stream-in>
<div class="clear"></div>
<div class="container">
<button class="button connectivityButton color-button-cancel color-shadow-black" (click)="onClickStart()">Start</button>
<button class="button connectivityButton color-button-validate color-shadow-black" id="connect-button" (click)="onClickConnect()" type="submit">Connect</button>
<button class="button connectivityButton color-button-validate color-shadow-black" id="disconnect-button" (click)="onClickDisconnect()" type="submit">Disconnect</button>
<button class="button connectivityButton color-button-cancel color-shadow-black" (click)="onClickStop()">Stop</button>
</div>
</div>

View File

@ -0,0 +1,10 @@
.container {
padding: 16px;
}
.connectivityButton {
margin: 2% 2%;
width: 21%;
}

View File

@ -0,0 +1,106 @@
/** @file
* @author Edouard DUPIN
* @copyright 2018, Edouard DUPIN, all right reserved
* @license PROPRIETARY (see license file)
*/
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, ParamMap } from '@angular/router';
import { Location } from '@angular/common';
import { fadeInAnimation } from '../../_animations/index';
import { ArianeService } from '../../service/ariane';
import { environment } from 'environments/environment';
@Component({
selector: 'conference',
templateUrl: './conference.html',
styleUrls: ['./conference.less'],
animations: [fadeInAnimation],
host: { '[@fadeInAnimation]': '' }
})
export class ConferenceComponent implements OnInit {
//id_type = -1;
//id_univers = -1;
id_group = -1;
name: string = "";
description: string = "";
cover: string = ""
covers: Array<string> = []
saisons_error: string = "";
saisons: Array<number> = [];
videos_error: string = "";
videos: Array<number> = [];
constructor(private route: ActivatedRoute,
private router: Router,
private locate: Location,
private arianeService: ArianeService) {
}
public streamOutRequested = false;
ngOnInit() {
/*
this.arianeService.updateManual(this.route.snapshot.paramMap);
//this.id_univers = parseInt(this.route.snapshot.paramMap.get('univers_id'));
//this.id_type = parseInt(this.route.snapshot.paramMap.get('type_id'));
this.id_group = this.arianeService.getGroupId();
let self = this;
this.groupService.get(this.id_group)
.then(function(response) {
self.name = response.name;
self.description = response.description;
if (response.covers == undefined || response.covers == null || response.covers.length == 0) {
self.cover = null;
self.covers = [];
} else {
self.cover = self.groupService.getCoverUrl(response.covers[0]);
for (let iii=0; iii<response.covers.length; iii++) {
self.covers.push(self.groupService.getCoverUrl(response.covers[iii]));
}
}
}).catch(function(response) {
self.description = "";
self.name = "???";
self.cover = null;
self.covers = [];
});
console.log("get parameter id: " + this.id_group);
this.groupService.getSaison(this.id_group, ["id", "name"])
.then(function(response) {
self.saisons_error = "";
self.saisons = response
}).catch(function(response) {
self.saisons_error = "Can not get the list of saison in this group";
self.saisons = []
});
this.groupService.getVideo(this.id_group)
.then(function(response) {
self.videos_error = "";
self.videos = response
}).catch(function(response) {
self.videos_error = "Can not get the List of video without saison";
self.videos = []
});
*/
}
onClickStart():void {
console.log("onStart ...");
}
onClickStop():void {
console.log("onStop ...");
}
onClickConnect():void {
console.log("onConnect ...");
this.streamOutRequested = true;
}
onClickDisconnect():void {
console.log("onDisconnect ...");
this.streamOutRequested = false;
}
}

View File

@ -0,0 +1,228 @@
var startButton = document.getElementById('startButton');
var callButton = document.getElementById('callButton');
var hangupButton = document.getElementById('hangupButton');
callButton.disabled = true;
hangupButton.disabled = true;
startButton.onclick = start;
callButton.onclick = call;
hangupButton.onclick = hangup;
var startTime;
var localVideo = document.getElementById('localVideo');
var remoteVideo = document.getElementById('remoteVideo');
localVideo.addEventListener('loadedmetadata', function() {
console.log('Local video videoWidth: ' + this.videoWidth +
'px, videoHeight: ' + this.videoHeight + 'px');
});
remoteVideo.addEventListener('loadedmetadata', function() {
console.log('Remote video videoWidth: ' + this.videoWidth +
'px, videoHeight: ' + this.videoHeight + 'px');
});
remoteVideo.onresize = function() {
console.log('Remote video size changed to ' +
remoteVideo.videoWidth + 'x' + remoteVideo.videoHeight);
// We'll use the first onsize callback as an indication that video has started
// playing out.
if (startTime) {
var elapsedTime = window.performance.now() - startTime;
console.log('Setup time: ' + elapsedTime.toFixed(3) + 'ms');
startTime = null;
}
};
var localStream;
var pc1;
var pc2;
function getName(pc) {
return (pc === pc1) ? 'pc1' : 'pc2';
}
function getOtherPc(pc) {
return (pc === pc1) ? pc2 : pc1;
}
/*
function gotStream(stream) {
console.log('Received local stream');
localVideo.srcObject = stream;
localStream = stream;
callButton.disabled = false;
}
function start() {
console.log('Requesting local stream');
startButton.disabled = true;
navigator.mediaDevices.getUserMedia({
audio: true,
video: true
})
.then(gotStream)
.catch(function(e) {
alert('getUserMedia() error: ' + e.name);
});
}
*/
function call() {
callButton.disabled = true;
hangupButton.disabled = false;
console.log('Starting call');
startTime = window.performance.now();
var videoTracks = localStream.getVideoTracks();
var audioTracks = localStream.getAudioTracks();
if (videoTracks.length > 0) {
console.log('Using video device: ' + videoTracks[0].label);
}
if (audioTracks.length > 0) {
console.log('Using audio device: ' + audioTracks[0].label);
}
var servers = null;
pc1 = new RTCPeerConnection(servers);
console.log('Created local peer connection object pc1');
pc1.onicecandidate = function(e) {
onIceCandidate(pc1, e);
};
pc2 = new RTCPeerConnection(servers);
console.log('Created remote peer connection object pc2');
pc2.onicecandidate = function(e) {
onIceCandidate(pc2, e);
};
pc1.oniceconnectionstatechange = function(e) {
onIceStateChange(pc1, e);
};
pc2.oniceconnectionstatechange = function(e) {
onIceStateChange(pc2, e);
};
pc2.onaddstream = gotRemoteStream;
pc1.addStream(localStream);
console.log('Added local stream to pc1');
console.log('pc1 createOffer start');
pc1.createOffer(
offerOptions
).then(
onCreateOfferSuccess,
onCreateSessionDescriptionError
);
}
function onCreateSessionDescriptionError(error) {
console.log('Failed to create session description: ' + error.toString());
}
function onCreateOfferSuccess(desc) {
console.log('Offer from pc1\n' + desc.sdp);
console.log('pc1 setLocalDescription start');
pc1.setLocalDescription(desc).then(
function() {
onSetLocalSuccess(pc1);
},
onSetSessionDescriptionError
);
console.log('pc2 setRemoteDescription start');
pc2.setRemoteDescription(desc).then(
function() {
onSetRemoteSuccess(pc2);
},
onSetSessionDescriptionError
);
console.log('pc2 createAnswer start');
// Since the 'remote' side has no media stream we need
// to pass in the right constraints in order for it to
// accept the incoming offer of audio and video.
pc2.createAnswer().then(
onCreateAnswerSuccess,
onCreateSessionDescriptionError
);
}
function onSetLocalSuccess(pc) {
console.log(getName(pc) + ' setLocalDescription complete');
}
function onSetRemoteSuccess(pc) {
console.log(getName(pc) + ' setRemoteDescription complete');
}
function onSetSessionDescriptionError(error) {
console.log('Failed to set session description: ' + error.toString());
}
function gotRemoteStream(e) {
remoteVideo.srcObject = e.stream;
console.log('pc2 received remote stream');
}
function onCreateAnswerSuccess(desc) {
console.log('Answer from pc2:\n' + desc.sdp);
console.log('pc2 setLocalDescription start');
pc2.setLocalDescription(desc).then(
function() {
onSetLocalSuccess(pc2);
},
onSetSessionDescriptionError
);
console.log('pc1 setRemoteDescription start');
pc1.setRemoteDescription(desc).then(
function() {
onSetRemoteSuccess(pc1);
},
onSetSessionDescriptionError
);
}
/*
function onIceCandidate(pc, event) {
getOtherPc(pc).addIceCandidate(event.candidate)
.then(
function() {
onAddIceCandidateSuccess(pc);
},
function(err) {
onAddIceCandidateError(pc, err);
}
);
console.log(getName(pc) + ' ICE candidate: \n' + (event.candidate ?
event.candidate.candidate : '(null)'));
}
*/
function onAddIceCandidateSuccess(pc) {
console.log(getName(pc) + ' addIceCandidate success');
}
function onAddIceCandidateError(pc, error) {
console.log(getName(pc) + ' failed to add ICE Candidate: ' + error.toString());
}
function onIceStateChange(pc, event) {
if (pc) {
console.log(getName(pc) + ' ICE state: ' + pc.iceConnectionState);
console.log('ICE state change event: ', event);
}
}
function hangup() {
console.log('Ending call');
pc1.close();
pc2.close();
pc1 = null;
pc2 = null;
hangupButton.disabled = true;
callButton.disabled = false;
}
// logging utility
function console.log(arg) {
var now = (window.performance.now() / 1000).toFixed(3);
console.log(now + ': ', arg);
}

View File

@ -18,7 +18,9 @@ import { ArianeService } from '../../service/ariane';
templateUrl: './season.html',
styleUrls: ['./season.less'],
animations: [fadeInAnimation],
host: { '[@fadeInAnimation]': '' }
host: {
'[@fadeInAnimation]': '',
},
})
export class SeasonScene implements OnInit {
name: string = "";
@ -85,6 +87,7 @@ export class SeasonScene implements OnInit {
}
onSelectVideo(_event: any, _idSelected: number):void {
console.log("select video : " + _idSelected);
this.arianeService.navigateVideo(_idSelected, _event.which==2, _event.ctrlKey);
}