OBSForCaiic/obs-studio/plugins/obs-browser/obs-browser-source.hpp
evan.liu d0074858bf CAIIC 定制版 v1.0.0:英文默认界面、2K/4K 支持、集成抠图插件、更换品牌图标
界面与品牌
- 默认 UI 语言固定为英文,不再跟随系统区域设置自动切换(frontend/OBSApp.cpp),用户仍可在设置中手动切换
- 程序图标更换为 CAIIC logo:exe 图标 obs-studio.ico 及界面/托盘/About 图标 obs.png
- About 窗口精简为 logo + 名称 + 版本号,移除项目介绍、赞助名单、Authors/License 标签页
- 版本号定为 1.0.0(构建参数 OBS_VERSION_OVERRIDE=1.0.0)

分辨率支持
- 移除首次启动将画布强制限制为 1920x1080 的逻辑,默认使用显示器原生分辨率
- 设置-视频 与自动配置向导新增 3840x2160 / 2560x1440 预设
- 自动配置向导性能测试上限放宽至 4K60(软硬件编码数据率上限及起始分辨率钳制)

插件
- 集成 obs-shaderfilter 2.6.0(绿幕抠图/自定义着色器滤镜),并适配新版 libobs 的 gs_image_file_ex API
- 补齐缺失的源码:obs-browser、obs-websocket、libdshowcapture(含 external/capture-device-support)

工程
- 新增 .gitignore,排除 deploy/ 发布目录与构建日志
2026-09-18 20:41:13 +08:00

136 lines
3.6 KiB
C++

/******************************************************************************
Copyright (C) 2014 by John R. Bradley <jrb@turrettech.com>
Copyright (C) 2023 by Lain Bailey <lain@obsproject.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#pragma once
#include <obs-module.h>
#include "cef-headers.hpp"
#include "browser-app.hpp"
#include <atomic>
#include <functional>
#include <string>
#include <mutex>
enum class ControlLevel : int {
None,
ReadObs,
ReadUser,
Basic,
Advanced,
All,
};
inline constexpr ControlLevel DEFAULT_CONTROL_LEVEL = ControlLevel::ReadObs;
extern bool hwaccel;
struct BrowserSource {
BrowserSource **p_prev_next = nullptr;
BrowserSource *next = nullptr;
obs_source_t *source = nullptr;
bool tex_sharing_avail = false;
bool create_browser = false;
std::recursive_mutex lockBrowser;
CefRefPtr<CefBrowser> cefBrowser;
std::string url;
std::string css;
gs_texture_t *texture = nullptr;
gs_texture_t *extra_texture = nullptr;
uint32_t last_cx = 0;
uint32_t last_cy = 0;
gs_color_format last_format = GS_UNKNOWN;
#ifdef ENABLE_BROWSER_SHARED_TEXTURE
#ifdef _WIN32
void *last_handle = INVALID_HANDLE_VALUE;
#elif defined(__APPLE__)
void *last_handle = nullptr;
#endif
#endif
int width = 0;
int height = 0;
bool fps_custom = false;
int fps = 0;
double canvas_fps = 0;
bool restart = false;
bool shutdown_on_invisible = false;
bool is_local = false;
bool first_update = true;
bool reroute_audio = true;
std::atomic<bool> destroying = false;
ControlLevel webpage_control_level = DEFAULT_CONTROL_LEVEL;
#if defined(BROWSER_EXTERNAL_BEGIN_FRAME_ENABLED) && defined(ENABLE_BROWSER_SHARED_TEXTURE)
bool reset_frame = false;
#endif
bool is_showing = false;
inline void DestroyTextures()
{
obs_enter_graphics();
if (extra_texture) {
gs_texture_destroy(extra_texture);
extra_texture = nullptr;
last_cx = 0;
last_cy = 0;
last_format = GS_UNKNOWN;
}
if (texture) {
gs_texture_destroy(texture);
texture = nullptr;
}
obs_leave_graphics();
}
/* ---------------------------- */
bool CreateBrowser();
void DestroyBrowser();
void ExecuteOnBrowser(BrowserFunc func, bool async = false);
/* ---------------------------- */
BrowserSource(obs_data_t *settings, obs_source_t *source);
~BrowserSource();
void Destroy();
void Update(obs_data_t *settings = nullptr);
void Tick();
void Render();
void SendMouseClick(const struct obs_mouse_event *event, int32_t type, bool mouse_up, uint32_t click_count);
void SendMouseMove(const struct obs_mouse_event *event, bool mouse_leave);
void SendMouseWheel(const struct obs_mouse_event *event, int x_delta, int y_delta);
void SendFocus(bool focus);
void SendKeyClick(const struct obs_key_event *event, bool key_up);
void SetShowing(bool showing);
void SetActive(bool active);
void Refresh();
#if defined(BROWSER_EXTERNAL_BEGIN_FRAME_ENABLED) && defined(ENABLE_BROWSER_SHARED_TEXTURE)
inline void SignalBeginFrame();
#endif
void SetBrowser(CefRefPtr<CefBrowser> b);
CefRefPtr<CefBrowser> GetBrowser();
};