[mirotalksfu] - add upload to s3 recording

هذا الالتزام موجود في:
Miroslav Pejic
2025-04-23 21:57:23 +02:00
الأصل 3510929589
التزام 7827c56759
9 ملفات معدلة مع 313 إضافات و66 حذوفات

عرض الملف

@@ -64,7 +64,7 @@ let BRAND = {
},
about: {
imageUrl: '../images/mirotalk-logo.gif',
title: '<strong>WebRTC SFU v1.8.25</strong>',
title: '<strong>WebRTC SFU v1.8.26</strong>',
html: `
<button
id="support-button"

عرض الملف

@@ -11,7 +11,7 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.8.25
* @version 1.8.26
*
*/
@@ -5351,7 +5351,7 @@ function showAbout() {
position: 'center',
imageUrl: BRAND.about?.imageUrl && BRAND.about.imageUrl.trim() !== '' ? BRAND.about.imageUrl : image.about,
customClass: { image: 'img-about' },
title: BRAND.about?.title && BRAND.about.title.trim() !== '' ? BRAND.about.title : 'WebRTC SFU v1.8.25',
title: BRAND.about?.title && BRAND.about.title.trim() !== '' ? BRAND.about.title : 'WebRTC SFU v1.8.26',
html: `
<br />
<div id="about">

عرض الملف

@@ -9,7 +9,7 @@
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.8.25
* @version 1.8.26
*
*/
@@ -373,6 +373,7 @@ class RoomClient {
this.recScreenStream = null;
this.recording = {
recSyncServerRecording: false,
recSyncServerToS3: false,
recSyncServerEndpoint: '',
};
this.recSyncTime = 4000; // 4 sec
@@ -6198,10 +6199,17 @@ class RoomClient {
}
}
generateUUIDv4() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16),
);
}
getServerRecFileName() {
const dateTime = getDataTimeStringFormat();
const roomName = this.room_id.trim();
return `Rec_${roomName}_${dateTime}.webm`;
const dateTime = getDataTimeStringFormat();
const uuid = this.generateUUIDv4();
return `Rec_${roomName}_${dateTime}_${uuid}.webm`;
}
handleMediaRecorderStart(evt) {
@@ -6218,6 +6226,8 @@ class RoomClient {
}
async syncRecordingInCloud(data) {
if (!this._isRecording) return;
const arrayBuffer = await data.arrayBuffer();
const chunkSize = rc.recSyncChunkSize;
const totalChunks = Math.ceil(arrayBuffer.byteLength / chunkSize);
@@ -6256,11 +6266,35 @@ class RoomClient {
}
}
handleMediaRecorderStop(evt) {
async handleMediaRecorderStop(evt) {
try {
console.log('MediaRecorder stopped: ', evt);
rc.recording.recSyncServerRecording ? rc.handleServerRecordingStop() : rc.handleLocalRecordingStop();
rc.disableRecordingOptions(false);
// Only do this if cloud sync was enabled and upload to s3
if (rc.recording.recSyncServerRecording && rc.recording.recSyncServerToS3) {
try {
const response = await axios.post(
`${rc.recording.recSyncServerEndpoint}/recSyncFinalize?fileName=` + rc.recServerFileName,
);
console.log('Finalized and uploaded to S3:', response.data);
userLog('success', 'Recording successfully uploaded to S3.', 'top-end', 3000);
} catch (error) {
let errorMessage = 'Finalization failed! ';
if (error.response) {
errorMessage += error.response.data?.message || 'Server error';
console.error('Finalization error response:', error.response);
} else if (error.request) {
errorMessage += 'No response from server';
console.error('Finalization error: No response', error.request);
} else {
errorMessage += error.message;
console.error('Finalization error:', error.message);
}
userLog('warning', errorMessage, 'top-end', 3000);
}
}
} catch (err) {
console.error('Recording save failed', err);
}