The computer is assumed to run pipewire for its sound system.
First, install icecast on a server somewhere, e.g. icecast.example.com, port 8000
Secondly, install VLC on your phone.
Then, install gstreamer and its plugins on the computer, e.g:
sudo apt install gstreamer1.0-plugins-goodFigure out the number of the sound device that you want to stream:
pw-cat -r --list-targetsLet's say it's 50. On my computer that is the number for the monitor source, which will be unaffacted by the volume levels of the computer.
Then issue this command line:
gst-launch-1.0 pipewiresrc path=50 ! \
audioconvert ! vorbisenc ! oggmux ! \
shout2send mount=/stream.ogg port=8000 username=source \
password=hackme ip=icecast.example.comThere may be extraneous stages in the pipeline above. But it works.
Update 2023-07-30
However for me, there was still one small problem: The volume was too low after coming out from icecast. However there is a pipeline stage you can put in with the plugin audioamplify which solved that problem.
So now the pipeline in Gstreamer looks like this:
gst-launch-1.0 pipewiresrc path=50 ! \
audioconvert ! audioamplify amplification=4 ! \
vorbisenc ! oggmux ! \
shout2send mount=/stream.ogg port=8000 username=source \
password=hackme ip=icecast.example.comThere is also a Gstreamer volume plugin, but it can only attenuate.