Skip to content

Commit

Permalink
Merge pull request #1685 from SimonBrandner/fix/12652/screen-share
Browse files Browse the repository at this point in the history
Support for screen-sharing using multi-stream VoIP (MSC3077)
  • Loading branch information
dbkr committed Jul 27, 2021
2 parents c5e113d + 019abc7 commit a69d9a9
Show file tree
Hide file tree
Showing 3 changed files with 410 additions and 92 deletions.
62 changes: 62 additions & 0 deletions spec/unit/webrtc/call.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.

import { TestClient } from '../../TestClient';
import { MatrixCall, CallErrorCode, CallEvent } from '../../../src/webrtc/call';
import { SDPStreamMetadataKey, SDPStreamMetadataPurpose } from '../../../src/webrtc/callEventTypes';

const DUMMY_SDP = (
"v=0\r\n" +
Expand Down Expand Up @@ -298,4 +299,65 @@ describe('Call', function() {
// Hangup to stop timers
call.hangup(CallErrorCode.UserHangup, true);
});

it("should map SDPStreamMetadata to feeds", async () => {
const callPromise = call.placeVoiceCall();
await client.httpBackend.flush();
await callPromise;

call.getOpponentMember = () => {
return { userId: "@bob:bar.uk" };
};

await call.onAnswerReceived({
getContent: () => {
return {
version: 1,
call_id: call.callId,
party_id: 'party_id',
answer: {
sdp: DUMMY_SDP,
},
[SDPStreamMetadataKey]: {
"stream_id": {
purpose: SDPStreamMetadataPurpose.Usermedia,
},
},
};
},
});

call.pushRemoteFeed({ id: "stream_id" });
expect(call.getFeeds().find((feed) => {
return feed.stream.id === "stream_id";
})?.purpose).toBe(SDPStreamMetadataPurpose.Usermedia);
});

it("should fallback to replaceTrack() if the other side doesn't support SPDStreamMetadata", async () => {
const callPromise = call.placeVoiceCall();
await client.httpBackend.flush();
await callPromise;

call.getOpponentMember = () => {
return { userId: "@bob:bar.uk" };
};

await call.onAnswerReceived({
getContent: () => {
return {
version: 1,
call_id: call.callId,
party_id: 'party_id',
answer: {
sdp: DUMMY_SDP,
},
};
},
});

call.setScreensharingEnabledWithoutMetadataSupport = jest.fn();

call.setScreensharingEnabled(true);
expect(call.setScreensharingEnabledWithoutMetadataSupport).toHaveBeenCalled();
});
});
Loading

0 comments on commit a69d9a9

Please sign in to comment.