You are not logged in.

#1 2024-10-10 17:30:44

hjheins
Member
Registered: 2020-03-08
Posts: 30

DLNA output solution for pipewire => pa-dlna

Hello all,

I started using pipewire a few weeks ago, and quickly found out that there wasn't any support for DLNA output.
Why is this important? It is a really nice to have if you want to play audio to any DLNA device directly from your computer.

Then I found pa-dlna. long story short: this works. I made it into a package so it runs in the background as a user service and is always available.

However: I am not that proficient in PKGBUILD and have no access to AUR. Is there anybody out there that is willing to adopt this package and publish it in aur?

Prerequisite: python-libpulse

# Maintainer: HJHeins <hjheins at proton . me>
pkgname=python-libpulse
pkgshort=libpulse
pkgver=0.4
pkgrel=1
pkgdesc="Pulsaudio python connectivity library. Also works with pipewire."
arch=('any')
url="https://gitlab.com/xdegaye/libpulse"
license=('MIT')
depends=('libpulse' 'python3')
makedepends=('git' 'python-wheel' 'python-build' 'python-installer' 'python-flit-core')
source=("${pkgshort}-v${pkgver}.tar.bz::https://gitlab.com/xdegaye/$pkgshort/-/archive/v$pkgver/$pkgshort-v$pkgver.tar.bz2")
sha256sums=('5f6c4df686039c5e7516b59a3d2201fd3d3a9726e36b6365221f789c7075c3dc')

build() {
  cd $pkgshort-v$pkgver
  python -m build --wheel --no-isolation
}

package() {
  cd $pkgshort-v$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 $srcdir/$pkgshort-v$pkgver/LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
}

the main course: pa-dlna

# Maintainer: HJHeins <hjheins at proton . me>
pkgname=pa-dlna
pkgver=0.13
pkgrel=1
pkgdesc="Pulsaudio DLNA server written in python. Also works with pipewire."
arch=('any')
url="https://gitlab.com/xdegaye/pa-dlna"
license=('MIT License')
depends=('libpulse' 'python3' 'python-libpulse')
makedepends=('git' 'python-wheel' 'python-build' 'python-installer' 'python-flit-core')
source=("${pkgname}-${pkgver}.tar.bz2::https://gitlab.com/xdegaye/pa-dlna/-/archive/v${pkgver}/${pkgname}-v${pkgver}.tar.bz2"
"${pkgname}.bak"
"upnp-cmd.bak"
"$pkgname.service")
sha256sums=('7148c365df4414dc3b05aa89e03367c21788435a0f6c2fcecc5b70b2e9a74a31'
'd824bd1f27c96ecb2cfb56122acd1904190634c0d0b04413e92edd8322afa5fb' '8a82c3d0b2d770b27a9d5f362ca5d5942d0e84984b03a3e9c1cc64d68824294b'
'46a0775fee7e740db9a393ce6128aaf65c433cabca565ad1c4075f0115e94653')

build() {
#  mv $pkgname-v$pkgver $pkgname-$pkgver
  cd $pkgname-v$pkgver
  python -m build --wheel --no-isolation
}

package() {
  cd $pkgname-v$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  install -Dm 644 $srcdir/$pkgname.service -t "${pkgdir}/etc/systemd/user/"
  install -Dm 755 $srcdir/upnp-cmd.bak -T "${pkgdir}/usr/bin/upnp-cmd"
  install -Dm 755 $srcdir/$pkgname.bak -T "${pkgdir}/usr/bin/pa-dlna"
  install -Dm 644 $srcdir/$pkgname-v$pkgver/LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
  rm -rf $srcdir/$pkgname-v$pkgver
  }

sources

pa-dlna.service

[Unit]
Description=Pulseaudio or Pipewire DLNA Service
After=network.target
Requires=pipewire-session-manager.service

[Service]
Type=simple
ExecStart=/usr/bin/pa-dlna
Restart=on-failure
RestartSec=5
Slice=session.slice
SyslogIdentifier=%n

[Install]
WantedBy=multi-user.target

pa-dlna.bak

#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from pa_dlna.pa_dlna import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

upnp-cmd.bak

#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from pa_dlna.upnp_cmd import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

Last edited by hjheins (2024-10-17 10:29:13)

Offline

#2 2024-10-10 17:32:40

hjheins
Member
Registered: 2020-03-08
Posts: 30

Re: DLNA output solution for pipewire => pa-dlna

As Info: this one is still build directly from git master as a bugfix that is needed is not yet packages as the next release

Offline

#3 2024-10-12 12:36:46

hjheins
Member
Registered: 2020-03-08
Posts: 30

Re: DLNA output solution for pipewire => pa-dlna

I would definitely also take comments on how to improve the pkgbuild file :-)

Offline

#4 2024-10-12 15:49:39

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 13,074

Re: DLNA output solution for pipewire => pa-dlna

The python-libpulse package build() function does nothing.
Also build() & package() are run from within $srcdir.

I think you should check https://man.archlinux.org/man/PKGBUILD.5 and https://wiki.archlinux.org/title/Python … guidelines


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#5 2024-10-12 20:44:51

hjheins
Member
Registered: 2020-03-08
Posts: 30

Re: DLNA output solution for pipewire => pa-dlna

thanks, and noted. I updated python-libpulse.

Offline

#6 2024-10-12 21:26:53

loqs
Member
Registered: 2014-03-06
Posts: 18,151

Re: DLNA output solution for pipewire => pa-dlna

That is still not following the python package guidelines. Is there an issue with using a build such as:

...
makedepends=('python-build' 'python-flit-core' 'python-installer' 'python-wheel')
...
build() {
  cd $pkgshort-v$pkgver
  python -m build --wheel --no-isolation
}

package() {
  cd $pkgshort-v$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
 }

Edit:
Other issues:

arch=('i686' 'x86_64' 'arm' 'armv7h' 'armv6h' 'aarch64' 'riscv64')

should be any for pure python packages.

options=(!lto)

Does not do anything in a pure python package.

license=('MIT License')

should be 'MIT'

makedepends=('git')

Not used as the source is a tarball.

source=("${pkgshort}-v${pkgver}.tar.gz::https://gitlab.com/xdegaye/$pkgshort/-/archive/v$pkgver/$pkgshort-v$pkgver.tar.bz2")

Why rename a bz2 tarball to .gz?

Last edited by loqs (2024-10-12 21:32:45)

Offline

#7 2024-10-13 09:11:56

hjheins
Member
Registered: 2020-03-08
Posts: 30

Re: DLNA output solution for pipewire => pa-dlna

Thank yo @loqs! that helps a lot.
I updated python-libpulse. As Info: when there is no source tarball, it pulls from git, which is also how I tested it. You think I should drop everything before the :  there?

I have also cleaned up pa-dlna the same way

Last edited by hjheins (2024-10-13 09:33:31)

Offline

#8 2024-11-26 18:00:04

dreieck
Member
Registered: 2012-10-08
Posts: 67

Re: DLNA output solution for pipewire => pa-dlna

Now, python-libpulse and pa-dlna are in the AUR (in their -git variants).

Since I do not use systemd, I cannot test the .service file and I have not included any.

If anyone can confirm that the posted `pa-dlna.service` is correct, or someone can post a correct one, AND tell where to install it, I can include it in the package.

(I assume that `pa-dlna` should be started per user, since pipewire / pulseaudio also run per user, correct?)

Regards!

Last edited by dreieck (2024-11-26 18:00:30)

Offline

#9 2024-12-08 10:56:51

hjheins
Member
Registered: 2020-03-08
Posts: 30

Re: DLNA output solution for pipewire => pa-dlna

Hi Dreieck,

For confirmation on the correctness and the location of the services files, I should not comment.
But indeed if run as a service, it should run on a per user basis (otherwise it won´t be able to connect to pulse or pipewire)

cheers

Offline

#10 2024-12-18 11:24:37

mccurly
Member
Registered: 2015-06-05
Posts: 23

Re: DLNA output solution for pipewire => pa-dlna

Hi, is this currently working?

I am trying to output my laptop's sound to the balenasound upnp device.

I am at loss as to how to make it work.

$ pa-dlna
init    INFO    pa-dlna version 0.14
init    INFO    Python version 3.12.7 (main, Oct  1 2024, 11:15:50) [GCC 14.2.1 20240910]
init    INFO    Options {'ip_addresses': [], 'nics': [], 'msearch_interval': 60, 'msearch_port': 0, 'ttl': b'\x02', 'port': 8080, 'dump_default': False, 'dump_internal': False, 'clients_uuids': None, 'loglevel': 'info', 'logfile': None, 'nolog_upnp': False, 'log_aio': False, 'test_devices': []}
init    INFO    Start pa-dlna
upnp    INFO    Start UPnP discovery on new IPs {'10.0.1.5'}
libpuls INFO    Python libpulse version 0.6.post3
libpuls INFO    LibPulse connection: ('PA_CONTEXT_READY', 'OK')
libpuls INFO    Server: PulseAudio (on PipeWire 1.2.7)
upnp    INFO    Close UPnPRootDevice uuid:852b9...b6124
upnp    WARNING Disable the UPnPRootDevice uuid:852b9...b6124 UPnP device permanently
upnp    ERROR   Exception in task 'UPnPRootDevice uuid:852b9...b6124' - function UPnPRootDevice._run():
        UPnPInvalidHttpError('Content-Length and actual length mismatch (2061 != 2063) from 10.0.1.151')
        Run this program at the 'debug' log level to print the exception backtrace
pa-dlna INFO    Got 'byebye' notification for UPnPRootDevice uuid:852b9...b6124
pa-dlna INFO    Ignore 'UPnPRootDevice uuid:852b9...b6124': missing deviceType or modelName

^Cpulse   INFO    Close pulse
upnp    INFO    Close UPnPControlPoint
pa-dlna INFO    Main task got: CancelledError('Got SIGINT or SIGTERM')
network INFO    End of the SSDP notify task
libpuls INFO    Disconnected from libpulse context
libpuls INFO    LibPulse main loop closed
init    INFO    End of pa-dlna

Could anyone lend a hand?

Thank you!

Offline

#11 2024-12-18 12:09:33

dreieck
Member
Registered: 2012-10-08
Posts: 67

Re: DLNA output solution for pipewire => pa-dlna

mccurly wrote:

Hi, is this currently working?

For me it sometimes works (and I have only one device to test with). But I did not dig deeper:

Sometimes, the device appears and I can select it as playback device from PulseAudio GUIs. Sometimes it does not.

Sometimes playback stops just in the middle and the device disappears.

However, via `pipewire-zeroconf`, the device still is visible and can be played back on (some apple protocol, another than DLNA).

Last edited by dreieck (2024-12-18 14:46:43)

Offline

#12 2024-12-18 14:26:55

mccurly
Member
Registered: 2015-06-05
Posts: 23

Re: DLNA output solution for pipewire => pa-dlna

dreieck wrote:
mccurly wrote:

Hi, is this currently working?

For me it sometimes works. But I did not dig deeper:
(...)

Hello, and thank you for your input.

Well, now it's working.

I guess the malfunction is/was due to BalenaSound. (I am going to point their support here to this thread onto the message I've posted before).

Now I am using moOde, and it works.

Thank you.

Offline

#13 2024-12-30 16:19:37

hjheins
Member
Registered: 2020-03-08
Posts: 30

Re: DLNA output solution for pipewire => pa-dlna

hi @mccurly,

Right I am also using it for Moode.
It was the only thing that seems to be able to get pipewire to directly play to dlna. (with the ease and flexibility that it is selectable in pavu (pulseaudio volume control))

@dreieck: soo: what are you using to play to here? (moode accepts dlna, I tried airplay from pipewire, but that did not work)

cheers

Last edited by hjheins (2024-12-30 16:22:47)

Offline

Board footer

Powered by FluxBB