mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 12:15:34 +08:00
[feat] add recent connections window
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -22,6 +22,8 @@ static std::vector<std::string> remote_desktop = {u8"控制远程桌面",
|
||||
"Control Remote Desktop"};
|
||||
static std::vector<std::string> remote_id = {u8"对端ID", "Remote ID"};
|
||||
static std::vector<std::string> connect = {u8"连接", "Connect"};
|
||||
static std::vector<std::string> recent_connections = {u8"近期连接",
|
||||
"Recent Connections"};
|
||||
static std::vector<std::string> disconnect = {u8"断开连接", "Disconnect"};
|
||||
static std::vector<std::string> fullscreen = {u8" 全屏", " Fullscreen"};
|
||||
static std::vector<std::string> exit_fullscreen = {u8" 退出全屏",
|
||||
|
||||
@@ -7,34 +7,42 @@
|
||||
#include "render.h"
|
||||
|
||||
int Render::LocalWindow() {
|
||||
ImGui::SetNextWindowPos(ImVec2(0, title_bar_height_ + 1), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowPos(ImVec2(-1.0f, title_bar_height_), ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
ImGui::BeginChild("LocalDesktopWindow",
|
||||
ImVec2(local_window_width_, local_window_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiChildFlags_None,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + main_window_text_y_padding_);
|
||||
ImGui::Indent(main_child_window_x_padding_);
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::Text(
|
||||
"%s", localization::local_desktop[localization_language_index_].c_str());
|
||||
|
||||
ImGui::TextColored(
|
||||
ImVec4(0.0f, 0.0f, 0.0f, 0.5f), "%s",
|
||||
localization::local_desktop[localization_language_index_].c_str());
|
||||
|
||||
ImGui::Spacing();
|
||||
{
|
||||
ImGui::SetNextWindowPos(ImVec2(30, title_bar_height_ + 50),
|
||||
ImGuiCond_Always);
|
||||
ImGui::SetNextWindowPos(
|
||||
ImVec2(main_child_window_x_padding_,
|
||||
title_bar_height_ + main_child_window_y_padding_),
|
||||
ImGuiCond_Always);
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg,
|
||||
ImVec4(239.0 / 255, 240.0 / 255, 242.0 / 255, 1.0f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
||||
ImGui::BeginChild("LocalDesktopWindow_1", ImVec2(330, 180),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
ImGui::BeginChild(
|
||||
"LocalDesktopWindow_1",
|
||||
ImVec2(local_child_window_width_, local_child_window_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleColor();
|
||||
{
|
||||
@@ -48,16 +56,17 @@ int Render::LocalWindow() {
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
|
||||
|
||||
char client_id_display[12] = "";
|
||||
for (int i = 0, j = 0; i < sizeof(client_id_); i++, j++) {
|
||||
client_id_display[j] = client_id_[i];
|
||||
if (i == 2 || i == 5) {
|
||||
client_id_display[++j] = ' ';
|
||||
if (strcmp(client_id_display_, client_id_)) {
|
||||
for (int i = 0, j = 0; i < sizeof(client_id_); i++, j++) {
|
||||
client_id_display_[j] = client_id_[i];
|
||||
if (i == 2 || i == 5) {
|
||||
client_id_display_[++j] = ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::InputText(
|
||||
"##local_id", client_id_display, IM_ARRAYSIZE(client_id_display),
|
||||
"##local_id", client_id_display_, IM_ARRAYSIZE(client_id_display_),
|
||||
ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_ReadOnly);
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "localization.h"
|
||||
#include "render.h"
|
||||
|
||||
int Render::MainWindow() {
|
||||
@@ -6,10 +7,75 @@ int Render::MainWindow() {
|
||||
// ImVec2(main_window_width_default_, main_window_height_default_),
|
||||
// ImGuiCond_Always);
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(0, title_bar_height_), ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
ImGui::BeginChild("MainWindow",
|
||||
ImVec2(main_window_width_default_, local_window_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
LocalWindow();
|
||||
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
draw_list->AddLine(
|
||||
ImVec2(main_window_width_default_ / 2, title_bar_height_ + 25.0f),
|
||||
ImVec2(main_window_width_default_ / 2, title_bar_height_ + 240.0f),
|
||||
IM_COL32(0, 0, 0, 122), 1.0f);
|
||||
|
||||
RemoteWindow();
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::SetNextWindowPos(
|
||||
ImVec2(0, title_bar_height_ + local_window_height_ - 1),
|
||||
ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 0.0f));
|
||||
ImGui::BeginChild("RecentConnectionsWindow",
|
||||
ImVec2(main_window_width_default_,
|
||||
main_window_height_default_ - title_bar_height_ -
|
||||
local_window_height_ - status_bar_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() +
|
||||
main_window_text_y_padding_ / 2);
|
||||
ImGui::Indent(main_child_window_x_padding_);
|
||||
ImGui::SetWindowFontScale(0.8f);
|
||||
|
||||
ImGui::TextColored(
|
||||
ImVec4(0.0f, 0.0f, 0.0f, 0.5f), "%s",
|
||||
localization::recent_connections[localization_language_index_].c_str());
|
||||
|
||||
draw_list->AddLine(
|
||||
ImVec2(25.0f, title_bar_height_ + local_window_height_ + 35.0f),
|
||||
ImVec2(main_window_width_default_ - 25.0f,
|
||||
title_bar_height_ + local_window_height_ + 35.0f),
|
||||
IM_COL32(0, 0, 0, 122), 1.0f);
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() +
|
||||
main_window_text_y_padding_ / 2);
|
||||
ShowRecentConnections();
|
||||
|
||||
ImGui::EndChild();
|
||||
|
||||
StatusBar();
|
||||
ConnectionStatusWindow();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Render::ShowRecentConnections() {
|
||||
ImGui::Image((ImTextureID)(intptr_t)recent_connection_texture_,
|
||||
ImVec2((float)recent_connection_image_width_,
|
||||
(float)recent_connection_image_height_));
|
||||
return 0;
|
||||
}
|
||||
@@ -4,47 +4,44 @@
|
||||
#include "rd_log.h"
|
||||
#include "render.h"
|
||||
|
||||
static int InputTextCallback(ImGuiInputTextCallbackData *data) {
|
||||
if (data->BufTextLen > 3 && data->Buf[3] != ' ') {
|
||||
data->InsertChars(3, " ");
|
||||
}
|
||||
|
||||
if (data->BufTextLen > 7 && data->Buf[7] != ' ') {
|
||||
data->InsertChars(7, " ");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int InputTextCallback(ImGuiInputTextCallbackData *data);
|
||||
|
||||
int Render::RemoteWindow() {
|
||||
ImGui::SetNextWindowPos(ImVec2(0, title_bar_height_ + local_window_height_),
|
||||
ImGui::SetNextWindowPos(ImVec2(local_window_width_ + 1.0f, title_bar_height_),
|
||||
ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
ImGui::BeginChild("RemoteDesktopWindow",
|
||||
ImVec2(remote_window_width_, remote_window_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiChildFlags_None,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + main_window_text_y_padding_);
|
||||
ImGui::Indent(main_child_window_x_padding_ - 1.0f);
|
||||
ImGui::SetWindowFontScale(1.0f);
|
||||
ImGui::Text(
|
||||
"%s", localization::remote_desktop[localization_language_index_].c_str());
|
||||
|
||||
ImGui::TextColored(
|
||||
ImVec4(0.0f, 0.0f, 0.0f, 0.5f), "%s",
|
||||
localization::remote_desktop[localization_language_index_].c_str());
|
||||
|
||||
ImGui::Spacing();
|
||||
{
|
||||
ImGui::SetNextWindowPos(
|
||||
ImVec2(30, title_bar_height_ + local_window_height_ + 50),
|
||||
ImVec2(local_window_width_ + main_child_window_x_padding_ - 1.0f,
|
||||
title_bar_height_ + main_child_window_y_padding_),
|
||||
ImGuiCond_Always);
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg,
|
||||
ImVec4(239.0 / 255, 240.0 / 255, 242.0 / 255, 1.0f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 10.0f);
|
||||
|
||||
ImGui::BeginChild(
|
||||
"RemoteDesktopWindow_1", ImVec2(330, 180), ImGuiChildFlags_Border,
|
||||
"RemoteDesktopWindow_1",
|
||||
ImVec2(remote_child_window_width_, remote_child_window_height_),
|
||||
ImGuiChildFlags_Border,
|
||||
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||
@@ -110,5 +107,17 @@ int Render::RemoteWindow() {
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int InputTextCallback(ImGuiInputTextCallbackData *data) {
|
||||
if (data->BufTextLen > 3 && data->Buf[3] != ' ') {
|
||||
data->InsertChars(3, " ");
|
||||
}
|
||||
|
||||
if (data->BufTextLen > 7 && data->Buf[7] != ' ') {
|
||||
data->InsertChars(7, " ");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -15,15 +15,21 @@
|
||||
#include "rd_log.h"
|
||||
#include "screen_capturer_factory.h"
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "libyuv.h"
|
||||
#include "stb_image_write.h"
|
||||
|
||||
// Refresh Event
|
||||
#define REFRESH_EVENT (SDL_USEREVENT + 1)
|
||||
#define NV12_BUFFER_SIZE 1280 * 720 * 3 / 2
|
||||
|
||||
#define MOUSE_GRAB_PADDING 5
|
||||
|
||||
SDL_HitTestResult Render::HitTestCallback(SDL_Window *window,
|
||||
const SDL_Point *area, void *data) {
|
||||
Render *render = (Render *)data;
|
||||
SDL_HitTestResult Render::HitTestCallback(SDL_Window* window,
|
||||
const SDL_Point* area, void* data) {
|
||||
Render* render = (Render*)data;
|
||||
if (!render) {
|
||||
return SDL_HITTEST_NORMAL;
|
||||
}
|
||||
@@ -69,6 +75,60 @@ SDL_HitTestResult Render::HitTestCallback(SDL_Window *window,
|
||||
return SDL_HITTEST_NORMAL;
|
||||
}
|
||||
|
||||
bool LoadTextureFromMemory(const void* data, size_t data_size,
|
||||
SDL_Renderer* renderer, SDL_Texture** out_texture,
|
||||
int* out_width, int* out_height) {
|
||||
int image_width = 0;
|
||||
int image_height = 0;
|
||||
int channels = 4;
|
||||
unsigned char* image_data =
|
||||
stbi_load_from_memory((const unsigned char*)data, (int)data_size,
|
||||
&image_width, &image_height, NULL, 4);
|
||||
if (image_data == nullptr) {
|
||||
fprintf(stderr, "Failed to load image: %s\n", stbi_failure_reason());
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(
|
||||
(void*)image_data, image_width, image_height, channels * 8,
|
||||
channels * image_width, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
|
||||
if (surface == nullptr) {
|
||||
fprintf(stderr, "Failed to create SDL surface: %s\n", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface);
|
||||
if (texture == nullptr)
|
||||
fprintf(stderr, "Failed to create SDL texture: %s\n", SDL_GetError());
|
||||
|
||||
*out_texture = texture;
|
||||
*out_width = image_width;
|
||||
*out_height = image_height;
|
||||
|
||||
SDL_FreeSurface(surface);
|
||||
stbi_image_free(image_data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Open and read a file, then forward to LoadTextureFromMemory()
|
||||
bool LoadTextureFromFile(const char* file_name, SDL_Renderer* renderer,
|
||||
SDL_Texture** out_texture, int* out_width,
|
||||
int* out_height) {
|
||||
FILE* f = fopen(file_name, "rb");
|
||||
if (f == NULL) return false;
|
||||
fseek(f, 0, SEEK_END);
|
||||
size_t file_size = (size_t)ftell(f);
|
||||
if (file_size == -1) return false;
|
||||
fseek(f, 0, SEEK_SET);
|
||||
void* file_data = IM_ALLOC(file_size);
|
||||
fread(file_data, 1, file_size, f);
|
||||
bool ret = LoadTextureFromMemory(file_data, file_size, renderer, out_texture,
|
||||
out_width, out_height);
|
||||
IM_FREE(file_data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Render::Render() {}
|
||||
|
||||
Render::~Render() {}
|
||||
@@ -162,13 +222,13 @@ int Render::LoadSettingsFromCacheFile() {
|
||||
}
|
||||
|
||||
int Render::StartScreenCapture() {
|
||||
screen_capturer_ = (ScreenCapturer *)screen_capturer_factory_->Create();
|
||||
screen_capturer_ = (ScreenCapturer*)screen_capturer_factory_->Create();
|
||||
last_frame_time_ = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch())
|
||||
.count();
|
||||
|
||||
int screen_capturer_init_ret = screen_capturer_->Init(
|
||||
60, [this](unsigned char *data, int size, int width, int height) -> void {
|
||||
60, [this](unsigned char* data, int size, int width, int height) -> void {
|
||||
auto now_time = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch())
|
||||
.count();
|
||||
@@ -178,7 +238,7 @@ int Render::StartScreenCapture() {
|
||||
// NV12_BUFFER_SIZE);
|
||||
|
||||
XVideoFrame frame;
|
||||
frame.data = (const char *)data;
|
||||
frame.data = (const char*)data;
|
||||
frame.size = size;
|
||||
frame.width = width;
|
||||
frame.height = height;
|
||||
@@ -213,11 +273,11 @@ int Render::StopScreenCapture() {
|
||||
|
||||
int Render::StartSpeakerCapture() {
|
||||
if (!speaker_capturer_) {
|
||||
speaker_capturer_ = (SpeakerCapturer *)speaker_capturer_factory_->Create();
|
||||
speaker_capturer_ = (SpeakerCapturer*)speaker_capturer_factory_->Create();
|
||||
int speaker_capturer_init_ret = speaker_capturer_->Init(
|
||||
[this](unsigned char *data, size_t size) -> void {
|
||||
[this](unsigned char* data, size_t size) -> void {
|
||||
if (connection_established_) {
|
||||
SendData(peer_, DATA_TYPE::AUDIO, (const char *)data, size);
|
||||
SendData(peer_, DATA_TYPE::AUDIO, (const char*)data, size);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -244,7 +304,7 @@ int Render::StopSpeakerCapture() {
|
||||
|
||||
int Render::StartMouseControl() {
|
||||
device_controller_factory_ = new DeviceControllerFactory();
|
||||
mouse_controller_ = (MouseController *)device_controller_factory_->Create(
|
||||
mouse_controller_ = (MouseController*)device_controller_factory_->Create(
|
||||
DeviceControllerFactory::Device::Mouse);
|
||||
int mouse_controller_init_ret =
|
||||
mouse_controller_->Init(screen_width_, screen_height_);
|
||||
@@ -488,7 +548,7 @@ int Render::DestroyStreamWindow() {
|
||||
|
||||
int Render::SetupFontAndStyle() {
|
||||
// Setup Dear ImGui style
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
// Master keyboard navigation enable flag. Enable full Tabbing + directional
|
||||
// arrows + space/enter to activate.
|
||||
io.ConfigFlags |=
|
||||
@@ -678,6 +738,8 @@ int Render::DrawStreamWindow() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Render::LoadRecentConnections() { return 0; }
|
||||
|
||||
int Render::Run() {
|
||||
LoadSettingsFromCacheFile();
|
||||
|
||||
@@ -763,6 +825,44 @@ int Render::Run() {
|
||||
localization_language_index_last_ = localization_language_index_;
|
||||
}
|
||||
|
||||
{
|
||||
const int scaled_video_width_ = 128;
|
||||
const int scaled_video_height_ = 72;
|
||||
// uint8_t scaled_yuv_data =
|
||||
// new uint8_t[scaled_video_width_ * scaled_video_height_ * 3 / 2];
|
||||
// uint8_t* rgb_data =
|
||||
// new uint8_t[scaled_video_width_ * scaled_video_height_ * 3];
|
||||
|
||||
uint8_t
|
||||
scaled_yuv_data[scaled_video_width_ * scaled_video_height_ * 3 / 2];
|
||||
uint8_t rgb_data[scaled_video_width_ * scaled_video_height_ * 3];
|
||||
|
||||
libyuv::I420Scale(
|
||||
dst_buffer_, video_width_, dst_buffer_ + video_width_ * video_height_,
|
||||
video_width_ / 2, dst_buffer_ + video_width_ * video_height_ * 5 / 4,
|
||||
video_width_ / 2, video_width_, video_height_, scaled_yuv_data,
|
||||
scaled_video_width_,
|
||||
scaled_yuv_data + scaled_video_width_ * scaled_video_height_,
|
||||
scaled_video_width_ / 2,
|
||||
scaled_yuv_data + scaled_video_width_ * scaled_video_height_ * 5 / 4,
|
||||
scaled_video_width_ / 2, scaled_video_width_, scaled_video_width_,
|
||||
libyuv::FilterMode::kFilterNone);
|
||||
|
||||
libyuv::I420ToRGB24(
|
||||
scaled_yuv_data, scaled_video_width_,
|
||||
scaled_yuv_data + scaled_video_width_ * scaled_video_height_,
|
||||
scaled_video_width_ / 2,
|
||||
scaled_yuv_data + scaled_video_width_ * scaled_video_height_ * 5 / 4,
|
||||
scaled_video_width_ / 2, rgb_data, scaled_video_width_ * 3,
|
||||
scaled_video_width_, scaled_video_height_);
|
||||
stbi_write_png("RecentConnectionImage01.png", scaled_video_width_,
|
||||
scaled_video_height_, 3, rgb_data,
|
||||
scaled_video_width_ * 3);
|
||||
|
||||
// delete[] scaled_yuv_data;
|
||||
// delete[] rgb_data;
|
||||
}
|
||||
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
{
|
||||
@@ -804,11 +904,51 @@ int Render::Run() {
|
||||
is_client_mode_ = false;
|
||||
audio_capture_button_pressed_ = false;
|
||||
fullscreen_button_pressed_ = false;
|
||||
reload_recent_connections_ = true;
|
||||
SDL_SetWindowFullscreen(main_window_, SDL_FALSE);
|
||||
memset(audio_buffer_, 0, 960);
|
||||
memset(audio_buffer_, 0, 720);
|
||||
SDL_SetWindowSize(main_window_, main_window_width_default_,
|
||||
main_window_height_default_);
|
||||
|
||||
// {
|
||||
// int scaled_video_width_ = 128;
|
||||
// int scaled_video_height_ = 72;
|
||||
// uint8_t* scaled_yuv_data =
|
||||
// new uint8_t[scaled_video_width_ * scaled_video_height_ * 3 /
|
||||
// 2];
|
||||
// uint8_t* rgb_data =
|
||||
// new uint8_t[scaled_video_width_ * scaled_video_height_ * 3];
|
||||
|
||||
// libyuv::I420Scale(
|
||||
// dst_buffer_, video_width_,
|
||||
// dst_buffer_ + video_width_ * video_height_, video_width_ / 2,
|
||||
// dst_buffer_ + video_width_ * video_height_ * 5 / 4,
|
||||
// video_width_ / 2, video_width_, video_height_,
|
||||
// scaled_yuv_data, scaled_video_width_, scaled_yuv_data +
|
||||
// scaled_video_width_ * scaled_video_height_,
|
||||
// scaled_video_width_ / 2,
|
||||
// scaled_yuv_data +
|
||||
// scaled_video_width_ * scaled_video_height_ * 5 / 4,
|
||||
// scaled_video_width_ / 2, scaled_video_width_,
|
||||
// scaled_video_width_, libyuv::FilterMode::kFilterNone);
|
||||
|
||||
// libyuv::I420ToRGB24(
|
||||
// scaled_yuv_data, scaled_video_width_,
|
||||
// scaled_yuv_data + scaled_video_width_ * scaled_video_height_,
|
||||
// scaled_video_width_ / 2,
|
||||
// scaled_yuv_data +
|
||||
// scaled_video_width_ * scaled_video_height_ * 5 / 4,
|
||||
// scaled_video_width_ / 2, rgb_data, scaled_video_width_ * 3,
|
||||
// scaled_video_width_, scaled_video_height_);
|
||||
// stbi_write_png("RecentConnectionImage01.jpg",
|
||||
// scaled_video_width_,
|
||||
// scaled_video_height_, 3, rgb_data,
|
||||
// scaled_video_width_ * 3);
|
||||
|
||||
// delete[] scaled_yuv_data;
|
||||
// delete[] rgb_data;
|
||||
// }
|
||||
|
||||
// SDL_Rect display_bounds;
|
||||
// SDL_GetDisplayBounds(0, &display_bounds);
|
||||
// int center_x = (display_bounds.w - main_window_width_default_) / 2;
|
||||
@@ -886,6 +1026,17 @@ int Render::Run() {
|
||||
}
|
||||
}
|
||||
|
||||
if (reload_recent_connections_) {
|
||||
bool ret = LoadTextureFromFile(
|
||||
"RecentConnectionImage01.png", main_renderer_,
|
||||
&recent_connection_texture_, &recent_connection_image_width_,
|
||||
&recent_connection_image_height_);
|
||||
if (!ret) {
|
||||
LOG_ERROR("Load recent connections image failed");
|
||||
}
|
||||
reload_recent_connections_ = false;
|
||||
}
|
||||
|
||||
if (connection_established_ && streaming_) {
|
||||
CreateStreamWindow();
|
||||
SetupStreamWindow();
|
||||
|
||||
@@ -42,6 +42,8 @@ class Render {
|
||||
int AboutWindow();
|
||||
int StatusBar();
|
||||
int ConnectionStatusWindow();
|
||||
int LoadRecentConnections();
|
||||
int ShowRecentConnections();
|
||||
|
||||
private:
|
||||
int CreateRtcConnection();
|
||||
@@ -150,32 +152,39 @@ class Render {
|
||||
char client_password_[20] = "";
|
||||
|
||||
private:
|
||||
int title_bar_width_ = 960;
|
||||
int title_bar_width_ = 640;
|
||||
int title_bar_height_ = 30;
|
||||
int screen_width_ = 1280;
|
||||
int screen_height_ = 720;
|
||||
int main_window_width_default_ = 960;
|
||||
int main_window_height_default_ = 590;
|
||||
int main_window_width_ = 960;
|
||||
int main_window_height_ = 590;
|
||||
int main_window_width_last_ = 960;
|
||||
int main_window_height_last_ = 540;
|
||||
int main_window_width_default_ = 640;
|
||||
int main_window_height_default_ = 480;
|
||||
int main_window_width_ = 640;
|
||||
int main_window_height_ = 480;
|
||||
int main_window_width_last_ = 640;
|
||||
int main_window_height_last_ = 480;
|
||||
int stream_window_width_default_ = 1280;
|
||||
int stream_window_height_default_ = 720;
|
||||
int stream_window_width_ = 1280;
|
||||
int stream_window_height_ = 720;
|
||||
int stream_window_width_last_ = 1280;
|
||||
int stream_window_height_last_ = 720;
|
||||
int main_window_width_before_maximized_ = 960;
|
||||
int main_window_height_before_maximized_ = 590;
|
||||
int main_window_width_before_maximized_ = 640;
|
||||
int main_window_height_before_maximized_ = 480;
|
||||
int control_window_min_width_ = 20;
|
||||
int control_window_max_width_ = 170;
|
||||
int control_window_width_ = 170;
|
||||
int control_window_height_ = 40;
|
||||
int local_window_width_ = 720;
|
||||
int local_window_height_ = 270;
|
||||
int remote_window_width_ = 720;
|
||||
int remote_window_height_ = 270;
|
||||
int local_window_width_ = 320;
|
||||
int local_window_height_ = 260;
|
||||
int remote_window_width_ = 320;
|
||||
int remote_window_height_ = 260;
|
||||
int local_child_window_width_ = 266;
|
||||
int local_child_window_height_ = 180;
|
||||
int remote_child_window_width_ = 266;
|
||||
int remote_child_window_height_ = 180;
|
||||
int main_window_text_y_padding_ = 20;
|
||||
int main_child_window_x_padding_ = 27;
|
||||
int main_child_window_y_padding_ = 60;
|
||||
int status_bar_height_ = 20;
|
||||
int connection_status_window_width_ = 200;
|
||||
int connection_status_window_height_ = 150;
|
||||
@@ -187,7 +196,7 @@ class Render {
|
||||
int control_bar_pos_x_ = 0;
|
||||
int control_bar_pos_y_ = 30;
|
||||
|
||||
int main_window_width_real_ = 960;
|
||||
int main_window_width_real_ = 720;
|
||||
int main_window_height_real_ = 540;
|
||||
float main_window_dpi_scaling_w_ = 1.0f;
|
||||
float main_window_dpi_scaling_h_ = 1.0f;
|
||||
@@ -214,6 +223,11 @@ class Render {
|
||||
bool stream_window_created_ = false;
|
||||
bool stream_window_inited_ = false;
|
||||
|
||||
// recent connections
|
||||
SDL_Texture *recent_connection_texture_ = nullptr;
|
||||
int recent_connection_image_width_ = 128;
|
||||
int recent_connection_image_height_ = 72;
|
||||
|
||||
// video window
|
||||
SDL_Texture *stream_texture_ = nullptr;
|
||||
SDL_Rect stream_render_rect_;
|
||||
@@ -253,6 +267,7 @@ class Render {
|
||||
bool is_client_mode_ = false;
|
||||
bool is_control_bar_in_left_ = true;
|
||||
bool control_window_width_is_changing_ = false;
|
||||
bool reload_recent_connections_ = true;
|
||||
|
||||
double copy_start_time_ = 0;
|
||||
double regenerate_password_start_time_ = 0;
|
||||
@@ -282,7 +297,7 @@ class Render {
|
||||
private:
|
||||
SDL_AudioDeviceID input_dev_;
|
||||
SDL_AudioDeviceID output_dev_;
|
||||
unsigned char audio_buffer_[960];
|
||||
unsigned char audio_buffer_[720];
|
||||
int audio_len_ = 0;
|
||||
unsigned char *dst_buffer_ = nullptr;
|
||||
int dst_buffer_capacity_ = 0;
|
||||
@@ -298,6 +313,7 @@ class Render {
|
||||
|
||||
private:
|
||||
char client_id_[10] = "";
|
||||
char client_id_display_[12] = "";
|
||||
char password_saved_[7] = "";
|
||||
int language_button_value_ = 0;
|
||||
int video_quality_button_value_ = 0;
|
||||
|
||||
8423
src/single_window/stb_image.h
Normal file
8423
src/single_window/stb_image.h
Normal file
File diff suppressed because it is too large
Load Diff
2019
src/single_window/stb_image_write.h
Normal file
2019
src/single_window/stb_image_write.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -124,6 +124,7 @@ target("localization")
|
||||
|
||||
target("single_window")
|
||||
set_kind("object")
|
||||
add_packages("libyuv")
|
||||
add_deps("rd_log", "common", "localization", "config_center", "projectx", "screen_capturer", "speaker_capturer", "device_controller")
|
||||
if is_os("macosx") then
|
||||
add_packages("ffmpeg")
|
||||
|
||||
Reference in New Issue
Block a user