-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(RTC): add additional checks for creating tracks via mediastream
- Loading branch information
1 parent
18de315
commit 83f98f9
Showing
3 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import JitsiMeetJS from './JitsiMeetJS'; | ||
import { VideoType } from './service/RTC/VideoType'; | ||
import { MediaType } from './service/RTC/MediaType'; | ||
import { JitsiTrackErrors } from './JitsiTrackErrors'; | ||
|
||
describe('JitsiMeetJS', () => { | ||
describe('createLocalTracksFromMediaStreams', () => { | ||
it('creates a local track from a media stream', () => { | ||
const canvas = document.createElement('canvas'); | ||
|
||
const canvasStream = canvas.captureStream(5); | ||
const trackInfo = { | ||
stream: canvasStream, | ||
sourceType: 'canvas', | ||
mediaType: MediaType.VIDEO, | ||
track: canvasStream.getVideoTracks()[0], | ||
videoType: VideoType.DESKTOP | ||
}; | ||
const newTracks = JitsiMeetJS.createLocalTracksFromMediaStreams([ trackInfo ]); | ||
|
||
expect(newTracks).toBeDefined(); | ||
expect(newTracks.length).toBe(1); | ||
}); | ||
|
||
it('throws an error if track is not from the same stream', () => { | ||
const canvas = document.createElement('canvas'); | ||
const otherCanvas = document.createElement('canvas'); | ||
|
||
const canvasStream = canvas.captureStream(5); | ||
const otherCanvasStream = otherCanvas.captureStream(5); | ||
const trackInfo = { | ||
stream: canvasStream, | ||
sourceType: 'canvas', | ||
mediaType: MediaType.VIDEO, | ||
track: otherCanvasStream.getVideoTracks()[0], | ||
videoType: VideoType.DESKTOP | ||
}; | ||
|
||
expect(() => JitsiMeetJS.createLocalTracksFromMediaStreams([ trackInfo ])) | ||
.toThrowError(JitsiTrackErrors.TRACK_MISMATCHED_STREAM); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters