mirror of https://github.com/jetkvm/kvm.git
[WIP] Cleanpup: Remove audio input quality settings to reduce complexity
This commit is contained in:
parent
b6858ab155
commit
c8630e7c7f
|
@ -307,42 +307,3 @@ func handleSetAudioQuality(c *gin.Context) {
|
|||
"config": current,
|
||||
})
|
||||
}
|
||||
|
||||
// handleMicrophoneQuality handles GET requests for microphone quality presets
|
||||
func handleMicrophoneQuality(c *gin.Context) {
|
||||
presets := GetMicrophoneQualityPresets()
|
||||
current := GetCurrentMicrophoneQuality()
|
||||
|
||||
c.JSON(200, gin.H{
|
||||
"presets": presets,
|
||||
"current": current,
|
||||
})
|
||||
}
|
||||
|
||||
// handleSetMicrophoneQuality handles POST requests to set microphone quality
|
||||
func handleSetMicrophoneQuality(c *gin.Context) {
|
||||
var req struct {
|
||||
Quality int `json:"quality"`
|
||||
}
|
||||
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(400, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
// Convert int to AudioQuality type
|
||||
quality := audio.AudioQuality(req.Quality)
|
||||
|
||||
// Set the microphone quality using global convenience function
|
||||
if err := SetMicrophoneQuality(quality); err != nil {
|
||||
c.JSON(500, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
// Return the updated configuration
|
||||
current := GetCurrentMicrophoneQuality()
|
||||
c.JSON(200, gin.H{
|
||||
"success": true,
|
||||
"config": current,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ interface AudioControlPopoverProps {
|
|||
|
||||
export default function AudioControlPopover({ microphone }: AudioControlPopoverProps) {
|
||||
const [currentConfig, setCurrentConfig] = useState<AudioConfig | null>(null);
|
||||
const [currentMicrophoneConfig, setCurrentMicrophoneConfig] = useState<AudioConfig | null>(null);
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
|
@ -123,15 +122,11 @@ export default function AudioControlPopover({ microphone }: AudioControlPopoverP
|
|||
const loadAudioConfigurations = async () => {
|
||||
try {
|
||||
// Use centralized audio quality service
|
||||
const { audio, microphone } = await audioQualityService.loadAllConfigurations();
|
||||
const { audio } = await audioQualityService.loadAllConfigurations();
|
||||
|
||||
if (audio) {
|
||||
setCurrentConfig(audio.current);
|
||||
}
|
||||
|
||||
if (microphone) {
|
||||
setCurrentMicrophoneConfig(microphone.current);
|
||||
}
|
||||
|
||||
setConfigsLoaded(true);
|
||||
} catch {
|
||||
|
@ -189,18 +184,6 @@ export default function AudioControlPopover({ microphone }: AudioControlPopoverP
|
|||
}
|
||||
};
|
||||
|
||||
const handleMicrophoneQualityChange = async (quality: number) => {
|
||||
try {
|
||||
const resp = await api.POST("/microphone/quality", { quality });
|
||||
if (resp.ok) {
|
||||
const data = await resp.json();
|
||||
setCurrentMicrophoneConfig(data.config);
|
||||
}
|
||||
} catch {
|
||||
// Failed to change microphone quality
|
||||
}
|
||||
};
|
||||
|
||||
const handleToggleMicrophoneEnable = async () => {
|
||||
const now = Date.now();
|
||||
|
||||
|
@ -416,45 +399,6 @@ export default function AudioControlPopover({ microphone }: AudioControlPopoverP
|
|||
</button>
|
||||
</div>
|
||||
|
||||
{/* Microphone Quality Settings */}
|
||||
{isMicrophoneActiveFromHook && (
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<MdMic className="h-4 w-4 text-slate-600 dark:text-slate-400" />
|
||||
<span className="font-medium text-slate-900 dark:text-slate-100">
|
||||
Microphone Quality
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{Object.entries(getQualityLabels()).map(([quality, label]) => (
|
||||
<button
|
||||
key={`mic-${quality}`}
|
||||
onClick={() => handleMicrophoneQualityChange(parseInt(quality))}
|
||||
disabled={isLoading}
|
||||
className={cx(
|
||||
"rounded-md border px-3 py-2 text-sm font-medium transition-colors",
|
||||
currentMicrophoneConfig?.Quality === parseInt(quality)
|
||||
? "border-green-500 bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-300"
|
||||
: "border-slate-200 bg-white text-slate-700 hover:bg-slate-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-300 dark:hover:bg-slate-600",
|
||||
isLoading && "opacity-50 cursor-not-allowed"
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{currentMicrophoneConfig && (
|
||||
<div className="text-xs text-slate-600 dark:text-slate-400 mt-2">
|
||||
Quality: {currentMicrophoneConfig.Quality} |
|
||||
Bitrate: {currentMicrophoneConfig.Bitrate}kbps |
|
||||
Sample Rate: {currentMicrophoneConfig.SampleRate}Hz
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Quality Settings */}
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center gap-2">
|
||||
|
@ -485,7 +429,6 @@ export default function AudioControlPopover({ microphone }: AudioControlPopoverP
|
|||
|
||||
{currentConfig && (
|
||||
<div className="text-xs text-slate-600 dark:text-slate-400 mt-2">
|
||||
Quality: {currentConfig.Quality} |
|
||||
Bitrate: {currentConfig.Bitrate}kbps |
|
||||
Sample Rate: {currentConfig.SampleRate}Hz
|
||||
</div>
|
||||
|
|
|
@ -44,23 +44,6 @@ class AudioQualityService {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch microphone quality presets from the backend
|
||||
*/
|
||||
async fetchMicrophoneQualityPresets(): Promise<AudioQualityResponse | null> {
|
||||
try {
|
||||
const response = await api.GET('/microphone/quality');
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
this.microphonePresets = data.presets;
|
||||
return data;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch microphone quality presets:', error);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update quality labels with actual bitrates from presets
|
||||
*/
|
||||
|
@ -131,32 +114,17 @@ class AudioQualityService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set microphone quality
|
||||
*/
|
||||
async setMicrophoneQuality(quality: number): Promise<boolean> {
|
||||
try {
|
||||
const response = await api.POST('/microphone/quality', { quality });
|
||||
return response.ok;
|
||||
} catch (error) {
|
||||
console.error('Failed to set microphone quality:', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load both audio and microphone configurations
|
||||
*/
|
||||
async loadAllConfigurations(): Promise<{
|
||||
audio: AudioQualityResponse | null;
|
||||
microphone: AudioQualityResponse | null;
|
||||
}> {
|
||||
const [audio, microphone] = await Promise.all([
|
||||
const [audio ] = await Promise.all([
|
||||
this.fetchAudioQualityPresets(),
|
||||
this.fetchMicrophoneQualityPresets()
|
||||
]);
|
||||
|
||||
return { audio, microphone };
|
||||
return { audio };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
web.go
2
web.go
|
@ -190,8 +190,6 @@ func setupRouter() *gin.Engine {
|
|||
protected.POST("/audio/mute", handleAudioMute)
|
||||
protected.GET("/audio/quality", handleAudioQuality)
|
||||
protected.POST("/audio/quality", handleSetAudioQuality)
|
||||
protected.GET("/microphone/quality", handleMicrophoneQuality)
|
||||
protected.POST("/microphone/quality", handleSetMicrophoneQuality)
|
||||
protected.POST("/microphone/start", handleMicrophoneStart)
|
||||
protected.POST("/microphone/stop", handleMicrophoneStop)
|
||||
protected.POST("/microphone/mute", handleMicrophoneMute)
|
||||
|
|
Loading…
Reference in New Issue