Project name refactoring and TypeScript port of browser client

pull/1/head
Micael Gallego 2016-10-15 00:11:17 +02:00
parent fa2987095d
commit 31389e683c
84 changed files with 2469 additions and 1152 deletions

View File

@ -5,10 +5,10 @@
<parent>
<groupId>org.openvidu</groupId>
<artifactId>openvidu</artifactId>
<version>6.6.1-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>openvidu-client-js</artifactId>
<artifactId>openvidu-browser</artifactId>
<packaging>jar</packaging>
<name>Kurento Room Client JS</name>

View File

@ -0,0 +1,11 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "tsc",
"isShellCommand": true,
"args": ["-w", "-p", "."],
"showOutput": "silent",
"isWatching": true,
"problemMatcher": "$tsc-watch"
}

View File

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@ -1,5 +1,5 @@
/*
* (C) Copyright 2016 Kurento (http://kurento.org/)
* (C) Copyright 2016 OpenVidu (http://kurento.org/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -458,6 +458,7 @@ function Stream(kurento, local, room, options) {
var wrStream;
var wp;
var id;
if (options.id) {
id = options.id;
} else {
@ -713,18 +714,18 @@ function Stream(kurento, local, room, options) {
options.dataChannels = true;
}
if (that.displayMyRemote()) {
wp = new kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options, function (error) {
this.wp = new kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options, function (error) {
if (error) {
return console.error(error);
}
this.generateOffer(sdpOfferCallback.bind(that));
this.wp.generateOffer(sdpOfferCallback.bind(that));
});
} else {
wp = new kurentoUtils.WebRtcPeer.WebRtcPeerSendonly(options, function (error) {
this.wp = new kurentoUtils.WebRtcPeer.WebRtcPeerSendonly(options, function (error) {
if (error) {
return console.error(error);
}
this.generateOffer(sdpOfferCallback.bind(that));
this.wp.generateOffer(sdpOfferCallback.bind(that));
});
}
} else {
@ -882,11 +883,11 @@ function Stream(kurento, local, room, options) {
}
}
// KurentoRoom --------------------------------
// OpenVidu --------------------------------
function KurentoRoom(wsUri, callback) {
if (!(this instanceof KurentoRoom))
return new KurentoRoom(wsUri, callback);
function OpenVidu(wsUri, callback) {
if (!(this instanceof OpenVidu))
return new OpenVidu(wsUri, callback);
var that = this;
@ -944,7 +945,6 @@ function KurentoRoom(wsUri, callback) {
function isRoomAvailable() {
if (room !== undefined && room instanceof Room) {
return true;
º
} else {
console.warn('Room instance not found');
return false;
@ -1059,6 +1059,13 @@ function KurentoRoom(wsUri, callback) {
}
this.Stream = function (room, options) {
options = options || {
audio : true,
video : true,
data : true
}
options.participant = room.getLocalParticipant();
return new Stream(that, true, room, options);
};

View File

@ -0,0 +1,4 @@
export { Room } from './Room';
export { Participant } from './Participant';
export { Stream } from './Stream';
export { OpenVidu } from './OpenVidu';

View File

@ -0,0 +1,247 @@
/*
* (C) Copyright 2016 OpenVidu (http://kurento.org/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { Room } from './Room';
import { Stream } from './Stream';
declare var RpcBuilder: any;
type Callback<T> = ( error?: any, openVidu?: T ) => void;
export class OpenVidu {
private room: Room;
private userName: string;
private jsonRpcClient: any;
private rpcParams: any;
private callback: Callback<OpenVidu>;
constructor( private wsUri: string ) { }
getRoom() {
return this.room;
}
connect( callback: Callback<OpenVidu> ): void {
this.callback = callback;
this.initJsonRpcClient( this.wsUri );
}
private initJsonRpcClient( wsUri: string ): void {
let config = {
heartbeat: 3000,
sendCloseMessage: false,
ws: {
uri: wsUri,
useSockJS: false,
onconnected: this.connectCallback.bind( this ),
ondisconnect: this.disconnectCallback.bind( this ),
onreconnecting: this.reconnectingCallback.bind( this ),
onreconnected: this.reconnectedCallback.bind( this )
},
rpc: {
requestTimeout: 15000,
//notifications
participantJoined: this.onParticipantJoined.bind( this ),
participantPublished: this.onParticipantPublished.bind( this ),
participantUnpublished: this.onParticipantLeft.bind( this ),
participantLeft: this.onParticipantLeft.bind( this ),
participantEvicted: this.onParticipantEvicted.bind( this ),
sendMessage: this.onNewMessage.bind( this ),
iceCandidate: this.iceCandidateEvent.bind( this ),
mediaError: this.onMediaError.bind( this ),
custonNotification: this.customNotification.bind( this )
}
};
this.jsonRpcClient = new RpcBuilder.clients.JsonRpcClient( config );
}
private customNotification( params ) {
if ( this.isRoomAvailable() ) {
this.room.emitEvent( "custom-message-received", [{ params: params }] );
}
}
private connectCallback( error ) {
if ( error ) {
this.callback( error );
} else {
this.callback( null, this );
}
}
private isRoomAvailable() {
if ( this.room !== undefined && this.room instanceof Room ) {
return true;
} else {
console.warn( 'Room instance not found' );
return false;
}
}
private disconnectCallback() {
console.log( 'Websocket connection lost' );
if ( this.isRoomAvailable() ) {
this.room.onLostConnection();
} else {
alert( 'Connection error. Please reload page.' );
}
}
private reconnectingCallback() {
console.log( 'Websocket connection lost (reconnecting)' );
if ( this.isRoomAvailable() ) {
this.room.onLostConnection();
} else {
alert( 'Connection error. Please reload page.' );
}
}
private reconnectedCallback() {
console.log( 'Websocket reconnected' );
}
private onParticipantJoined( params ) {
if ( this.isRoomAvailable() ) {
this.room.onParticipantJoined( params );
}
}
private onParticipantPublished( params ) {
if ( this.isRoomAvailable() ) {
this.room.onParticipantPublished( params );
}
}
private onParticipantLeft( params ) {
if ( this.isRoomAvailable() ) {
this.room.onParticipantLeft( params );
}
}
private onParticipantEvicted( params ) {
if ( this.isRoomAvailable() ) {
this.room.onParticipantEvicted( params );
}
}
private onNewMessage( params ) {
if ( this.isRoomAvailable() ) {
this.room.onNewMessage( params );
}
}
private iceCandidateEvent( params ) {
if ( this.isRoomAvailable() ) {
this.room.recvIceCandidate( params );
}
}
private onRoomClosed( params ) {
if ( this.isRoomAvailable() ) {
this.room.onRoomClosed( params );
}
}
private onMediaError( params ) {
if ( this.isRoomAvailable() ) {
this.room.onMediaError( params );
}
}
setRpcParams( params: any ) {
this.rpcParams = params;
}
sendRequest( method, params, callback?) {
if ( params && params instanceof Function ) {
callback = params;
params = undefined;
}
params = params || {};
if ( this.rpcParams && this.rpcParams !== null && this.rpcParams !== undefined ) {
for ( let index in this.rpcParams ) {
if ( this.rpcParams.hasOwnProperty( index ) ) {
params[index] = this.rpcParams[index];
console.log( 'RPC param added to request {' + index + ': ' + this.rpcParams[index] + '}' );
}
}
}
console.log( 'Sending request: { method:"' + method + '", params: ' + JSON.stringify( params ) + ' }' );
this.jsonRpcClient.send( method, params, callback );
}
close( forced ) {
if ( this.isRoomAvailable() ) {
this.room.leave( forced, this.jsonRpcClient );
}
};
disconnectParticipant( stream ) {
if ( this.isRoomAvailable() ) {
this.room.disconnect( stream );
}
}
Stream( room, options ) {
options = options || {
audio: true,
video: true,
data: true
}
options.participant = room.getLocalParticipant();
return new Stream( this, true, room, options );
};
Room( options ) {
let room = new Room( this, options );
return room;
};
//CHAT
sendMessage( room, user, message ) {
this.sendRequest( 'sendMessage', {
message: message,
userMessage: user,
roomMessage: room
}, function( error, response ) {
if ( error ) {
console.error( error );
}
});
};
sendCustomRequest( params, callback ) {
this.sendRequest( 'customRequest', params, callback );
};
}

View File

@ -0,0 +1,89 @@
// Participant --------------------------------
import { Stream, StreamOptions } from './Stream';
import { OpenVidu } from './OpenVidu';
import { Room } from './Room';
type ObjMap<T> = { [s: string]: T; }
export interface ParticipantOptions {
id: string;
streams?: StreamOptions[];
}
export class Participant {
private id: string;
private streams: ObjMap<Stream> = {};
private streamsOpts: StreamOptions[] = [];
constructor( private openVidu: OpenVidu, private local: boolean, private room: Room, private options: ParticipantOptions ) {
this.id = options.id;
if ( options.streams ) {
for ( let streamOptions of options.streams ) {
let streamOpts = {
id: streamOptions.id,
participant: this,
recvVideo: ( streamOptions.recvVideo == undefined ? true : streamOptions.recvVideo ),
recvAudio: ( streamOptions.recvAudio == undefined ? true : streamOptions.recvAudio ),
audio: streamOptions.audio,
video: streamOptions.video,
data: streamOptions.data
}
let stream = new Stream( openVidu, false, room, streamOpts );
this.addStream( stream );
this.streamsOpts.push( streamOpts );
}
}
console.log( "New " + ( local ? "local " : "remote " ) + "participant " + this.id
+ ", streams opts: ", this.streamsOpts );
}
setId( newId ) {
this.id = newId;
}
addStream( stream ) {
this.streams[stream.getID()] = stream;
this.room.getStreams()[stream.getID()] = stream;
}
getStreams() {
return this.streams;
}
dispose() {
for ( let key in this.streams ) {
this.streams[key].dispose();
}
}
getID() {
return this.id;
}
sendIceCandidate( candidate ) {
console.debug(( this.local ? "Local" : "Remote" ), "candidate for",
this.getID(), JSON.stringify( candidate ) );
this.openVidu.sendRequest( "onIceCandidate", {
endpointName: this.getID(),
candidate: candidate.candidate,
sdpMid: candidate.sdpMid,
sdpMLineIndex: candidate.sdpMLineIndex
}, function( error, response ) {
if ( error ) {
console.error( "Error sending ICE candidate: "
+ JSON.stringify( error ) );
}
});
}
}

View File

@ -0,0 +1,386 @@
import { Stream } from './Stream';
import { OpenVidu } from './OpenVidu';
import { Participant, ParticipantOptions } from './Participant';
declare let EventEmitter;
export interface RoomOptions {
room: string;
user: string;
subscribeToStreams: boolean;
updateSpeakerInterval: number;
thresholdSpeaker: number;
}
export class Room {
private name: string;
private ee = new EventEmitter();
private streams = {};
private participants = {};
private participantsSpeaking: Participant[] = [];
private connected = false;
private localParticipant;
private subscribeToStreams: boolean;
private updateSpeakerInterval: number;
public thresholdSpeaker: number;
constructor( private openVidu: OpenVidu, private options: RoomOptions ) {
this.name = options.room;
this.subscribeToStreams = options.subscribeToStreams || true;
this.updateSpeakerInterval = options.updateSpeakerInterval || 1500;
this.thresholdSpeaker = options.thresholdSpeaker || -50;
this.activateUpdateMainSpeaker();
this.localParticipant = new Participant(openVidu, true, this, { id: options.user });
this.participants[options.user] = this.localParticipant;
}
private activateUpdateMainSpeaker() {
setInterval(() => {
if ( this.participantsSpeaking.length > 0 ) {
this.ee.emitEvent( 'update-main-speaker', [{
participantId: this.participantsSpeaking[this.participantsSpeaking.length - 1]
}] );
}
}, this.updateSpeakerInterval );
}
getLocalParticipant() {
return this.localParticipant;
}
addEventListener( eventName, listener ) {
this.ee.addListener( eventName, listener );
}
emitEvent( eventName, eventsArray ) {
this.ee.emitEvent( eventName, eventsArray );
}
connect() {
let joinParams = {
user: this.options.user,
room: this.options.room,
dataChannels: false
}
if ( this.localParticipant ) {
if ( Object.keys( this.localParticipant.getStreams() ).some( streamId =>
this.streams[streamId].isDataChannelEnabled() ) ) {
joinParams.dataChannels = true;
}
}
this.openVidu.sendRequest( 'joinRoom', joinParams, ( error, response ) => {
if ( error ) {
console.warn( 'Unable to join room', error );
this.ee.emitEvent( 'error-room', [{
error: error
}] );
} else {
this.connected = true;
let exParticipants = response.value;
let roomEvent = {
participants: new Array<Participant>(),
streams: new Array<Stream>()
}
let length = exParticipants.length;
for ( let i = 0; i < length; i++ ) {
let participant = new Participant( this.openVidu, false, this,
exParticipants[i] );
this.participants[participant.getID()] = participant;
roomEvent.participants.push( participant );
let streams = participant.getStreams();
for ( let key in streams ) {
roomEvent.streams.push( streams[key] );
if ( this.subscribeToStreams ) {
streams[key].subscribe();
}
}
}
this.ee.emitEvent( 'room-connected', [roomEvent] );
}
});
}
subscribe( stream ) {
stream.subscribe();
}
onParticipantPublished( options ) {
let participant = new Participant( this.openVidu, false, this, options );
let pid = participant.getID();
if ( !( pid in this.participants ) ) {
console.info( "Publisher not found in participants list by its id", pid );
} else {
console.log( "Publisher found in participants list by its id", pid );
}
//replacing old participant (this one has streams)
this.participants[pid] = participant;
this.ee.emitEvent( 'participant-published', [{
participant: participant
}] );
let streams = participant.getStreams();
for ( let key in streams ) {
let stream = streams[key];
if ( this.subscribeToStreams ) {
stream.subscribe();
this.ee.emitEvent( 'stream-added', [{
stream: stream
}] );
}
}
}
onParticipantJoined( msg ) {
let participant = new Participant( this.openVidu, false, this, msg );
let pid = participant.getID();
if ( !( pid in this.participants ) ) {
console.log( "New participant to participants list with id", pid );
this.participants[pid] = participant;
} else {
//use existing so that we don't lose streams info
console.info( "Participant already exists in participants list with " +
"the same id, old:", this.participants[pid], ", joined now:", participant );
participant = this.participants[pid];
}
this.ee.emitEvent( 'participant-joined', [{
participant: participant
}] );
}
onParticipantLeft( msg ) {
let participant = this.participants[msg.name];
if ( participant !== undefined ) {
delete this.participants[msg.name];
this.ee.emitEvent( 'participant-left', [{
participant: participant
}] );
let streams = participant.getStreams();
for ( let key in streams ) {
this.ee.emitEvent( 'stream-removed', [{
stream: streams[key]
}] );
}
participant.dispose();
} else {
console.warn( "Participant " + msg.name
+ " unknown. Participants: "
+ JSON.stringify( this.participants ) );
}
};
onParticipantEvicted( msg ) {
this.ee.emitEvent( 'participant-evicted', [{
localParticipant: this.localParticipant
}] );
};
onNewMessage( msg ) {
console.log( "New message: " + JSON.stringify( msg ) );
let room = msg.room;
let user = msg.user;
let message = msg.message;
if ( user !== undefined ) {
this.ee.emitEvent( 'newMessage', [{
room: room,
user: user,
message: message
}] );
} else {
console.error( "User undefined in new message:", msg );
}
}
recvIceCandidate( msg ) {
let candidate = {
candidate: msg.candidate,
sdpMid: msg.sdpMid,
sdpMLineIndex: msg.sdpMLineIndex
}
let participant = this.participants[msg.endpointName];
if ( !participant ) {
console.error( "Participant not found for endpoint " +
msg.endpointName + ". Ice candidate will be ignored.",
candidate );
return;
}
let streams = participant.getStreams();
for ( let key in streams ) {
let stream = streams[key];
stream.getWebRtcPeer().addIceCandidate( candidate, function( error ) {
if ( error ) {
console.error( "Error adding candidate for " + key
+ " stream of endpoint " + msg.endpointName
+ ": " + error );
}
});
}
}
onRoomClosed( msg ) {
console.log( "Room closed: " + JSON.stringify( msg ) );
let room = msg.room;
if ( room !== undefined ) {
this.ee.emitEvent( 'room-closed', [{
room: room
}] );
} else {
console.error( "Room undefined in on room closed", msg );
}
}
onLostConnection() {
if ( !this.connected ) {
console.warn( 'Not connected to room, ignoring lost connection notification' );
return;
}
console.log( 'Lost connection in room ' + this.name );
let room = this.name;
if ( room !== undefined ) {
this.ee.emitEvent( 'lost-connection', [{room}] );
} else {
console.error( 'Room undefined when lost connection' );
}
}
onMediaError( params ) {
console.error( "Media error: " + JSON.stringify( params ) );
let error = params.error;
if ( error ) {
this.ee.emitEvent( 'error-media', [{
error: error
}] );
} else {
console.error( "Received undefined media error. Params:", params );
}
}
/*
* forced means the user was evicted, no need to send the 'leaveRoom' request
*/
leave( forced, jsonRpcClient ) {
forced = !!forced;
console.log( "Leaving room (forced=" + forced + ")" );
if ( this.connected && !forced ) {
this.openVidu.sendRequest( 'leaveRoom', function( error, response ) {
if ( error ) {
console.error( error );
}
jsonRpcClient.close();
});
} else {
jsonRpcClient.close();
}
this.connected = false;
if ( this.participants ) {
for ( let pid in this.participants ) {
this.participants[pid].dispose();
delete this.participants[pid];
}
}
}
disconnect( stream ) {
let participant = stream.getParticipant();
if ( !participant ) {
console.error( "Stream to disconnect has no participant", stream );
return;
}
delete this.participants[participant.getID()];
participant.dispose();
if ( participant === this.localParticipant ) {
console.log( "Unpublishing my media (I'm " + participant.getID() + ")" );
delete this.localParticipant;
this.openVidu.sendRequest( 'unpublishVideo', function( error, response ) {
if ( error ) {
console.error( error );
} else {
console.info( "Media unpublished correctly" );
}
});
} else {
console.log( "Unsubscribing from " + stream.getGlobalID() );
this.openVidu.sendRequest( 'unsubscribeFromVideo', {
sender: stream.getGlobalID()
},
function( error, response ) {
if ( error ) {
console.error( error );
} else {
console.info( "Unsubscribed correctly from " + stream.getGlobalID() );
}
});
}
}
getStreams() {
return this.streams;
}
addParticipantSpeaking( participantId ) {
this.participantsSpeaking.push( participantId );
}
removeParticipantSpeaking( participantId ) {
let pos = -1;
for ( let i = 0; i < this.participantsSpeaking.length; i++ ) {
if ( this.participantsSpeaking[i] == participantId ) {
pos = i;
break;
}
}
if ( pos != -1 ) {
this.participantsSpeaking.splice( pos, 1 );
}
}
}

View File

@ -0,0 +1,495 @@
/*
* options: name: XXX data: true (Maybe this is based on webrtc) audio: true,
* video: true, url: "file:///..." > Player screen: true > Desktop (implicit
* video:true, audio:false) audio: true, video: true > Webcam
*
* stream.hasAudio(); stream.hasVideo(); stream.hasData();
*/
import { Participant } from './Participant';
import { Room } from './Room';
import { OpenVidu } from './OpenVidu';
declare type JQuery = any;
declare var $: JQuery;
declare var kurentoUtils: any;
declare var getUserMedia: any;
declare var RTCSessionDescription: any;
declare var EventEmitter: any;
function jq(id: string) {
return "#" + id.replace(/(@|:|\.|\[|\]|,)/g, "\\$1");
}
export interface StreamOptions {
id: string;
participant: Participant;
recvVideo: any;
recvAudio: any;
video: boolean;
audio: boolean;
data: boolean;
}
export interface VideoOptions {
thumb: string;
video: HTMLVideoElement;
}
export class Stream {
private ee = new EventEmitter();
private wrStream: any;
private wp: any;
private id: string;
private video: HTMLVideoElement;
private videoElements: VideoOptions[] = [];
private elements: HTMLDivElement[] = [];
private participant: Participant;
private speechEvent: any;
private recvVideo: any;
private recvAudio: any;
private showMyRemote = false;
private localMirrored = false;
private chanId = 0;
private dataChannel: boolean;
private dataChannelOpened = false;
constructor( private openVidu: OpenVidu, private local: boolean, private room: Room, options: StreamOptions ) {
if ( options.id ) {
this.id = options.id;
} else {
this.id = "webcam";
}
this.participant = options.participant;
this.recvVideo = options.recvVideo;
this.recvAudio = options.recvAudio;
this.dataChannel = options.data || false;
}
getRecvVideo() {
return this.recvVideo;
}
getRecvAudio() {
return this.recvAudio;
}
subscribeToMyRemote() {
this.showMyRemote = true;
}
displayMyRemote() {
return this.showMyRemote;
}
mirrorLocalStream( wr ) {
this.showMyRemote = true;
this.localMirrored = true;
if ( wr ) {
this.wrStream = wr;
}
}
isLocalMirrored() {
return this.localMirrored;
}
getChannelName() {
return this.getGlobalID() + '_' + this.chanId++;
}
isDataChannelEnabled() {
return this.dataChannel;
}
isDataChannelOpened() {
return this.dataChannelOpened;
}
onDataChannelOpen( event ) {
console.log( 'Data channel is opened' );
this.dataChannelOpened = true;
}
onDataChannelClosed( event ) {
console.log( 'Data channel is closed' );
this.dataChannelOpened = false;
}
sendData( data ) {
if ( this.wp === undefined ) {
throw new Error( 'WebRTC peer has not been created yet' );
}
if ( !this.dataChannelOpened ) {
throw new Error( 'Data channel is not opened' );
}
console.log( "Sending through data channel: " + data );
this.wp.send( data );
}
getWrStream() {
return this.wrStream;
}
getWebRtcPeer() {
return this.wp;
}
addEventListener( eventName: string, listener: any ) {
this.ee.addListener( eventName, listener );
}
showSpinner( spinnerParentId: string ) {
let progress = document.createElement( 'div' );
progress.id = 'progress-' + this.getGlobalID();
progress.style.background = "center transparent url('img/spinner.gif') no-repeat";
let spinnerParent = document.getElementById( spinnerParentId );
if(spinnerParent){
spinnerParent.appendChild( progress );
}
}
hideSpinner( spinnerId?: string ) {
spinnerId = ( spinnerId === undefined ) ? this.getGlobalID() : spinnerId;
$( jq( 'progress-' + spinnerId ) ).hide();
}
playOnlyVideo( parentElement, thumbnailId ) {
this.video = document.createElement( 'video' );
this.video.id = 'native-video-' + this.getGlobalID();
this.video.autoplay = true;
this.video.controls = false;
if ( this.wrStream ) {
this.video.src = URL.createObjectURL( this.wrStream );
$( jq( thumbnailId ) ).show();
this.hideSpinner();
} else {
console.log( "No wrStream yet for", this.getGlobalID() );
}
this.videoElements.push( {
thumb: thumbnailId,
video: this.video
});
if ( this.local ) {
this.video.muted = true;
}
if ( typeof parentElement === "string" ) {
let parentElementDom = document.getElementById( parentElement );
if(parentElementDom){
parentElementDom.appendChild( this.video );
}
} else {
parentElement.appendChild( this.video );
}
return this.video;
}
playThumbnail( thumbnailId ) {
let container = document.createElement( 'div' );
container.className = "participant";
container.id = this.getGlobalID();
let thumbnail = document.getElementById( thumbnailId );
if(thumbnail){
thumbnail.appendChild( container );
}
this.elements.push( container );
let name = document.createElement( 'div' );
container.appendChild( name );
let userName = this.getGlobalID().replace( '_webcam', '' );
if ( userName.length >= 16 ) {
userName = userName.substring( 0, 16 ) + "...";
}
name.appendChild( document.createTextNode( userName ) );
name.id = "name-" + this.getGlobalID();
name.className = "name";
name.title = this.getGlobalID();
this.showSpinner( thumbnailId );
return this.playOnlyVideo( container, thumbnailId );
}
getID() {
return this.id;
}
getParticipant() {
return this.participant;
}
getGlobalID() {
if ( this.participant ) {
return this.participant.getID() + "_" + this.id;
} else {
return this.id + "_webcam";
}
}
init() {
this.participant.addStream( this );
let constraints = {
audio: true,
video: {
width: {
ideal: 1280
},
frameRate: {
ideal: 15
}
}
};
getUserMedia( constraints, userStream => {
this.wrStream = userStream;
this.ee.emitEvent( 'access-accepted', null );
}, error => {
console.error( "Access denied", error );
this.ee.emitEvent( 'access-denied', null );
});
}
publishVideoCallback( error, sdpOfferParam, wp ) {
if ( error ) {
return console.error( "(publish) SDP offer error: "
+ JSON.stringify( error ) );
}
console.log( "Sending SDP offer to publish as "
+ this.getGlobalID(), sdpOfferParam );
this.openVidu.sendRequest( "publishVideo", {
sdpOffer: sdpOfferParam,
doLoopback: this.displayMyRemote() || false
}, ( error, response ) => {
if ( error ) {
console.error( "Error on publishVideo: " + JSON.stringify( error ) );
} else {
this.room.emitEvent( 'stream-published', [{
stream: this
}] )
this.processSdpAnswer( response.sdpAnswer );
}
});
}
startVideoCallback( error, sdpOfferParam, wp ) {
if ( error ) {
return console.error( "(subscribe) SDP offer error: "
+ JSON.stringify( error ) );
}
console.log( "Sending SDP offer to subscribe to "
+ this.getGlobalID(), sdpOfferParam );
this.openVidu.sendRequest( "receiveVideoFrom", {
sender: this.getGlobalID(),
sdpOffer: sdpOfferParam
}, ( error, response ) => {
if ( error ) {
console.error( "Error on recvVideoFrom: " + JSON.stringify( error ) );
} else {
this.processSdpAnswer( response.sdpAnswer );
}
});
}
private initWebRtcPeer( sdpOfferCallback ) {
if ( this.local ) {
let options: any = {
videoStream: this.wrStream,
onicecandidate: this.participant.sendIceCandidate.bind( this.participant ),
}
if ( this.dataChannel ) {
options.dataChannelConfig = {
id: this.getChannelName(),
onopen: this.onDataChannelOpen,
onclose: this.onDataChannelClosed
};
options.dataChannels = true;
}
if ( this.displayMyRemote() ) {
this.wp = new kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv( options, error => {
if ( error ) {
return console.error( error );
}
this.wp.generateOffer( sdpOfferCallback.bind( this ) );
});
} else {
this.wp = new kurentoUtils.WebRtcPeer.WebRtcPeerSendonly( options, error => {
if ( error ) {
return console.error( error );
}
this.wp.generateOffer( sdpOfferCallback.bind( this ) );
});
}
} else {
let offerConstraints = {
mandatory: {
OfferToReceiveVideo: this.recvVideo,
OfferToReceiveAudio: this.recvAudio
}
};
console.log( "Constraints of generate SDP offer (subscribing)",
offerConstraints );
let options = {
onicecandidate: this.participant.sendIceCandidate.bind( this.participant ),
connectionConstraints: offerConstraints
}
this.wp = new kurentoUtils.WebRtcPeer.WebRtcPeerRecvonly( options, error => {
if ( error ) {
return console.error( error );
}
this.wp.generateOffer( sdpOfferCallback.bind( this ) );
});
}
console.log( "Waiting for SDP offer to be generated ("
+ ( this.local ? "local" : "remote" ) + " peer: " + this.getGlobalID() + ")" );
}
publish() {
// FIXME: Throw error when stream is not local
this.initWebRtcPeer( this.publishVideoCallback );
// FIXME: Now we have coupled connecting to a room and adding a
// stream to this room. But in the new API, there are two steps.
// This is the second step. For now, it do nothing.
}
subscribe() {
// FIXME: In the current implementation all participants are subscribed
// automatically to all other participants. We use this method only to
// negotiate SDP
this.initWebRtcPeer( this.startVideoCallback );
}
processSdpAnswer( sdpAnswer ) {
let answer = new RTCSessionDescription( {
type: 'answer',
sdp: sdpAnswer,
});
console.log( this.getGlobalID() + ": set peer connection with recvd SDP answer",
sdpAnswer );
let participantId = this.getGlobalID();
let pc = this.wp.peerConnection;
pc.setRemoteDescription( answer, () => {
// Avoids to subscribe to your own stream remotely
// except when showMyRemote is true
if ( !this.local || this.displayMyRemote() ) {
this.wrStream = pc.getRemoteStreams()[0];
console.log( "Peer remote stream", this.wrStream );
if ( this.wrStream != undefined ) {
this.speechEvent = kurentoUtils.WebRtcPeer.hark( this.wrStream, { threshold: this.room.thresholdSpeaker });
this.speechEvent.on( 'speaking', () => {
this.room.addParticipantSpeaking( participantId );
this.room.emitEvent( 'stream-speaking', [{
participantId: participantId
}] );
});
this.speechEvent.on( 'stopped_speaking', () => {
this.room.removeParticipantSpeaking( participantId );
this.room.emitEvent( 'stream-stopped-speaking', [{
participantId: participantId
}] );
});
}
for (let videoElement of this.videoElements) {
let thumbnailId = videoElement.thumb;
let video = videoElement.video;
video.src = URL.createObjectURL( this.wrStream );
video.onplay = () => {
console.log( this.getGlobalID() + ': ' + 'Video playing' );
$( jq( thumbnailId ) ).show();
this.hideSpinner( this.getGlobalID() );
};
}
this.room.emitEvent( 'stream-subscribed', [{
stream: this
}] );
}
}, error => {
console.error( this.getGlobalID() + ": Error setting SDP to the peer connection: "
+ JSON.stringify( error ) );
});
}
unpublish() {
if ( this.wp ) {
this.wp.dispose();
} else {
if ( this.wrStream ) {
this.wrStream.getAudioTracks().forEach( function( track ) {
track.stop && track.stop()
})
this.wrStream.getVideoTracks().forEach( function( track ) {
track.stop && track.stop()
})
}
}
if ( this.speechEvent ) {
this.speechEvent.stop();
}
console.log( this.getGlobalID() + ": Stream '" + this.id + "' unpublished" );
}
dispose() {
function disposeElement( element ) {
if ( element && element.parentNode ) {
element.parentNode.removeChild( element );
}
}
this.elements.forEach( e => disposeElement( e ) );
this.videoElements.forEach( ve => disposeElement( ve ) );
disposeElement( "progress-" + this.getGlobalID() );
if ( this.wp ) {
this.wp.dispose();
} else {
if ( this.wrStream ) {
this.wrStream.getAudioTracks().forEach( function( track ) {
track.stop && track.stop()
})
this.wrStream.getVideoTracks().forEach( function( track ) {
track.stop && track.stop()
})
}
}
if ( this.speechEvent ) {
this.speechEvent.stop();
}
console.log( this.getGlobalID() + ": Stream '" + this.id + "' disposed" );
}
}

View File

@ -0,0 +1,27 @@
{
"compilerOptions": {
"target": "es5",
"module": "system",
//"noImplicitAny": true,
"noImplicitThis": true,
//"noUnusedLocals": true,
//"noUnusedParameters": true,
"skipDefaultLibCheck": true,
"skipLibCheck": true,
"suppressExcessPropertyErrors": true,
"suppressImplicitAnyIndexErrors": true,
//"allowUnusedLabels": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
//"allowUnreachableCode": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"strictNullChecks": true,
"outFile": "../ts_js/OpenVidu.js",
"emitBOM": false,
"preserveConstEnums": true,
"sourceMap": true
},
//"buildOnSave": true,
"compileOnSave":true
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>kurento-room-client-js</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -1,3 +0,0 @@
eclipse.preferences.version=1
encoding//src/main/resources=UTF-8
encoding/<project>=UTF-8

View File

@ -1,5 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -1,4 +0,0 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

View File

@ -1,39 +0,0 @@
{
"name": "webrtc-adapter",
"version": "0.2.3",
"description": "A shim to insulate apps from WebRTC spec changes and prefix differences",
"repository": {
"type": "git",
"url": "https://github.com/webrtc/adapter.git"
},
"authors": [
"The WebRTC project authors (http://www.webrtc.org/)"
],
"main": "adapter.js",
"moduleType": [
"globals"
],
"ignore": [
"test/*"
],
"keywords": [
"WebRTC",
"PeerConnection",
"RTCPeerConnection",
"getUserMedia",
"Chrome",
"Chromium",
"Firefox"
],
"license": "BSD-3-Clause",
"homepage": "https://github.com/webrtc/adapter",
"_release": "0.2.3",
"_resolution": {
"type": "version",
"tag": "v0.2.3",
"commit": "c51190130048443ec853f95d0a89362c4c79931a"
},
"_source": "git://github.com/webrtc/adapter.git",
"_target": "*",
"_originalSource": "adapter.js"
}

View File

@ -1,3 +0,0 @@
browsers/
node_modules/
*~

View File

@ -1,3 +0,0 @@
{
"preset": "google"
}

View File

@ -1,53 +0,0 @@
{
"browser": true,
"camelcase": true,
"curly": true,
"devel": true,
"eqeqeq": true,
"forin": false,
"globalstrict": true,
"quotmark": "single",
"undef": true,
"unused": "strict",
"globals": {
"addExplicitTest": true,
"addTest": true,
"arrayAverage": true,
"arrayMax": true,
"arrayMin": true,
"attachMediaStream": true,
"attachMediaStream": true,
"audioContext": true,
"AudioContext": true,
"Call": true,
"createIceServers": true,
"createIceServer": true,
"createLineChart": true,
"define": true,
"doGetUserMedia": true,
"expectEquals": true,
"getUserMedia": true,
"getUserMedia": true,
"ga": true,
"GumHandler": true,
"MediaStreamTrack": true,
"reattachMediaStream": true,
"report": true,
"reportBug": true,
"reportError": true,
"reportFatal": true,
"reportInfo": true,
"reportSuccess": true,
"RTCIceCandidate": true,
"RTCPeerConnection": true,
"RTCSessionDescription": true,
"setTestProgress": true,
"setTimeoutWithProgressBar": true,
"Ssim": true,
"StatisticsAggregate": true,
"testFinished": true,
"trace": true,
"webrtcDetectedBrowser": true,
"webrtcDetectedVersion": true
}
}

View File

@ -1,34 +0,0 @@
sudo: false
language: node_js
node_js:
- 0.10
env:
matrix:
- BROWSER=chrome BVER=stable
- BROWSER=chrome BVER=beta
- BROWSER=chrome BVER=unstable
- BROWSER=firefox BVER=stable
- BROWSER=firefox BVER=beta
- BROWSER=firefox BVER=unstable
- BROWSER=firefox BVER=esr
matrix:
fast_finish: true
allow_failures:
- env: BROWSER=chrome BVER=unstable
- env: BROWSER=firefox BVER=unstable
before_script:
- ./node_modules/travis-multirunner/setup.sh
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
script:
- node_modules/.bin/grunt
- npm test
after_failure:
- for file in *.log; do echo $file; echo "======================"; cat $file; done || true

View File

@ -1,15 +0,0 @@
WebRTC welcomes patches/pulls for features and bug fixes.
For contributors external to Google, follow the instructions given in the [Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual).
In all cases, contributors must sign a contributor license agreement before a contribution can be accepted. Please complete the agreement for an [individual](https://developers.google.com/open-source/cla/individual) or a [corporation](https://developers.google.com/open-source/cla/corporate) as appropriate.
If you plan to add a significant component or large chunk of code, we recommend you bring this up on the [webrtc-discuss group](https://groups.google.com/forum/#!forum/discuss-webrtc) for a design discussion before writing code.
If appropriate, write a unit test which demonstrates that your code functions as expected. Tests are the best way to ensure that future contributors do not break your code accidentally.
To request a change or addition, you must [submit a pull request](https://help.github.com/categories/collaborating/).
WebRTC developers monitor outstanding pull requests. They may request changes to the pull request before accepting. They will also verify that a CLA has been signed.
The [Developer's Guide](https://bit.ly/webrtcdevguide) for this repo has more detailed information about code style, structure and validation.

View File

@ -1,40 +0,0 @@
'use strict';
/* For jshint: */
/* globals module, require */
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
githooks: {
all: {
'pre-commit': 'jshint jscs'
}
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
files: ['adapter.js', 'test/*.js']
},
jscs: {
src: ['adapter.js', 'test/*.js'],
options: {
config: '.jscsrc',
'excludeFiles': [
]
}
},
testling: {
files: 'test/test.js'
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jscs');
grunt.loadNpmTasks('grunt-githooks');
grunt.registerTask('verify-require', 'Verifies the script can be required in a node context', function () {
require('./adapter');
});
grunt.registerTask('default', ['jshint', 'jscs', 'verify-require']);
};

View File

@ -1,29 +0,0 @@
Copyright (c) 2014, The WebRTC project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Google nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,14 +0,0 @@
How to use adapter with W3C tests
---------------------------------
If you want to test that the adapter works with the W3C tests, execute
the following (where TESTDIR is the root of the web-platform-tests repo):
- (cd $TESTDIR; git checkout master; git checkout -b some-unused-branch-name)
- cat adapter.js > $TESTDIR/common/vendor-prefix.js
- Run the tests according to $TESTDIR/README.md
WebRTC-specific tests are found in "mediacapture-streams" and "webrtc".
With the adapter installed, the tests should run *without* vendor prefixes.
Note: Not all of the W3C tests are updated to be spec-conformant.

View File

@ -1,65 +0,0 @@
[![Build Status](https://travis-ci.org/webrtc/adapter.svg)](https://travis-ci.org/webrtc/adapter)
# WebRTC adapter #
[adapter.js] is a shim to insulate apps from spec changes and prefix differences. In fact, the standards and protocols used for WebRTC implementations are highly stable, and there are only a few prefixed names. For full interop information, see [webrtc.org/web-apis/interop](http://www.webrtc.org/web-apis/interop).
## Install ##
#### Bower
```bash
bower install webrtc-adapter
```
#### NPM
```bash
npm install webrtc-adapter-test
```
## Inclusion on Browser ##
#### Bower
```html
<script src="bower_components/webrtc-adapter/adapter.js"></script>
```
#### NPM
Copy to desired location in your src tree or use a minify/vulcanize tool (node_modules is usually not published with the code).
See [webrtc/samples repo](https://github.com/webrtc/samples/blob/master/package.json) as an example on how you can do this.
## Development ##
Detailed information on developing in the [webrtc](https://github.com/webrtc) github repo can be found in the [WebRTC GitHub repo developer's guide](https://docs.google.com/document/d/1tn1t6LW2ffzGuYTK3366w1fhTkkzsSvHsBnOHoDfRzY/edit?pli=1#heading=h.e3366rrgmkdk).
This guide assumes you are running a Debian based Linux distribution (travis-multirunner currently fetches .deb browser packages).
#### Clone the repo in desired folder
```bash
git clone https://github.com/webrtc/adapter.git
```
#### Install npm dependencies
```bash
sudo npm install
```
#### Run tests
Runs the tests in test/tests.js using testling.
```bash
npm test
```
#### Change browser and channel/version for testing
Chrome stable is currently installed as the default browser for the tests.
Currently Chrome and Firefox are supported, check [travis-multirunner](https://github.com/DamonOehlman/travis-multirunner/blob/master/) repo for updates around this.
Firefox channels supported are stable, beta and nightly.
Chrome channels supported on Linux are stable, beta and unstable.
To select a different browser and/or channel version, change environment variables BROWSER and BVER, then you can rerun the tests with the new browser.
```bash
export BROWSER=firefox BVER=nightly
```
Alternatively you can also do it without changing environment variables.
```bash
BROWSER=firefox BVER=nightly npm test
```

View File

@ -1,29 +0,0 @@
{
"name": "webrtc-adapter",
"version": "0.2.3",
"description": "A shim to insulate apps from WebRTC spec changes and prefix differences",
"repository": {
"type": "git",
"url": "https://github.com/webrtc/adapter.git"
},
"authors": [
"The WebRTC project authors (http://www.webrtc.org/)"
],
"main": "adapter.js",
"moduleType": [
"globals"
],
"ignore": [
"test/*"
],
"keywords": [
"WebRTC",
"PeerConnection",
"RTCPeerConnection",
"getUserMedia",
"Chrome",
"Chromium",
"Firefox"
],
"license": "BSD-3-Clause"
}

View File

@ -1,30 +0,0 @@
{
"name": "webrtc-adapter-test",
"version": "0.2.3",
"description": "Hide browser differences in WebRTC APIs (test package name)",
"license": "BSD-3-Clause",
"main": "adapter.js",
"repository": {
"type": "git",
"url": "https://github.com/webrtc/adapter.git"
},
"scripts": {
"test": "test/run-tests"
},
"testling": {
"files": "test/test.js"
},
"devDependencies": {
"browserify": "^10.2.1",
"grunt": "^0.4.5",
"grunt-cli": ">=0.1.9",
"grunt-contrib-jshint": "^0.11.2",
"grunt-contrib-nodeunit": "~0.4.1",
"grunt-contrib-uglify": "^0.9.1",
"grunt-githooks": "^0.3.1",
"grunt-jscs": "^2.0.0",
"tape": "^4.0.0",
"testling": "^1.7.1",
"travis-multirunner": "^2.6.0"
}
}

View File

@ -5,7 +5,7 @@
<parent>
<groupId>org.openvidu</groupId>
<artifactId>openvidu</artifactId>
<version>6.6.1-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>openvidu-client</artifactId>

View File

@ -5,8 +5,9 @@
<parent>
<groupId>org.openvidu</groupId>
<artifactId>openvidu</artifactId>
<version>6.6.1-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>openvidu-demo</artifactId>
<packaging>jar</packaging>
@ -61,7 +62,7 @@
</dependency>
<dependency>
<groupId>org.openvidu</groupId>
<artifactId>openvidu-client-js</artifactId>
<artifactId>openvidu-browser</artifactId>
</dependency>
<dependency>
<groupId>org.openvidu</groupId>

View File

@ -1,6 +1,6 @@
var kurento_room = angular.module('kurento_room', ['ngRoute', 'FBAngular', 'lumx', 'angular-clipboard']);
var openVidu_room = angular.module('openVidu_room', ['ngRoute', 'FBAngular', 'lumx', 'angular-clipboard']);
kurento_room.config(['$routeProvider', function ($routeProvider) {
openVidu_room.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'angular/login/login.html',

View File

@ -3,17 +3,17 @@
* @author Raquel Díaz González
*/
kurento_room.controller('callController', function ($scope, $window, ServiceParticipant, ServiceRoom, Fullscreen, LxNotificationService) {
openVidu_room.controller('callController', function ($scope, $window, ServiceParticipant, ServiceRoom, Fullscreen, LxNotificationService) {
$scope.roomName = ServiceRoom.getRoomName();
$scope.userName = ServiceRoom.getUserName();
$scope.participants = ServiceParticipant.getParticipants();
$scope.kurento = ServiceRoom.getKurento();
$scope.openVidu = ServiceRoom.getOpenVidu();
$scope.filter = ServiceRoom.getFilterRequestParam();
$scope.leaveRoom = function () {
ServiceRoom.closeKurento();
ServiceRoom.closeOpenVidu();
ServiceParticipant.removeParticipants();
@ -24,14 +24,14 @@ kurento_room.controller('callController', function ($scope, $window, ServicePart
window.onbeforeunload = function () {
//not necessary if not connected
if (ServiceParticipant.isConnected()) {
ServiceRoom.closeKurento();
ServiceRoom.closeOpenVidu();
}
};
$scope.$on("$locationChangeStart", function () {
console.log("Changed location to: " + document.location);
if (ServiceParticipant.isConnected()) {
ServiceRoom.closeKurento();
ServiceRoom.closeOpenVidu();
ServiceParticipant.removeParticipants();
}
});
@ -97,7 +97,7 @@ kurento_room.controller('callController', function ($scope, $window, ServicePart
return false;
}
ServiceParticipant.disconnectParticipant(participant);
ServiceRoom.getKurento().disconnectParticipant(participant.getStream());
ServiceRoom.getOpenVidu().disconnectParticipant(participant.getStream());
}
//chat
@ -105,8 +105,8 @@ kurento_room.controller('callController', function ($scope, $window, ServicePart
$scope.sendMessage = function () {
console.log("Sending message", $scope.message);
var kurento = ServiceRoom.getKurento();
kurento.sendMessage($scope.roomName, $scope.userName, $scope.message);
var openVidu = ServiceRoom.getOpenVidu();
openVidu.sendMessage($scope.roomName, $scope.userName, $scope.message);
$scope.message = "";
};
@ -160,7 +160,7 @@ kurento_room.controller('callController', function ($scope, $window, ServicePart
}
}
ServiceRoom.getKurento().sendCustomRequest(reqParams, function (error, response) {
ServiceRoom.getOpenVidu().sendCustomRequest(reqParams, function (error, response) {
if (error) {
console.error("Unable to toggle filter, currently " +
$scope.filterState, error);

View File

@ -3,7 +3,7 @@
* @author Radu Tom Vlad
*/
kurento_room.controller('loginController', function($scope, $rootScope, $http,
openVidu_room.controller('loginController', function($scope, $rootScope, $http,
$window, $routeParams, ServiceParticipant, ServiceRoom, LxNotificationService) {
$scope.existingRoomName = false;
@ -68,23 +68,23 @@ kurento_room.controller('loginController', function($scope, $rootScope, $http,
//also show local stream when display my remote
var mirrorLocal = $scope.clientConfig.loopbackAndLocal || false;
var kurento = KurentoRoom(wsUri, function(error, kurento) {
var openVidu = OpenVidu(wsUri, function(error, openVidu) {
if (error) {
return console.error('Error in KurentoRoom client', error);
return console.error('Error in OpenVidu client', error);
}
//TODO token should be generated by the server or a 3rd-party component
//kurento.setRpcParams({token : "securityToken"});
//openVidu.setRpcParams({token : "securityToken"});
room = kurento.Room({
room = openVidu.Room({
room: $scope.roomName,
user: $scope.userName,
updateSpeakerInterval: $scope.updateSpeakerInterval,
thresholdSpeaker: $scope.thresholdSpeaker
});
var localStream = kurento.Stream(room, {
var localStream = openVidu.Stream(room, {
audio: true,
video: true,
data: false
@ -106,7 +106,7 @@ kurento_room.controller('loginController', function($scope, $rootScope, $http,
room.addEventListener("stream-published", function(streamEvent) {
ServiceParticipant.addLocalParticipant(localStream);
if (mirrorLocal && localStream.displayMyRemote()) {
var localVideo = kurento.Stream(room, {
var localVideo = openVidu.Stream(room, {
video: true,
id: "localStream"
});
@ -135,7 +135,7 @@ kurento_room.controller('loginController', function($scope, $rootScope, $http,
ServiceParticipant.alertMediaError($window, LxNotificationService, msg.error, contextPath, function(answer) {
console.warn("Leave room because of error: " + answer);
if (answer) {
kurento.close(true);
openVidu.close(true);
}
});
});
@ -145,14 +145,14 @@ kurento_room.controller('loginController', function($scope, $rootScope, $http,
console.error("Closed room name doesn't match this room's name",
msg.room, $scope.roomName);
} else {
kurento.close(true);
openVidu.close(true);
ServiceParticipant.forceClose($window, LxNotificationService, 'Room ' +
msg.room + ' has been forcibly closed from server', contextpath);
}
});
room.addEventListener("lost-connection", function(msg) {
kurento.close(true);
openVidu.close(true);
ServiceParticipant.forceClose($window, LxNotificationService,
'Lost connection with room "' + msg.room +
'". Please try reloading the webpage...');
@ -189,8 +189,8 @@ kurento_room.controller('loginController', function($scope, $rootScope, $http,
localStream.init();
});
//save kurento & roomName & userName in service
ServiceRoom.setKurento(kurento);
//save openVidu & roomName & userName in service
ServiceRoom.setOpenVidu(openVidu);
ServiceRoom.setRoomName($scope.roomName);
ServiceRoom.setUserName($scope.userName);
ServiceRoom.setFilterRequestParam($scope.clientConfig.filterRequestParam);

View File

@ -1,5 +1,5 @@
/*
* (C) Copyright 2016 Kurento (http://kurento.org/)
* (C) Copyright 2016 OpenVidu (http://openVidu.org/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -362,7 +362,7 @@ function Participants() {
};
function relogin($window, contextPath) {
//TODO call leaveRoom() in kurento
//TODO call leaveRoom() in openVidu
contextPath = contextPath || '/';
$window.location.href = contextPath; //'#/login';
}

View File

@ -2,7 +2,7 @@
* @author Raquel Díaz González
*/
kurento_room.factory('ServiceParticipant', function () {
openVidu_room.factory('ServiceParticipant', function () {
return new Participants();

View File

@ -2,24 +2,24 @@
* @author Raquel Díaz González
*/
kurento_room.service('ServiceRoom', function () {
openVidu_room.service('ServiceRoom', function () {
var kurento;
var openVidu;
var roomName;
var userName;
var localStream;
var filterRequestParam;
this.getKurento = function () {
return kurento;
this.getOpenVidu = function () {
return openVidu;
};
this.getRoomName = function () {
return roomName;
};
this.setKurento = function (value) {
kurento = value;
this.setOpenVidu = function (value) {
openVidu = value;
};
this.setRoomName = function (value) {
@ -42,11 +42,11 @@ kurento_room.service('ServiceRoom', function () {
userName = value;
};
this.closeKurento = function () {
if (kurento && kurento instanceof KurentoRoom) {
kurento.close();
this.closeOpenVidu = function () {
if (openVidu && openVidu instanceof OpenVidu) {
openVidu.close();
} else {
console.log('KurentoRoom instance is not set');
console.log('OpenVidu instance is not set');
}
};

View File

@ -34,7 +34,7 @@
<!-- Kurento JavaScript dependencies -->
<script src="./js/kurento-utils.js"></script>
<script src="./js/kurento-jsonrpc.js"></script>
<script src="./js/KurentoRoom.js"></script>
<script src="./js/OpenVidu.js"></script>
<!-- Custom JavaScript dependencies -->
<script src="./angular/app.js"></script>
@ -45,7 +45,7 @@
<script src="./angular/services/serviceRoom.js"></script>
</head>
<body ng-app="kurento_room">
<body ng-app="openVidu_room">
<div ng-view>
<!--display the view (login/call) with route system-->
</div>

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>openvidu-sampleapp-minimal</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -1,6 +0,0 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

View File

@ -1,5 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -1,4 +0,0 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

View File

@ -1,536 +0,0 @@
/*
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree.
*/
/* More information about these options at jshint.com/docs/options */
/* jshint browser: true, camelcase: true, curly: true, devel: true,
eqeqeq: true, forin: false, globalstrict: true, node: true,
quotmark: single, undef: true, unused: strict */
/* global mozRTCIceCandidate, mozRTCPeerConnection, Promise,
mozRTCSessionDescription, webkitRTCPeerConnection, MediaStreamTrack */
/* exported trace,requestUserMedia */
'use strict';
var getUserMedia = null;
var attachMediaStream = null;
var reattachMediaStream = null;
var webrtcDetectedBrowser = null;
var webrtcDetectedVersion = null;
var webrtcMinimumVersion = null;
var webrtcUtils = {
log: function() {
// suppress console.log output when being included as a module.
if (typeof module !== 'undefined' ||
typeof require === 'function' && typeof define === 'function') {
return;
}
console.log.apply(console, arguments);
}
};
function trace(text) {
// This function is used for logging.
if (text[text.length - 1] === '\n') {
text = text.substring(0, text.length - 1);
}
if (window.performance) {
var now = (window.performance.now() / 1000).toFixed(3);
webrtcUtils.log(now + ': ' + text);
} else {
webrtcUtils.log(text);
}
}
if (typeof window === 'object') {
if (window.HTMLMediaElement &&
!('srcObject' in window.HTMLMediaElement.prototype)) {
// Shim the srcObject property, once, when HTMLMediaElement is found.
Object.defineProperty(window.HTMLMediaElement.prototype, 'srcObject', {
get: function() {
// If prefixed srcObject property exists, return it.
// Otherwise use the shimmed property, _srcObject
return 'mozSrcObject' in this ? this.mozSrcObject : this._srcObject;
},
set: function(stream) {
if ('mozSrcObject' in this) {
this.mozSrcObject = stream;
} else {
// Use _srcObject as a private property for this shim
this._srcObject = stream;
// TODO: revokeObjectUrl(this.src) when !stream to release resources?
this.src = URL.createObjectURL(stream);
}
}
});
}
// Proxy existing globals
getUserMedia = window.navigator && window.navigator.getUserMedia;
}
// Attach a media stream to an element.
attachMediaStream = function(element, stream) {
element.srcObject = stream;
};
reattachMediaStream = function(to, from) {
to.srcObject = from.srcObject;
};
if (typeof window === 'undefined' || !window.navigator) {
webrtcUtils.log('This does not appear to be a browser');
webrtcDetectedBrowser = 'not a browser';
} else if (navigator.mozGetUserMedia && window.mozRTCPeerConnection) {
webrtcUtils.log('This appears to be Firefox');
webrtcDetectedBrowser = 'firefox';
// the detected firefox version.
webrtcDetectedVersion =
parseInt(navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1], 10);
// the minimum firefox version still supported by adapter.
webrtcMinimumVersion = 31;
// The RTCPeerConnection object.
window.RTCPeerConnection = function(pcConfig, pcConstraints) {
if (webrtcDetectedVersion < 38) {
// .urls is not supported in FF < 38.
// create RTCIceServers with a single url.
if (pcConfig && pcConfig.iceServers) {
var newIceServers = [];
for (var i = 0; i < pcConfig.iceServers.length; i++) {
var server = pcConfig.iceServers[i];
if (server.hasOwnProperty('urls')) {
for (var j = 0; j < server.urls.length; j++) {
var newServer = {
url: server.urls[j]
};
if (server.urls[j].indexOf('turn') === 0) {
newServer.username = server.username;
newServer.credential = server.credential;
}
newIceServers.push(newServer);
}
} else {
newIceServers.push(pcConfig.iceServers[i]);
}
}
pcConfig.iceServers = newIceServers;
}
}
return new mozRTCPeerConnection(pcConfig, pcConstraints); // jscs:ignore requireCapitalizedConstructors
};
// The RTCSessionDescription object.
window.RTCSessionDescription = mozRTCSessionDescription;
// The RTCIceCandidate object.
window.RTCIceCandidate = mozRTCIceCandidate;
// getUserMedia constraints shim.
getUserMedia = function(constraints, onSuccess, onError) {
var constraintsToFF37 = function(c) {
if (typeof c !== 'object' || c.require) {
return c;
}
var require = [];
Object.keys(c).forEach(function(key) {
if (key === 'require' || key === 'advanced' || key === 'mediaSource') {
return;
}
var r = c[key] = (typeof c[key] === 'object') ?
c[key] : {ideal: c[key]};
if (r.min !== undefined ||
r.max !== undefined || r.exact !== undefined) {
require.push(key);
}
if (r.exact !== undefined) {
if (typeof r.exact === 'number') {
r.min = r.max = r.exact;
} else {
c[key] = r.exact;
}
delete r.exact;
}
if (r.ideal !== undefined) {
c.advanced = c.advanced || [];
var oc = {};
if (typeof r.ideal === 'number') {
oc[key] = {min: r.ideal, max: r.ideal};
} else {
oc[key] = r.ideal;
}
c.advanced.push(oc);
delete r.ideal;
if (!Object.keys(r).length) {
delete c[key];
}
}
});
if (require.length) {
c.require = require;
}
return c;
};
if (webrtcDetectedVersion < 38) {
webrtcUtils.log('spec: ' + JSON.stringify(constraints));
if (constraints.audio) {
constraints.audio = constraintsToFF37(constraints.audio);
}
if (constraints.video) {
constraints.video = constraintsToFF37(constraints.video);
}
webrtcUtils.log('ff37: ' + JSON.stringify(constraints));
}
return navigator.mozGetUserMedia(constraints, onSuccess, onError);
};
navigator.getUserMedia = getUserMedia;
// Shim for mediaDevices on older versions.
if (!navigator.mediaDevices) {
navigator.mediaDevices = {getUserMedia: requestUserMedia,
addEventListener: function() { },
removeEventListener: function() { }
};
}
navigator.mediaDevices.enumerateDevices =
navigator.mediaDevices.enumerateDevices || function() {
return new Promise(function(resolve) {
var infos = [
{kind: 'audioinput', deviceId: 'default', label: '', groupId: ''},
{kind: 'videoinput', deviceId: 'default', label: '', groupId: ''}
];
resolve(infos);
});
};
if (webrtcDetectedVersion < 41) {
// Work around http://bugzil.la/1169665
var orgEnumerateDevices =
navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices);
navigator.mediaDevices.enumerateDevices = function() {
return orgEnumerateDevices().catch(function(e) {
if (e.name === 'NotFoundError') {
return [];
}
throw e;
});
};
}
} else if (navigator.webkitGetUserMedia && !!window.chrome) {
webrtcUtils.log('This appears to be Chrome');
webrtcDetectedBrowser = 'chrome';
// the detected chrome version.
webrtcDetectedVersion =
parseInt(navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)[2], 10);
// the minimum chrome version still supported by adapter.
webrtcMinimumVersion = 38;
// The RTCPeerConnection object.
window.RTCPeerConnection = function(pcConfig, pcConstraints) {
// Translate iceTransportPolicy to iceTransports,
// see https://code.google.com/p/webrtc/issues/detail?id=4869
if (pcConfig && pcConfig.iceTransportPolicy) {
pcConfig.iceTransports = pcConfig.iceTransportPolicy;
}
var pc = new webkitRTCPeerConnection(pcConfig, pcConstraints); // jscs:ignore requireCapitalizedConstructors
var origGetStats = pc.getStats.bind(pc);
pc.getStats = function(selector, successCallback, errorCallback) { // jshint ignore: line
var self = this;
var args = arguments;
// If selector is a function then we are in the old style stats so just
// pass back the original getStats format to avoid breaking old users.
if (arguments.length > 0 && typeof selector === 'function') {
return origGetStats(selector, successCallback);
}
var fixChromeStats = function(response) {
var standardReport = {};
var reports = response.result();
reports.forEach(function(report) {
var standardStats = {
id: report.id,
timestamp: report.timestamp,
type: report.type
};
report.names().forEach(function(name) {
standardStats[name] = report.stat(name);
});
standardReport[standardStats.id] = standardStats;
});
return standardReport;
};
if (arguments.length >= 2) {
var successCallbackWrapper = function(response) {
args[1](fixChromeStats(response));
};
return origGetStats.apply(this, [successCallbackWrapper, arguments[0]]);
}
// promise-support
return new Promise(function(resolve, reject) {
if (args.length === 1 && selector === null) {
origGetStats.apply(self, [
function(response) {
resolve.apply(null, [fixChromeStats(response)]);
}, reject]);
} else {
origGetStats.apply(self, [resolve, reject]);
}
});
};
return pc;
};
// add promise support
['createOffer', 'createAnswer'].forEach(function(method) {
var nativeMethod = webkitRTCPeerConnection.prototype[method];
webkitRTCPeerConnection.prototype[method] = function() {
var self = this;
if (arguments.length < 1 || (arguments.length === 1 &&
typeof(arguments[0]) === 'object')) {
var opts = arguments.length === 1 ? arguments[0] : undefined;
return new Promise(function(resolve, reject) {
nativeMethod.apply(self, [resolve, reject, opts]);
});
} else {
return nativeMethod.apply(this, arguments);
}
};
});
['setLocalDescription', 'setRemoteDescription',
'addIceCandidate'].forEach(function(method) {
var nativeMethod = webkitRTCPeerConnection.prototype[method];
webkitRTCPeerConnection.prototype[method] = function() {
var args = arguments;
var self = this;
return new Promise(function(resolve, reject) {
nativeMethod.apply(self, [args[0],
function() {
resolve();
if (args.length >= 2) {
args[1].apply(null, []);
}
},
function(err) {
reject(err);
if (args.length >= 3) {
args[2].apply(null, [err]);
}
}]
);
});
};
});
// getUserMedia constraints shim.
var constraintsToChrome = function(c) {
if (typeof c !== 'object' || c.mandatory || c.optional) {
return c;
}
var cc = {};
Object.keys(c).forEach(function(key) {
if (key === 'require' || key === 'advanced' || key === 'mediaSource') {
return;
}
var r = (typeof c[key] === 'object') ? c[key] : {ideal: c[key]};
if (r.exact !== undefined && typeof r.exact === 'number') {
r.min = r.max = r.exact;
}
var oldname = function(prefix, name) {
if (prefix) {
return prefix + name.charAt(0).toUpperCase() + name.slice(1);
}
return (name === 'deviceId') ? 'sourceId' : name;
};
if (r.ideal !== undefined) {
cc.optional = cc.optional || [];
var oc = {};
if (typeof r.ideal === 'number') {
oc[oldname('min', key)] = r.ideal;
cc.optional.push(oc);
oc = {};
oc[oldname('max', key)] = r.ideal;
cc.optional.push(oc);
} else {
oc[oldname('', key)] = r.ideal;
cc.optional.push(oc);
}
}
if (r.exact !== undefined && typeof r.exact !== 'number') {
cc.mandatory = cc.mandatory || {};
cc.mandatory[oldname('', key)] = r.exact;
} else {
['min', 'max'].forEach(function(mix) {
if (r[mix] !== undefined) {
cc.mandatory = cc.mandatory || {};
cc.mandatory[oldname(mix, key)] = r[mix];
}
});
}
});
if (c.advanced) {
cc.optional = (cc.optional || []).concat(c.advanced);
}
return cc;
};
getUserMedia = function(constraints, onSuccess, onError) {
if (constraints.audio) {
constraints.audio = constraintsToChrome(constraints.audio);
}
if (constraints.video) {
constraints.video = constraintsToChrome(constraints.video);
}
webrtcUtils.log('chrome: ' + JSON.stringify(constraints));
return navigator.webkitGetUserMedia(constraints, onSuccess, onError);
};
navigator.getUserMedia = getUserMedia;
if (!navigator.mediaDevices) {
navigator.mediaDevices = {getUserMedia: requestUserMedia,
enumerateDevices: function() {
return new Promise(function(resolve) {
var kinds = {audio: 'audioinput', video: 'videoinput'};
return MediaStreamTrack.getSources(function(devices) {
resolve(devices.map(function(device) {
return {label: device.label,
kind: kinds[device.kind],
deviceId: device.id,
groupId: ''};
}));
});
});
}};
}
// A shim for getUserMedia method on the mediaDevices object.
// TODO(KaptenJansson) remove once implemented in Chrome stable.
if (!navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia = function(constraints) {
return requestUserMedia(constraints);
};
} else {
// Even though Chrome 45 has navigator.mediaDevices and a getUserMedia
// function which returns a Promise, it does not accept spec-style
// constraints.
var origGetUserMedia = navigator.mediaDevices.getUserMedia.
bind(navigator.mediaDevices);
navigator.mediaDevices.getUserMedia = function(c) {
webrtcUtils.log('spec: ' + JSON.stringify(c)); // whitespace for alignment
c.audio = constraintsToChrome(c.audio);
c.video = constraintsToChrome(c.video);
webrtcUtils.log('chrome: ' + JSON.stringify(c));
return origGetUserMedia(c);
};
}
// Dummy devicechange event methods.
// TODO(KaptenJansson) remove once implemented in Chrome stable.
if (typeof navigator.mediaDevices.addEventListener === 'undefined') {
navigator.mediaDevices.addEventListener = function() {
webrtcUtils.log('Dummy mediaDevices.addEventListener called.');
};
}
if (typeof navigator.mediaDevices.removeEventListener === 'undefined') {
navigator.mediaDevices.removeEventListener = function() {
webrtcUtils.log('Dummy mediaDevices.removeEventListener called.');
};
}
// Attach a media stream to an element.
attachMediaStream = function(element, stream) {
if (webrtcDetectedVersion >= 43) {
element.srcObject = stream;
} else if (typeof element.src !== 'undefined') {
element.src = URL.createObjectURL(stream);
} else {
webrtcUtils.log('Error attaching stream to element.');
}
};
reattachMediaStream = function(to, from) {
if (webrtcDetectedVersion >= 43) {
to.srcObject = from.srcObject;
} else {
to.src = from.src;
}
};
} else if (navigator.mediaDevices && navigator.userAgent.match(
/Edge\/(\d+).(\d+)$/)) {
webrtcUtils.log('This appears to be Edge');
webrtcDetectedBrowser = 'edge';
webrtcDetectedVersion =
parseInt(navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)[2], 10);
// the minimum version still supported by adapter.
webrtcMinimumVersion = 12;
} else {
webrtcUtils.log('Browser does not appear to be WebRTC-capable');
}
// Returns the result of getUserMedia as a Promise.
function requestUserMedia(constraints) {
return new Promise(function(resolve, reject) {
getUserMedia(constraints, resolve, reject);
});
}
var webrtcTesting = {};
Object.defineProperty(webrtcTesting, 'version', {
set: function(version) {
webrtcDetectedVersion = version;
}
});
if (typeof module !== 'undefined') {
var RTCPeerConnection;
if (typeof window !== 'undefined') {
RTCPeerConnection = window.RTCPeerConnection;
}
module.exports = {
RTCPeerConnection: RTCPeerConnection,
getUserMedia: getUserMedia,
attachMediaStream: attachMediaStream,
reattachMediaStream: reattachMediaStream,
webrtcDetectedBrowser: webrtcDetectedBrowser,
webrtcDetectedVersion: webrtcDetectedVersion,
webrtcMinimumVersion: webrtcMinimumVersion,
webrtcTesting: webrtcTesting
//requestUserMedia: not exposed on purpose.
//trace: not exposed on purpose.
};
} else if ((typeof require === 'function') && (typeof define === 'function')) {
// Expose objects and functions when RequireJS is doing the loading.
define([], function() {
return {
RTCPeerConnection: window.RTCPeerConnection,
getUserMedia: getUserMedia,
attachMediaStream: attachMediaStream,
reattachMediaStream: reattachMediaStream,
webrtcDetectedBrowser: webrtcDetectedBrowser,
webrtcDetectedVersion: webrtcDetectedVersion,
webrtcMinimumVersion: webrtcMinimumVersion,
webrtcTesting: webrtcTesting
//requestUserMedia: not exposed on purpose.
//trace: not exposed on purpose.
};
});
}

View File

@ -5,7 +5,7 @@
<parent>
<groupId>org.openvidu</groupId>
<artifactId>openvidu</artifactId>
<version>6.6.1-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>openvidu-server</artifactId>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>org.openvidu</groupId>
<artifactId>openvidu</artifactId>
<version>6.6.1-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>openvidu-test</artifactId>

View File

@ -5,10 +5,11 @@
<parent>
<groupId>org.openvidu</groupId>
<artifactId>openvidu</artifactId>
<version>6.6.1-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>openvidu-sampleapp-minimal</artifactId>
<artifactId>openvidu-testapp</artifactId>
<packaging>jar</packaging>
<name>OpenVidu Sample App "Minimal"</name>
@ -202,7 +203,7 @@
</dependency>
<dependency>
<groupId>org.openvidu</groupId>
<artifactId>openvidu-client-js</artifactId>
<artifactId>openvidu-browser</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -213,6 +214,11 @@
<artifactId>openvidu-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>system.js</artifactId>
<version>0.19.17</version>
</dependency>
</dependencies>
<profiles>

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openvidu.sampleapp.minimal;
package org.openvidu.testapp;
import org.kurento.commons.ConfigFileManager;
import org.openvidu.server.OpenViduServer;
@ -28,7 +28,7 @@ import org.springframework.context.annotation.Import;
* @since 5.0.0
*/
@Import(OpenViduServer.class)
public class OpenViduSampleApp {
public class OpenViduTestApp {
private final static String BASICAPP_CFG_FILENAME = "kroombasic.conf.json";
@ -37,6 +37,6 @@ public class OpenViduSampleApp {
}
public static void main(String[] args) {
SpringApplication.run(OpenViduSampleApp.class, args);
SpringApplication.run(OpenViduTestApp.class, args);
}
}

View File

@ -11,11 +11,16 @@
<script src="./js/kurento-jsonrpc.js"></script>
<script src="./js/console.js"></script>
<script src="./js/EventEmitter.js"></script>
<script src="./js/KurentoRoom.js"></script>
<script src="./js/demo.js"></script>
<script src="webjars/system.js/0.19.17/dist/system.js"></script>
<script src="./ts_js/OpenVidu.js"></script>
<script src="./js/testapp.js"></script>
<script src="./js/color.js"></script>
<script src="./js/stats.js"></script>
<script>
System.import('Main').then(function(m){ Main = m; }, console.error.bind(console));
</script>
</head>
<body>
<div id="container">

View File

@ -1,5 +1,5 @@
/*
* (C) Copyright 2016 Kurento (http://kurento.org/)
* (C) Copyright 2016 OpenVidu (http://kurento.org/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* (C) Copyright 2013 Kurento (http://kurento.org/)
* (C) Copyright 2013 OpenVidu (http://kurento.org/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -88,6 +88,6 @@ function Console(id, console) {
*/
this.debug = function(msg) {
console.log(msg);
// this._append(createMessage(msg, "#0000FF"));
this._append(createMessage(msg, "#0000FF"));
};
}

View File

@ -1,5 +1,5 @@
/*
* (C) Copyright 2016 Kurento (http://kurento.org/)
* (C) Copyright 2016 OpenVidu (http://kurento.org/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -82,7 +82,7 @@ module.exports = Mapper;
},{}],2:[function(_dereq_,module,exports){
/*
* (C) Copyright 2014 Kurento (http://kurento.org/)
* (C) Copyright 2014 OpenVidu (http://kurento.org/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -105,7 +105,7 @@ exports.JsonRpcClient = JsonRpcClient;
},{"./jsonrpcclient":3}],3:[function(_dereq_,module,exports){
/*
* (C) Copyright 2014 Kurento (http://kurento.org/)
* (C) Copyright 2014 OpenVidu (http://kurento.org/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -142,7 +142,7 @@ module.exports = JsonRpcClient;
},{"../..":4,"ws":10}],4:[function(_dereq_,module,exports){
/*
* (C) Copyright 2014 Kurento (http://kurento.org/)
* (C) Copyright 2014 OpenVidu (http://kurento.org/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* (C) Copyright 2016 Kurento (http://kurento.org/)
* (C) Copyright 2016 OpenVidu (http://kurento.org/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* (C) Copyright 2016 Kurento (http://kurento.org/)
* (C) Copyright 2016 OpenVidu (http://kurento.org/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,13 +14,29 @@
* limitations under the License.
*
*/
var kurento;
var openVidu;
var room;
window.onload = function() {
console = new Console('console', console);
}
function playVideo(stream) {
var elementId = "video-" + stream.getGlobalID();
var div = document.createElement('div');
div.setAttribute("id", elementId);
document.getElementById("participants").appendChild(div);
stream.playThumbnail(elementId);
// Check color
var videoTag = document.getElementById("native-" + elementId);
var userId = stream.getGlobalID();
var canvas = document.createElement('CANVAS');
checkColor(videoTag, canvas, userId);
}
function register() {
var userId = document.getElementById('name').value;
@ -28,38 +44,22 @@ function register() {
var wsUri = 'wss://' + location.host + '/room';
kurento = KurentoRoom(wsUri, function(error, kurento) {
openVidu = new Main.OpenVidu(wsUri);
openVidu.connect(function(error, openVidu) {
if (error)
return console.log(error);
room = kurento.Room({
room = openVidu.Room({
room : roomId,
user : userId,
subscribeToStreams : true
});
var localStream = kurento.Stream(room, {
audio : true,
video : true,
data : true
});
var camera = openVidu.Stream(room);
localStream.addEventListener("access-accepted", function() {
var playVideo = function(stream) {
var elementId = "video-" + stream.getGlobalID();
var div = document.createElement('div');
div.setAttribute("id", elementId);
document.getElementById("participants").appendChild(div);
stream.playThumbnail(elementId);
// Check color
var videoTag = document.getElementById("native-" + elementId);
var userId = stream.getGlobalID();
var canvas = document.createElement('CANVAS');
checkColor(videoTag, canvas, userId);
}
camera.addEventListener("access-accepted", function() {
room.addEventListener("room-connected", function(roomEvent) {
@ -68,7 +68,7 @@ function register() {
document.getElementById('join').style.display = 'none';
document.getElementById('room').style.display = 'block';
localStream.publish();
camera.publish();
var streams = roomEvent.streams;
for (var i = 0; i < streams.length; i++) {
@ -88,12 +88,12 @@ function register() {
}
});
playVideo(localStream);
playVideo(camera);
room.connect();
});
localStream.init();
camera.init();
});
}
@ -104,16 +104,17 @@ function leaveRoom() {
document.getElementById('room').style.display = 'none';
var streams = room.getStreams();
for ( var index in streams) {
for (var index in streams) {
var stream = streams[index];
var element = document.getElementById("video-" + stream.getGlobalID());
if (element) {
element.parentNode.removeChild(element);
}
}
kurento.close();
openVidu.close();
}
window.onbeforeunload = function() {
kurento.close();
openVidu.close();
};

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.openvidu.test.basic;
package org.openvidu.testapp.test;
import java.lang.invoke.MethodHandles;
import java.util.Collection;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.openvidu.test.basic;
package org.openvidu.testapp.test;
import java.lang.invoke.MethodHandles;
import java.util.Collection;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.openvidu.test.basic;
package org.openvidu.testapp.test;
import java.lang.invoke.MethodHandles;
import java.util.Collection;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.openvidu.test.basic;
package org.openvidu.testapp.test;
import java.lang.invoke.MethodHandles;
import java.util.Collection;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.openvidu.test.basic;
package org.openvidu.testapp.test;
import java.lang.invoke.MethodHandles;
import java.util.Collection;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.openvidu.test.basic;
package org.openvidu.testapp.test;
import java.lang.invoke.MethodHandles;
import java.util.Collection;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.openvidu.test.basic;
package org.openvidu.testapp.test;
import java.lang.invoke.MethodHandles;
import java.util.Collection;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.openvidu.test.basic;
package org.openvidu.testapp.test;
import java.lang.invoke.MethodHandles;
import java.util.Collection;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openvidu.test.basic.fake;
package org.openvidu.testapp.test.fake;
import java.lang.invoke.MethodHandles;
import java.util.Collection;

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openvidu.test.basic.fake;
package org.openvidu.testapp.test.fake;
import java.lang.invoke.MethodHandles;
import java.util.Collection;

23
pom.xml
View File

@ -10,6 +10,7 @@
<groupId>org.openvidu</groupId>
<artifactId>openvidu</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Kurento Room</name>
@ -49,7 +50,7 @@
<properties>
<!-- Kurento versions -->
<version.kurento.room>6.6.1-SNAPSHOT</version.kurento.room>
<version.openvidu>0.0.1-SNAPSHOT</version.openvidu>
<version.kurento.jsonrpc.js>5.1.4-SNAPSHOT</version.kurento.jsonrpc.js>
@ -69,10 +70,10 @@
<modules>
<module>openvidu-server</module>
<module>openvidu-client</module>
<module>openvidu-client-js</module>
<module>openvidu-browser</module>
<module>openvidu-test</module>
<module>openvidu-demo</module>
<module>openvidu-sampleapp-minimal</module>
<module>openvidu-testapp</module>
</modules>
</profile>
<profile>
@ -98,37 +99,37 @@
<dependency>
<groupId>org.openvidu</groupId>
<artifactId>openvidu-sdk</artifactId>
<version>${version.kurento.room}</version>
<version>${version.openvidu}</version>
</dependency>
<dependency>
<groupId>org.openvidu</groupId>
<artifactId>openvidu-server</artifactId>
<version>${version.kurento.room}</version>
<version>${version.openvidu}</version>
</dependency>
<dependency>
<groupId>org.openvidu</groupId>
<artifactId>openvidu-client</artifactId>
<version>${version.kurento.room}</version>
<version>${version.openvidu}</version>
</dependency>
<dependency>
<groupId>org.openvidu</groupId>
<artifactId>openvidu-client-js</artifactId>
<version>${version.kurento.room}</version>
<artifactId>openvidu-browser</artifactId>
<version>${version.openvidu}</version>
</dependency>
<dependency>
<groupId>org.openvidu</groupId>
<artifactId>openvidu-test</artifactId>
<version>${version.kurento.room}</version>
<version>${version.openvidu}</version>
</dependency>
<dependency>
<groupId>org.openvidu</groupId>
<artifactId>openvidu-demo</artifactId>
<version>${version.kurento.room}</version>
<version>${version.openvidu}</version>
</dependency>
<dependency>
<groupId>org.openvidu</groupId>
<artifactId>openvidu-basicapp</artifactId>
<version>${version.kurento.room}</version>
<version>${version.openvidu}</version>
</dependency>
<dependency>