openvidu-browser: rename WebRtcPeer handler methods

pull/630/head
pabloFuente 2021-05-27 21:28:17 +02:00
parent 9fff788546
commit ac0e93ea27
2 changed files with 12 additions and 9 deletions

View File

@ -814,8 +814,8 @@ export class Stream {
const options: WebRtcPeerConfiguration = {
mediaStream: this.mediaStream,
mediaConstraints: userMediaConstraints,
onicecandidate: this.connection.sendIceCandidate.bind(this.connection),
onexception: (exceptionName: ExceptionEventName, message: string, data?: any) => { this.session.emitEvent('exception', [new ExceptionEvent(this.session, exceptionName, this, message, data)]) },
onIceCandidate: this.connection.sendIceCandidate.bind(this.connection),
onIceConnectionStateException: this.onIceConnectionStateExceptionHandler.bind(this),
iceServers: this.getIceServersConf(),
simulcast: false
};
@ -943,9 +943,9 @@ export class Stream {
logger.debug("'Session.subscribe(Stream)' called. Constraints of generate SDP offer",
offerConstraints);
const options = {
onicecandidate: this.connection.sendIceCandidate.bind(this.connection),
onexception: (exceptionName: ExceptionEventName, message: string, data?: any) => { this.session.emitEvent('exception', [new ExceptionEvent(this.session, exceptionName, this, message, data)]) },
mediaConstraints: offerConstraints,
onIceCandidate: this.connection.sendIceCandidate.bind(this.connection),
onIceConnectionStateException: this.onIceConnectionStateExceptionHandler.bind(this),
iceServers: this.getIceServersConf(),
simulcast: false
};
@ -968,6 +968,9 @@ export class Stream {
});
};
if (reconnect) {
this.disposeWebRtcPeer();
}
this.webRtcPeer = new WebRtcPeerRecvonly(options);
this.webRtcPeer.addIceConnectionStateChangeListener(this.streamId);
this.webRtcPeer.processRemoteOffer(sdpOffer)

View File

@ -37,8 +37,8 @@ export interface WebRtcPeerConfiguration {
video: boolean
};
simulcast: boolean;
onicecandidate: (event: RTCIceCandidate) => void;
onexception: (exceptionName: ExceptionEventName, message: string, data?: any) => void;
onIceCandidate: (event: RTCIceCandidate) => void;
onIceConnectionStateException: (exceptionName: ExceptionEventName, message: string, data?: any) => void;
iceServers: RTCIceServer[] | undefined;
mediaStream?: MediaStream;
mode?: 'sendonly' | 'recvonly' | 'sendrecv';
@ -64,7 +64,7 @@ export class WebRtcPeer {
this.pc.addEventListener('icecandidate', (event: RTCPeerConnectionIceEvent) => {
if (event.candidate != null) {
const candidate: RTCIceCandidate = event.candidate;
this.configuration.onicecandidate(candidate);
this.configuration.onIceCandidate(candidate);
if (candidate.candidate !== '') {
this.localCandidatesQueue.push(<RTCIceCandidate>{ candidate: candidate.candidate });
}
@ -326,12 +326,12 @@ export class WebRtcPeer {
// Possible network disconnection
const msg1 = 'IceConnectionState of RTCPeerConnection ' + this.id + ' (' + otherId + ') change to "disconnected". Possible network disconnection';
logger.warn(msg1);
this.configuration.onexception(ExceptionEventName.ICE_CONNECTION_DISCONNECTED, msg1);
this.configuration.onIceConnectionStateException(ExceptionEventName.ICE_CONNECTION_DISCONNECTED, msg1);
break;
case 'failed':
const msg2 = 'IceConnectionState of RTCPeerConnection ' + this.id + ' (' + otherId + ') to "failed"';
logger.error(msg2);
this.configuration.onexception(ExceptionEventName.ICE_CONNECTION_FAILED, msg2);
this.configuration.onIceConnectionStateException(ExceptionEventName.ICE_CONNECTION_FAILED, msg2);
break;
case 'closed':
logger.log('IceConnectionState of RTCPeerConnection ' + this.id + ' (' + otherId + ') change to "closed"');