You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Merge pull request #1929 from matrix-org/robertlong/datachannels
Add WebRTC DataChannels to MatrixCall
This commit is contained in:
@@ -128,7 +128,9 @@ export enum CallEvent {
|
|||||||
|
|
||||||
AssertedIdentityChanged = 'asserted_identity_changed',
|
AssertedIdentityChanged = 'asserted_identity_changed',
|
||||||
|
|
||||||
LengthChanged = 'length_changed'
|
LengthChanged = 'length_changed',
|
||||||
|
|
||||||
|
DataChannel = 'datachannel',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum CallErrorCode {
|
export enum CallErrorCode {
|
||||||
@@ -342,6 +344,18 @@ export class MatrixCall extends EventEmitter {
|
|||||||
await this.placeCall(true, true);
|
await this.placeCall(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a datachannel using this call's peer connection.
|
||||||
|
* @param label A human readable label for this datachannel
|
||||||
|
* @param options An object providing configuration options for the data channel.
|
||||||
|
*/
|
||||||
|
public createDataChannel(label: string, options: RTCDataChannelInit) {
|
||||||
|
const dataChannel = this.peerConn.createDataChannel(label, options);
|
||||||
|
this.emit(CallEvent.DataChannel, dataChannel);
|
||||||
|
logger.debug("created data channel");
|
||||||
|
return dataChannel;
|
||||||
|
}
|
||||||
|
|
||||||
public getOpponentMember(): RoomMember {
|
public getOpponentMember(): RoomMember {
|
||||||
return this.opponentMember;
|
return this.opponentMember;
|
||||||
}
|
}
|
||||||
@@ -1495,6 +1509,10 @@ export class MatrixCall extends EventEmitter {
|
|||||||
stream.addEventListener("removetrack", () => this.deleteFeedByStream(stream));
|
stream.addEventListener("removetrack", () => this.deleteFeedByStream(stream));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private onDataChannel = (ev: RTCDataChannelEvent): void => {
|
||||||
|
this.emit(CallEvent.DataChannel, ev.channel);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method removes all video/rtx codecs from screensharing video
|
* This method removes all video/rtx codecs from screensharing video
|
||||||
* transceivers. This is necessary since they can cause problems. Without
|
* transceivers. This is necessary since they can cause problems. Without
|
||||||
@@ -1866,6 +1884,7 @@ export class MatrixCall extends EventEmitter {
|
|||||||
pc.addEventListener('icegatheringstatechange', this.onIceGatheringStateChange);
|
pc.addEventListener('icegatheringstatechange', this.onIceGatheringStateChange);
|
||||||
pc.addEventListener('track', this.onTrack);
|
pc.addEventListener('track', this.onTrack);
|
||||||
pc.addEventListener('negotiationneeded', this.onNegotiationNeeded);
|
pc.addEventListener('negotiationneeded', this.onNegotiationNeeded);
|
||||||
|
pc.addEventListener('datachannel', this.onDataChannel);
|
||||||
|
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user