You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-06 12:02:40 +03:00
@@ -56,9 +56,6 @@ export const DUMMY_SDP = (
|
|||||||
"a=ssrc:3619738545 cname:2RWtmqhXLdoF4sOi\r\n"
|
"a=ssrc:3619738545 cname:2RWtmqhXLdoF4sOi\r\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
export const USERMEDIA_STREAM_ID = "mock_stream_from_media_handler";
|
|
||||||
export const SCREENSHARE_STREAM_ID = "mock_screen_stream_from_media_handler";
|
|
||||||
|
|
||||||
class MockMediaStreamAudioSourceNode {
|
class MockMediaStreamAudioSourceNode {
|
||||||
connect() {}
|
connect() {}
|
||||||
}
|
}
|
||||||
@@ -131,10 +128,6 @@ export class MockRTCPeerConnection {
|
|||||||
return new MockRTCRtpSender(track);
|
return new MockRTCRtpSender(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeTrack() {
|
|
||||||
this.needsNegotiation = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
doNegotiation() {
|
doNegotiation() {
|
||||||
if (this.needsNegotiation && this.negotiationNeededListener) {
|
if (this.needsNegotiation && this.negotiationNeededListener) {
|
||||||
this.needsNegotiation = false;
|
this.needsNegotiation = false;
|
||||||
@@ -229,7 +222,7 @@ export class MockMediaHandler {
|
|||||||
if (audio) tracks.push(new MockMediaStreamTrack("audio_track", "audio"));
|
if (audio) tracks.push(new MockMediaStreamTrack("audio_track", "audio"));
|
||||||
if (video) tracks.push(new MockMediaStreamTrack("video_track", "video"));
|
if (video) tracks.push(new MockMediaStreamTrack("video_track", "video"));
|
||||||
|
|
||||||
const stream = new MockMediaStream(USERMEDIA_STREAM_ID, tracks);
|
const stream = new MockMediaStream("mock_stream_from_media_handler", tracks);
|
||||||
this.userMediaStreams.push(stream);
|
this.userMediaStreams.push(stream);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
@@ -240,7 +233,7 @@ export class MockMediaHandler {
|
|||||||
const tracks = [new MockMediaStreamTrack("video_track", "video")];
|
const tracks = [new MockMediaStreamTrack("video_track", "video")];
|
||||||
if (opts?.audio) tracks.push(new MockMediaStreamTrack("audio_track", "audio"));
|
if (opts?.audio) tracks.push(new MockMediaStreamTrack("audio_track", "audio"));
|
||||||
|
|
||||||
const stream = new MockMediaStream(SCREENSHARE_STREAM_ID, tracks);
|
const stream = new MockMediaStream("mock_screen_stream_from_media_handler", tracks);
|
||||||
this.screensharingStreams.push(stream);
|
this.screensharingStreams.push(stream);
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
@@ -30,8 +30,6 @@ import {
|
|||||||
MockMediaStream,
|
MockMediaStream,
|
||||||
MockMediaStreamTrack,
|
MockMediaStreamTrack,
|
||||||
installWebRTCMocks,
|
installWebRTCMocks,
|
||||||
MockRTCPeerConnection,
|
|
||||||
SCREENSHARE_STREAM_ID,
|
|
||||||
} from "../../test-utils/webrtc";
|
} from "../../test-utils/webrtc";
|
||||||
import { CallFeed } from "../../../src/webrtc/callFeed";
|
import { CallFeed } from "../../../src/webrtc/callFeed";
|
||||||
import { EventType, MatrixEvent } from "../../../src";
|
import { EventType, MatrixEvent } from "../../../src";
|
||||||
@@ -943,84 +941,4 @@ describe('Call', function() {
|
|||||||
|
|
||||||
expect(call.state).toEqual(CallState.Ended);
|
expect(call.state).toEqual(CallState.Ended);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("Screen sharing", () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
await startVoiceCall(client, call);
|
|
||||||
|
|
||||||
await call.onAnswerReceived({
|
|
||||||
getContent: () => {
|
|
||||||
return {
|
|
||||||
"version": 1,
|
|
||||||
"call_id": call.callId,
|
|
||||||
"party_id": 'party_id',
|
|
||||||
"answer": {
|
|
||||||
sdp: DUMMY_SDP,
|
|
||||||
},
|
|
||||||
"org.matrix.msc3077.sdp_stream_metadata": {
|
|
||||||
"foo": {
|
|
||||||
"purpose": "m.usermedia",
|
|
||||||
"audio_muted": false,
|
|
||||||
"video_muted": false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
getSender: () => "@test:foo",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
// Hangup to stop timers
|
|
||||||
call.hangup(CallErrorCode.UserHangup, true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("enables screensharing", async () => {
|
|
||||||
await call.setScreensharingEnabled(true);
|
|
||||||
|
|
||||||
expect(call.feeds.filter(f => f.purpose == SDPStreamMetadataPurpose.Screenshare).length).toEqual(1);
|
|
||||||
|
|
||||||
client.client.sendEvent.mockReset();
|
|
||||||
const sendNegotiatePromise = new Promise<void>(resolve => {
|
|
||||||
client.client.sendEvent.mockImplementation(() => {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
MockRTCPeerConnection.triggerAllNegotiations();
|
|
||||||
await sendNegotiatePromise;
|
|
||||||
|
|
||||||
expect(client.client.sendEvent).toHaveBeenCalledWith(
|
|
||||||
FAKE_ROOM_ID,
|
|
||||||
EventType.CallNegotiate,
|
|
||||||
expect.objectContaining({
|
|
||||||
"version": "1",
|
|
||||||
"call_id": call.callId,
|
|
||||||
"org.matrix.msc3077.sdp_stream_metadata": expect.objectContaining({
|
|
||||||
[SCREENSHARE_STREAM_ID]: expect.objectContaining({
|
|
||||||
purpose: SDPStreamMetadataPurpose.Screenshare,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("disables screensharing", async () => {
|
|
||||||
await call.setScreensharingEnabled(true);
|
|
||||||
|
|
||||||
client.client.sendEvent.mockReset();
|
|
||||||
const sendNegotiatePromise = new Promise<void>(resolve => {
|
|
||||||
client.client.sendEvent.mockImplementation(() => {
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
MockRTCPeerConnection.triggerAllNegotiations();
|
|
||||||
await sendNegotiatePromise;
|
|
||||||
|
|
||||||
await call.setScreensharingEnabled(false);
|
|
||||||
|
|
||||||
expect(call.feeds.filter(f => f.purpose == SDPStreamMetadataPurpose.Screenshare).length).toEqual(0);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user