Feat: Android client Phase 0-3 full implementation

This commit is contained in:
yuanyuanxiang
2026-06-17 23:19:12 +02:00
parent 837d89c8b5
commit a8684753a9
53 changed files with 3322 additions and 28 deletions

View File

@@ -694,13 +694,17 @@ void CWebService::HandleConnect(void* ws_ptr, const std::string& token, uint64_t
// Get screen dimensions + audio state from device info cache (may not be ready)
int width = 0, height = 0;
int audio_enabled = -1; // -1 = unknown yet (前端走 audio_state 事件兜底)
bool top_down = false;
std::string client_type;
{
std::lock_guard<std::mutex> lock(m_DeviceCacheMutex);
auto it = m_DeviceCache.find(device_id);
if (it != m_DeviceCache.end()) {
width = it->second->screen_width;
height = it->second->screen_height;
width = it->second->screen_width;
height = it->second->screen_height;
audio_enabled = it->second->audio_enabled;
top_down = it->second->top_down;
client_type = it->second->client_type;
}
}
@@ -713,6 +717,8 @@ void CWebService::HandleConnect(void* ws_ptr, const std::string& token, uint64_t
if (width > 0 && height > 0) {
res["width"] = width;
res["height"] = height;
res["top_down"] = top_down;
if (!client_type.empty()) res["client_type"] = client_type;
}
if (audio_enabled >= 0) {
res["audio_enabled"] = (audio_enabled != 0);
@@ -1712,7 +1718,7 @@ void CWebService::BroadcastH264Frame(uint64_t device_id, const uint8_t* data, si
}
}
void CWebService::NotifyResolutionChange(uint64_t device_id, int width, int height) {
void CWebService::NotifyResolutionChange(uint64_t device_id, int width, int height, bool top_down, const std::string& client_type) {
if (m_bStopping) return;
// Update cache
@@ -1723,8 +1729,10 @@ void CWebService::NotifyResolutionChange(uint64_t device_id, int width, int heig
m_DeviceCache[device_id] = std::make_shared<WebDeviceInfo>();
it = m_DeviceCache.find(device_id);
}
it->second->screen_width = width;
it->second->screen_width = width;
it->second->screen_height = height;
it->second->top_down = top_down;
if (!client_type.empty()) it->second->client_type = client_type;
}
// Notify watching clients
@@ -1733,6 +1741,8 @@ void CWebService::NotifyResolutionChange(uint64_t device_id, int width, int heig
res["id"] = device_id;
res["width"] = width;
res["height"] = height;
res["top_down"] = top_down;
if (!client_type.empty()) res["client_type"] = client_type;
Json::StreamWriterBuilder builder;
builder["indentation"] = "";