One of the weak points of FreeBSD as a desktop system is its limitations in terms of playing multimedia content from streaming platforms such as Netflix or HBO, among others. Although it is possible to install a Linux-simulating browser through linuxulator, the steps are complex and convoluted. In this article, we will resort to a little trick that will allow us to stream our mobile device on the PC. The idea is to enable debug-USB mode and stream through it.
The article is composed of several parts:
Enabling debug-USB:
To enable USB debugging, we must first enable developer options. To do this, we access the Android configuration parameters, Settings -> Phone Information:
We look for the build number and tap it 7 times:
A message will appear warning us that we have activated the developer options:
We access the Settings -> System section:
Advanced section:
Developer options:
Debugging -> USB debugging:
When activated, the following warning will appear:
We connect the phone to the PC and in the dmesg we will see:
ugen0.9: <Xiaomi SDM660-MTP SN:4420871C> at usbus0
On the phone, it will ask us for access confirmation:
Video streaming:
Now we install the video streaming software:
We run the adb server as root:
* daemon not running; starting now at tcp:5037
* daemon started successfully
It is not necessary to run scrcpy as root, so we launch it as a regular user:
At this point, we will be able to control our phone from the PC:
Audio streaming:
We install VLC since it is a dependency of sndcpy:
The audio streaming software is an apk that we will install on the phone. It is supposed to come with a script that pushes and installs the apk through adb, but in my case, it has only given me problems, so I will install it manually.
We download the apk from the project repository:
cd sndcpy
fetch https://github.com/rom1v/sndcpy/releases/download/v1.0/sndcpy-v1.0.zip
unzip sndcpy-v1.0.zip
In my case, I am going to transfer the apk to the phone through Telegram, but to be able to install insecure applications from an app on Android, we will have to configure the settings of this:
And authorize the download from this source:
Now we can install it:
There is no need to open the application, so we click on “Listo”:
Through adb, we forward the mobile’s port 28200 to our PC:
We start the newly installed application:
On the mobile, we will see the window to start recording audio, we click on “Iniciar Ahora”:
Now we tell VLC to play the received audio on localhost:28200 through the previously configured forward:
And that’s it, all mobile applications on the PC, both video and audio working, if we start playing a movie, we just need to maximize the window and that’s it.
NOTE: If sndcpy is difficult to use, we could always pair Bluetooth headphones/speakers with the phone and play the audio through them.
Relaunching:
If we restart the phone, we must re-enable USB debugging (just the last step):
If, on the other hand, we restart the PC, we can use the following script:
#!/usr/local/bin/bash
sudo /usr/local/bin/adb kill-server
sudo /usr/local/bin/adb start-server
killall scrcpy 2>/dev/null
nohup scrcpy &
adb forward tcp:28200 localabstract:sndcpy
adb shell am start com.rom1v.sndcpy/.MainActivity
echo "-- Press ENTER when mobile audio recording is started"
read AA
killall vlc 2>/dev/null
nohup vlc -Idummy --demux rawaud --network-caching=50 --play-and-exit tcp://localhost:28200 &
We assign the necessary permissions:
We configure sudo to allow executing commands that require root permissions:
# ADB
kr0m ALL=(ALL) NOPASSWD: /usr/local/bin/adb kill-server
kr0m ALL=(ALL) NOPASSWD: /usr/local/bin/adb start-server
Troubleshooting:
We can check the devices detected by adb:
List of devices attached
2d70b8a device
We can check the phone logs using adb:
Also, we can enable debug mode by exporting the value of the ADB_TRACE variable before executing any adb command: