OpenVidu.initPublisher() totally independent from Session

pull/32/head
pabloFuente 2018-03-02 11:03:45 +01:00
parent d5d383ce90
commit c2b3c46969
8 changed files with 25 additions and 16 deletions

View File

@ -19,7 +19,6 @@ import { OpenViduInternal } from '../OpenViduInternal/OpenViduInternal';
import { Session } from './Session';
import { Publisher } from './Publisher';
import { OpenViduError, OpenViduErrorName } from '../OpenViduInternal/OpenViduError';
import { OutboundStreamOptions } from '../OpenViduInternal/index';
import { Stream } from '../OpenViduInternal/Stream';
import { LocalRecorder } from '../OpenViduInternal/LocalRecorder';

View File

@ -48,7 +48,7 @@ export class Publisher {
}
destroy() {
this.session.unpublish(this);
if (!!this.session) this.session.unpublish(this);
this.stream.dispose();
this.stream.removeVideo(this.element);
return this;

View File

@ -102,6 +102,7 @@ export class Session {
private streamPublish(publisher: Publisher) {
publisher.session = this;
this.connection.addStream(publisher.stream);
publisher.stream.publish();
}

View File

@ -22,7 +22,7 @@ export class Connection {
console.info( "'Connection' created (" + ( local ? "local" : "remote" ) + ")" + ( local ? "" : ", with 'connectionId' [" + (options ? options.id : '') + "] " ));
if ( options ) {
if ( options && !local ) {
this.connectionId = options.id;
if (options.metadata) {
@ -36,6 +36,7 @@ export class Connection {
}
addStream( stream: Stream ) {
stream.connection = this;
this.streams[stream.streamId] = stream;
this.room.getStreams()[stream.streamId] = stream;
}

View File

@ -15,6 +15,7 @@
*
*/
import { SessionInternal, SessionOptions } from './SessionInternal';
import { Connection } from './Connection';
import { OpenViduError, OpenViduErrorName } from './OpenViduError';
import { Stream, OutboundStreamOptions } from './Stream';
import * as RpcBuilder from '../KurentoUtils/kurento-jsonrpc';
@ -45,7 +46,6 @@ export class OpenViduInternal {
if (newStream) {
if (cameraOptions == null) {
cameraOptions = {
connection: this.session.getLocalParticipant(),
sendAudio: true,
sendVideo: true,
activeAudio: true,
@ -56,8 +56,6 @@ export class OpenViduInternal {
video: { width: { ideal: 1280 } }
}
}
} else {
cameraOptions.connection = this.session.getLocalParticipant();
}
this.localStream = new Stream(this, true, this.session, cameraOptions);
}

View File

@ -41,7 +41,7 @@ export class SessionInternal {
constructor(private openVidu: OpenViduInternal, sessionId: string) {
this.sessionId = this.getUrlWithoutSecret(sessionId);
this.localParticipant = new Connection(this.openVidu, true, this);
if (!this.openVidu.getWsUri()) {
if (!this.openVidu.getWsUri() && !!sessionId) {
this.processOpenViduUrl(sessionId);
}
}
@ -214,6 +214,10 @@ export class SessionInternal {
this.updateSpeakerInterval = options.updateSpeakerInterval || 1500;
this.thresholdSpeaker = options.thresholdSpeaker || -50;
this.activateUpdateMainSpeaker();
if (!this.openVidu.getWsUri()) {
this.processOpenViduUrl(options.sessionId);
}
}
getId() {

View File

@ -52,7 +52,6 @@ export interface InboundStreamOptions {
export interface OutboundStreamOptions {
activeAudio: boolean;
activeVideo: boolean;
connection: Connection;
dataChannel: boolean;
mediaConstraints: any;
sendAudio: boolean;
@ -93,6 +92,7 @@ export class Stream {
constructor(private openVidu: OpenViduInternal, private local: boolean, private room: SessionInternal, options: any) {
if (options !== 'screen-options') {
// Outbound stream (not screen share) or Inbound stream
if ('id' in options) {
this.inboundOptions = options;
} else {
@ -100,11 +100,15 @@ export class Stream {
}
this.streamId = (options.id != null) ? options.id : ((options.sendVideo) ? "CAMERA" : "MICRO");
this.typeOfVideo = (options.typeOfVideo != null) ? options.typeOfVideo : '';
this.connection = options.connection;
if ('recvAudio' in options) {
// Set Connection for an Inbound stream (for Outbound streams will be set on Session.Publish(Publisher))
this.connection = options.connection;
}
} else {
// Outbound stream for screen share
this.isScreenRequested = true;
this.typeOfVideo = 'SCREEN';
this.connection = this.room.getLocalParticipant();
}
this.addEventListener('mediastream-updated', () => {
if (this.video) this.video.srcObject = this.mediaStream;
@ -336,8 +340,6 @@ export class Stream {
requestCameraAccess(callback: Callback<Stream>) {
this.connection.addStream(this);
let constraints = this.outboundOptions.mediaConstraints;
/*let constraints2 = {

View File

@ -140,8 +140,9 @@ export class WebRtcStats {
"@timestamp": new Date(stat.timestamp).toISOString(),
"exec": instrumentation.exec,
"component": instrumentation.component,
"stream": "webRtc",
"type": metricId,
"stream_type": "composed_metric",
"stream_type": "composed_metrics",
"units": units
}
json[metricId] = metrics;
@ -179,8 +180,9 @@ export class WebRtcStats {
"@timestamp": new Date(stat.timestamp).toISOString(),
"exec": instrumentation.exec,
"component": instrumentation.component,
"stream": "webRtc",
"type": metricId,
"stream_type": "composed_metric",
"stream_type": "composed_metrics",
"units": units
}
json[metricId] = metrics;
@ -232,8 +234,9 @@ export class WebRtcStats {
"@timestamp": new Date(stat.timestamp).toISOString(),
"exec": instrumentation.exec,
"component": instrumentation.component,
"stream": "webRtc",
"type": metricId,
"stream_type": "composed_metric",
"stream_type": "composed_metrics",
"units": units
}
json[metricId] = metrics;
@ -265,8 +268,9 @@ export class WebRtcStats {
"@timestamp": new Date(stat.timestamp).toISOString(),
"exec": instrumentation.exec,
"component": instrumentation.component,
"stream": "webRtc",
"type": metricId,
"stream_type": "composed_metric",
"stream_type": "composed_metrics",
"units": units
}
json[metricId] = metrics;