1 |
efrain |
1 |
// This file is part of Moodle - http://moodle.org/
|
|
|
2 |
//
|
|
|
3 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
4 |
// it under the terms of the GNU General Public License as published by
|
|
|
5 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
6 |
// (at your option) any later version.
|
|
|
7 |
//
|
|
|
8 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
9 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
10 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
11 |
// GNU General Public License for more details.
|
|
|
12 |
//
|
|
|
13 |
// You should have received a copy of the GNU General Public License
|
|
|
14 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
15 |
|
|
|
16 |
/**
|
|
|
17 |
* Tiny Record RTC - Video recorder configuration.
|
|
|
18 |
*
|
|
|
19 |
* @module tiny_recordrtc/video_recorder
|
|
|
20 |
* @copyright 2022 Stevani Andolo <stevani@hotmail.com.au>
|
|
|
21 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
22 |
*/
|
|
|
23 |
|
|
|
24 |
import BaseClass from './base_recorder';
|
|
|
25 |
import Modal from 'tiny_recordrtc/modal';
|
|
|
26 |
import {component} from 'tiny_recordrtc/common';
|
|
|
27 |
|
|
|
28 |
export default class Video extends BaseClass {
|
|
|
29 |
configurePlayer() {
|
|
|
30 |
return this.modalRoot.querySelector('video');
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
getSupportedTypes() {
|
|
|
34 |
return [
|
|
|
35 |
// Support webm as a preference.
|
|
|
36 |
// This container supports both vp9, and vp8.
|
|
|
37 |
// It does not support AVC1/h264 at all.
|
|
|
38 |
// It is supported by Chromium, and Firefox browsers, but not Safari.
|
|
|
39 |
'video/webm;codecs=vp9,opus',
|
|
|
40 |
'video/webm;codecs=vp8,opus',
|
|
|
41 |
|
|
|
42 |
// Fall back to mp4 if webm is not available.
|
|
|
43 |
// The mp4 container supports v9, and h264 but neither of these are supported for recording on other
|
|
|
44 |
// browsers.
|
|
|
45 |
// In addition to this, we can record in v9, but VideoJS does not support an mp4 containern with v9 codec
|
|
|
46 |
// for playback. We leave it as a final option as a just-in-case.
|
|
|
47 |
'video/mp4;codecs=h264,opus',
|
|
|
48 |
'video/mp4;codecs=h264,wav',
|
|
|
49 |
'video/mp4;codecs=v9,opus',
|
|
|
50 |
];
|
|
|
51 |
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
getRecordingOptions() {
|
|
|
55 |
return {
|
|
|
56 |
audioBitsPerSecond: parseInt(this.config.audiobitrate),
|
|
|
57 |
videoBitsPerSecond: parseInt(this.config.videobitrate)
|
|
|
58 |
};
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
getMediaConstraints() {
|
|
|
62 |
return {
|
|
|
63 |
audio: true,
|
|
|
64 |
video: {
|
|
|
65 |
width: {
|
|
|
66 |
ideal: 640,
|
|
|
67 |
},
|
|
|
68 |
height: {
|
|
|
69 |
ideal: 480,
|
|
|
70 |
},
|
|
|
71 |
},
|
|
|
72 |
};
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
playOnCapture() {
|
|
|
76 |
// Play the recording back on capture.
|
|
|
77 |
return true;
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
getRecordingType() {
|
|
|
81 |
return 'video';
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
getTimeLimit() {
|
|
|
85 |
return this.config.videotimelimit;
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
getEmbedTemplateName() {
|
|
|
89 |
return 'tiny_recordrtc/embed_video';
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
getFileName(prefix) {
|
|
|
93 |
return `${prefix}-video.${this.getFileExtension()}`;
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
getFileExtension() {
|
|
|
97 |
if (window.MediaRecorder.isTypeSupported('audio/webm')) {
|
|
|
98 |
return 'webm';
|
|
|
99 |
} else if (window.MediaRecorder.isTypeSupported('audio/mp4')) {
|
|
|
100 |
return 'mp4';
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
window.console.warn(`Unknown file type for MediaRecorder API`);
|
|
|
104 |
return '';
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
static getModalClass() {
|
|
|
108 |
return class extends Modal {
|
|
|
109 |
static TYPE = `${component}/video_recorder`;
|
|
|
110 |
static TEMPLATE = `${component}/video_recorder`;
|
|
|
111 |
};
|
|
|
112 |
}
|
|
|
113 |
}
|