forked from mystiq/hydrogen-web
more WIP
This commit is contained in:
parent
382fba88bd
commit
c42292f1b0
2 changed files with 21 additions and 7 deletions
|
@ -164,7 +164,7 @@ export class PeerCall implements IDisposable {
|
||||||
}
|
}
|
||||||
this.direction = CallDirection.Outbound;
|
this.direction = CallDirection.Outbound;
|
||||||
this.setState(CallState.CreateOffer, log);
|
this.setState(CallState.CreateOffer, log);
|
||||||
this.updateLocalMedia(localMedia, log);
|
await this.updateLocalMedia(localMedia, log);
|
||||||
if (this.localMedia?.dataChannelOptions) {
|
if (this.localMedia?.dataChannelOptions) {
|
||||||
this._dataChannel = this.peerConnection.createDataChannel(this.localMedia.dataChannelOptions);
|
this._dataChannel = this.peerConnection.createDataChannel(this.localMedia.dataChannelOptions);
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ export class PeerCall implements IDisposable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setState(CallState.CreateAnswer, log);
|
this.setState(CallState.CreateAnswer, log);
|
||||||
this.updateLocalMedia(localMedia, log);
|
await this.updateLocalMedia(localMedia, log);
|
||||||
let myAnswer: RTCSessionDescriptionInit;
|
let myAnswer: RTCSessionDescriptionInit;
|
||||||
try {
|
try {
|
||||||
myAnswer = await this.peerConnection.createAnswer();
|
myAnswer = await this.peerConnection.createAnswer();
|
||||||
|
@ -220,6 +220,9 @@ export class PeerCall implements IDisposable {
|
||||||
|
|
||||||
const oldMetaData = this.getSDPMetadata();
|
const oldMetaData = this.getSDPMetadata();
|
||||||
const willRenegotiate = await this.updateLocalMedia(localMedia, log);
|
const willRenegotiate = await this.updateLocalMedia(localMedia, log);
|
||||||
|
// TODO: if we will renegotiate, we don't bother sending the metadata changed event
|
||||||
|
// because the renegotiate event will send new metadata anyway, but is that the right
|
||||||
|
// call?
|
||||||
if (!willRenegotiate) {
|
if (!willRenegotiate) {
|
||||||
const newMetaData = this.getSDPMetadata();
|
const newMetaData = this.getSDPMetadata();
|
||||||
if (JSON.stringify(oldMetaData) !== JSON.stringify(newMetaData)) {
|
if (JSON.stringify(oldMetaData) !== JSON.stringify(newMetaData)) {
|
||||||
|
@ -229,7 +232,7 @@ export class PeerCall implements IDisposable {
|
||||||
seq: this.seq++,
|
seq: this.seq++,
|
||||||
[SDPStreamMetadataKey]: newMetaData
|
[SDPStreamMetadataKey]: newMetaData
|
||||||
};
|
};
|
||||||
await this.sendSignallingMessage({type: EventType.SDPStreamMetadataChanged, content}, log);
|
await this.sendSignallingMessage({type: EventType.SDPStreamMetadataChangedPrefix, content}, log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -859,7 +862,14 @@ export class PeerCall implements IDisposable {
|
||||||
const oldMedia = this.localMedia;
|
const oldMedia = this.localMedia;
|
||||||
this.localMedia = localMedia;
|
this.localMedia = localMedia;
|
||||||
const applyStream = async (oldStream: Stream | undefined, stream: Stream | undefined, oldMuteSettings: LocalMedia | undefined, mutedSettings: LocalMedia | undefined, logLabel: string) => {
|
const applyStream = async (oldStream: Stream | undefined, stream: Stream | undefined, oldMuteSettings: LocalMedia | undefined, mutedSettings: LocalMedia | undefined, logLabel: string) => {
|
||||||
const streamSender = oldStream ? this.peerConnection.localStreams.get(oldStream.id) : undefined;
|
let streamSender;
|
||||||
|
if (oldStream) {
|
||||||
|
streamSender = this.peerConnection.localStreams.get(oldStream.id);
|
||||||
|
if (stream && stream.id !== oldStream.id) {
|
||||||
|
this.peerConnection.localStreams.set(stream.id, streamSender);
|
||||||
|
this.peerConnection.localStreams.delete(oldStream.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const applyTrack = async (oldTrack: Track | undefined, sender: TrackSender | undefined, track: Track | undefined, wasMuted: boolean | undefined, muted: boolean | undefined) => {
|
const applyTrack = async (oldTrack: Track | undefined, sender: TrackSender | undefined, track: Track | undefined, wasMuted: boolean | undefined, muted: boolean | undefined) => {
|
||||||
const changed = (!track && oldTrack) ||
|
const changed = (!track && oldTrack) ||
|
||||||
|
@ -899,11 +909,13 @@ export class PeerCall implements IDisposable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (track) {
|
} else if (track) {
|
||||||
console.log({muted, wasMuted, wasCameraMuted: oldMedia?.cameraMuted});
|
log.log({l: "checking mute status", muted, wasMuted, wasCameraMuted: oldMedia?.cameraMuted, sender: !!sender, streamSender: !!streamSender, oldStream: oldStream?.id, stream: stream?.id});
|
||||||
if (sender && muted !== wasMuted) {
|
if (sender && muted !== wasMuted) {
|
||||||
// TODO: why does unmuting not work? wasMuted is false
|
// TODO: why does unmuting not work? wasMuted is false
|
||||||
log.wrap(`${logLabel} ${track.kind} ${muted ? "muting" : "unmuting"}`, log => {
|
log.wrap(`${logLabel} ${track.kind} ${muted ? "muting" : "unmuting"}`, log => {
|
||||||
sender.track.enabled = !muted;
|
// sender.track.enabled = !muted;
|
||||||
|
// This doesn't always seem to trigger renegotiation??
|
||||||
|
// We should probably always send the new metadata first ...
|
||||||
sender.enable(!muted);
|
sender.enable(!muted);
|
||||||
willRenegotiate = true;
|
willRenegotiate = true;
|
||||||
});
|
});
|
||||||
|
@ -918,7 +930,7 @@ export class PeerCall implements IDisposable {
|
||||||
}
|
}
|
||||||
|
|
||||||
await applyStream(oldMedia?.userMedia, localMedia?.userMedia, oldMedia, localMedia, "userMedia");
|
await applyStream(oldMedia?.userMedia, localMedia?.userMedia, oldMedia, localMedia, "userMedia");
|
||||||
applyStream(oldMedia?.screenShare, localMedia?.screenShare, undefined, undefined, "screenShare");
|
await applyStream(oldMedia?.screenShare, localMedia?.screenShare, undefined, undefined, "screenShare");
|
||||||
return willRenegotiate;
|
return willRenegotiate;
|
||||||
// TODO: datachannel, but don't do it here as we don't want to do it from answer, rather in different method
|
// TODO: datachannel, but don't do it here as we don't want to do it from answer, rather in different method
|
||||||
});
|
});
|
||||||
|
|
|
@ -154,6 +154,8 @@ export class Member {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
// TODO: remove this for release
|
||||||
|
log.set("payload", groupMessage.content);
|
||||||
const request = this.options.hsApi.sendToDevice(
|
const request = this.options.hsApi.sendToDevice(
|
||||||
message.type,
|
message.type,
|
||||||
//"m.room.encrypted",
|
//"m.room.encrypted",
|
||||||
|
|
Loading…
Reference in a new issue