Skip to content

Commit

Permalink
[mirotalksfu] - improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpejic85 committed Jul 1, 2024
1 parent 6437b81 commit 47e2c4a
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 11 deletions.
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.73
* @version 1.4.74
*
*/

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.73",
"version": "1.4.74",
"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.73
* @version 1.4.74
*
*/

Expand Down Expand Up @@ -4032,7 +4032,7 @@ function showAbout() {
imageUrl: image.about,
customClass: { image: 'img-about' },
position: 'center',
title: 'WebRTC SFU v1.4.73',
title: 'WebRTC SFU v1.4.74',
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.73
* @version 1.4.74
*
*/

Expand Down
26 changes: 23 additions & 3 deletions public/js/RtmpStreamer.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,23 @@ function showError(message) {
showPopup(message, 'error');
}

function isChromeBased() {
const parser = new UAParser();
const browser = parser.getBrowser();
const browserName = browser.name.toLowerCase();

// List of known Chrome-based browser names
const chromeBasedBrowsers = ['chrome', 'chromium', 'opera', 'edge', 'brave', 'samsung internet'];

return chromeBasedBrowsers.includes(browserName);
}

function checkBrowserSupport() {
const userAgent = navigator.userAgent.toLowerCase();

console.log('UserAgent', userAgent);

if (userAgent.includes('chrome') && !userAgent.includes('edge') && !userAgent.includes('opr')) {
if (isChromeBased()) {
console.log('Browser is Chrome-based. Proceed with functionality.');
} else {
toggleButtons(true);
Expand Down Expand Up @@ -85,7 +96,7 @@ window.onload = function () {
async function startCapture(constraints) {
try {
const stream = await navigator.mediaDevices.getUserMedia(constraints);
videoElement.srcObject = stream;
attachMediaStream(stream);
return stream;
} catch (err) {
console.error('Error accessing media devices.', err);
Expand All @@ -96,14 +107,23 @@ async function startCapture(constraints) {
async function startScreenCapture(constraints) {
try {
const stream = await navigator.mediaDevices.getDisplayMedia(constraints);
videoElement.srcObject = stream;
attachMediaStream(stream);
return stream;
} catch (err) {
console.error('Error accessing screen media.', err);
showError('Error accessing screen sharing. Please try again or check your screen sharing permissions.');
}
}

function attachMediaStream(stream) {
videoElement.srcObject = stream;
videoElement.playsInline = true;
videoElement.autoplay = true;
videoElement.muted = true;
videoElement.volume = 0;
videoElement.controls = false;
}

async function initRTMP(stream) {
const apiSecret = apiSecretInput.value;
try {
Expand Down
7 changes: 5 additions & 2 deletions public/views/RtmpStreamer.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@

<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>

<!-- JS scripts -->
<!-- UAParser -->

<script defer src="https://cdn.jsdelivr.net/npm/ua-parser-js@latest/dist/ua-parser.min.js"></script>

<!-- JS scripts -->
<script defer src="../js/Brand.js"></script>
<script defer src="../js/RtmpStreamer.js"></script>
</head>
Expand Down Expand Up @@ -82,7 +85,7 @@ <h1>MiroTalk RTMP Streamer</h1>
<button id="copy" title="Click to copy the RTMP URL">Copy</button>
</div>

<video id="video" width="640" height="480" autoplay></video>
<video id="video" width="640" height="480"></video>

<div class="button-group">
<button id="startCamera" title="Click to start camera streaming">Start Camera Streaming</button>
Expand Down
2 changes: 2 additions & 0 deletions rtmpServers/node-media-server/docker-compose.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
image: mirotalk/nms:latest
volumes:
- ./src/config.js/:/app/src/config.js/:ro
# - /etc/letsencrypt/live/your-domain-name/fullchain.pem/:/app/src/cert.pem/:ro
# - /etc/letsencrypt/live/your-domain-name/privkey.pem/:/app/src/key.pem/:ro
ports:
- '1935:1935'
- '8081:8081'
Expand Down
2 changes: 1 addition & 1 deletion rtmpServers/node-media-server/src/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function generateRTMPUrl(baseURL, streamPath, secretKey, expirationHours = 8) {
return rtmpUrl;
}

// Example usage
// Example usage (change it for your server setup)
const baseURL = 'rtmp://localhost:1935'; // Rtmp server
const streamKey = uuidv4(); // Generate random stream key
const streamPath = '/live/' + streamKey; // Path/stream-key
Expand Down

0 comments on commit 47e2c4a

Please sign in to comment.