跳转至

使用 Linux 作为 Miracast 接收器

文档时效性说明

本文为早期笔记,可能存在版本过时、命令失效、链接失效、最佳实践变化等问题。请以官方最新文档为准。

原英文标题:Use Linux as a Miracast receiver

1. Download and compile miraclecast

https://github.com/albfan/miraclecast 下载 zip 包,按 README 操作。

1.1 安装依赖

sudo dnf install cmake meson glib2-devel systemd-devel readline-devel check libtool iw
sudo dnf install gstreamer1-libav

1.2 测试兼容性

1
2
3
cd res
sudo ./test-hardware-capabilities.sh
sudo ./test-viewer.sh

1.3 编译并安装

1
2
3
4
5
6
sudo cp org.freedesktop.miracle.conf /etc/dbus-1/system.d/
mkdir build
cd build/
../autogen.sh g --prefix=/usr
make -j12
sudo make install

1.1 启动服务端

1
2
3
4
systemctl stop NetworkManager
sudo systemctl stop NetworkManager
sudo systemctl stop wpa_supplicant
sudo miracle-wifid &

1.2 连接

sudo miracle-sinkctl
run 3
$ sudo miracle-wifictl --log-level trace
[miraclectl] # list
  LINK INTERFACE                FRIENDLY-NAME                 
     3 wlp3s0                   archlinux-alberto             

  LINK PEER-ID                  FRIENDLY-NAME                  CONNECTED 

 0 peers and 1 links listed.
[miraclectl] # select 3
link 3 selected
[ADD] Peer: f2:27:65:35:b6:8f@3
[PROV] Peer: ff:ff:ff:ff:ff:ff@3 Type: pbc PIN: 
[miraclectl] # list
  LINK INTERFACE                FRIENDLY-NAME                 
     3 wlp3s0                   archlinux-alberto             

  LINK PEER-ID                  FRIENDLY-NAME                  CONNECTED 
     3 ff:ff:ff:ff:ff:ff@3           Alberto Fanjul Alonso            no        

 1 peers and 1 links listed.
[miraclectl] # connect ff:ff:ff:ff:ff:ff@3
[CONNECT] Peer: ff:ff:ff:ff:ff:ff@3
[miraclectl] # list
  LINK INTERFACE                FRIENDLY-NAME                 
     3 wlp3s0                   archlinux-alberto             

  LINK PEER-ID                  FRIENDLY-NAME                  CONNECTED 
     3 ff:ff:ff:ff:ff:ff@3           Alberto Fanjul Alonso            yes        

 1 peers and 1 links listed.

1.3 故障排查

如果无法连接到 miraclecast,运行

sudo miracle-wifid --log-level trace

查看调试信息。如果错误描述为

ERROR: supplicant: HUP on dhcp-comm socket on p2p-wlo1-1 (supplicant_group_comm_fn() in ../../../src/wifi/wifid-supplicant.c:247)

尝试

sudo miracle-dhcp --netdev <your_interface>

在我的案例中,该命令报错:

ERROR: dhcp: execution of ip-binary (/bin/ip) not allowed: No such file or directory (parse_argv() in ../../../src/dhcp/dhcp.c:877)

运行

which ip

输出

/usr/sbin/ip

因此解决方案为

sudo ln -s /usr/sbin/ip /bin/ip

1.4 原文(English)

---
tags:
  - 网络
  - Linux
---

# 使用 Linux 作为 Miracast 接收器


!!! warning "文档时效性说明"
    本文为早期笔记,可能存在版本过时、命令失效、链接失效、最佳实践变化等问题。请以官方最新文档为准。

# Download and compile miraclecast

Download zip from <https://github.com/albfan/miraclecast>

Do what README says.

### Install dependencies

```bash
sudo dnf install cmake meson glib2-devel systemd-devel readline-devel check libtool iw
sudo dnf install gstreamer1-libav

Test compatibilities

1
2
3
cd res
sudo ./test-hardware-capabilities.sh
sudo ./test-viewer.sh

Make and install

1
2
3
4
5
6
sudo cp org.freedesktop.miracle.conf /etc/dbus-1/system.d/
mkdir build
cd build/
../autogen.sh g --prefix=/usr
make -j12
sudo make install

Fire up the server

1
2
3
4
systemctl stop NetworkManager
sudo systemctl stop NetworkManager
sudo systemctl stop wpa_supplicant
sudo miracle-wifid &

Connect

sudo miracle-sinkctl
run 3
$ sudo miracle-wifictl --log-level trace
[miraclectl] # list
  LINK INTERFACE                FRIENDLY-NAME                 
     3 wlp3s0                   archlinux-alberto             

  LINK PEER-ID                  FRIENDLY-NAME                  CONNECTED 

 0 peers and 1 links listed.
[miraclectl] # select 3
link 3 selected
[ADD] Peer: f2:27:65:35:b6:8f@3
[PROV] Peer: ff:ff:ff:ff:ff:ff@3 Type: pbc PIN: 
[miraclectl] # list
  LINK INTERFACE                FRIENDLY-NAME                 
     3 wlp3s0                   archlinux-alberto             

  LINK PEER-ID                  FRIENDLY-NAME                  CONNECTED 
     3 ff:ff:ff:ff:ff:ff@3           Alberto Fanjul Alonso            no        

 1 peers and 1 links listed.
[miraclectl] # connect ff:ff:ff:ff:ff:ff@3
[CONNECT] Peer: ff:ff:ff:ff:ff:ff@3
[miraclectl] # list
  LINK INTERFACE                FRIENDLY-NAME                 
     3 wlp3s0                   archlinux-alberto             

  LINK PEER-ID                  FRIENDLY-NAME                  CONNECTED 
     3 ff:ff:ff:ff:ff:ff@3           Alberto Fanjul Alonso            yes        

 1 peers and 1 links listed.

Troubleshooting

If you cannot connect to miraclecast, run

sudo miracle-wifid --log-level trace

to show debug information. And if the error is described as

ERROR: supplicant: HUP on DHCP-comm socket on p2p-wlo1-1 (supplicant_group_comm_fn() in ../../../src/wifi/wifid-supplicant.c:247)

try

sudo miracle-DHCP --netdev <your_interface>

In my case, the command failed with error:

ERROR: DHCP: execution of ip-binary (/bin/ip) not allowed: No such file or directory (parse_argv() in ../../../src/dhcp/dhcp.c:877)

I ran

which ip

it prints

/usr/sbin/ip

So the solution was

sudo ln -s /usr/sbin/ip /bin/ip
```