feat: initial release — SRT Streamer v1.0.0
Cross-platform Electron + React + FFmpeg desktop app for sending multiple SRT streams simultaneously. Features: - Multiple simultaneous SRT output streams - Video sources: desktop, window capture, cameras, capture cards - Audio sources: microphones, system loopback, sound cards - H.264 encoding with HW acceleration (NVENC/QSV/AMF/VideoToolbox) - SRT modes: caller / listener / rendezvous - Frame profile presets (4K, 1080p, 720p, 480p, 360p) - Tolbek SRT receiver with configurable mode - System tray: minimize-to-tray, exit confirmation dialog - Portable build via electron-builder Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
# Normalize line endings
|
||||
* text=auto eol=lf
|
||||
*.bat text eol=crlf
|
||||
*.cmd text eol=crlf
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
node_modules/
|
||||
dist/
|
||||
dist-electron/
|
||||
ffmpeg-bin/ffmpeg
|
||||
ffmpeg-bin/ffmpeg.exe
|
||||
ffmpeg-bin/ffprobe
|
||||
ffmpeg-bin/ffprobe.exe
|
||||
assets/icon.png
|
||||
assets/tray-icon.png
|
||||
assets/icon.ico
|
||||
assets/icon.icns
|
||||
@@ -0,0 +1,80 @@
|
||||
# SRT Streamer
|
||||
|
||||
Кроссплатформенное десктопное приложение для отправки нескольких SRT-потоков.
|
||||
|
||||
## Требования
|
||||
|
||||
- **Node.js** 18+ — https://nodejs.org
|
||||
- **FFmpeg с поддержкой SRT** — обязательно
|
||||
|
||||
## Установка
|
||||
|
||||
### Windows
|
||||
|
||||
1. Скачать FFmpeg с SRT: https://github.com/BtbN/FFmpeg-Builds/releases
|
||||
Файл: `ffmpeg-master-latest-win64-gpl.zip`
|
||||
2. Положить `ffmpeg.exe` в папку `ffmpeg-bin\`
|
||||
3. Запустить:
|
||||
```
|
||||
setup.bat
|
||||
```
|
||||
|
||||
### macOS / Linux
|
||||
|
||||
```bash
|
||||
# macOS
|
||||
brew install ffmpeg
|
||||
|
||||
# Linux (Ubuntu/Debian)
|
||||
sudo apt install ffmpeg
|
||||
|
||||
# Затем:
|
||||
chmod +x setup.sh
|
||||
./setup.sh
|
||||
```
|
||||
|
||||
## Запуск
|
||||
|
||||
```bash
|
||||
# Режим разработки
|
||||
npm run dev
|
||||
|
||||
# Собрать портативный .exe (Windows)
|
||||
npm run build:win
|
||||
|
||||
# Собрать для macOS
|
||||
npm run build:mac
|
||||
|
||||
# Собрать AppImage (Linux)
|
||||
npm run build:linux
|
||||
```
|
||||
|
||||
## Возможности
|
||||
|
||||
- Несколько одновременных SRT-потоков
|
||||
- Источники видео: карты захвата, камеры, рабочий стол, захват окна (с опцией скрыть курсор)
|
||||
- Источники аудио: микрофоны, гарнитуры, системный звук (loopback), устройство по умолчанию
|
||||
- Кодировка H.264 с аппаратным ускорением (NVENC / QSV / AMF / VideoToolbox)
|
||||
- SRT режимы: caller / listener / rendezvous
|
||||
- Приёмник Tolbek (входящий SRT-поток)
|
||||
- Сворачивание в трей, выход только через меню трея
|
||||
|
||||
## Структура
|
||||
|
||||
```
|
||||
SRT_stream/
|
||||
├── electron/ — Electron main process
|
||||
│ ├── main.js — Окно, трей, IPC
|
||||
│ ├── preload.js — Bridge renderer ↔ main
|
||||
│ ├── ffmpeg.js — Управление FFmpeg процессами
|
||||
│ └── devices.js — Перечисление устройств
|
||||
├── src/ — React UI
|
||||
│ ├── App.jsx
|
||||
│ └── components/
|
||||
│ ├── StreamCard.jsx
|
||||
│ ├── StreamSettings.jsx
|
||||
│ ├── TolbekSettings.jsx
|
||||
│ └── LogPanel.jsx
|
||||
├── ffmpeg-bin/ — Положить ffmpeg.exe сюда
|
||||
└── assets/ — Иконки
|
||||
```
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Creates minimal placeholder PNG icons without any dependencies.
|
||||
* Run: node assets/create-placeholder-icons.js
|
||||
*/
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
// Minimal valid 16x16 PNG (dark blue background)
|
||||
function createSimplePng(size) {
|
||||
// Use a canvas-like approach with raw PNG data
|
||||
// This creates a simple colored square PNG
|
||||
const { createCanvas } = (() => {
|
||||
try { return require('canvas') } catch { return null }
|
||||
})() || {}
|
||||
|
||||
if (createCanvas) {
|
||||
const canvas = createCanvas(size, size)
|
||||
const ctx = canvas.getContext('2d')
|
||||
|
||||
// Background
|
||||
ctx.fillStyle = '#1a1a2e'
|
||||
const r = size * 0.19
|
||||
ctx.beginPath()
|
||||
ctx.moveTo(r, 0)
|
||||
ctx.lineTo(size - r, 0)
|
||||
ctx.quadraticCurveTo(size, 0, size, r)
|
||||
ctx.lineTo(size, size - r)
|
||||
ctx.quadraticCurveTo(size, size, size - r, size)
|
||||
ctx.lineTo(r, size)
|
||||
ctx.quadraticCurveTo(0, size, 0, size - r)
|
||||
ctx.lineTo(0, r)
|
||||
ctx.quadraticCurveTo(0, 0, r, 0)
|
||||
ctx.closePath()
|
||||
ctx.fill()
|
||||
|
||||
// Play triangle
|
||||
const cx = size / 2, cy = size / 2
|
||||
const s = size * 0.3
|
||||
ctx.fillStyle = '#4f8ef7'
|
||||
ctx.beginPath()
|
||||
ctx.moveTo(cx - s * 0.5, cy - s * 0.6)
|
||||
ctx.lineTo(cx + s * 0.7, cy)
|
||||
ctx.lineTo(cx - s * 0.5, cy + s * 0.6)
|
||||
ctx.closePath()
|
||||
ctx.fill()
|
||||
|
||||
// Red dot
|
||||
ctx.fillStyle = '#ef4444'
|
||||
ctx.beginPath()
|
||||
ctx.arc(size * 0.75, size * 0.25, size * 0.1, 0, Math.PI * 2)
|
||||
ctx.fill()
|
||||
|
||||
return canvas.toBuffer('image/png')
|
||||
}
|
||||
|
||||
// Fallback: minimal 1x1 PNG
|
||||
return Buffer.from(
|
||||
'89504e470d0a1a0a0000000d4948445200000001000000010802000000' +
|
||||
'9001' + '2e00000000c4944415408d7626060600000000200014fd7181000000049454e44ae426082', 'hex'
|
||||
)
|
||||
}
|
||||
|
||||
const sizes = [
|
||||
{ name: 'icon.png', size: 512 },
|
||||
{ name: 'tray-icon.png', size: 32 }
|
||||
]
|
||||
|
||||
for (const { name, size } of sizes) {
|
||||
const buf = createSimplePng(size)
|
||||
fs.writeFileSync(path.join(__dirname, name), buf)
|
||||
console.log(`Created ${name}`)
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Run with: node assets/generate-icons.js
|
||||
* Requires: npm install sharp (dev only)
|
||||
* Generates PNG icons from SVG for all platforms.
|
||||
* If sharp is not available, falls back to copying a placeholder.
|
||||
*/
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
async function generate() {
|
||||
const svgPath = path.join(__dirname, 'icon.svg')
|
||||
const svgData = fs.readFileSync(svgPath)
|
||||
|
||||
try {
|
||||
const sharp = require('sharp')
|
||||
// PNG 512x512
|
||||
await sharp(svgData).resize(512, 512).png().toFile(path.join(__dirname, 'icon.png'))
|
||||
console.log('icon.png generated')
|
||||
|
||||
// Tray icon 32x32
|
||||
await sharp(svgData).resize(32, 32).png().toFile(path.join(__dirname, 'tray-icon.png'))
|
||||
console.log('tray-icon.png generated')
|
||||
|
||||
console.log('Done. For ICO/ICNS, use electron-icon-builder or convert manually.')
|
||||
} catch (e) {
|
||||
console.log('sharp not available, creating placeholder PNG...')
|
||||
// Create a minimal 1x1 placeholder PNG (will work as fallback)
|
||||
const minPng = Buffer.from(
|
||||
'89504e470d0a1a0a0000000d49484452000000010000000108020000009001' +
|
||||
'2e000000000c4944415408d76360f8cfc00000000200017e21bc330000000049454e44ae426082',
|
||||
'hex'
|
||||
)
|
||||
fs.writeFileSync(path.join(__dirname, 'icon.png'), minPng)
|
||||
fs.writeFileSync(path.join(__dirname, 'tray-icon.png'), minPng)
|
||||
console.log('Placeholder icons created.')
|
||||
}
|
||||
}
|
||||
|
||||
generate().catch(console.error)
|
||||
@@ -0,0 +1,22 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="256" height="256">
|
||||
<defs>
|
||||
<linearGradient id="bg" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#1a1a2e"/>
|
||||
<stop offset="100%" stop-color="#16213e"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="accent" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#4f8ef7"/>
|
||||
<stop offset="100%" stop-color="#22c55e"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="256" height="256" rx="48" fill="url(#bg)"/>
|
||||
<!-- Signal waves -->
|
||||
<path d="M60 128 Q60 68 128 68 Q196 68 196 128 Q196 188 128 188 Q60 188 60 128" fill="none" stroke="#4f8ef7" stroke-width="8" stroke-opacity="0.3" stroke-dasharray="8 6"/>
|
||||
<!-- Play triangle -->
|
||||
<polygon points="100,90 172,128 100,166" fill="url(#accent)" opacity="0.9"/>
|
||||
<!-- Live dot -->
|
||||
<circle cx="188" cy="68" r="18" fill="#ef4444"/>
|
||||
<circle cx="188" cy="68" r="10" fill="#ffffff"/>
|
||||
<!-- SRT text -->
|
||||
<text x="128" y="220" font-family="Arial,sans-serif" font-size="22" font-weight="700" fill="#94a3b8" text-anchor="middle" letter-spacing="4">SRT</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,289 @@
|
||||
const { spawn, exec } = require('child_process')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
|
||||
let ffmpegPath = null
|
||||
|
||||
function getFfmpegPath() {
|
||||
if (ffmpegPath) return ffmpegPath
|
||||
|
||||
const resourcesPath = process.resourcesPath || path.join(__dirname, '..')
|
||||
const candidates = [
|
||||
path.join(resourcesPath, 'ffmpeg-bin', process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg'),
|
||||
path.join(__dirname, '..', 'ffmpeg-bin', process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg'),
|
||||
]
|
||||
|
||||
for (const p of candidates) {
|
||||
if (fs.existsSync(p)) {
|
||||
ffmpegPath = p
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
ffmpegPath = process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg'
|
||||
return ffmpegPath
|
||||
}
|
||||
|
||||
function runCommand(cmd, args) {
|
||||
return new Promise((resolve) => {
|
||||
const proc = spawn(cmd, args, { stdio: ['pipe', 'pipe', 'pipe'] })
|
||||
let stdout = ''
|
||||
let stderr = ''
|
||||
proc.stdout.on('data', d => stdout += d)
|
||||
proc.stderr.on('data', d => stderr += d)
|
||||
proc.on('close', () => resolve({ stdout, stderr }))
|
||||
proc.on('error', () => resolve({ stdout: '', stderr: '' }))
|
||||
// Timeout
|
||||
setTimeout(() => { proc.kill(); resolve({ stdout, stderr }) }, 10000)
|
||||
})
|
||||
}
|
||||
|
||||
async function getWindowsDevices() {
|
||||
const ffmpeg = getFfmpegPath()
|
||||
const { stderr } = await runCommand(ffmpeg, [
|
||||
'-list_devices', 'true',
|
||||
'-f', 'dshow',
|
||||
'-i', 'dummy'
|
||||
])
|
||||
|
||||
const video = []
|
||||
const audio = []
|
||||
|
||||
const lines = stderr.split('\n')
|
||||
let section = null
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.includes('"') && line.includes('(video)')) {
|
||||
section = 'video'
|
||||
const match = line.match(/"([^"]+)"\s*\(video\)/)
|
||||
if (match) {
|
||||
video.push({ name: match[1], deviceName: match[1], type: 'device' })
|
||||
}
|
||||
} else if (line.includes('"') && line.includes('(audio)')) {
|
||||
section = 'audio'
|
||||
const match = line.match(/"([^"]+)"\s*\(audio\)/)
|
||||
if (match) {
|
||||
audio.push({ name: match[1], deviceName: match[1], type: 'device' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add system audio loopback devices (WASAPI)
|
||||
// These appear as "virtual-audio-capturer" or similar dshow devices
|
||||
// Also detect via registry / wmic
|
||||
audio.push({
|
||||
name: 'System Audio (Loopback)',
|
||||
deviceName: 'virtual-audio-capturer',
|
||||
type: 'system',
|
||||
description: 'Capture all system audio output'
|
||||
})
|
||||
|
||||
// Add screen capture options
|
||||
const screenDevices = [
|
||||
{ name: 'Desktop (Full Screen)', type: 'desktop', deviceName: 'desktop' },
|
||||
]
|
||||
|
||||
// Try to enumerate monitors
|
||||
const monitors = await getWindowsMonitors()
|
||||
monitors.forEach((m, i) => {
|
||||
screenDevices.push({
|
||||
name: `Monitor ${i + 1}${m.label ? ': ' + m.label : ''}`,
|
||||
type: 'desktop',
|
||||
deviceName: `desktop`,
|
||||
monitorIndex: i
|
||||
})
|
||||
})
|
||||
|
||||
return { video: [...screenDevices, ...video], audio }
|
||||
}
|
||||
|
||||
async function getWindowsMonitors() {
|
||||
return new Promise((resolve) => {
|
||||
exec('wmic desktopmonitor get Name,ScreenHeight,ScreenWidth /format:list', (err, stdout) => {
|
||||
if (err) { resolve([]); return }
|
||||
const monitors = []
|
||||
const blocks = stdout.split('\r\n\r\n').filter(b => b.trim())
|
||||
for (const block of blocks) {
|
||||
const nameMatch = block.match(/Name=(.+)/)
|
||||
if (nameMatch) monitors.push({ label: nameMatch[1].trim() })
|
||||
}
|
||||
resolve(monitors)
|
||||
})
|
||||
setTimeout(() => resolve([]), 5000)
|
||||
})
|
||||
}
|
||||
|
||||
async function getMacDevices() {
|
||||
const ffmpeg = getFfmpegPath()
|
||||
const { stderr } = await runCommand(ffmpeg, [
|
||||
'-f', 'avfoundation',
|
||||
'-list_devices', 'true',
|
||||
'-i', ''
|
||||
])
|
||||
|
||||
const video = []
|
||||
const audio = []
|
||||
|
||||
const lines = stderr.split('\n')
|
||||
let section = null
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.includes('AVFoundation video devices')) {
|
||||
section = 'video'
|
||||
continue
|
||||
}
|
||||
if (line.includes('AVFoundation audio devices')) {
|
||||
section = 'audio'
|
||||
continue
|
||||
}
|
||||
|
||||
const match = line.match(/\[(\d+)\]\s+(.+)/)
|
||||
if (match) {
|
||||
const index = match[1]
|
||||
const name = match[2].trim()
|
||||
if (section === 'video') {
|
||||
const isScreen = name.toLowerCase().includes('screen') || name.toLowerCase().includes('capture')
|
||||
video.push({
|
||||
name,
|
||||
deviceIndex: index,
|
||||
type: isScreen ? 'desktop' : 'device'
|
||||
})
|
||||
} else if (section === 'audio') {
|
||||
audio.push({
|
||||
name,
|
||||
deviceIndex: index,
|
||||
type: 'device'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { video, audio }
|
||||
}
|
||||
|
||||
async function getLinuxDevices() {
|
||||
const video = []
|
||||
const audio = []
|
||||
|
||||
// V4L2 devices
|
||||
try {
|
||||
const v4l2Devices = await new Promise((resolve) => {
|
||||
exec('ls /dev/video* 2>/dev/null', (err, stdout) => {
|
||||
if (err) { resolve([]); return }
|
||||
resolve(stdout.trim().split('\n').filter(Boolean))
|
||||
})
|
||||
})
|
||||
|
||||
for (const dev of v4l2Devices) {
|
||||
const { stdout } = await runCommand('v4l2-ctl', ['--device', dev, '--info'])
|
||||
const nameMatch = stdout.match(/Card type\s*:\s*(.+)/)
|
||||
video.push({
|
||||
name: nameMatch ? nameMatch[1].trim() : dev,
|
||||
devicePath: dev,
|
||||
type: 'device'
|
||||
})
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// Add screen capture
|
||||
const display = process.env.DISPLAY || ':0'
|
||||
video.unshift({ name: `Desktop (${display})`, type: 'desktop', devicePath: display })
|
||||
|
||||
// PulseAudio devices
|
||||
try {
|
||||
const { stdout: paList } = await runCommand('pactl', ['list', 'short', 'sources'])
|
||||
const lines = paList.split('\n').filter(Boolean)
|
||||
for (const line of lines) {
|
||||
const parts = line.split('\t')
|
||||
if (parts.length >= 2) {
|
||||
const deviceName = parts[1]
|
||||
const isMonitor = deviceName.includes('.monitor')
|
||||
audio.push({
|
||||
name: deviceName,
|
||||
deviceName,
|
||||
type: isMonitor ? 'system' : 'device',
|
||||
description: isMonitor ? 'System audio (loopback)' : ''
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
audio.push({ name: 'default', deviceName: 'default', type: 'device' })
|
||||
}
|
||||
|
||||
return { video, audio }
|
||||
}
|
||||
|
||||
async function getDevices() {
|
||||
let result
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
result = await getWindowsDevices()
|
||||
} else if (process.platform === 'darwin') {
|
||||
result = await getMacDevices()
|
||||
} else {
|
||||
result = await getLinuxDevices()
|
||||
}
|
||||
|
||||
// Always add "None" options
|
||||
result.video.unshift({ name: '— No Video —', type: 'none', deviceName: 'none' })
|
||||
result.audio.unshift({ name: '— No Audio —', type: 'none', deviceName: 'none' })
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
async function getWindows() {
|
||||
if (process.platform === 'win32') {
|
||||
return getWindowsWindowsList()
|
||||
} else if (process.platform === 'darwin') {
|
||||
return getMacWindowsList()
|
||||
} else {
|
||||
return getLinuxWindowsList()
|
||||
}
|
||||
}
|
||||
|
||||
function getWindowsWindowsList() {
|
||||
return new Promise((resolve) => {
|
||||
const script = `
|
||||
$windows = Get-Process | Where-Object {$_.MainWindowTitle -ne ""} | Select-Object ProcessName, MainWindowTitle
|
||||
$windows | ForEach-Object { Write-Output "$($_.MainWindowTitle)" }
|
||||
`
|
||||
exec(`powershell -Command "${script.replace(/\n/g, ' ')}"`, (err, stdout) => {
|
||||
if (err) { resolve([]); return }
|
||||
const windows = stdout.trim().split('\n')
|
||||
.map(w => w.trim())
|
||||
.filter(Boolean)
|
||||
.map(title => ({ title, type: 'window' }))
|
||||
resolve(windows)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function getMacWindowsList() {
|
||||
return new Promise((resolve) => {
|
||||
exec(`osascript -e 'tell application "System Events" to get name of every process whose has UI elements is true'`, (err, stdout) => {
|
||||
if (err) { resolve([]); return }
|
||||
const apps = stdout.trim().split(', ')
|
||||
.filter(Boolean)
|
||||
.map(title => ({ title, type: 'window' }))
|
||||
resolve(apps)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function getLinuxWindowsList() {
|
||||
return new Promise((resolve) => {
|
||||
exec('wmctrl -l 2>/dev/null', (err, stdout) => {
|
||||
if (err) { resolve([]); return }
|
||||
const windows = stdout.trim().split('\n')
|
||||
.map(line => {
|
||||
const parts = line.split(/\s+/)
|
||||
const title = parts.slice(3).join(' ')
|
||||
return { title, type: 'window' }
|
||||
})
|
||||
.filter(w => w.title)
|
||||
resolve(windows)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = { getDevices, getWindows }
|
||||
@@ -0,0 +1,370 @@
|
||||
const { EventEmitter } = require('events')
|
||||
const { spawn } = require('child_process')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const { app } = require('electron')
|
||||
|
||||
class FFmpegManager extends EventEmitter {
|
||||
constructor() {
|
||||
super()
|
||||
this.streams = new Map() // id -> { process, config }
|
||||
this.tolbekProcess = null
|
||||
this.ffmpegPath = this._resolveFfmpegPath()
|
||||
}
|
||||
|
||||
_resolveFfmpegPath() {
|
||||
// 1. Check bundled ffmpeg in app resources
|
||||
const resourcesPath = process.resourcesPath || path.join(__dirname, '..')
|
||||
const candidates = [
|
||||
path.join(resourcesPath, 'ffmpeg-bin', process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg'),
|
||||
path.join(__dirname, '..', 'ffmpeg-bin', process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg'),
|
||||
]
|
||||
|
||||
for (const p of candidates) {
|
||||
if (fs.existsSync(p)) {
|
||||
console.log('[FFmpeg] Using bundled:', p)
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Fallback to system ffmpeg
|
||||
console.log('[FFmpeg] Using system ffmpeg')
|
||||
return process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg'
|
||||
}
|
||||
|
||||
// Build FFmpeg args for a stream config
|
||||
_buildStreamArgs(config) {
|
||||
const args = []
|
||||
const platform = process.platform
|
||||
|
||||
// === VIDEO INPUT ===
|
||||
const { videoSource, audioSource } = config
|
||||
|
||||
if (videoSource.type === 'desktop') {
|
||||
// Screen capture
|
||||
if (platform === 'win32') {
|
||||
args.push('-f', 'gdigrab')
|
||||
const hideCursor = videoSource.hideCursor ? '0' : '1'
|
||||
args.push('-draw_mouse', hideCursor)
|
||||
args.push('-framerate', String(config.framerate || 30))
|
||||
args.push('-i', 'desktop')
|
||||
} else if (platform === 'darwin') {
|
||||
args.push('-f', 'avfoundation')
|
||||
args.push('-framerate', String(config.framerate || 30))
|
||||
args.push('-capture_cursor', videoSource.hideCursor ? '0' : '1')
|
||||
args.push('-i', `${videoSource.screenIndex || '1'}:none`)
|
||||
} else {
|
||||
args.push('-f', 'x11grab')
|
||||
const display = process.env.DISPLAY || ':0'
|
||||
args.push('-framerate', String(config.framerate || 30))
|
||||
if (videoSource.hideCursor) args.push('-draw_mouse', '0')
|
||||
args.push('-i', `${display}`)
|
||||
}
|
||||
} else if (videoSource.type === 'window') {
|
||||
// Window capture
|
||||
if (platform === 'win32') {
|
||||
args.push('-f', 'gdigrab')
|
||||
args.push('-draw_mouse', videoSource.hideCursor ? '0' : '1')
|
||||
args.push('-framerate', String(config.framerate || 30))
|
||||
args.push('-i', `title=${videoSource.windowTitle}`)
|
||||
} else if (platform === 'darwin') {
|
||||
// macOS window capture via avfoundation index
|
||||
args.push('-f', 'avfoundation')
|
||||
args.push('-framerate', String(config.framerate || 30))
|
||||
args.push('-i', `${videoSource.deviceIndex || '1'}:none`)
|
||||
} else {
|
||||
args.push('-f', 'x11grab')
|
||||
args.push('-framerate', String(config.framerate || 30))
|
||||
args.push('-i', process.env.DISPLAY || ':0')
|
||||
}
|
||||
} else if (videoSource.type === 'device') {
|
||||
// Camera or capture card
|
||||
if (platform === 'win32') {
|
||||
args.push('-f', 'dshow')
|
||||
args.push('-framerate', String(config.framerate || 30))
|
||||
if (config.resolution) args.push('-video_size', config.resolution)
|
||||
args.push('-i', `video=${videoSource.deviceName}`)
|
||||
} else if (platform === 'darwin') {
|
||||
args.push('-f', 'avfoundation')
|
||||
args.push('-framerate', String(config.framerate || 30))
|
||||
if (config.resolution) args.push('-video_size', config.resolution)
|
||||
args.push('-i', `${videoSource.deviceIndex}:none`)
|
||||
} else {
|
||||
args.push('-f', 'v4l2')
|
||||
args.push('-framerate', String(config.framerate || 30))
|
||||
if (config.resolution) args.push('-video_size', config.resolution)
|
||||
args.push('-i', videoSource.devicePath || '/dev/video0')
|
||||
}
|
||||
} else if (videoSource.type === 'none') {
|
||||
// No video - generate black frame
|
||||
args.push('-f', 'lavfi', '-i', 'color=black:640x480:rate=25')
|
||||
}
|
||||
|
||||
// === AUDIO INPUT ===
|
||||
if (audioSource && audioSource.type !== 'none') {
|
||||
if (platform === 'win32') {
|
||||
if (audioSource.type === 'system') {
|
||||
// System audio loopback via wasapi
|
||||
args.push('-f', 'dshow')
|
||||
args.push('-i', `audio=${audioSource.deviceName}`)
|
||||
} else {
|
||||
args.push('-f', 'dshow')
|
||||
args.push('-i', `audio=${audioSource.deviceName}`)
|
||||
}
|
||||
} else if (platform === 'darwin') {
|
||||
args.push('-f', 'avfoundation')
|
||||
args.push('-i', `:${audioSource.deviceIndex || '0'}`)
|
||||
} else {
|
||||
if (audioSource.type === 'system') {
|
||||
// PulseAudio monitor for system audio
|
||||
args.push('-f', 'pulse')
|
||||
args.push('-i', audioSource.deviceName || 'default.monitor')
|
||||
} else {
|
||||
args.push('-f', 'alsa')
|
||||
args.push('-i', audioSource.deviceName || 'default')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// === VIDEO ENCODING ===
|
||||
const videoCodec = this._selectVideoCodec(config.hwAccel)
|
||||
args.push('-c:v', videoCodec)
|
||||
|
||||
// Codec-specific options
|
||||
if (videoCodec === 'h264_nvenc') {
|
||||
args.push('-preset', 'p4', '-tune', 'ull', '-rc', 'cbr')
|
||||
} else if (videoCodec === 'h264_qsv') {
|
||||
args.push('-preset', 'faster')
|
||||
} else if (videoCodec === 'h264_amf') {
|
||||
args.push('-quality', 'speed', '-rc', 'cbr')
|
||||
} else if (videoCodec === 'h264_videotoolbox') {
|
||||
args.push('-realtime', '1')
|
||||
} else {
|
||||
// libx264 software
|
||||
args.push('-preset', 'ultrafast', '-tune', 'zerolatency')
|
||||
}
|
||||
|
||||
const videoBitrate = config.videoBitrate || '2000k'
|
||||
args.push('-b:v', videoBitrate)
|
||||
args.push('-maxrate', videoBitrate)
|
||||
args.push('-bufsize', videoBitrate)
|
||||
|
||||
if (config.resolution) {
|
||||
args.push('-vf', `scale=${config.resolution.replace('x', ':')}`)
|
||||
}
|
||||
|
||||
args.push('-g', String((config.framerate || 30) * 2)) // keyframe interval
|
||||
|
||||
// === AUDIO ENCODING ===
|
||||
if (audioSource && audioSource.type !== 'none') {
|
||||
args.push('-c:a', 'aac')
|
||||
args.push('-b:a', config.audioBitrate || '128k')
|
||||
args.push('-ar', '44100')
|
||||
} else {
|
||||
args.push('-an')
|
||||
}
|
||||
|
||||
// === SRT OUTPUT ===
|
||||
const { serverAddress, port, srtMode, latency } = config
|
||||
const address = serverAddress.replace(/^(srt:\/\/|rtmp:\/\/|http:\/\/|https:\/\/)/, '')
|
||||
const lat = latency || 200
|
||||
const mode = srtMode || 'caller'
|
||||
|
||||
let srtUrl = `srt://${address}:${port}?mode=${mode}&latency=${lat * 1000}&pkt_size=1316`
|
||||
|
||||
args.push('-f', 'mpegts')
|
||||
args.push(srtUrl)
|
||||
|
||||
return args
|
||||
}
|
||||
|
||||
_selectVideoCodec(hwAccel) {
|
||||
if (!hwAccel || hwAccel === 'none') return 'libx264'
|
||||
if (hwAccel === 'auto') {
|
||||
// Will be detected at runtime; return in preference order
|
||||
if (process.platform === 'darwin') return 'h264_videotoolbox'
|
||||
return 'h264_nvenc' // Will fallback in startStream if unavailable
|
||||
}
|
||||
const codecMap = {
|
||||
'nvenc': 'h264_nvenc',
|
||||
'qsv': 'h264_qsv',
|
||||
'amf': 'h264_amf',
|
||||
'videotoolbox': 'h264_videotoolbox',
|
||||
'vaapi': 'h264_vaapi',
|
||||
'software': 'libx264'
|
||||
}
|
||||
return codecMap[hwAccel] || 'libx264'
|
||||
}
|
||||
|
||||
async startStream(config) {
|
||||
const { id } = config
|
||||
if (this.streams.has(id)) {
|
||||
this.stopStream(id)
|
||||
}
|
||||
|
||||
const args = this._buildStreamArgs(config)
|
||||
console.log(`[FFmpeg] Starting stream ${id}:`, this.ffmpegPath, args.join(' '))
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const proc = spawn(this.ffmpegPath, args, {
|
||||
stdio: ['pipe', 'pipe', 'pipe']
|
||||
})
|
||||
|
||||
let started = false
|
||||
let errorBuffer = ''
|
||||
|
||||
proc.stderr.on('data', (data) => {
|
||||
const text = data.toString()
|
||||
errorBuffer += text
|
||||
this.emit('log', { id, text })
|
||||
|
||||
if (!started && (text.includes('Output #0') || text.includes('frame='))) {
|
||||
started = true
|
||||
resolve({ pid: proc.pid })
|
||||
}
|
||||
})
|
||||
|
||||
proc.on('error', (err) => {
|
||||
console.error(`[FFmpeg] Process error for ${id}:`, err)
|
||||
if (!started) reject(err)
|
||||
this.emit('error', { id, error: err.message })
|
||||
this.streams.delete(id)
|
||||
})
|
||||
|
||||
proc.on('exit', (code, signal) => {
|
||||
console.log(`[FFmpeg] Stream ${id} exited: code=${code} signal=${signal}`)
|
||||
this.streams.delete(id)
|
||||
this.emit('ended', { id, code, signal })
|
||||
|
||||
// If hwAccel failed, retry with software encoding
|
||||
if (!started && code !== 0 && config.hwAccel !== 'software') {
|
||||
console.log(`[FFmpeg] HW encode failed for ${id}, retrying with software...`)
|
||||
this.startStream({ ...config, hwAccel: 'software' })
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
} else if (!started) {
|
||||
reject(new Error(`FFmpeg exited with code ${code}\n${errorBuffer}`))
|
||||
}
|
||||
})
|
||||
|
||||
// Start timeout
|
||||
setTimeout(() => {
|
||||
if (!started) {
|
||||
started = true
|
||||
resolve({ pid: proc.pid })
|
||||
}
|
||||
}, 5000)
|
||||
|
||||
this.streams.set(id, { process: proc, config })
|
||||
})
|
||||
}
|
||||
|
||||
stopStream(id) {
|
||||
const stream = this.streams.get(id)
|
||||
if (stream) {
|
||||
console.log(`[FFmpeg] Stopping stream ${id}`)
|
||||
if (process.platform === 'win32') {
|
||||
stream.process.kill('SIGTERM')
|
||||
} else {
|
||||
stream.process.kill('SIGINT')
|
||||
}
|
||||
this.streams.delete(id)
|
||||
}
|
||||
}
|
||||
|
||||
stopAllStreams() {
|
||||
for (const [id] of this.streams) {
|
||||
this.stopStream(id)
|
||||
}
|
||||
this.stopTolbek()
|
||||
}
|
||||
|
||||
getActiveCount() {
|
||||
return this.streams.size + (this.tolbekProcess ? 1 : 0)
|
||||
}
|
||||
|
||||
getActiveStreams() {
|
||||
const result = []
|
||||
for (const [id, { config }] of this.streams) {
|
||||
result.push({ id, config })
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// === TOLBEK (SRT RECEIVER) ===
|
||||
async startTolbek(config) {
|
||||
if (this.tolbekProcess) {
|
||||
this.stopTolbek()
|
||||
}
|
||||
|
||||
const { port, latency, mode, serverAddress } = config
|
||||
const lat = (latency || 200) * 1000
|
||||
const srtMode = mode || 'listener'
|
||||
|
||||
let srtUrl
|
||||
if (srtMode === 'listener') {
|
||||
srtUrl = `srt://0.0.0.0:${port}?mode=listener&latency=${lat}`
|
||||
} else if (srtMode === 'caller') {
|
||||
const addr = (serverAddress || '').replace(/^srt:\/\//, '')
|
||||
srtUrl = `srt://${addr}:${port}?mode=caller&latency=${lat}`
|
||||
} else {
|
||||
// rendezvous
|
||||
const addr = (serverAddress || '0.0.0.0').replace(/^srt:\/\//, '')
|
||||
srtUrl = `srt://${addr}:${port}?mode=rendezvous&latency=${lat}`
|
||||
}
|
||||
|
||||
const args = [
|
||||
'-fflags', 'nobuffer',
|
||||
'-flags', 'low_delay',
|
||||
'-f', 'mpegts',
|
||||
'-i', srtUrl,
|
||||
'-f', 'null', '-'
|
||||
]
|
||||
|
||||
console.log('[FFmpeg] Starting Tolbek receiver:', args.join(' '))
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const proc = spawn(this.ffmpegPath, args, {
|
||||
stdio: ['pipe', 'pipe', 'pipe']
|
||||
})
|
||||
|
||||
let started = false
|
||||
|
||||
proc.stderr.on('data', (data) => {
|
||||
const text = data.toString()
|
||||
this.emit('log', { id: 'tolbek', text })
|
||||
if (!started) {
|
||||
started = true
|
||||
resolve({ pid: proc.pid })
|
||||
}
|
||||
})
|
||||
|
||||
proc.on('error', (err) => {
|
||||
if (!started) reject(err)
|
||||
this.emit('error', { id: 'tolbek', error: err.message })
|
||||
this.tolbekProcess = null
|
||||
})
|
||||
|
||||
proc.on('exit', (code) => {
|
||||
this.tolbekProcess = null
|
||||
this.emit('ended', { id: 'tolbek', code })
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
if (!started) { started = true; resolve({ pid: proc.pid }) }
|
||||
}, 3000)
|
||||
|
||||
this.tolbekProcess = proc
|
||||
})
|
||||
}
|
||||
|
||||
stopTolbek() {
|
||||
if (this.tolbekProcess) {
|
||||
console.log('[FFmpeg] Stopping Tolbek receiver')
|
||||
this.tolbekProcess.kill(process.platform === 'win32' ? 'SIGTERM' : 'SIGINT')
|
||||
this.tolbekProcess = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new FFmpegManager()
|
||||
@@ -0,0 +1,306 @@
|
||||
const { app, BrowserWindow, ipcMain, Tray, Menu, nativeImage, dialog } = require('electron')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const ffmpegManager = require('./ffmpeg')
|
||||
const deviceManager = require('./devices')
|
||||
|
||||
// Inline tray icon as SVG → base64 DataURL (no external file needed)
|
||||
function makeTrayIcon() {
|
||||
const size = 16
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 16 16">
|
||||
<rect width="16" height="16" rx="3" fill="#1a1a2e"/>
|
||||
<polygon points="4,2 13,8 4,14" fill="#4f8ef7"/>
|
||||
<circle cx="13" cy="3" r="2.5" fill="#ef4444"/>
|
||||
</svg>`
|
||||
const dataUrl = `data:image/svg+xml;base64,${Buffer.from(svg).toString('base64')}`
|
||||
const img = nativeImage.createFromDataURL(dataUrl)
|
||||
if (process.platform === 'darwin') {
|
||||
img.setTemplateImage(true)
|
||||
}
|
||||
return img
|
||||
}
|
||||
|
||||
// Inline icon for main window (32x32)
|
||||
function makeWindowIcon() {
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256">
|
||||
<defs>
|
||||
<linearGradient id="g" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#1a1a2e"/>
|
||||
<stop offset="100%" stop-color="#16213e"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="256" height="256" rx="48" fill="url(#g)"/>
|
||||
<polygon points="72,48 200,128 72,208" fill="#4f8ef7"/>
|
||||
<circle cx="200" cy="56" r="32" fill="#ef4444"/>
|
||||
<circle cx="200" cy="56" r="18" fill="#fff"/>
|
||||
</svg>`
|
||||
const dataUrl = `data:image/svg+xml;base64,${Buffer.from(svg).toString('base64')}`
|
||||
return nativeImage.createFromDataURL(dataUrl)
|
||||
}
|
||||
|
||||
const isDev = process.env.NODE_ENV === 'development' || !app.isPackaged
|
||||
|
||||
let mainWindow = null
|
||||
let tray = null
|
||||
let isQuitting = false
|
||||
|
||||
// Persistent config storage
|
||||
const configPath = path.join(app.getPath('userData'), 'config.json')
|
||||
|
||||
function loadConfig() {
|
||||
try {
|
||||
if (fs.existsSync(configPath)) {
|
||||
return JSON.parse(fs.readFileSync(configPath, 'utf8'))
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load config:', e)
|
||||
}
|
||||
return { streams: [], tolbek: { enabled: false, port: 5000, latency: 200 } }
|
||||
}
|
||||
|
||||
function saveConfig(config) {
|
||||
try {
|
||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf8')
|
||||
} catch (e) {
|
||||
console.error('Failed to save config:', e)
|
||||
}
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1100,
|
||||
height: 750,
|
||||
minWidth: 800,
|
||||
minHeight: 600,
|
||||
backgroundColor: '#1a1a2e',
|
||||
frame: false,
|
||||
titleBarStyle: 'hidden',
|
||||
titleBarOverlay: {
|
||||
color: '#16213e',
|
||||
symbolColor: '#e0e0e0',
|
||||
height: 36
|
||||
},
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false
|
||||
},
|
||||
icon: makeWindowIcon()
|
||||
})
|
||||
|
||||
if (isDev) {
|
||||
mainWindow.loadURL('http://localhost:5173')
|
||||
mainWindow.webContents.openDevTools({ mode: 'detach' })
|
||||
} else {
|
||||
mainWindow.loadFile(path.join(__dirname, '../dist/index.html'))
|
||||
}
|
||||
|
||||
// Hide to tray on close instead of quitting
|
||||
mainWindow.on('close', (event) => {
|
||||
if (!isQuitting) {
|
||||
event.preventDefault()
|
||||
mainWindow.hide()
|
||||
if (process.platform === 'darwin') {
|
||||
app.dock.hide()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function createTray() {
|
||||
const trayImage = makeTrayIcon()
|
||||
tray = new Tray(trayImage)
|
||||
tray.setToolTip('SRT Streamer')
|
||||
updateTrayMenu()
|
||||
|
||||
tray.on('click', () => {
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isVisible()) {
|
||||
mainWindow.focus()
|
||||
} else {
|
||||
showWindow()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function showWindow() {
|
||||
if (mainWindow) {
|
||||
mainWindow.show()
|
||||
mainWindow.focus()
|
||||
if (process.platform === 'darwin') {
|
||||
app.dock.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateTrayMenu(activeCount = 0) {
|
||||
if (!tray) return
|
||||
const statusLabel = activeCount > 0
|
||||
? `Active streams: ${activeCount}`
|
||||
: 'No active streams'
|
||||
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{ label: 'SRT Streamer', enabled: false },
|
||||
{ label: statusLabel, enabled: false },
|
||||
{ type: 'separator' },
|
||||
{ label: 'Show', click: () => showWindow() },
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Stop All Streams',
|
||||
enabled: activeCount > 0,
|
||||
click: () => {
|
||||
ffmpegManager.stopAllStreams()
|
||||
mainWindow && mainWindow.webContents.send('all-streams-stopped')
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Quit',
|
||||
click: () => {
|
||||
const activeCount = ffmpegManager.getActiveCount()
|
||||
if (activeCount > 0) {
|
||||
const choice = dialog.showMessageBoxSync({
|
||||
type: 'question',
|
||||
buttons: ['Quit', 'Cancel'],
|
||||
defaultId: 1,
|
||||
cancelId: 1,
|
||||
title: 'Quit SRT Streamer',
|
||||
message: `${activeCount} stream(s) are active.`,
|
||||
detail: 'All running streams will be stopped. Are you sure you want to quit?'
|
||||
})
|
||||
if (choice !== 0) return
|
||||
}
|
||||
isQuitting = true
|
||||
ffmpegManager.stopAllStreams()
|
||||
app.quit()
|
||||
}
|
||||
}
|
||||
])
|
||||
tray.setContextMenu(contextMenu)
|
||||
}
|
||||
|
||||
// IPC Handlers
|
||||
|
||||
ipcMain.handle('get-config', () => loadConfig())
|
||||
ipcMain.handle('save-config', (_, config) => { saveConfig(config); return true })
|
||||
|
||||
ipcMain.handle('get-devices', async () => {
|
||||
try {
|
||||
return await deviceManager.getDevices()
|
||||
} catch (e) {
|
||||
console.error('Device enumeration error:', e)
|
||||
return { video: [], audio: [] }
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle('get-windows', async () => {
|
||||
try {
|
||||
return await deviceManager.getWindows()
|
||||
} catch (e) {
|
||||
return []
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle('start-stream', async (_, streamConfig) => {
|
||||
try {
|
||||
const result = await ffmpegManager.startStream(streamConfig)
|
||||
const active = ffmpegManager.getActiveCount()
|
||||
updateTrayMenu(active)
|
||||
mainWindow && mainWindow.webContents.send('stream-status', {
|
||||
id: streamConfig.id,
|
||||
status: 'running'
|
||||
})
|
||||
return { success: true }
|
||||
} catch (e) {
|
||||
return { success: false, error: e.message }
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle('stop-stream', async (_, streamId) => {
|
||||
try {
|
||||
ffmpegManager.stopStream(streamId)
|
||||
const active = ffmpegManager.getActiveCount()
|
||||
updateTrayMenu(active)
|
||||
return { success: true }
|
||||
} catch (e) {
|
||||
return { success: false, error: e.message }
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle('start-tolbek', async (_, config) => {
|
||||
try {
|
||||
const result = await ffmpegManager.startTolbek(config)
|
||||
return { success: true }
|
||||
} catch (e) {
|
||||
return { success: false, error: e.message }
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle('stop-tolbek', async () => {
|
||||
try {
|
||||
ffmpegManager.stopTolbek()
|
||||
return { success: true }
|
||||
} catch (e) {
|
||||
return { success: false, error: e.message }
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle('get-active-streams', () => {
|
||||
return ffmpegManager.getActiveStreams()
|
||||
})
|
||||
|
||||
ipcMain.handle('minimize-window', () => {
|
||||
mainWindow && mainWindow.minimize()
|
||||
})
|
||||
|
||||
ipcMain.handle('hide-window', () => {
|
||||
mainWindow && mainWindow.hide()
|
||||
})
|
||||
|
||||
ipcMain.on('update-tray-count', (_, count) => {
|
||||
updateTrayMenu(count)
|
||||
})
|
||||
|
||||
// Forward FFmpeg log events to renderer
|
||||
ffmpegManager.on('log', (data) => {
|
||||
mainWindow && mainWindow.webContents.send('stream-log', data)
|
||||
})
|
||||
|
||||
ffmpegManager.on('error', (data) => {
|
||||
mainWindow && mainWindow.webContents.send('stream-error', data)
|
||||
const active = ffmpegManager.getActiveCount()
|
||||
updateTrayMenu(active)
|
||||
})
|
||||
|
||||
ffmpegManager.on('ended', (data) => {
|
||||
mainWindow && mainWindow.webContents.send('stream-ended', data)
|
||||
const active = ffmpegManager.getActiveCount()
|
||||
updateTrayMenu(active)
|
||||
})
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
createTray()
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow()
|
||||
} else {
|
||||
showWindow()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', (e) => {
|
||||
// Keep app running in tray
|
||||
if (process.platform !== 'darwin') {
|
||||
e.preventDefault()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('before-quit', () => {
|
||||
isQuitting = true
|
||||
ffmpegManager.stopAllStreams()
|
||||
})
|
||||
@@ -0,0 +1,34 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
// Config
|
||||
getConfig: () => ipcRenderer.invoke('get-config'),
|
||||
saveConfig: (config) => ipcRenderer.invoke('save-config', config),
|
||||
|
||||
// Devices
|
||||
getDevices: () => ipcRenderer.invoke('get-devices'),
|
||||
getWindows: () => ipcRenderer.invoke('get-windows'),
|
||||
|
||||
// Streams
|
||||
startStream: (config) => ipcRenderer.invoke('start-stream', config),
|
||||
stopStream: (id) => ipcRenderer.invoke('stop-stream', id),
|
||||
getActiveStreams: () => ipcRenderer.invoke('get-active-streams'),
|
||||
|
||||
// Tolbek receiver
|
||||
startTolbek: (config) => ipcRenderer.invoke('start-tolbek', config),
|
||||
stopTolbek: () => ipcRenderer.invoke('stop-tolbek'),
|
||||
|
||||
// Window controls
|
||||
minimizeWindow: () => ipcRenderer.invoke('minimize-window'),
|
||||
hideWindow: () => ipcRenderer.invoke('hide-window'),
|
||||
updateTrayCount: (count) => ipcRenderer.send('update-tray-count', count),
|
||||
|
||||
// Event listeners
|
||||
onStreamStatus: (cb) => ipcRenderer.on('stream-status', (_, data) => cb(data)),
|
||||
onStreamLog: (cb) => ipcRenderer.on('stream-log', (_, data) => cb(data)),
|
||||
onStreamError: (cb) => ipcRenderer.on('stream-error', (_, data) => cb(data)),
|
||||
onStreamEnded: (cb) => ipcRenderer.on('stream-ended', (_, data) => cb(data)),
|
||||
onAllStreamsStopped: (cb) => ipcRenderer.on('all-streams-stopped', () => cb()),
|
||||
|
||||
removeAllListeners: (channel) => ipcRenderer.removeAllListeners(channel)
|
||||
})
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; font-src 'self' data:;" />
|
||||
<title>SRT Streamer</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
Generated
+7291
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "srt-streamer",
|
||||
"version": "1.0.0",
|
||||
"description": "Cross-platform SRT multi-stream sender with system tray",
|
||||
"main": "electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "concurrently \"vite\" \"wait-on http://localhost:5173 && electron .\"",
|
||||
"build": "vite build && electron-builder",
|
||||
"build:win": "vite build && electron-builder --win",
|
||||
"build:mac": "vite build && electron-builder --mac",
|
||||
"build:linux": "vite build && electron-builder --linux",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"fluent-ffmpeg": "^2.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"concurrently": "^9.1.2",
|
||||
"electron": "^33.4.0",
|
||||
"electron-builder": "^25.1.8",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"vite": "^6.0.7",
|
||||
"vite-plugin-electron": "^0.29.0",
|
||||
"wait-on": "^8.0.1"
|
||||
},
|
||||
"build": {
|
||||
"appId": "com.srtstreamer.app",
|
||||
"productName": "SRT Streamer",
|
||||
"directories": {
|
||||
"output": "dist-electron"
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"electron/**/*",
|
||||
"assets/**/*"
|
||||
],
|
||||
"extraResources": [
|
||||
{
|
||||
"from": "ffmpeg-bin/",
|
||||
"to": "ffmpeg-bin/",
|
||||
"filter": ["**/*"]
|
||||
}
|
||||
],
|
||||
"win": {
|
||||
"target": "portable",
|
||||
"icon": "assets/icon.ico"
|
||||
},
|
||||
"mac": {
|
||||
"target": "dmg",
|
||||
"icon": "assets/icon.icns"
|
||||
},
|
||||
"linux": {
|
||||
"target": "AppImage",
|
||||
"icon": "assets/icon.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
@echo off
|
||||
echo ============================================================
|
||||
echo SRT Streamer - Setup
|
||||
echo ============================================================
|
||||
echo.
|
||||
|
||||
:: Check Node.js
|
||||
where node >nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
echo [ERROR] Node.js not found! Please install from https://nodejs.org
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Check FFmpeg
|
||||
echo Checking FFmpeg...
|
||||
where ffmpeg >nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
echo [WARNING] FFmpeg not found in system PATH.
|
||||
echo.
|
||||
echo Please place ffmpeg.exe in the ffmpeg-bin\ folder.
|
||||
echo Download FFmpeg with SRT support from:
|
||||
echo https://github.com/BtbN/FFmpeg-Builds/releases
|
||||
echo (download ffmpeg-master-latest-win64-gpl.zip)
|
||||
echo.
|
||||
mkdir ffmpeg-bin 2>nul
|
||||
echo After placing ffmpeg.exe in ffmpeg-bin\, run this setup again.
|
||||
) else (
|
||||
echo [OK] FFmpeg found in system PATH.
|
||||
echo.
|
||||
echo Copying FFmpeg to ffmpeg-bin\...
|
||||
mkdir ffmpeg-bin 2>nul
|
||||
for /f "tokens=*" %%i in ('where ffmpeg') do (
|
||||
copy "%%i" "ffmpeg-bin\ffmpeg.exe" >nul 2>&1
|
||||
echo Copied: %%i
|
||||
goto :ffmpeg_done
|
||||
)
|
||||
:ffmpeg_done
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Installing dependencies...
|
||||
call npm install
|
||||
if %errorlevel% neq 0 (
|
||||
echo [ERROR] npm install failed!
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo.
|
||||
echo Generating icons...
|
||||
node assets/create-placeholder-icons.js
|
||||
|
||||
echo.
|
||||
echo ============================================================
|
||||
echo Setup complete!
|
||||
echo Run: npm run dev (development mode)
|
||||
echo Run: npm run build (build portable .exe)
|
||||
echo ============================================================
|
||||
echo.
|
||||
pause
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
echo "============================================================"
|
||||
echo " SRT Streamer - Setup (Linux/macOS)"
|
||||
echo "============================================================"
|
||||
echo ""
|
||||
|
||||
# Check Node.js
|
||||
if ! command -v node &>/dev/null; then
|
||||
echo "[ERROR] Node.js not found! Install from https://nodejs.org"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check FFmpeg
|
||||
mkdir -p ffmpeg-bin
|
||||
|
||||
if command -v ffmpeg &>/dev/null; then
|
||||
echo "[OK] FFmpeg found: $(which ffmpeg)"
|
||||
cp "$(which ffmpeg)" ffmpeg-bin/ffmpeg
|
||||
chmod +x ffmpeg-bin/ffmpeg
|
||||
echo "Copied to ffmpeg-bin/"
|
||||
else
|
||||
echo "[WARNING] FFmpeg not found in PATH."
|
||||
echo ""
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
echo "Install via Homebrew: brew install ffmpeg"
|
||||
else
|
||||
echo "Install via apt: sudo apt install ffmpeg"
|
||||
echo "Or download from: https://ffmpeg.org/download.html"
|
||||
fi
|
||||
echo ""
|
||||
echo "After installing FFmpeg, copy the binary to ffmpeg-bin/ffmpeg"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Installing npm dependencies..."
|
||||
npm install
|
||||
|
||||
echo ""
|
||||
echo "Generating icons..."
|
||||
node assets/create-placeholder-icons.js || true
|
||||
|
||||
echo ""
|
||||
echo "============================================================"
|
||||
echo " Setup complete!"
|
||||
echo " Run: npm run dev (development mode)"
|
||||
echo " Run: npm run build (build app)"
|
||||
echo "============================================================"
|
||||
+236
@@ -0,0 +1,236 @@
|
||||
import React, { useState, useEffect, useCallback } from 'react'
|
||||
import StreamCard from './components/StreamCard.jsx'
|
||||
import TolbekSettings from './components/TolbekSettings.jsx'
|
||||
import LogPanel from './components/LogPanel.jsx'
|
||||
|
||||
const ipc = window.electronAPI || null
|
||||
|
||||
const DEFAULT_STREAM = () => ({
|
||||
id: `stream_${Date.now()}`,
|
||||
name: 'Stream 1',
|
||||
videoSource: { type: 'desktop', deviceName: '', hideCursor: false },
|
||||
audioSource: { type: 'none', deviceName: '' },
|
||||
serverAddress: '',
|
||||
port: '4900',
|
||||
srtMode: 'caller',
|
||||
latency: 200,
|
||||
resolution: '1920x1080',
|
||||
framerate: 30,
|
||||
videoBitrate: '4000k',
|
||||
audioBitrate: '128k',
|
||||
hwAccel: 'auto',
|
||||
status: 'idle'
|
||||
})
|
||||
|
||||
export default function App() {
|
||||
const [streams, setStreams] = useState([DEFAULT_STREAM()])
|
||||
const [tolbek, setTolbek] = useState({ enabled: false, port: 5000, latency: 200 })
|
||||
const [devices, setDevices] = useState({ video: [], audio: [] })
|
||||
const [windows, setWindows] = useState([])
|
||||
const [logs, setLogs] = useState([])
|
||||
const [activeTab, setActiveTab] = useState('streams')
|
||||
const [devicesLoaded, setDevicesLoaded] = useState(false)
|
||||
|
||||
// Load config and devices on mount
|
||||
useEffect(() => {
|
||||
if (!ipc) return
|
||||
|
||||
ipc.getConfig().then(config => {
|
||||
if (config.streams && config.streams.length > 0) {
|
||||
setStreams(config.streams.map(s => ({ ...s, status: 'idle' })))
|
||||
}
|
||||
if (config.tolbek) setTolbek(config.tolbek)
|
||||
})
|
||||
|
||||
ipc.getDevices().then(devs => {
|
||||
setDevices(devs)
|
||||
setDevicesLoaded(true)
|
||||
})
|
||||
|
||||
ipc.getWindows().then(wins => setWindows(wins))
|
||||
}, [])
|
||||
|
||||
// Subscribe to stream events
|
||||
useEffect(() => {
|
||||
if (!ipc) return
|
||||
|
||||
const handleStatus = ({ id, status }) => {
|
||||
setStreams(prev => prev.map(s => s.id === id ? { ...s, status } : s))
|
||||
}
|
||||
const handleLog = ({ id, text }) => {
|
||||
setLogs(prev => [...prev.slice(-499), { id, text: text.trim(), time: Date.now() }])
|
||||
}
|
||||
const handleError = ({ id, error }) => {
|
||||
setStreams(prev => prev.map(s => s.id === id ? { ...s, status: 'error' } : s))
|
||||
setLogs(prev => [...prev.slice(-499), { id, text: `ERROR: ${error}`, time: Date.now(), isError: true }])
|
||||
}
|
||||
const handleEnded = ({ id }) => {
|
||||
setStreams(prev => prev.map(s => s.id === id ? { ...s, status: 'idle' } : s))
|
||||
}
|
||||
const handleAllStopped = () => {
|
||||
setStreams(prev => prev.map(s => ({ ...s, status: 'idle' })))
|
||||
}
|
||||
|
||||
ipc.onStreamStatus(handleStatus)
|
||||
ipc.onStreamLog(handleLog)
|
||||
ipc.onStreamError(handleError)
|
||||
ipc.onStreamEnded(handleEnded)
|
||||
ipc.onAllStreamsStopped(handleAllStopped)
|
||||
|
||||
return () => {
|
||||
ipc.removeAllListeners('stream-status')
|
||||
ipc.removeAllListeners('stream-log')
|
||||
ipc.removeAllListeners('stream-error')
|
||||
ipc.removeAllListeners('stream-ended')
|
||||
ipc.removeAllListeners('all-streams-stopped')
|
||||
}
|
||||
}, [])
|
||||
|
||||
// Persist config when streams/tolbek change
|
||||
useEffect(() => {
|
||||
if (!ipc) return
|
||||
const saveData = { streams: streams.map(s => { const {status, ...rest} = s; return rest }), tolbek }
|
||||
ipc.saveConfig(saveData)
|
||||
ipc.updateTrayCount(streams.filter(s => s.status === 'running').length)
|
||||
}, [streams, tolbek])
|
||||
|
||||
const addStream = useCallback(() => {
|
||||
const newStream = DEFAULT_STREAM()
|
||||
newStream.name = `Stream ${streams.length + 1}`
|
||||
setStreams(prev => [...prev, newStream])
|
||||
}, [streams.length])
|
||||
|
||||
const updateStream = useCallback((id, changes) => {
|
||||
setStreams(prev => prev.map(s => s.id === id ? { ...s, ...changes } : s))
|
||||
}, [])
|
||||
|
||||
const removeStream = useCallback((id) => {
|
||||
if (ipc) ipc.stopStream(id)
|
||||
setStreams(prev => prev.filter(s => s.id !== id))
|
||||
}, [])
|
||||
|
||||
const startStream = useCallback(async (id) => {
|
||||
if (!ipc) return
|
||||
const stream = streams.find(s => s.id === id)
|
||||
if (!stream) return
|
||||
setStreams(prev => prev.map(s => s.id === id ? { ...s, status: 'connecting' } : s))
|
||||
const result = await ipc.startStream(stream)
|
||||
if (!result.success) {
|
||||
setStreams(prev => prev.map(s => s.id === id ? { ...s, status: 'error' } : s))
|
||||
setLogs(prev => [...prev, { id, text: `Failed to start: ${result.error}`, time: Date.now(), isError: true }])
|
||||
}
|
||||
}, [streams])
|
||||
|
||||
const stopStream = useCallback(async (id) => {
|
||||
if (!ipc) return
|
||||
await ipc.stopStream(id)
|
||||
setStreams(prev => prev.map(s => s.id === id ? { ...s, status: 'idle' } : s))
|
||||
}, [])
|
||||
|
||||
const refreshDevices = useCallback(() => {
|
||||
if (!ipc) return
|
||||
setDevicesLoaded(false)
|
||||
ipc.getDevices().then(devs => {
|
||||
setDevices(devs)
|
||||
setDevicesLoaded(true)
|
||||
})
|
||||
ipc.getWindows().then(wins => setWindows(wins))
|
||||
}, [])
|
||||
|
||||
const handleMinimize = () => ipc && ipc.minimizeWindow()
|
||||
const handleHide = () => ipc && ipc.hideWindow()
|
||||
|
||||
const activeCount = streams.filter(s => s.status === 'running' || s.status === 'connecting').length
|
||||
|
||||
return (
|
||||
<div className="app">
|
||||
{/* Title Bar */}
|
||||
<div className="titlebar" style={{ WebkitAppRegion: 'drag' }}>
|
||||
<div className="titlebar-left">
|
||||
<span className="app-logo">▶</span>
|
||||
<span className="app-title">SRT Streamer</span>
|
||||
{activeCount > 0 && (
|
||||
<span className="active-badge">{activeCount} active</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="titlebar-controls" style={{ WebkitAppRegion: 'no-drag' }}>
|
||||
<button className="tb-btn" onClick={handleMinimize} title="Minimize">−</button>
|
||||
<button className="tb-btn" onClick={handleHide} title="Hide to tray">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Tab Bar */}
|
||||
<div className="tabbar">
|
||||
<button
|
||||
className={`tab ${activeTab === 'streams' ? 'active' : ''}`}
|
||||
onClick={() => setActiveTab('streams')}
|
||||
>
|
||||
Streams
|
||||
{activeCount > 0 && <span className="tab-badge">{activeCount}</span>}
|
||||
</button>
|
||||
<button
|
||||
className={`tab ${activeTab === 'tolbek' ? 'active' : ''}`}
|
||||
onClick={() => setActiveTab('tolbek')}
|
||||
>
|
||||
Tolbek (Receiver)
|
||||
{tolbek.running && <span className="tab-badge tab-badge--green">●</span>}
|
||||
</button>
|
||||
<button
|
||||
className={`tab ${activeTab === 'logs' ? 'active' : ''}`}
|
||||
onClick={() => setActiveTab('logs')}
|
||||
>
|
||||
Logs
|
||||
{logs.some(l => l.isError) && <span className="tab-badge tab-badge--red">!</span>}
|
||||
</button>
|
||||
<div className="tabbar-spacer" />
|
||||
<button className="tab tab--icon" onClick={refreshDevices} title="Refresh device list">
|
||||
↻ Devices
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className="content">
|
||||
{activeTab === 'streams' && (
|
||||
<div className="streams-view">
|
||||
<div className="streams-grid">
|
||||
{streams.map(stream => (
|
||||
<StreamCard
|
||||
key={stream.id}
|
||||
stream={stream}
|
||||
devices={devices}
|
||||
windows={windows}
|
||||
devicesLoaded={devicesLoaded}
|
||||
onChange={(changes) => updateStream(stream.id, changes)}
|
||||
onStart={() => startStream(stream.id)}
|
||||
onStop={() => stopStream(stream.id)}
|
||||
onRemove={() => removeStream(stream.id)}
|
||||
/>
|
||||
))}
|
||||
|
||||
<button className="add-stream-btn" onClick={addStream}>
|
||||
<span className="add-icon">+</span>
|
||||
<span>Add Stream</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === 'tolbek' && (
|
||||
<TolbekSettings
|
||||
config={tolbek}
|
||||
onChange={setTolbek}
|
||||
ipc={ipc}
|
||||
/>
|
||||
)}
|
||||
|
||||
{activeTab === 'logs' && (
|
||||
<LogPanel
|
||||
logs={logs}
|
||||
streams={streams}
|
||||
onClear={() => setLogs([])}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import React, { useRef, useEffect, useState } from 'react'
|
||||
|
||||
export default function LogPanel({ logs, streams, onClear }) {
|
||||
const bottomRef = useRef(null)
|
||||
const [filter, setFilter] = useState('all')
|
||||
const [autoScroll, setAutoScroll] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
if (autoScroll && bottomRef.current) {
|
||||
bottomRef.current.scrollIntoView({ behavior: 'smooth' })
|
||||
}
|
||||
}, [logs, autoScroll])
|
||||
|
||||
const filtered = filter === 'all'
|
||||
? logs
|
||||
: filter === 'errors'
|
||||
? logs.filter(l => l.isError)
|
||||
: logs.filter(l => l.id === filter)
|
||||
|
||||
const streamOptions = [...new Set(logs.map(l => l.id))].filter(Boolean)
|
||||
|
||||
return (
|
||||
<div className="log-panel">
|
||||
<div className="log-toolbar">
|
||||
<div className="log-filters">
|
||||
<button
|
||||
className={`filter-btn ${filter === 'all' ? 'active' : ''}`}
|
||||
onClick={() => setFilter('all')}
|
||||
>
|
||||
All
|
||||
</button>
|
||||
<button
|
||||
className={`filter-btn ${filter === 'errors' ? 'active' : ''}`}
|
||||
onClick={() => setFilter('errors')}
|
||||
>
|
||||
Errors
|
||||
</button>
|
||||
{streamOptions.map(id => {
|
||||
const stream = streams.find(s => s.id === id)
|
||||
return (
|
||||
<button
|
||||
key={id}
|
||||
className={`filter-btn ${filter === id ? 'active' : ''}`}
|
||||
onClick={() => setFilter(id)}
|
||||
>
|
||||
{stream ? stream.name : id}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="log-actions">
|
||||
<label className="checkbox-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={autoScroll}
|
||||
onChange={e => setAutoScroll(e.target.checked)}
|
||||
/>
|
||||
Auto-scroll
|
||||
</label>
|
||||
<button className="btn btn--small" onClick={onClear}>Clear</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="log-content">
|
||||
{filtered.length === 0 ? (
|
||||
<div className="log-empty">No log entries yet. Start a stream to see FFmpeg output.</div>
|
||||
) : (
|
||||
filtered.map((entry, i) => (
|
||||
<div key={i} className={`log-line ${entry.isError ? 'log-line--error' : ''}`}>
|
||||
<span className="log-stream">[{
|
||||
entry.id === 'tolbek' ? 'Tolbek'
|
||||
: streams.find(s => s.id === entry.id)?.name || entry.id
|
||||
}]</span>
|
||||
<span className="log-text">{entry.text}</span>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
<div ref={bottomRef} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
import React, { useState } from 'react'
|
||||
import StreamSettings from './StreamSettings.jsx'
|
||||
|
||||
const STATUS_LABELS = {
|
||||
idle: 'Idle',
|
||||
connecting: 'Connecting…',
|
||||
running: 'Live',
|
||||
error: 'Error'
|
||||
}
|
||||
|
||||
const STATUS_CLASS = {
|
||||
idle: 'status--idle',
|
||||
connecting: 'status--connecting',
|
||||
running: 'status--running',
|
||||
error: 'status--error'
|
||||
}
|
||||
|
||||
export default function StreamCard({ stream, devices, windows, devicesLoaded, onChange, onStart, onStop, onRemove }) {
|
||||
const [expanded, setExpanded] = useState(true)
|
||||
const [editingName, setEditingName] = useState(false)
|
||||
const [nameValue, setNameValue] = useState(stream.name)
|
||||
|
||||
const isActive = stream.status === 'running' || stream.status === 'connecting'
|
||||
|
||||
const handleNameBlur = () => {
|
||||
setEditingName(false)
|
||||
onChange({ name: nameValue || stream.name })
|
||||
}
|
||||
|
||||
const getStreamSummary = () => {
|
||||
const parts = []
|
||||
if (stream.videoSource?.type !== 'none') {
|
||||
if (stream.videoSource?.type === 'desktop') parts.push('Desktop')
|
||||
else if (stream.videoSource?.type === 'window') parts.push('Window')
|
||||
else parts.push(stream.videoSource?.deviceName?.split('(')[0]?.trim() || 'Video')
|
||||
}
|
||||
if (stream.audioSource?.type !== 'none') {
|
||||
parts.push(stream.audioSource?.deviceName?.split('(')[0]?.trim() || 'Audio')
|
||||
}
|
||||
const dest = stream.serverAddress
|
||||
? `→ ${stream.serverAddress}:${stream.port}`
|
||||
: '→ (not configured)'
|
||||
return parts.length > 0 ? `${parts.join(' + ')} ${dest}` : dest
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`stream-card ${STATUS_CLASS[stream.status] || ''} ${isActive ? 'stream-card--active' : ''}`}>
|
||||
{/* Card Header */}
|
||||
<div className="card-header">
|
||||
<div className="card-header-left">
|
||||
<div className={`status-dot ${STATUS_CLASS[stream.status]}`} />
|
||||
{editingName ? (
|
||||
<input
|
||||
className="name-input"
|
||||
value={nameValue}
|
||||
autoFocus
|
||||
onChange={e => setNameValue(e.target.value)}
|
||||
onBlur={handleNameBlur}
|
||||
onKeyDown={e => { if (e.key === 'Enter') handleNameBlur() }}
|
||||
onClick={e => e.stopPropagation()}
|
||||
/>
|
||||
) : (
|
||||
<span
|
||||
className="stream-name"
|
||||
onClick={(e) => { e.stopPropagation(); setEditingName(true) }}
|
||||
title="Click to rename"
|
||||
>
|
||||
{stream.name}
|
||||
</span>
|
||||
)}
|
||||
<span className="status-label">{STATUS_LABELS[stream.status] || 'Idle'}</span>
|
||||
</div>
|
||||
|
||||
<div className="card-header-right">
|
||||
{!isActive ? (
|
||||
<button
|
||||
className="btn btn--start"
|
||||
onClick={onStart}
|
||||
disabled={!stream.serverAddress || !stream.port}
|
||||
title={!stream.serverAddress ? 'Enter server address first' : 'Start stream'}
|
||||
>
|
||||
▶ Start
|
||||
</button>
|
||||
) : (
|
||||
<button className="btn btn--stop" onClick={onStop}>
|
||||
■ Stop
|
||||
</button>
|
||||
)}
|
||||
|
||||
<button
|
||||
className="btn btn--icon"
|
||||
onClick={() => setExpanded(v => !v)}
|
||||
title={expanded ? 'Collapse' : 'Expand'}
|
||||
>
|
||||
{expanded ? '▲' : '▼'}
|
||||
</button>
|
||||
|
||||
<button
|
||||
className="btn btn--icon btn--danger"
|
||||
onClick={() => { if (window.confirm(`Remove "${stream.name}"?`)) onRemove() }}
|
||||
title="Remove stream"
|
||||
disabled={isActive}
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Summary when collapsed */}
|
||||
{!expanded && (
|
||||
<div className="card-summary">{getStreamSummary()}</div>
|
||||
)}
|
||||
|
||||
{/* Settings Panel */}
|
||||
{expanded && (
|
||||
<StreamSettings
|
||||
stream={stream}
|
||||
devices={devices}
|
||||
windows={windows}
|
||||
devicesLoaded={devicesLoaded}
|
||||
disabled={isActive}
|
||||
onChange={onChange}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,403 @@
|
||||
import React, { useState } from 'react'
|
||||
|
||||
// ─── Frame profiles ────────────────────────────────────────────────────────────
|
||||
const FRAME_PROFILES = [
|
||||
{ label: '— Custom —', value: 'custom', res: null, fps: null, vbr: null },
|
||||
{ label: '4K UHD · 3840×2160 · 30fps · 20 Mbps', value: '4k30', res: '3840x2160', fps: 30, vbr: '20000k' },
|
||||
{ label: '4K UHD · 3840×2160 · 60fps · 40 Mbps', value: '4k60', res: '3840x2160', fps: 60, vbr: '40000k' },
|
||||
{ label: '1080p · 1920×1080 · 60fps · 8 Mbps', value: '1080p60',res: '1920x1080', fps: 60, vbr: '8000k' },
|
||||
{ label: '1080p · 1920×1080 · 30fps · 4 Mbps', value: '1080p30',res: '1920x1080', fps: 30, vbr: '4000k' },
|
||||
{ label: '1080p · 1920×1080 · 25fps · 4 Mbps', value: '1080p25',res: '1920x1080', fps: 25, vbr: '4000k' },
|
||||
{ label: '720p · 1280×720 · 60fps · 4 Mbps', value: '720p60', res: '1280x720', fps: 60, vbr: '4000k' },
|
||||
{ label: '720p · 1280×720 · 30fps · 2 Mbps', value: '720p30', res: '1280x720', fps: 30, vbr: '2000k' },
|
||||
{ label: '720p · 1280×720 · 25fps · 2 Mbps', value: '720p25', res: '1280x720', fps: 25, vbr: '2000k' },
|
||||
{ label: '480p · 854×480 · 30fps · 1 Mbps', value: '480p30', res: '854x480', fps: 30, vbr: '1000k' },
|
||||
{ label: '480p · 854×480 · 25fps · 1 Mbps', value: '480p25', res: '854x480', fps: 25, vbr: '1000k' },
|
||||
{ label: '360p · 640×360 · 25fps · 500 kbps', value: '360p', res: '640x360', fps: 25, vbr: '500k' },
|
||||
]
|
||||
|
||||
const RESOLUTIONS = ['3840x2160','2560x1440','1920x1080','1280x720','854x480','640x360','Custom']
|
||||
const FRAMERATES = ['15','24','25','30','50','60']
|
||||
|
||||
const VIDEO_BITRATES = [
|
||||
{ label: '500 kbps', value: '500k' },
|
||||
{ label: '1 Mbps', value: '1000k' },
|
||||
{ label: '2 Mbps', value: '2000k' },
|
||||
{ label: '4 Mbps', value: '4000k' },
|
||||
{ label: '6 Mbps', value: '6000k' },
|
||||
{ label: '8 Mbps', value: '8000k' },
|
||||
{ label: '12 Mbps', value: '12000k' },
|
||||
{ label: '20 Mbps', value: '20000k' },
|
||||
{ label: '40 Mbps', value: '40000k' },
|
||||
{ label: 'Custom', value: 'custom' },
|
||||
]
|
||||
|
||||
const AUDIO_BITRATES = [
|
||||
{ label: '64 kbps', value: '64k' },
|
||||
{ label: '96 kbps', value: '96k' },
|
||||
{ label: '128 kbps', value: '128k' },
|
||||
{ label: '192 kbps', value: '192k' },
|
||||
{ label: '256 kbps', value: '256k' },
|
||||
{ label: '320 kbps', value: '320k' },
|
||||
]
|
||||
|
||||
const HW_ACCEL_OPTIONS = [
|
||||
{ label: 'Auto (best available)', value: 'auto' },
|
||||
{ label: 'NVIDIA NVENC', value: 'nvenc' },
|
||||
{ label: 'Intel QSV', value: 'qsv' },
|
||||
{ label: 'AMD AMF', value: 'amf' },
|
||||
{ label: 'Apple VideoToolbox', value: 'videotoolbox' },
|
||||
{ label: 'VAAPI (Linux)', value: 'vaapi' },
|
||||
{ label: 'Software (libx264)', value: 'software' },
|
||||
]
|
||||
|
||||
const SRT_MODES = [
|
||||
{ label: 'Caller — подключиться к серверу', value: 'caller' },
|
||||
{ label: 'Listener — принимать подключения', value: 'listener' },
|
||||
{ label: 'Rendezvous', value: 'rendezvous'},
|
||||
]
|
||||
|
||||
// ─── helpers ──────────────────────────────────────────────────────────────────
|
||||
function Select({ label, value, onChange, options, disabled, className = '' }) {
|
||||
return (
|
||||
<div className={`field ${className}`}>
|
||||
{label && <label className="field-label">{label}</label>}
|
||||
<select className="field-select" value={value} onChange={e => onChange(e.target.value)} disabled={disabled}>
|
||||
{options.map(opt =>
|
||||
typeof opt === 'string'
|
||||
? <option key={opt} value={opt}>{opt}</option>
|
||||
: <option key={opt.value} value={opt.value} disabled={opt.disabled}>{opt.label ?? opt.name ?? opt.value}</option>
|
||||
)}
|
||||
</select>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Input({ label, value, onChange, placeholder, disabled, type = 'text', min, max, className = '' }) {
|
||||
return (
|
||||
<div className={`field ${className}`}>
|
||||
{label && <label className="field-label">{label}</label>}
|
||||
<input
|
||||
className="field-input" type={type} value={value}
|
||||
onChange={e => onChange(e.target.value)} placeholder={placeholder}
|
||||
disabled={disabled} min={min} max={max}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── detect current frame profile ─────────────────────────────────────────────
|
||||
function detectProfile(res, fps, vbr) {
|
||||
const p = FRAME_PROFILES.find(p =>
|
||||
p.res === res && p.fps === Number(fps) && p.vbr === vbr
|
||||
)
|
||||
return p ? p.value : 'custom'
|
||||
}
|
||||
|
||||
// ─── main component ───────────────────────────────────────────────────────────
|
||||
export default function StreamSettings({ stream, devices, windows, devicesLoaded, disabled, onChange }) {
|
||||
const [activeSection, setActiveSection] = useState('source')
|
||||
|
||||
const updateVideo = changes => onChange({ videoSource: { ...stream.videoSource, ...changes } })
|
||||
const updateAudio = changes => onChange({ audioSource: { ...stream.audioSource, ...changes } })
|
||||
|
||||
const videoDevices = devices.video || []
|
||||
const audioDevices = devices.audio || []
|
||||
|
||||
// Build grouped video options
|
||||
const noneOpts = videoDevices.filter(d => d.type === 'none')
|
||||
const screenOpts = videoDevices.filter(d => d.type === 'desktop')
|
||||
const cameraOpts = videoDevices.filter(d => d.type === 'device')
|
||||
const windowOpts = (windows || []).map(w => ({
|
||||
name: w.title, deviceName: w.title, type: 'window', windowTitle: w.title
|
||||
}))
|
||||
|
||||
const videoOptions = [
|
||||
...noneOpts,
|
||||
...(screenOpts.length ? [{ name: '─── Экран / Рабочий стол ───', deviceName: '__sep_screen__', type: 'separator' }] : []),
|
||||
...screenOpts,
|
||||
...(windowOpts.length ? [{ name: '─── Окна приложений ───', deviceName: '__sep_win__', type: 'separator' }] : []),
|
||||
...windowOpts,
|
||||
...(cameraOpts.length ? [{ name: '─── Камеры / Карты захвата ───',deviceName: '__sep_cam__', type: 'separator' }] : []),
|
||||
...cameraOpts,
|
||||
]
|
||||
|
||||
const currentVideoName = stream.videoSource?.deviceName || ''
|
||||
const currentVideoType = stream.videoSource?.type || 'none'
|
||||
|
||||
function handleVideoSelect(deviceName) {
|
||||
if (deviceName.startsWith('__sep_')) return
|
||||
const allOpts = [...noneOpts, ...screenOpts, ...windowOpts, ...cameraOpts]
|
||||
const dev = allOpts.find(d => d.deviceName === deviceName || d.name === deviceName)
|
||||
if (dev) {
|
||||
updateVideo({
|
||||
deviceName: dev.deviceName || dev.name,
|
||||
type: dev.type,
|
||||
deviceIndex: dev.deviceIndex,
|
||||
devicePath: dev.devicePath,
|
||||
windowTitle: dev.windowTitle,
|
||||
screenIndex: dev.monitorIndex,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function handleAudioSelect(deviceName) {
|
||||
const dev = audioDevices.find(d => d.deviceName === deviceName || d.name === deviceName)
|
||||
if (dev) updateAudio({ deviceName: dev.deviceName || dev.name, type: dev.type || 'device' })
|
||||
}
|
||||
|
||||
// Frame profile
|
||||
const currentProfile = detectProfile(stream.resolution, stream.framerate, stream.videoBitrate)
|
||||
|
||||
function applyProfile(profileValue) {
|
||||
const p = FRAME_PROFILES.find(x => x.value === profileValue)
|
||||
if (!p || p.value === 'custom') return
|
||||
onChange({ resolution: p.res, framerate: p.fps, videoBitrate: p.vbr })
|
||||
}
|
||||
|
||||
// Resolution
|
||||
const currentResolution = RESOLUTIONS.includes(stream.resolution) ? stream.resolution : 'Custom'
|
||||
const isCustomBitrate = !VIDEO_BITRATES.find(b => b.value === stream.videoBitrate && b.value !== 'custom')
|
||||
|
||||
return (
|
||||
<div className="stream-settings">
|
||||
{/* Section Tabs */}
|
||||
<div className="section-tabs">
|
||||
{['source', 'output', 'encoding'].map(s => (
|
||||
<button key={s} className={`section-tab ${activeSection === s ? 'active' : ''}`}
|
||||
onClick={() => setActiveSection(s)}>
|
||||
{s === 'source' ? 'Источник' : s === 'output' ? 'Вывод / SRT' : 'Кодирование'}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* ── SOURCE ── */}
|
||||
{activeSection === 'source' && (
|
||||
<div className="settings-section">
|
||||
{/* Video */}
|
||||
<div className="settings-group">
|
||||
<div className="group-title">Видеоисточник</div>
|
||||
<div className="field">
|
||||
<label className="field-label">Устройство / Источник</label>
|
||||
{devicesLoaded ? (
|
||||
<select
|
||||
className="field-select"
|
||||
value={currentVideoName}
|
||||
onChange={e => handleVideoSelect(e.target.value)}
|
||||
disabled={disabled}
|
||||
size={1}
|
||||
>
|
||||
{videoOptions.map((dev, i) =>
|
||||
dev.type === 'separator'
|
||||
? <option key={i} value={dev.deviceName} disabled style={{ color: '#475569', fontStyle: 'italic' }}>
|
||||
{dev.name}
|
||||
</option>
|
||||
: <option key={dev.deviceName || i} value={dev.deviceName || dev.name}>
|
||||
{dev.name}
|
||||
</option>
|
||||
)}
|
||||
</select>
|
||||
) : (
|
||||
<div className="field-loading">Загрузка устройств…</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{(currentVideoType === 'desktop' || currentVideoType === 'window') && (
|
||||
<label className="checkbox-label field">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={stream.videoSource?.hideCursor || false}
|
||||
onChange={e => updateVideo({ hideCursor: e.target.checked })}
|
||||
disabled={disabled}
|
||||
/>
|
||||
Скрыть курсор мыши
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Audio */}
|
||||
<div className="settings-group">
|
||||
<div className="group-title">Аудиоисточник</div>
|
||||
<div className="field">
|
||||
<label className="field-label">Устройство</label>
|
||||
{devicesLoaded ? (
|
||||
<select
|
||||
className="field-select"
|
||||
value={stream.audioSource?.deviceName || ''}
|
||||
onChange={e => handleAudioSelect(e.target.value)}
|
||||
disabled={disabled}
|
||||
>
|
||||
{audioDevices.map((dev, i) => (
|
||||
<option key={dev.deviceName || i} value={dev.deviceName || dev.name}>
|
||||
{dev.name}{dev.description ? ` — ${dev.description}` : ''}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
) : (
|
||||
<div className="field-loading">Загрузка устройств…</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── OUTPUT / SRT ── */}
|
||||
{activeSection === 'output' && (
|
||||
<div className="settings-section">
|
||||
<div className="settings-group">
|
||||
<div className="group-title">SRT Соединение</div>
|
||||
<div className="fields-row">
|
||||
<Input
|
||||
label="Адрес сервера"
|
||||
value={stream.serverAddress}
|
||||
onChange={v => onChange({ serverAddress: v })}
|
||||
placeholder="192.168.1.100 или domain.com"
|
||||
disabled={disabled}
|
||||
className="field--grow"
|
||||
/>
|
||||
<Input
|
||||
label="Порт"
|
||||
value={stream.port}
|
||||
onChange={v => onChange({ port: v })}
|
||||
placeholder="4900"
|
||||
disabled={disabled}
|
||||
type="number" min="1" max="65535"
|
||||
className="field--port"
|
||||
/>
|
||||
</div>
|
||||
<div className="fields-row">
|
||||
<Select
|
||||
label="Режим SRT"
|
||||
value={stream.srtMode}
|
||||
onChange={v => onChange({ srtMode: v })}
|
||||
options={SRT_MODES}
|
||||
disabled={disabled}
|
||||
className="field--half"
|
||||
/>
|
||||
<Input
|
||||
label="Задержка (мс)"
|
||||
value={stream.latency}
|
||||
onChange={v => onChange({ latency: parseInt(v) || 200 })}
|
||||
placeholder="200"
|
||||
disabled={disabled}
|
||||
type="number" min="20" max="8000"
|
||||
className="field--half"
|
||||
/>
|
||||
</div>
|
||||
<div className="srt-preview">
|
||||
<span className="srt-preview-label">SRT URL:</span>
|
||||
<code className="srt-url">
|
||||
{stream.serverAddress
|
||||
? `srt://${stream.serverAddress}:${stream.port}?mode=${stream.srtMode}&latency=${(stream.latency||200)*1000}`
|
||||
: 'srt://(не настроен)'}
|
||||
</code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* ── ENCODING ── */}
|
||||
{activeSection === 'encoding' && (
|
||||
<div className="settings-section">
|
||||
{/* Frame Profile */}
|
||||
<div className="settings-group">
|
||||
<div className="group-title">Профиль кадра</div>
|
||||
<div className="field">
|
||||
<label className="field-label">Пресет (устанавливает разрешение, FPS, битрейт)</label>
|
||||
<select
|
||||
className="field-select"
|
||||
value={currentProfile}
|
||||
onChange={e => applyProfile(e.target.value)}
|
||||
disabled={disabled}
|
||||
>
|
||||
{FRAME_PROFILES.map(p => (
|
||||
<option key={p.value} value={p.value}>{p.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Manual overrides */}
|
||||
<div className="settings-group">
|
||||
<div className="group-title">Параметры видео</div>
|
||||
<div className="fields-row">
|
||||
<div className="field field--half">
|
||||
<label className="field-label">Разрешение</label>
|
||||
<select
|
||||
className="field-select"
|
||||
value={currentResolution}
|
||||
onChange={e => {
|
||||
if (e.target.value !== 'Custom') onChange({ resolution: e.target.value })
|
||||
}}
|
||||
disabled={disabled}
|
||||
>
|
||||
{RESOLUTIONS.map(r => <option key={r} value={r}>{r}</option>)}
|
||||
</select>
|
||||
{currentResolution === 'Custom' && (
|
||||
<input
|
||||
className="field-input field-input--small"
|
||||
type="text"
|
||||
value={stream.resolution}
|
||||
onChange={e => onChange({ resolution: e.target.value })}
|
||||
placeholder="1920x1080"
|
||||
disabled={disabled}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<Select
|
||||
label="Частота кадров"
|
||||
value={String(stream.framerate || 30)}
|
||||
onChange={v => onChange({ framerate: parseInt(v) })}
|
||||
options={FRAMERATES.map(f => ({ label: `${f} fps`, value: f }))}
|
||||
disabled={disabled}
|
||||
className="field--half"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="fields-row">
|
||||
<div className="field field--half">
|
||||
<label className="field-label">Битрейт видео</label>
|
||||
<select
|
||||
className="field-select"
|
||||
value={isCustomBitrate ? 'custom' : stream.videoBitrate}
|
||||
onChange={e => { if (e.target.value !== 'custom') onChange({ videoBitrate: e.target.value }) }}
|
||||
disabled={disabled}
|
||||
>
|
||||
{VIDEO_BITRATES.map(b => <option key={b.value} value={b.value}>{b.label}</option>)}
|
||||
</select>
|
||||
{isCustomBitrate && (
|
||||
<input
|
||||
className="field-input field-input--small"
|
||||
type="text"
|
||||
value={stream.videoBitrate}
|
||||
onChange={e => onChange({ videoBitrate: e.target.value })}
|
||||
placeholder="4000k"
|
||||
disabled={disabled}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<Select
|
||||
label="Битрейт аудио"
|
||||
value={stream.audioBitrate}
|
||||
onChange={v => onChange({ audioBitrate: v })}
|
||||
options={AUDIO_BITRATES}
|
||||
disabled={disabled || stream.audioSource?.type === 'none'}
|
||||
className="field--half"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="settings-group">
|
||||
<div className="group-title">Аппаратное ускорение (H.264)</div>
|
||||
<Select
|
||||
value={stream.hwAccel || 'auto'}
|
||||
onChange={v => onChange({ hwAccel: v })}
|
||||
options={HW_ACCEL_OPTIONS}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
import React, { useState, useEffect } from 'react'
|
||||
|
||||
const SRT_MODES = [
|
||||
{ value: 'listener', label: 'Listener — ждать входящего подключения' },
|
||||
{ value: 'caller', label: 'Caller — подключиться к удалённому серверу' },
|
||||
{ value: 'rendezvous', label: 'Rendezvous — одновременный набор' },
|
||||
]
|
||||
|
||||
export default function TolbekSettings({ config, onChange, ipc }) {
|
||||
const [status, setStatus] = useState('idle') // idle | connecting | running | error
|
||||
const [logs, setLogs] = useState([])
|
||||
|
||||
const isRunning = status === 'running' || status === 'connecting'
|
||||
|
||||
// Subscribe to tolbek-specific log/error/ended events
|
||||
useEffect(() => {
|
||||
if (!ipc) return
|
||||
const handleLog = ({ id, text }) => {
|
||||
if (id !== 'tolbek') return
|
||||
setLogs(prev => [...prev.slice(-199), text.trim()])
|
||||
if (status === 'connecting') setStatus('running')
|
||||
}
|
||||
const handleError = ({ id, error }) => {
|
||||
if (id !== 'tolbek') return
|
||||
setStatus('error')
|
||||
setLogs(prev => [...prev, `ERROR: ${error}`])
|
||||
}
|
||||
const handleEnded = ({ id }) => {
|
||||
if (id !== 'tolbek') return
|
||||
setStatus('idle')
|
||||
}
|
||||
ipc.onStreamLog(handleLog)
|
||||
ipc.onStreamError(handleError)
|
||||
ipc.onStreamEnded(handleEnded)
|
||||
return () => {
|
||||
ipc.removeAllListeners('stream-log')
|
||||
ipc.removeAllListeners('stream-error')
|
||||
ipc.removeAllListeners('stream-ended')
|
||||
}
|
||||
}, [ipc, status])
|
||||
|
||||
const handleStart = async () => {
|
||||
if (!ipc) return
|
||||
setStatus('connecting')
|
||||
setLogs([])
|
||||
const result = await ipc.startTolbek(config)
|
||||
if (!result.success) {
|
||||
setStatus('error')
|
||||
setLogs([`Ошибка запуска: ${result.error}`])
|
||||
}
|
||||
}
|
||||
|
||||
const handleStop = async () => {
|
||||
if (!ipc) return
|
||||
await ipc.stopTolbek()
|
||||
setStatus('idle')
|
||||
}
|
||||
|
||||
const update = (key, value) => onChange({ ...config, [key]: value })
|
||||
|
||||
const mode = config.mode || 'listener'
|
||||
const port = config.port || 5000
|
||||
const latency = config.latency || 200
|
||||
const serverAddress = config.serverAddress || ''
|
||||
|
||||
// Build URL preview
|
||||
const urlPreview = mode === 'listener'
|
||||
? `srt://0.0.0.0:${port}?mode=listener&latency=${latency * 1000}`
|
||||
: mode === 'caller'
|
||||
? `srt://${serverAddress || 'HOST'}:${port}?mode=caller&latency=${latency * 1000}`
|
||||
: `srt://${serverAddress || 'HOST'}:${port}?mode=rendezvous&latency=${latency * 1000}`
|
||||
|
||||
const statusInfo = {
|
||||
idle: { cls: 'status--idle', label: 'Не запущен' },
|
||||
connecting: { cls: 'status--connecting', label: 'Запуск…' },
|
||||
running: { cls: 'status--running', label: mode === 'listener' ? 'Слушает порт…' : 'Подключён' },
|
||||
error: { cls: 'status--error', label: 'Ошибка' },
|
||||
}[status]
|
||||
|
||||
return (
|
||||
<div className="tolbek-settings">
|
||||
<div className="section-header">
|
||||
<h2 className="section-title">Tolbek — SRT Приёмник</h2>
|
||||
<p className="section-desc">
|
||||
Приём одного входящего SRT-потока (обратная связь, мониторинг, IFB).
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="settings-card">
|
||||
|
||||
{/* ── Connection settings ── */}
|
||||
<div className="settings-group">
|
||||
<div className="group-title">Подключение</div>
|
||||
|
||||
<div className="field">
|
||||
<label className="field-label">Режим SRT</label>
|
||||
<select
|
||||
className="field-select"
|
||||
value={mode}
|
||||
onChange={e => update('mode', e.target.value)}
|
||||
disabled={isRunning}
|
||||
>
|
||||
{SRT_MODES.map(m => (
|
||||
<option key={m.value} value={m.value}>{m.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* Caller / Rendezvous — нужен адрес */}
|
||||
{(mode === 'caller' || mode === 'rendezvous') && (
|
||||
<div className="field">
|
||||
<label className="field-label">Адрес сервера</label>
|
||||
<input
|
||||
className="field-input"
|
||||
type="text"
|
||||
value={serverAddress}
|
||||
onChange={e => update('serverAddress', e.target.value)}
|
||||
placeholder="192.168.1.100 или domain.com"
|
||||
disabled={isRunning}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="fields-row">
|
||||
<div className="field field--port">
|
||||
<label className="field-label">Порт</label>
|
||||
<input
|
||||
className="field-input"
|
||||
type="number"
|
||||
value={port}
|
||||
onChange={e => update('port', parseInt(e.target.value) || 5000)}
|
||||
min="1" max="65535"
|
||||
disabled={isRunning}
|
||||
/>
|
||||
</div>
|
||||
<div className="field field--half">
|
||||
<label className="field-label">Задержка (мс)</label>
|
||||
<input
|
||||
className="field-input"
|
||||
type="number"
|
||||
value={latency}
|
||||
onChange={e => update('latency', parseInt(e.target.value) || 200)}
|
||||
min="20" max="8000"
|
||||
disabled={isRunning}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="srt-preview">
|
||||
<span className="srt-preview-label">SRT URL:</span>
|
||||
<code className="srt-url">{urlPreview}</code>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ── Status + controls ── */}
|
||||
<div className="settings-group">
|
||||
<div className="group-title">Статус</div>
|
||||
<div className="tolbek-status">
|
||||
<div className={`status-indicator ${statusInfo.cls}`}>
|
||||
<div className={`status-dot ${statusInfo.cls}`} />
|
||||
<span>{statusInfo.label}</span>
|
||||
</div>
|
||||
<div className="tolbek-actions">
|
||||
{!isRunning ? (
|
||||
<button
|
||||
className="btn btn--start"
|
||||
onClick={handleStart}
|
||||
disabled={mode !== 'listener' && !serverAddress}
|
||||
title={mode !== 'listener' && !serverAddress ? 'Укажите адрес сервера' : ''}
|
||||
>
|
||||
▶ Запустить
|
||||
</button>
|
||||
) : (
|
||||
<button className="btn btn--stop" onClick={handleStop}>
|
||||
■ Остановить
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{logs.length > 0 && (
|
||||
<div className="tolbek-log">
|
||||
{logs.map((line, i) => (
|
||||
<div key={i} className={`log-line ${line.startsWith('ERROR') ? 'log-line--error' : ''}`}>
|
||||
<span className="log-text">{line}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* ── Info ── */}
|
||||
<div className="settings-group">
|
||||
<div className="group-title">Справка по режимам</div>
|
||||
<div className="tolbek-modes-info">
|
||||
<div className="mode-row">
|
||||
<span className="mode-tag">Listener</span>
|
||||
<span className="mode-desc">Приёмник ждёт входящего подключения на указанном порту. Отправитель использует режим <em>caller</em> и указывает ваш IP.</span>
|
||||
</div>
|
||||
<div className="mode-row">
|
||||
<span className="mode-tag">Caller</span>
|
||||
<span className="mode-desc">Приёмник сам подключается к удалённому серверу. Укажите адрес и порт источника.</span>
|
||||
</div>
|
||||
<div className="mode-row">
|
||||
<span className="mode-tag">Rendezvous</span>
|
||||
<span className="mode-desc">Оба конца одновременно набирают соединение. Оба используют одинаковый порт.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import App from './App.jsx'
|
||||
import './styles/App.css'
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
)
|
||||
@@ -0,0 +1,737 @@
|
||||
/* ========== RESET & BASE ========== */
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
:root {
|
||||
--bg-primary: #0f0f1a;
|
||||
--bg-secondary: #16213e;
|
||||
--bg-card: #1a1a2e;
|
||||
--bg-hover: #1e2a4a;
|
||||
--bg-input: #0d1117;
|
||||
--bg-section: #12162a;
|
||||
|
||||
--accent: #4f8ef7;
|
||||
--accent-hover: #6aa0ff;
|
||||
--accent-dim: rgba(79, 142, 247, 0.15);
|
||||
|
||||
--green: #22c55e;
|
||||
--green-dim: rgba(34, 197, 94, 0.15);
|
||||
--red: #ef4444;
|
||||
--red-dim: rgba(239, 68, 68, 0.15);
|
||||
--orange: #f59e0b;
|
||||
--orange-dim: rgba(245, 158, 11, 0.15);
|
||||
|
||||
--text-primary: #e2e8f0;
|
||||
--text-secondary: #94a3b8;
|
||||
--text-muted: #475569;
|
||||
--text-code: #7dd3fc;
|
||||
|
||||
--border: #1e2a4a;
|
||||
--border-bright: #2d3f6a;
|
||||
--border-focus: #4f8ef7;
|
||||
|
||||
--radius-sm: 6px;
|
||||
--radius: 10px;
|
||||
--radius-lg: 14px;
|
||||
|
||||
--shadow: 0 2px 12px rgba(0,0,0,0.4);
|
||||
--shadow-lg: 0 4px 24px rgba(0,0,0,0.6);
|
||||
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
html, body, #root {
|
||||
height: 100%;
|
||||
background: var(--bg-primary);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ========== APP LAYOUT ========== */
|
||||
.app {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
background: var(--bg-primary);
|
||||
}
|
||||
|
||||
/* ========== TITLE BAR ========== */
|
||||
.titlebar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 36px;
|
||||
background: var(--bg-secondary);
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 0 8px 0 12px;
|
||||
flex-shrink: 0;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.titlebar-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.app-logo {
|
||||
color: var(--accent);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.app-title {
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.active-badge {
|
||||
background: var(--green);
|
||||
color: #000;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
padding: 1px 6px;
|
||||
border-radius: 10px;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.titlebar-controls {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.tb-btn {
|
||||
width: 28px;
|
||||
height: 24px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
.tb-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
|
||||
|
||||
/* ========== TAB BAR ========== */
|
||||
.tabbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: var(--bg-secondary);
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 0 8px;
|
||||
height: 38px;
|
||||
gap: 2px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tab {
|
||||
position: relative;
|
||||
padding: 0 14px;
|
||||
height: 30px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: 12.5px;
|
||||
font-weight: 500;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.tab:hover { background: var(--bg-hover); color: var(--text-primary); }
|
||||
.tab.active {
|
||||
background: var(--accent-dim);
|
||||
color: var(--accent);
|
||||
border: 1px solid rgba(79, 142, 247, 0.3);
|
||||
}
|
||||
|
||||
.tab--icon { margin-left: 4px; font-size: 12px; }
|
||||
|
||||
.tab-badge {
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
padding: 1px 5px;
|
||||
border-radius: 8px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.tab-badge--green { background: var(--green); padding: 1px 3px; }
|
||||
.tab-badge--red { background: var(--red); }
|
||||
|
||||
.tabbar-spacer { flex: 1; }
|
||||
|
||||
/* ========== CONTENT AREA ========== */
|
||||
.content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.content::-webkit-scrollbar { width: 6px; }
|
||||
.content::-webkit-scrollbar-track { background: transparent; }
|
||||
.content::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
|
||||
.content::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
|
||||
|
||||
/* ========== STREAMS VIEW ========== */
|
||||
.streams-view { min-height: 100%; }
|
||||
|
||||
.streams-grid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
/* ========== ADD STREAM BUTTON ========== */
|
||||
.add-stream-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
padding: 14px;
|
||||
border: 2px dashed var(--border-bright);
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
border-radius: var(--radius);
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.add-stream-btn:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
background: var(--accent-dim);
|
||||
}
|
||||
.add-icon {
|
||||
font-size: 20px;
|
||||
font-weight: 300;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* ========== STREAM CARD ========== */
|
||||
.stream-card {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
overflow: hidden;
|
||||
transition: border-color 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
.stream-card:hover { border-color: var(--border-bright); }
|
||||
.stream-card--active { border-color: var(--green); box-shadow: 0 0 0 1px var(--green-dim); }
|
||||
.stream-card.status--error { border-color: var(--red); }
|
||||
|
||||
/* Card Header */
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 12px;
|
||||
background: var(--bg-secondary);
|
||||
border-bottom: 1px solid var(--border);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.card-header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.card-header-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Status dot */
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
background: var(--text-muted);
|
||||
}
|
||||
.status-dot.status--idle { background: var(--text-muted); }
|
||||
.status-dot.status--connecting {
|
||||
background: var(--orange);
|
||||
animation: pulse 1s infinite;
|
||||
}
|
||||
.status-dot.status--running {
|
||||
background: var(--green);
|
||||
box-shadow: 0 0 6px var(--green);
|
||||
}
|
||||
.status-dot.status--error { background: var(--red); }
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.3; }
|
||||
}
|
||||
|
||||
.stream-name {
|
||||
font-weight: 600;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.stream-name:hover { color: var(--accent); }
|
||||
|
||||
.name-input {
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border-focus);
|
||||
color: var(--text-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 2px 8px;
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
outline: none;
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.status-label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Card summary */
|
||||
.card-summary {
|
||||
padding: 8px 12px;
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
font-family: 'SF Mono', 'Consolas', monospace;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* ========== BUTTONS ========== */
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 5px;
|
||||
padding: 5px 12px;
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
transition: all 0.15s;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
|
||||
|
||||
.btn--start {
|
||||
background: var(--green);
|
||||
color: #000;
|
||||
}
|
||||
.btn--start:hover:not(:disabled) {
|
||||
background: #16a34a;
|
||||
box-shadow: 0 0 10px rgba(34,197,94,0.4);
|
||||
}
|
||||
|
||||
.btn--stop {
|
||||
background: var(--red);
|
||||
color: #fff;
|
||||
}
|
||||
.btn--stop:hover {
|
||||
background: #dc2626;
|
||||
box-shadow: 0 0 10px rgba(239,68,68,0.4);
|
||||
}
|
||||
|
||||
.btn--icon {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.btn--icon:hover { background: var(--bg-hover); border-color: var(--border-bright); color: var(--text-primary); }
|
||||
.btn--danger:hover { border-color: var(--red); color: var(--red); }
|
||||
|
||||
.btn--small {
|
||||
padding: 4px 10px;
|
||||
background: var(--bg-hover);
|
||||
color: var(--text-secondary);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
.btn--small:hover { color: var(--text-primary); border-color: var(--border-bright); }
|
||||
|
||||
/* ========== STREAM SETTINGS ========== */
|
||||
.stream-settings {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.section-tabs {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
margin-bottom: 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.section-tab {
|
||||
padding: 4px 12px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
.section-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
|
||||
.section-tab.active {
|
||||
background: var(--accent-dim);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.settings-section { display: flex; flex-direction: column; gap: 12px; }
|
||||
|
||||
.settings-group {
|
||||
background: var(--bg-section);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.group-title {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/* ========== FIELDS ========== */
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.field:last-child { margin-bottom: 0; }
|
||||
|
||||
.field-label {
|
||||
font-size: 11.5px;
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.field-select,
|
||||
.field-input {
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 6px 10px;
|
||||
font-size: 12.5px;
|
||||
outline: none;
|
||||
transition: border-color 0.15s;
|
||||
width: 100%;
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
.field-select {
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 8px center;
|
||||
padding-right: 28px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.field-select:focus,
|
||||
.field-input:focus {
|
||||
border-color: var(--border-focus);
|
||||
box-shadow: 0 0 0 2px rgba(79,142,247,0.15);
|
||||
}
|
||||
.field-select:disabled,
|
||||
.field-input:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.field-input--small {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.field-loading {
|
||||
padding: 6px 10px;
|
||||
color: var(--text-muted);
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.fields-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.fields-row:last-child { margin-bottom: 0; }
|
||||
.fields-row .field { margin-bottom: 0; }
|
||||
|
||||
.field--grow { flex: 1; }
|
||||
.field--half { flex: 1; }
|
||||
.field--port { width: 100px; flex-shrink: 0; }
|
||||
|
||||
.checkbox-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 12.5px;
|
||||
color: var(--text-secondary);
|
||||
user-select: none;
|
||||
}
|
||||
.checkbox-label input { cursor: pointer; accent-color: var(--accent); }
|
||||
|
||||
/* SRT URL Preview */
|
||||
.srt-preview {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
padding: 6px 10px;
|
||||
background: rgba(0,0,0,0.3);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
.srt-preview-label {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.srt-url {
|
||||
font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
|
||||
font-size: 11px;
|
||||
color: var(--text-code);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* ========== TOLBEK SETTINGS ========== */
|
||||
.tolbek-settings {
|
||||
max-width: 700px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.section-desc {
|
||||
font-size: 12.5px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.settings-card {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.tolbek-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.status-indicator {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 12.5px;
|
||||
}
|
||||
.status-indicator.status--running { color: var(--green); }
|
||||
.status-indicator.status--connecting { color: var(--orange); }
|
||||
.status-indicator.status--error { color: var(--red); }
|
||||
.status-indicator.status--idle { color: var(--text-muted); }
|
||||
|
||||
.tolbek-actions { display: flex; gap: 8px; }
|
||||
|
||||
.tolbek-log {
|
||||
margin-top: 8px;
|
||||
max-height: 120px;
|
||||
overflow-y: auto;
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 8px;
|
||||
font-family: monospace;
|
||||
font-size: 11px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.info-text {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
line-height: 1.6;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.info-text:last-child { margin-bottom: 0; }
|
||||
.info-text strong { color: var(--text-secondary); }
|
||||
.info-text em { color: var(--text-code); font-style: normal; }
|
||||
|
||||
/* Tolbek modes info */
|
||||
.tolbek-modes-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.mode-row {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: flex-start;
|
||||
font-size: 12px;
|
||||
}
|
||||
.mode-tag {
|
||||
flex-shrink: 0;
|
||||
width: 82px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
background: var(--accent-dim);
|
||||
color: var(--accent);
|
||||
border: 1px solid rgba(79,142,247,0.25);
|
||||
}
|
||||
.mode-desc {
|
||||
color: var(--text-muted);
|
||||
line-height: 1.5;
|
||||
}
|
||||
.mode-desc em { color: var(--text-code); font-style: normal; }
|
||||
|
||||
/* ========== LOG PANEL ========== */
|
||||
.log-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: calc(100vh - 74px - 32px);
|
||||
}
|
||||
|
||||
.log-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding-bottom: 8px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
margin-bottom: 8px;
|
||||
flex-shrink: 0;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.log-filters {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.filter-btn {
|
||||
padding: 3px 10px;
|
||||
border: 1px solid var(--border);
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: 11.5px;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
.filter-btn:hover { border-color: var(--border-bright); color: var(--text-secondary); }
|
||||
.filter-btn.active {
|
||||
background: var(--accent-dim);
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.log-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.log-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
|
||||
font-size: 11px;
|
||||
line-height: 1.5;
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.log-empty {
|
||||
text-align: center;
|
||||
color: var(--text-muted);
|
||||
padding: 24px;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.log-line {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
padding: 1px 0;
|
||||
word-break: break-all;
|
||||
}
|
||||
.log-line--error { color: var(--red); }
|
||||
|
||||
.log-stream {
|
||||
color: var(--accent);
|
||||
flex-shrink: 0;
|
||||
font-size: 10px;
|
||||
padding-top: 1px;
|
||||
}
|
||||
|
||||
.log-text {
|
||||
color: var(--text-secondary);
|
||||
flex: 1;
|
||||
}
|
||||
.log-line--error .log-text { color: var(--red); }
|
||||
|
||||
/* ========== SCROLLBAR ========== */
|
||||
* { scrollbar-width: thin; scrollbar-color: var(--border-bright) transparent; }
|
||||
::-webkit-scrollbar { width: 6px; height: 6px; }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
|
||||
|
||||
/* ========== SELECT OPTION STYLING ========== */
|
||||
option { background: #1a1a2e; color: var(--text-primary); }
|
||||
option:disabled { color: var(--text-muted); }
|
||||
@@ -0,0 +1,24 @@
|
||||
@echo off
|
||||
title SRT Streamer
|
||||
cd /d "%~dp0"
|
||||
|
||||
:: Check node_modules
|
||||
if not exist "node_modules" (
|
||||
echo [INFO] Dependencies not installed. Running setup...
|
||||
echo.
|
||||
call setup.bat
|
||||
)
|
||||
|
||||
:: Check ffmpeg-bin
|
||||
if not exist "ffmpeg-bin\ffmpeg.exe" (
|
||||
echo [WARNING] ffmpeg.exe not found in ffmpeg-bin\
|
||||
echo.
|
||||
echo Place ffmpeg.exe in the ffmpeg-bin\ folder and restart.
|
||||
echo Download: https://github.com/BtbN/FFmpeg-Builds/releases
|
||||
echo.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Starting SRT Streamer...
|
||||
npm run dev
|
||||
@@ -0,0 +1,14 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
base: './',
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
emptyOutDir: true
|
||||
},
|
||||
server: {
|
||||
port: 5173
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user