Major enhancements to stream management and UI improvements
- Changed branding from "OBS Stream Manager" to "Live Stream Manager" throughout UI - Enhanced stream deletion with comprehensive OBS cleanup: - Removes stream's nested scene - Deletes browser source - Clears text files referencing the stream - Removes stream from all source switchers - Enhanced team deletion to clean up all OBS components: - Deletes team scene/group - Removes team text source - Deletes all associated stream scenes and sources - Clears all related text files - Fixed stream selection to use proper team-prefixed names in text files - Added StreamWithTeam type for proper team data handling - Improved browser source creation with audio controls: - Enabled "Control Audio via OBS" setting - Auto-mutes audio on creation - Attempted multiple approaches to fix text centering (still unresolved) Known issue: Text centering still positions left edge at center despite multiple attempts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
931813964f
commit
d6c9ac8d7f
9 changed files with 484 additions and 56 deletions
|
@ -3,7 +3,7 @@ import fs from 'fs';
|
|||
import path from 'path';
|
||||
import { FILE_DIRECTORY } from '../../../config';
|
||||
import { getDatabase } from '../../../lib/database';
|
||||
import { Stream } from '@/types';
|
||||
import { StreamWithTeam } from '@/types';
|
||||
import { validateScreenInput } from '../../../lib/security';
|
||||
import { TABLE_NAMES } from '../../../lib/constants';
|
||||
|
||||
|
@ -27,8 +27,11 @@ export async function POST(request: NextRequest) {
|
|||
|
||||
try {
|
||||
const db = await getDatabase();
|
||||
const stream: Stream | undefined = await db.get<Stream>(
|
||||
`SELECT * FROM ${TABLE_NAMES.STREAMS} WHERE id = ?`,
|
||||
const stream: StreamWithTeam | undefined = await db.get<StreamWithTeam>(
|
||||
`SELECT s.*, t.team_name, t.group_name
|
||||
FROM ${TABLE_NAMES.STREAMS} s
|
||||
LEFT JOIN ${TABLE_NAMES.TEAMS} t ON s.team_id = t.team_id
|
||||
WHERE s.id = ?`,
|
||||
[id]
|
||||
);
|
||||
|
||||
|
@ -38,8 +41,11 @@ export async function POST(request: NextRequest) {
|
|||
return NextResponse.json({ error: 'Stream not found' }, { status: 400 });
|
||||
}
|
||||
|
||||
// Use stream group name instead of individual obs_source_name
|
||||
const streamGroupName = `${stream.name.toLowerCase().replace(/\s+/g, '_')}_stream`;
|
||||
// Construct proper stream group name with team prefix
|
||||
const groupName = stream.group_name || stream.team_name;
|
||||
const cleanGroupName = groupName.toLowerCase().replace(/\s+/g, '_');
|
||||
const cleanStreamName = stream.name.toLowerCase().replace(/\s+/g, '_');
|
||||
const streamGroupName = `${cleanGroupName}_${cleanStreamName}_stream`;
|
||||
fs.writeFileSync(filePath, streamGroupName);
|
||||
return NextResponse.json({ message: `${screen} updated successfully.` }, { status: 200 });
|
||||
} catch (error) {
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getDatabase } from '../../../../lib/database';
|
||||
import { TABLE_NAMES } from '../../../../lib/constants';
|
||||
import { getOBSClient } from '../../../../lib/obsClient';
|
||||
|
||||
interface OBSInput {
|
||||
inputName: string;
|
||||
inputUuid: string;
|
||||
}
|
||||
|
||||
interface GetInputListResponse {
|
||||
inputs: OBSInput[];
|
||||
}
|
||||
import { deleteStreamComponents, clearTextFilesForStream } from '../../../../lib/obsClient';
|
||||
|
||||
// GET single stream
|
||||
export async function GET(
|
||||
|
@ -103,9 +94,12 @@ export async function DELETE(
|
|||
const resolvedParams = await params;
|
||||
const db = await getDatabase();
|
||||
|
||||
// Check if stream exists
|
||||
// Check if stream exists and get team info
|
||||
const existingStream = await db.get(
|
||||
`SELECT * FROM ${TABLE_NAMES.STREAMS} WHERE id = ?`,
|
||||
`SELECT s.*, t.team_name, t.group_name
|
||||
FROM ${TABLE_NAMES.STREAMS} s
|
||||
LEFT JOIN ${TABLE_NAMES.TEAMS} t ON s.team_id = t.team_id
|
||||
WHERE s.id = ?`,
|
||||
[resolvedParams.id]
|
||||
);
|
||||
|
||||
|
@ -116,35 +110,38 @@ export async function DELETE(
|
|||
);
|
||||
}
|
||||
|
||||
// Try to delete from OBS first
|
||||
// Try comprehensive OBS cleanup first
|
||||
let obsCleanupResults = null;
|
||||
try {
|
||||
const obs = await getOBSClient();
|
||||
console.log('OBS client obtained:', !!obs);
|
||||
|
||||
if (obs && existingStream.obs_source_name) {
|
||||
console.log(`Attempting to remove OBS source: ${existingStream.obs_source_name}`);
|
||||
if (existingStream.name && existingStream.team_name) {
|
||||
const groupName = existingStream.group_name || existingStream.team_name;
|
||||
|
||||
// Get the input UUID first
|
||||
const response = await obs.call('GetInputList');
|
||||
const inputs = response as GetInputListResponse;
|
||||
console.log(`Found ${inputs.inputs.length} inputs in OBS`);
|
||||
console.log(`Starting comprehensive OBS cleanup for stream: ${existingStream.name}`);
|
||||
console.log(`Team: ${existingStream.team_name}, Group: ${groupName}`);
|
||||
|
||||
const input = inputs.inputs.find((i: OBSInput) => i.inputName === existingStream.obs_source_name);
|
||||
// Perform comprehensive OBS deletion
|
||||
obsCleanupResults = await deleteStreamComponents(
|
||||
existingStream.name,
|
||||
existingStream.team_name,
|
||||
groupName
|
||||
);
|
||||
|
||||
console.log('OBS cleanup results:', obsCleanupResults);
|
||||
|
||||
// Clear text files that reference this stream
|
||||
const cleanGroupName = groupName.toLowerCase().replace(/\s+/g, '_');
|
||||
const cleanStreamName = existingStream.name.toLowerCase().replace(/\s+/g, '_');
|
||||
const streamGroupName = `${cleanGroupName}_${cleanStreamName}_stream`;
|
||||
|
||||
const textFileResults = await clearTextFilesForStream(streamGroupName);
|
||||
console.log('Text file cleanup results:', textFileResults);
|
||||
|
||||
if (input) {
|
||||
console.log(`Found input with UUID: ${input.inputUuid}`);
|
||||
await obs.call('RemoveInput', { inputUuid: input.inputUuid });
|
||||
console.log(`Successfully removed OBS source: ${existingStream.obs_source_name}`);
|
||||
} else {
|
||||
console.log(`Input not found in OBS: ${existingStream.obs_source_name}`);
|
||||
console.log('Available inputs:', inputs.inputs.map((i: OBSInput) => i.inputName));
|
||||
}
|
||||
} else {
|
||||
console.log('OBS client not available or no source name provided');
|
||||
console.log('Missing stream or team information for comprehensive cleanup');
|
||||
}
|
||||
} catch (obsError) {
|
||||
console.error('Error removing source from OBS:', obsError);
|
||||
// Continue with database deletion even if OBS removal fails
|
||||
console.error('Error during comprehensive OBS cleanup:', obsError);
|
||||
// Continue with database deletion even if OBS cleanup fails
|
||||
}
|
||||
|
||||
// Delete stream from database
|
||||
|
@ -154,7 +151,8 @@ export async function DELETE(
|
|||
);
|
||||
|
||||
return NextResponse.json({
|
||||
message: 'Stream deleted successfully'
|
||||
message: 'Stream deleted successfully',
|
||||
cleanup: obsCleanupResults || 'OBS cleanup was not performed'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error deleting stream:', error);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { NextResponse } from 'next/server';
|
||||
import { getDatabase } from '@/lib/database';
|
||||
import { TABLE_NAMES } from '@/lib/constants';
|
||||
import { deleteTeamComponents, deleteStreamComponents, clearTextFilesForStream } from '@/lib/obsClient';
|
||||
|
||||
export async function PUT(
|
||||
request: Request,
|
||||
|
@ -65,26 +66,78 @@ export async function DELETE(
|
|||
const teamId = parseInt(teamIdParam);
|
||||
const db = await getDatabase();
|
||||
|
||||
// First get the team and stream information before deletion
|
||||
const team = await db.get(
|
||||
`SELECT * FROM ${TABLE_NAMES.TEAMS} WHERE team_id = ?`,
|
||||
[teamId]
|
||||
);
|
||||
|
||||
if (!team) {
|
||||
return NextResponse.json({ error: 'Team not found' }, { status: 404 });
|
||||
}
|
||||
|
||||
// Get all streams for this team
|
||||
const streams = await db.all(
|
||||
`SELECT * FROM ${TABLE_NAMES.STREAMS} WHERE team_id = ?`,
|
||||
[teamId]
|
||||
);
|
||||
|
||||
console.log(`Deleting team "${team.team_name}" with ${streams.length} streams`);
|
||||
|
||||
// Try to clean up OBS components first
|
||||
let obsCleanupResults = null;
|
||||
try {
|
||||
// Delete each stream's OBS components
|
||||
for (const stream of streams) {
|
||||
try {
|
||||
const groupName = team.group_name || team.team_name;
|
||||
console.log(`Deleting OBS components for stream "${stream.name}"`);
|
||||
|
||||
// Delete stream components
|
||||
await deleteStreamComponents(stream.name, team.team_name, groupName);
|
||||
|
||||
// Clear any text files that reference this stream
|
||||
const cleanGroupName = groupName.toLowerCase().replace(/\s+/g, '_');
|
||||
const cleanStreamName = stream.name.toLowerCase().replace(/\s+/g, '_');
|
||||
const streamGroupName = `${cleanGroupName}_${cleanStreamName}_stream`;
|
||||
await clearTextFilesForStream(streamGroupName);
|
||||
} catch (streamError) {
|
||||
console.error(`Error deleting stream "${stream.name}" OBS components:`, streamError);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete team-level OBS components
|
||||
obsCleanupResults = await deleteTeamComponents(team.team_name, team.group_name);
|
||||
console.log('Team OBS cleanup results:', obsCleanupResults);
|
||||
|
||||
} catch (obsError) {
|
||||
console.error('Error during OBS cleanup:', obsError);
|
||||
// Continue with database deletion even if OBS cleanup fails
|
||||
}
|
||||
|
||||
// Now delete from database
|
||||
await db.run('BEGIN TRANSACTION');
|
||||
|
||||
try {
|
||||
// Delete all streams for this team
|
||||
await db.run(
|
||||
`DELETE FROM ${TABLE_NAMES.STREAMS} WHERE team_id = ?`,
|
||||
[teamId]
|
||||
);
|
||||
|
||||
// Delete the team
|
||||
const result = await db.run(
|
||||
`DELETE FROM ${TABLE_NAMES.TEAMS} WHERE team_id = ?`,
|
||||
[teamId]
|
||||
);
|
||||
|
||||
if (result.changes === 0) {
|
||||
await db.run('ROLLBACK');
|
||||
return NextResponse.json({ error: 'Team not found' }, { status: 404 });
|
||||
}
|
||||
|
||||
await db.run('COMMIT');
|
||||
return NextResponse.json({ message: 'Team and associated streams deleted successfully' });
|
||||
|
||||
return NextResponse.json({
|
||||
message: 'Team and all associated components deleted successfully',
|
||||
deletedStreams: streams.length,
|
||||
obsCleanup: obsCleanupResults || 'OBS cleanup was not performed'
|
||||
});
|
||||
} catch (error) {
|
||||
await db.run('ROLLBACK');
|
||||
throw error;
|
||||
|
|
|
@ -5,8 +5,8 @@ import { ErrorBoundary } from '@/components/ErrorBoundary';
|
|||
import PerformanceDashboard from '@/components/PerformanceDashboard';
|
||||
|
||||
export const metadata = {
|
||||
title: 'OBS Source Switcher',
|
||||
description: 'A tool to manage OBS sources dynamically',
|
||||
title: 'Live Stream Manager',
|
||||
description: 'A tool to manage live stream sources dynamically',
|
||||
};
|
||||
|
||||
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
|
|
|
@ -140,7 +140,7 @@ export default function Home() {
|
|||
<div className="container section">
|
||||
{/* Title */}
|
||||
<div className="text-center mb-8">
|
||||
<h1 className="title">Stream Control Center</h1>
|
||||
<h1 className="title">Live Stream Control Center</h1>
|
||||
<p className="subtitle">
|
||||
Manage your OBS sources across multiple screen positions
|
||||
</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue