mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 12:15:34 +08:00
Support AV1 codec
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
[signal server]
|
||||
ip = 120.77.216.215
|
||||
ip = 150.158.81.30
|
||||
port = 9099
|
||||
|
||||
[stun server]
|
||||
ip = 120.77.216.215
|
||||
ip = 150.158.81.30
|
||||
port = 3478
|
||||
|
||||
[turn server]
|
||||
ip = 120.77.216.215
|
||||
ip = 150.158.81.30
|
||||
port = 3478
|
||||
username = dijunkun
|
||||
password = dijunkunpw
|
||||
|
||||
[hardware acceleration]
|
||||
turn_on = false
|
||||
|
||||
[av1 encoding]
|
||||
turn_on = true
|
||||
@@ -440,9 +440,11 @@ int initResampler() {
|
||||
fprintf(stderr, "Could not allocate destination samples\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main(int argc, char *argv[]) {
|
||||
LOG_INFO("Remote desk");
|
||||
|
||||
last_ts = static_cast<uint32_t>(
|
||||
@@ -495,7 +497,8 @@ int main() {
|
||||
pixformat = SDL_PIXELFORMAT_NV12;
|
||||
|
||||
sdlTexture = SDL_CreateTexture(sdlRenderer, pixformat,
|
||||
SDL_TEXTUREACCESS_STREAMING, pixel_w, pixel_h);
|
||||
SDL_TEXTUREACCESS_STREAMING, pixel_w,
|
||||
pixel_h);
|
||||
|
||||
// Audio
|
||||
SDL_AudioSpec want_in, have_in, want_out, have_out;
|
||||
@@ -509,7 +512,7 @@ int main() {
|
||||
input_dev = SDL_OpenAudioDevice(NULL, 1, &want_in, &have_in, 0);
|
||||
if (input_dev == 0) {
|
||||
SDL_Log("Failed to open input: %s", SDL_GetError());
|
||||
return 1;
|
||||
// return 1;
|
||||
}
|
||||
|
||||
SDL_zero(want_out);
|
||||
@@ -523,7 +526,7 @@ int main() {
|
||||
output_dev = SDL_OpenAudioDevice(NULL, 0, &want_out, &have_out, 0);
|
||||
if (output_dev == 0) {
|
||||
SDL_Log("Failed to open input: %s", SDL_GetError());
|
||||
return 1;
|
||||
// return 1;
|
||||
}
|
||||
|
||||
SDL_PauseAudioDevice(input_dev, 0);
|
||||
@@ -614,7 +617,8 @@ int main() {
|
||||
|
||||
// Screen capture
|
||||
screen_capturer_factory = new ScreenCapturerFactory();
|
||||
screen_capturer = (ScreenCapturer *)screen_capturer_factory->Create();
|
||||
screen_capturer = (ScreenCapturer
|
||||
*)screen_capturer_factory->Create();
|
||||
|
||||
last_frame_time_ = std::chrono::high_resolution_clock::now();
|
||||
ScreenCapturer::RECORD_DESKTOP_RECT rect;
|
||||
@@ -625,14 +629,16 @@ int main() {
|
||||
|
||||
screen_capturer->Init(
|
||||
rect, 60,
|
||||
[](unsigned char *data, int size, int width, int height) -> void {
|
||||
[](unsigned char *data, int size, int width, int height) ->
|
||||
void {
|
||||
auto now_time = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::duration<double> duration =
|
||||
now_time - last_frame_time_;
|
||||
auto tc = duration.count() * 1000;
|
||||
|
||||
if (tc >= 0) {
|
||||
SendData(peer_server, DATA_TYPE::VIDEO, (const char *)data,
|
||||
SendData(peer_server, DATA_TYPE::VIDEO, (const char
|
||||
*)data,
|
||||
NV12_BUFFER_SIZE);
|
||||
last_frame_time_ = now_time;
|
||||
}
|
||||
@@ -679,29 +685,34 @@ int main() {
|
||||
ImGui::InputText(
|
||||
"##local_id", (char *)mac_addr_str.c_str(),
|
||||
mac_addr_str.length() + 1,
|
||||
ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_ReadOnly);
|
||||
ImGuiInputTextFlags_CharsUppercase |
|
||||
ImGuiInputTextFlags_ReadOnly);
|
||||
|
||||
ImGui::Text(" PASSWORD:");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(95);
|
||||
|
||||
char input_password_tmp[7] = "";
|
||||
strncpy(input_password_tmp, input_password, sizeof(input_password));
|
||||
strncpy(input_password_tmp, input_password,
|
||||
sizeof(input_password));
|
||||
|
||||
ImGui::InputTextWithHint("##server_pwd", "max 6 chars", input_password,
|
||||
ImGui::InputTextWithHint("##server_pwd", "max 6 chars",
|
||||
input_password,
|
||||
IM_ARRAYSIZE(input_password),
|
||||
ImGuiInputTextFlags_CharsNoBlank);
|
||||
if (strcmp(input_password_tmp, input_password)) {
|
||||
cd_cache_file = fopen("cache.cd", "w+");
|
||||
if (cd_cache_file) {
|
||||
fseek(cd_cache_file, 0, SEEK_SET);
|
||||
strncpy(cd_cache.password, input_password, sizeof(input_password));
|
||||
fwrite(&cd_cache.password, sizeof(cd_cache.password), 1,
|
||||
strncpy(cd_cache.password, input_password,
|
||||
sizeof(input_password)); fwrite(&cd_cache.password,
|
||||
sizeof(cd_cache.password), 1,
|
||||
cd_cache_file);
|
||||
fclose(cd_cache_file);
|
||||
}
|
||||
LeaveConnection(peer_server);
|
||||
CreateConnection(peer_server, mac_addr_str.c_str(), input_password);
|
||||
CreateConnection(peer_server, mac_addr_str.c_str(),
|
||||
input_password);
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
@@ -736,11 +747,12 @@ int main() {
|
||||
if ("ClientSignalConnected" == client_signal_status_str) {
|
||||
if (strcmp(connect_label, "Connect") == 0 && !joined) {
|
||||
std::string user_id = "C-" + mac_addr_str;
|
||||
ret = JoinConnection(peer_client, remote_id, client_password);
|
||||
if (0 == ret) {
|
||||
ret = JoinConnection(peer_client, remote_id,
|
||||
client_password); if (0 == ret) {
|
||||
// joined = true;
|
||||
}
|
||||
} else if (strcmp(connect_label, "Disconnect") == 0 && joined) {
|
||||
} else if (strcmp(connect_label, "Disconnect") == 0 &&
|
||||
joined) {
|
||||
ret = LeaveConnection(peer_client);
|
||||
memset(audio_buffer, 0, 960);
|
||||
if (0 == ret) {
|
||||
@@ -818,8 +830,8 @@ int main() {
|
||||
if (!joined || !received_frame) {
|
||||
SDL_RenderClear(sdlRenderer);
|
||||
SDL_SetRenderDrawColor(
|
||||
sdlRenderer, (Uint8)(clear_color.x * 0), (Uint8)(clear_color.y * 0),
|
||||
(Uint8)(clear_color.z * 0), (Uint8)(clear_color.w * 0));
|
||||
sdlRenderer, (Uint8)(clear_color.x * 0), (Uint8)(clear_color.y *
|
||||
0), (Uint8)(clear_color.z * 0), (Uint8)(clear_color.w * 0));
|
||||
}
|
||||
|
||||
ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData());
|
||||
|
||||
@@ -167,7 +167,7 @@ void ScreenCapturerWgc::OnFrame(const WgcSession::wgc_session_frame &frame) {
|
||||
if (_on_data)
|
||||
BGRAToNV12FFmpeg((unsigned char *)frame.data, frame.width, frame.height,
|
||||
nv12_frame_);
|
||||
_on_data(nv12_frame_, frame.width * frame.height * 4, frame.width,
|
||||
_on_data(nv12_frame_, frame.width * frame.height * 3 / 2, frame.width,
|
||||
frame.height);
|
||||
}
|
||||
|
||||
|
||||
2
thirdparty/projectx
vendored
2
thirdparty/projectx
vendored
Submodule thirdparty/projectx updated: a309627ca3...f5586a7922
10
xmake.lua
10
xmake.lua
@@ -13,7 +13,7 @@ if is_mode("debug") then
|
||||
add_defines("REMOTE_DESK_DEBUG")
|
||||
end
|
||||
|
||||
add_requires("sdl2", {system = false})
|
||||
add_requires("sdl2 2.28.3", {system = false})
|
||||
add_requires("spdlog 1.11.0", {system = false})
|
||||
add_requires("imgui 1.89.9", {configs = {sdl2 = true, sdl2_renderer = true}})
|
||||
|
||||
@@ -157,7 +157,7 @@ target("remote_desk")
|
||||
-- "-lxcb-shm", "-lXext", "-lX11", "-lXv", "-lpthread", "-lSDL2", "-lopenh264",
|
||||
-- "-ldl", {force = true})
|
||||
|
||||
target("mouse_control")
|
||||
set_kind("binary")
|
||||
add_files("test/linux_mouse_control/mouse_control.cpp")
|
||||
add_includedirs("test/linux_mouse_control")
|
||||
-- target("mouse_control")
|
||||
-- set_kind("binary")
|
||||
-- add_files("test/linux_mouse_control/mouse_control.cpp")
|
||||
-- add_includedirs("test/linux_mouse_control")
|
||||
Reference in New Issue
Block a user