vlc-unity编译过程
2024/8/25大约 2 分钟
最近一个项目需要在 Unity 中播放 RTSP 视频流,打算使用 vlc-unity,简单记录一下自行编译过程。
这篇文章在未来的某个时刻,肯定会过期的,看的时候要注意一下。
看文章要思考,不要看到命令就复制,要学会举一反三,自行思考。
本篇文章基本是按照
vlc-unity
的 .gitlab-ci.yml 文件写的,所以请以.gitlab-ci.yml
为准,阅读本文前,请阅读.gitlab-ci.yml
,并注意后续更新。本文以 win64 平台为例,其他平台请自行思考。
本篇文章以 llvm-ucrt 编译,而且仅适用于 Win10 1903 及更高的版本。
基础环境
准备 docker 环境,这里不再赘述。
启动镜像
docker run -it --user root --entrypoint /bin/bash registry.videolan.org/vlc-debian-llvm-ucrt:20241111035123 -s
其中标签可以在列表查询
然后克隆代码
git clone https://github.com/videolan/vlc-unity.git && cd vlc-unity
git clone https://github.com/videolan/vlc.git && cd vlc
git apply ../patches/disable-activex.patch
编译 VLC
编译 vlc
extras/package/win32/build.sh -u -c -z -r -x -a x86_64 -i nope -g l -S 0x0A000007
cd win64-ucrt
make package-win-strip
rm -rf vlc-4.0.0-dev/lua/http
cd ../../
然后把 vlc/win64-ucrt/vlc-4.0.0-dev/
目录拷贝下来备用。
编译 VLC-UNITY
PKG_CONFIG_PATH=./vlc/win64-ucrt/_win32/lib/pkgconfig meson setup build_windows --cross-file=cross/windows-x86_64.txt -Dwatermark=false --buildtype release
ninja -C build_windows
cp build_windows/PluginSource/libVLCUnityPlugin-1.dll VLCUnityPlugin.dll
然后把 VLCUnityPlugin.dll
拷贝下来备用。
编译 LIBVLCSHARP
这一部分可以不做,插件中自带 LIBVLCSHARP
这一部分在 windows 环境上搞就行,当然 Linux 中也可以,这里还是用 Docker。
docker run -it --user root --entrypoint /bin/bash mcr.microsoft.com/dotnet/sdk:8.0 -s
git clone https://github.com/videolan/LibVLCSharp lvs && cd lvs
git checkout -f master
dotnet build src/LibVLCSharp/LibVLCSharp.csproj /p:UNITY=true -c Release
然后把 lvs/src/LibVLCSharp/bin/Release/netstandard2.0/
目录拷贝下来备用。
测试
至此,所有需要的文件就全部编译完成了,下载试用版插件,将自己编译的文件替换试用版插件中的文件即可。
其他
Windows API Version
来源: https://doxygen.reactos.org/d9/d16/sdkddkver_8h_source.html
#define NTDDI_WIN7 0x06010000 // Windows 7
#define NTDDI_WIN8 0x06020000 // Windows 8
#define NTDDI_WINBLUE 0x06030000 // Windows 8.1
#define NTDDI_WINTHRESHOLD 0x0A000000 // Windows 10.0.10240 / 1507 / Threshold 1
#define NTDDI_WIN10 0x0A000000
#define NTDDI_WIN10_TH2 0x0A000001 // Windows 10.0.10586 / 1511 / Threshold 2
#define NTDDI_WIN10_RS1 0x0A000002 // Windows 10.0.14393 / 1607 / Redstone 1
#define NTDDI_WIN10_RS2 0x0A000003 // Windows 10.0.15063 / 1703 / Redstone 2
#define NTDDI_WIN10_RS3 0x0A000004 // Windows 10.0.16299 / 1709 / Redstone 3
#define NTDDI_WIN10_RS4 0x0A000005 // Windows 10.0.17134 / 1803 / Redstone 4
#define NTDDI_WIN10_RS5 0x0A000006 // Windows 10.0.17763 / 1809 / Redstone 5
#define NTDDI_WIN10_19H1 0x0A000007 // Windows 10.0.18362 / 1903 / 19H1 "Titanium"
// 10.0.18363 / Vanadium
#define NTDDI_WIN10_VB 0x0A000008 // Windows 10.0.19041 / 2004 / Vibranium
#define NTDDI_WIN10_MN 0x0A000009 // Windows 10.0.19042 / 20H2 / Manganese
#define NTDDI_WIN10_FE 0x0A00000A // Windows 10.0.19043 / 21H1 / Ferrum
#define NTDDI_WIN10_CO 0x0A00000B // Windows 10.0.19044 / 21H2 / Cobalt
#define NTDDI_WIN11_CO NTDDI_WIN10_CO // Windows 10.0.22000 / 21H2 / Cobalt
#define NTDDI_WIN11 NTDDI_WIN11_CO
#define NTDDI_WIN10_NI 0x0A00000C // Windows 10.0.22621 / 22H2 / Nickel
#define NTDDI_WIN11_NI NTDDI_WIN10_NI
#define NTDDI_WIN10_CU 0x0A00000D // Windows 10.0.22621 / 22H2 / Copper