前言
- 测试的linux系统为ubuntu 18.04
- 测试的windows系统为win10
- 将windows的显示器作为linux的扩展屏,需要使用微软的Miracast技术。windows自带就不多说了,linux使用的是这个开源软件albfan/miraclecast
- 操作分成两个部分,在linux和windows上都要进行配置
Win
- 打开蓝牙,连接WiFi
- 进入设置,找到系统=>投影到此电脑
- 如果其中的选项都是灰色无法设置,可能是没有安装相应的功能,则在设置中搜索可选功能,然后找到“无线显示器”安装即可
- 若选项可以设置,则根据自己的需求设置
- 然后打开软件“连接”(可以直接在菜单栏中搜索)
Linux
强烈建议参考官方README设置,下面的方法仅仅是做个记录,操作默认使用root权限
Requirements
-
首先下载代码
git clone --depth=1 https://github.com/albfan/miraclecast.git
-
systemd: 要求版本>=221,查看方式如下
dpkg -l|grep systemd
-
glib: A utility library. Used by the current DHCP implementation. Will be removed once sd-dns gains DHCP-server capabilities. required: ~=glib2-2.38 (might work with older releases, untested…)
-
gstreamer: 运行源码中的
res/test-viewer.sh
,如果没有安装完全的话会提示类似Try to install “gst-plugins-bad, gst-plugins-base, gst-plugins-base-libs, gst-plugins-good, gst-plugins-ugly, gst-libav, gstreamer”
但是直接用
apt search
这些包名可能是找不到的(可能是我用的ubuntu18.04太老了),于是我一个个分开检索没有安装的包apt search gst | grep gst | grep plugin | grep -v installed | grep base apt search gst | grep gst | grep plugin | grep -v installed | grep bad apt search gst | grep gst | grep plugin | grep -v installed | grep good apt search gst | grep gst | grep plugin | grep -v installed | grep ugly apt search gst | grep gst | grep libav | grep -v installed
根据上述命令的输出来选择需要安装的包,最终我安装了如下
apt install libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav
注意:dbg结尾的不要安装
然后再次运行源码中的
res/test-viewer.sh
,全都pass则成功,否则再次检查有啥没有安装 -
wpa_supplicant: MiracleCast spawns wpa_supplicant with a custom config.
apt install wpasupplicant
-
检查无线网卡是否支持P2P:进入源码中的
res
文件夹,运行test-hardware-capabilities.sh
-
(可选)check: 作者测试的版本是0.9.11
apt install check
Build and install
参考官方文档
-
安装依赖,ubuntu18.04的如下
apt install cmake libglib2.0-dev libudev-dev libsystemd-dev libreadline-dev check libtool autoconf
-
然后我选择使用cmake进行build
mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX=/usr .. make -j6 make install
如果报如下错误
则根据issue,在源码的src/shared/CMakeLists.txt
后面加上一行target_link_libraries(miracle-shared m)
运行
关于sink和peer,作者在这个issue中有解释:
“in miracast protocol your device can act as source (share a video stream (normally from its screen)) or as sink( receives and shows a video streaming). Both are peers for miracast”
-
shutdown wpa_supplicant and NetworkManager
systemctl stop NetworkManager.service systemctl stop wpa_supplicant.service
-
launch wifi control
miracle-wifictl
-
Enable visibility for other devices文章来源:https://www.toymoban.com/news/detail-491618.html
-
Locate them using scanning文章来源地址https://www.toymoban.com/news/detail-491618.html
p2p-scan
到了这里,关于将windows的显示器作为linux的扩展屏的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!