# RTCX PC SDK Windows 集成指南

本文档随 **RTCX WinSDK Release 包** 一并发布，路径：`doc/RTCX_WinSDK_Integration_zh-CN.md`。

## 1. 包内目录

```
RTCX_WinSDK_x64_.../
├── include/                 # 公开头文件（rtcxpcsdk、common、account）
├── thirdparty/
│   └── include/             # 三方头文件：json（curl 已封装在 common 库内）
├── libs/                    # 静态库 + IM/播放器 + 三方 .lib
├── bin/                     # 运行时 DLL + config.ini 示例（不含 Qt）
└── doc/                     # 集成文档
```

主 API 头文件：`include/rtcxpcsdk/IRtcxPcApi.h`

---

## 2. 环境要求

| 项目 | 要求 |
|------|------|
| 操作系统 | Windows 10/11 x64 |
| 编译器 | Visual Studio 2019（MSVC v142），**x64** |
| C++ 标准 | C++17 |
| UI | 无强制要求；Demo 使用 Qt 5.14（可选） |

---

## 3. CMake 集成（推荐）

假设 SDK 解压到 `D:/SDK/RTCX_WinSDK`：

```cmake
cmake_minimum_required(VERSION 3.18)
project(MyApp LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)

set(RTCX_SDK_DIR "D:/SDK/RTCX_WinSDK")

add_executable(my_app main.cpp)

target_include_directories(my_app PRIVATE
    ${RTCX_SDK_DIR}/thirdparty/include
    ${RTCX_SDK_DIR}/include
    ${RTCX_SDK_DIR}/include/rtcxpcsdk
    ${RTCX_SDK_DIR}/include/common
    ${RTCX_SDK_DIR}/include/account
)

target_link_directories(my_app PRIVATE ${RTCX_SDK_DIR}/libs)

target_link_libraries(my_app PRIVATE
    rtcxpcsdk common sdkcfg dns account im player
    librtcx_imsdk librtcx_tools librtcx_innerplayer jsoncppr
    libcurl jsoncpp spdlog fmt ssl crypto
    ws2_32 winmm bcrypt
)

if(MSVC)
    target_compile_options(my_app PRIVATE /utf-8)
endif()

add_custom_command(TARGET my_app POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_directory
        ${RTCX_SDK_DIR}/bin $<TARGET_FILE_DIR:my_app>
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
        ${RTCX_SDK_DIR}/bin/config.ini $<TARGET_FILE_DIR:my_app>/config.ini
)
```

> **说明：** `jsoncppr.lib` 为 IM 预编译库自带 jsoncpp；`jsoncpp.lib` 为 SDK `common` 模块编译所用 vcpkg 版本。两者均需链接，请勿替换为本机其他 jsoncpp。HTTP 请求由 `common.lib` 内部实现，集成方只需链接 `libcurl.lib`，无需配置 curl 头文件路径。

---

## 4. Visual Studio 手动配置

**附加包含目录：**

```
$(RTCX_SDK)\thirdparty\include
$(RTCX_SDK)\include
$(RTCX_SDK)\include\rtcxpcsdk
$(RTCX_SDK)\include\common
$(RTCX_SDK)\include\account
```

**附加库目录：** `$(RTCX_SDK)\libs`

**附加依赖项（Release）：**

```
rtcxpcsdk.lib;common.lib;sdkcfg.lib;dns.lib;account.lib;im.lib;player.lib;
librtcx_imsdk.lib;librtcx_tools.lib;librtcx_innerplayer.lib;jsoncppr.lib;
libcurl.lib;jsoncpp.lib;spdlog.lib;fmt.lib;ssl.lib;crypto.lib;
ws2_32.lib;winmm.lib;bcrypt.lib
```

编译选项建议开启 **`/utf-8`**（与 SDK 一致）。

---

## 5. 配置文件

将 `bin/config.ini` 复制到 **exe 工作目录**，或在初始化时指定路径：

```ini
[dns]
domain = https://dnms.iotrtc.cn

[rtc]
stunUrl = stun:stun.iotrtc.cn:3478

[log]
level = info
console = false
file = true
path = logs/
filename = pcsdk.log
```

```cpp
#include "IRtcxPcApi.h"

rtx::pcsdk::InitParam param;
param.cfgFileName = "config.ini";
param.appKey = "your_app_key";
param.appSecret = "your_app_secret";
rtx::pcsdk::IRtcxPcApi::Initialize(param);
```
