Feat: Implement H264 for Linux client with dynamic libx264 loading
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#import <dispatch/dispatch.h>
|
||||
#import <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#import "../client/IOCPClient.h"
|
||||
#import "../common/commands.h" // QualityLevel, QualityProfile, ALGORITHM_*
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
@@ -33,11 +34,7 @@ struct BITMAPINFOHEADER_MAC {
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
// Screen algorithm constants
|
||||
#define ALGORITHM_GRAY 0
|
||||
#define ALGORITHM_DIFF 1
|
||||
#define ALGORITHM_H264 2
|
||||
#define ALGORITHM_RGB565 3
|
||||
// Algorithm constants from commands.h: ALGORITHM_GRAY, ALGORITHM_DIFF, ALGORITHM_H264, ALGORITHM_RGB565
|
||||
|
||||
class ScreenHandler : public IOCPManager {
|
||||
public:
|
||||
|
||||
@@ -357,28 +357,40 @@ void ScreenHandler::applyQualityLevel(int8_t level, bool persist)
|
||||
{
|
||||
m_qualityLevel = level;
|
||||
|
||||
// TODO: persist to config file if needed
|
||||
(void)persist;
|
||||
|
||||
if (level == QUALITY_DISABLED) {
|
||||
NSLog(@"Quality: Disabled");
|
||||
// Disabled mode: keep current settings
|
||||
NSLog(@"Quality: Disabled (keep current)");
|
||||
return;
|
||||
}
|
||||
|
||||
// Quality profiles: [FPS, Algorithm]
|
||||
// H264 provides best compression for remote desktop
|
||||
// Note: macOS uses slightly higher FPS than Windows for smoother experience
|
||||
static const int profiles[QUALITY_COUNT][2] = {
|
||||
{5, ALGORITHM_GRAY}, // Level 0: Emergency (very low bandwidth)
|
||||
{10, ALGORITHM_RGB565}, // Level 1: Low
|
||||
{15, ALGORITHM_H264}, // Level 2: Medium (office work default)
|
||||
{20, ALGORITHM_H264}, // Level 3: Good
|
||||
{25, ALGORITHM_H264}, // Level 4: High
|
||||
{30, ALGORITHM_H264}, // Level 5: Smooth
|
||||
};
|
||||
|
||||
if (level >= 0 && level < QUALITY_COUNT) {
|
||||
m_maxFPS.store(profiles[level][0]);
|
||||
m_algorithm.store(profiles[level][1]);
|
||||
NSLog(@"Quality: Level=%d, FPS=%d, Algo=%d", level, profiles[level][0], profiles[level][1]);
|
||||
// Get profile from commands.h (shared with Windows/Linux)
|
||||
const QualityProfile& profile = GetQualityProfile(level);
|
||||
|
||||
// Apply FPS
|
||||
m_maxFPS.store(profile.maxFPS);
|
||||
|
||||
// Apply algorithm (macOS supports all algorithms including H264 via VideoToolbox)
|
||||
m_algorithm.store(profile.algorithm);
|
||||
|
||||
// Update H264 bitrate if applicable
|
||||
if (profile.algorithm == ALGORITHM_H264 && profile.bitRate > 0) {
|
||||
m_h264Bitrate = profile.bitRate * 1000; // kbps -> bps
|
||||
}
|
||||
|
||||
NSLog(@"Quality: Level=%d (%s), FPS=%d, Algo=%d, BitRate=%d kbps",
|
||||
level,
|
||||
level == QUALITY_ULTRA ? "Ultra" :
|
||||
level == QUALITY_HIGH ? "High" :
|
||||
level == QUALITY_GOOD ? "Good" :
|
||||
level == QUALITY_MEDIUM ? "Medium" :
|
||||
level == QUALITY_LOW ? "Low" : "Minimal",
|
||||
profile.maxFPS, profile.algorithm, profile.bitRate);
|
||||
} else {
|
||||
// Adaptive mode (level=-1): server adjusts dynamically
|
||||
NSLog(@"Quality: Adaptive mode");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user