|
@@ -9,7 +9,6 @@ import {
|
9
|
9
|
import { _handleParticipantError } from '../base/conference';
|
10
|
10
|
import { MEDIA_TYPE } from '../base/media';
|
11
|
11
|
import { getParticipants } from '../base/participants';
|
12
|
|
-import { getTrackByMediaTypeAndParticipant } from '../base/tracks';
|
13
|
12
|
import { reportError } from '../base/util';
|
14
|
13
|
import { shouldDisplayTileView } from '../video-layout';
|
15
|
14
|
|
|
@@ -18,57 +17,6 @@ import {
|
18
|
17
|
UPDATE_KNOWN_LARGE_VIDEO_RESOLUTION
|
19
|
18
|
} from './actionTypes';
|
20
|
19
|
|
21
|
|
-/**
|
22
|
|
-* Captures a screenshot of the video displayed on the large video.
|
23
|
|
-*
|
24
|
|
-* @returns {Function}
|
25
|
|
-*/
|
26
|
|
-export function captureLargeVideoScreenshot() {
|
27
|
|
- return (dispatch: Dispatch<any>, getState: Function): Promise<Object> => {
|
28
|
|
- const state = getState();
|
29
|
|
- const largeVideo = state['features/large-video'];
|
30
|
|
-
|
31
|
|
- if (!largeVideo) {
|
32
|
|
- return Promise.resolve();
|
33
|
|
- }
|
34
|
|
- const tracks = state['features/base/tracks'];
|
35
|
|
- const { jitsiTrack } = getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.VIDEO, largeVideo.participantId);
|
36
|
|
- const videoStream = jitsiTrack.getOriginalStream();
|
37
|
|
-
|
38
|
|
- // Create a HTML canvas and draw video from the track on to the canvas.
|
39
|
|
- const [ track ] = videoStream.getVideoTracks();
|
40
|
|
- const { height, width } = track.getSettings() ?? track.getConstraints();
|
41
|
|
- const canvasElement = document.createElement('canvas');
|
42
|
|
- const ctx = canvasElement.getContext('2d');
|
43
|
|
- const videoElement = document.createElement('video');
|
44
|
|
-
|
45
|
|
- videoElement.height = parseInt(height, 10);
|
46
|
|
- videoElement.width = parseInt(width, 10);
|
47
|
|
- videoElement.autoplay = true;
|
48
|
|
- videoElement.srcObject = videoStream;
|
49
|
|
- canvasElement.height = videoElement.height;
|
50
|
|
- canvasElement.width = videoElement.width;
|
51
|
|
-
|
52
|
|
- // Wait for the video to load before drawing on to the canvas.
|
53
|
|
- const promise = new Promise(resolve => {
|
54
|
|
- videoElement.onloadeddata = () => resolve();
|
55
|
|
- });
|
56
|
|
-
|
57
|
|
- return promise.then(() => {
|
58
|
|
- ctx.drawImage(videoElement, 0, 0, videoElement.width, videoElement.height);
|
59
|
|
- const dataURL = canvasElement.toDataURL('image/png', 1.0);
|
60
|
|
-
|
61
|
|
- // Cleanup.
|
62
|
|
- ctx.clearRect(0, 0, videoElement.width, videoElement.height);
|
63
|
|
- videoElement.srcObject = null;
|
64
|
|
- canvasElement.remove();
|
65
|
|
- videoElement.remove();
|
66
|
|
-
|
67
|
|
- return Promise.resolve(dataURL);
|
68
|
|
- });
|
69
|
|
- };
|
70
|
|
-}
|
71
|
|
-
|
72
|
20
|
/**
|
73
|
21
|
* Signals conference to select a participant.
|
74
|
22
|
*
|