Skip to content

Commit

Permalink
[mirotalksfu] - add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpejic85 committed Jun 30, 2024
1 parent 93a8773 commit 7199ba2
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 24 deletions.
42 changes: 24 additions & 18 deletions app/src/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,18 @@ module.exports = class Room {
}

async getRTMP(dir = 'rtmp') {
const folderPath = path.join(__dirname, '..', dir);

// Create dir if not exists
if (!fs.existsSync(folderPath)) {
fs.mkdirSync(folderPath, { recursive: true });
}
//
const folderPath = path.join(__dirname, '../', dir);
log.debug('[getRTMP] Files from dir', folderPath);

try {
// Create dir if not exists
if (!fs.existsSync(folderPath)) {
log.debug('[getRTMP] Dir not exist going to create', folderPath);
fs.mkdirSync(folderPath, { recursive: true });
}
const files = fs.readdirSync(folderPath);
log.info('RTMP files', files);
log.info('[getRTMP] Files', files);
return files;
} catch (error) {
log.error(`[getRTMP] Error reading directory: ${error.message}`);
Expand All @@ -119,22 +121,24 @@ module.exports = class Room {

async startRTMP(socket_id, room, host = 'localhost', port = 1935, file = '../rtmp/BigBuckBunny.mp4') {
if (!this.rtmp || !this.rtmp.enabled) {
log.debug('RTMP server is not enabled or missing the config');
log.debug('[startRTMP] Server is not enabled or missing the config');
return false;
}

if (this.rtmpFileStreamer) {
log.debug('RtmpFile is already in progress');
log.debug('[startRTMP] Already in progress');
return false;
}

const inputFilePath = path.join(__dirname, file);

if (!fs.existsSync(inputFilePath)) {
log.error(`File not found: ${inputFilePath}`);
log.error(`[startRTMP] File not found: ${inputFilePath}`);
return false;
}

log.debug('[startRTMP] Read all stream from file', inputFilePath);

this.rtmpFileStreamer = new RtmpFile(socket_id, room);

const inputStream = fs.createReadStream(inputFilePath);
Expand All @@ -152,16 +156,16 @@ module.exports = class Room {

stopRTMP() {
if (!this.rtmp || !this.rtmp.enabled) {
log.debug('RTMP server is not enabled or missing the config');
log.debug('[stopRTMP] Server is not enabled or missing the config');
return false;
}
if (this.rtmpFileStreamer) {
this.rtmpFileStreamer.stop();
this.rtmpFileStreamer = null;
log.debug('RTMP File Streamer Stopped successfully!');
log.debug('[stopRTMP] Streamer Stopped successfully!');
return true;
} else {
log.debug('No RtmpFile process to stop');
log.debug('[stopRTMP] No process to stop');
return false;
}
}
Expand All @@ -182,15 +186,17 @@ module.exports = class Room {
inputVideoURL = 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
) {
if (!this.rtmp || !this.rtmp.enabled) {
log.debug('RTMP server is not enabled or missing the config');
log.debug('[startRTMPfromURL] Server is not enabled or missing the config');
return false;
}

if (this.rtmpUrlStreamer) {
log.debug('RtmpFile is already in progress');
log.debug('[startRTMPfromURL] Already in progress');
return false;
}

log.debug('[startRTMPfromURL] Input video URL', inputVideoURL);

this.rtmpUrlStreamer = new RtmpUrl(socket_id, room);

const rtmpUrl = this.getRTMPUrl(host, port);
Expand All @@ -206,16 +212,16 @@ module.exports = class Room {

stopRTMPfromURL() {
if (!this.rtmp || !this.rtmp.enabled) {
log.debug('RTMP server is not enabled or missing the config');
log.debug('[stopRTMPfromURL] Server is not enabled or missing the config');
return false;
}
if (this.rtmpUrlStreamer) {
this.rtmpUrlStreamer.stop();
this.rtmpUrlStreamer = null;
log.debug('RTMP Url Streamer Stopped successfully!');
log.debug('[stopRTMPfromURL] Streamer Stopped successfully!');
return true;
} else {
log.debug('No RtmpUrl process to stop');
log.debug('[stopRTMPfromURL] No process to stop');
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/RtmpFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class RtmpFile {
/* log.debug('Processing', progress); */
})
.on('error', (err, stdout, stderr) => {
log.debug('Error: ' + err.message);
this.ffmpegProcess = null;
if (!err.message.includes('Exiting normally')) {
log.error('Error: ' + err.message);
this.handleError(err.message);
}
})
Expand Down
2 changes: 1 addition & 1 deletion app/src/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies: {
* @license For commercial or closed source, contact us at [email protected] or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - [email protected]
* @version 1.4.71
* @version 1.4.72
*
*/

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mirotalksfu",
"version": "1.4.71",
"version": "1.4.72",
"description": "WebRTC SFU browser-based video calls",
"main": "Server.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions public/js/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - [email protected]
* @version 1.4.71
* @version 1.4.72
*
*/

Expand Down Expand Up @@ -4032,7 +4032,7 @@ function showAbout() {
imageUrl: image.about,
customClass: { image: 'img-about' },
position: 'center',
title: 'WebRTC SFU 1.4.71',
title: 'WebRTC SFU 1.4.72',
html: `
<br />
<div id="about">
Expand Down
2 changes: 1 addition & 1 deletion public/js/RoomClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license For commercial or closed source, contact us at [email protected] or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - [email protected]
* @version 1.4.71
* @version 1.4.72
*
*/

Expand Down

0 comments on commit 7199ba2

Please sign in to comment.