Author Topic: UPnP 2025 - Continuation of the original UPnP/DLNA plugin  (Read 34819 times)

BoringName

  • Sr. Member
  • ****
  • Posts: 916
Attempting to get seeking working for encoded streams....

To do this you need to set Accept-Ranges to bytes in the HTTP headers. If it's set to none then seeking wont work. Well there is timeseeking but it seems both the renderers I'm testing on don't use that method.

This enables renderers to request a byte range of a track. So when you seek to 1:00, the renderer will close the current stream and request a new stream with a byte range beginning with the byte that corresponds to 1:00 and ending with the last byte of the track.

When you enable Accept-Ranges for Foobar. Before it even starts playing the track, it requests a byte range that returns the last few milliseconds of the track. It does this A LOT (by the dozens) with slightly varying ranges, 20ms-400ms roughly. The longer the duration of the track the more it repeats this. The foobar UPnP log has a stupid amount of information in it, 10000 lines per few seconds of playback but it doesn't show when or why it's doing these requests.

Once it gets over this absurdity, it doesn't just play the stream. It plays it via byte range requests. So it's constantly closing and reopening streams. Sometimes it seems to lose track of where it's up to and starts requesting ranges it's already played so the playback is messed up.

So while I can get seeking to work and the duration to display, it's not functional, also the method required to get this to work will not be usable for AAC and OGG codecs. A constant bitrate needs to be set and they can't do that.

BubbleUPnP doesn't do all the byte range request nonsense but I can't get it to seek. The progress bar (in bubbleUPnP) moves to the correct position so I know the request was valid but then drops to zero and playback stops. All the BubbleUPnP error log lists is an error code that means Unknown Error, super helpful!

So I'm calling it quits on that. Steven has fixed the issue that could cause the plugin to lockup with encoded streams and I did get BubbleUPnP to display the correct duration for encoded MP3 streams.

Like I said earlier, I'm not that worried about seeking but I really wanted to get Foobar to at least display the track duration. But the only way to do that is enable Accept-Ranges and that makes it go berserk. It's just going to remain messed up because I'm pretty sure whatever it's problem is, it's not something I can fix. The foobar UPnP plugin hasn't been updated since 2015 so that doesn't help.

BoringName

  • Sr. Member
  • ****
  • Posts: 916
New version mb_Upnp2025_1.5

Changes
- Fixed an issue that caused BubbleUPnP to re-encode a continuous stream unnecessarily.
- SetNextAVtransportURI support added. This should result in gapless playback without requiring a continuous stream. This will only be available if the device advertises that it supports the SetNextAVTransportURI command.
- New option "Disable NextURI support". For devices that advertise they support SetNextAVTransportURI but either don't support it or have issues with their implementation. This setting is profile specific. The plugin currently assumes the renderer will automatically start playing the NextURI when the initial track has finished. That's how all the renderers I've tested have behaved. If your device doesn't automatically transition to the NextURI, you will need to check this option to regain normal functionality.
- The log will now state if a stream is being encoded to apply Replaygain/DSP settings.
- Fixed multiple issues that prevented the DLNA type flag to be set for native streams and encoded WAV streams.
- Fixed an issue that caused bubbleUPnP to display the wrong duration for encoded non PCM streams. The same fix didn't work for Foobar....
- Added tooltips to some items on the settings page.

Musicbee version 3.6.9189 is required for NextURI to work. Also make sure to copy over the MusicBeeBass.dll file from the latest patch file. - Link in the post below.

There is very little chance this version will fix Marantz users with the white noise issue. I have got a theory on that but it would be good if I could get confirmation on whether native streams work for these devices.

The gapless playback from NextURI support doesn't apply any fade in/transition effects. It simply means the renderer will queue up the next track ahead of time so it avoids any delay when switching tracks. I haven't got much to test with so your results may vary.... I can say it worked perfectly in foobar but that was runnning off the same machine so no network issues to worry about.
Last Edit: February 27, 2025, 12:47:41 PM by BoringName

jorgemg1984

  • Jr. Member
  • **
  • Posts: 31
Hi!

I've been trying to make it work but no luck so far, I think the reason is I don't have MusicBee 3.6.9189, my version is 3.6.9171.

I can't find a link for the 3.6.9189 version, any tips?

Thanks!


jorgemg1984

  • Jr. Member
  • **
  • Posts: 31
OK, thanks!

I installed it, but it's from scratch, I'll have to edit my library again :)

As for the UPNP,  this configuration had both the old and the new plugin, I had to disable the old one and restart MusicBee to make the new one work.

With a Cambridge Audio MXN10 there's still a small gap between tracks, but much smaller than before (0..5 seconds maybe)

With an Auralic Aries S1, it plays on tracks and stops (with SetNext on or off).

simbun

  • Jr. Member
  • **
  • Posts: 39
I'm afraid it's a similar story with WiiM and Sonos.

I disabled all the DSP but there's still a gap between tracks.

WiIM

Displayed album art, metadata (track title, album and albumartist), track progress and track technical details.

Code
2835; 9 Profile - WiiM, useragent=|Linux/4.9.113
2836; 10 Profile - WiiM, useragent=|Linux/4.9.113
2857; 11 Activate - WiiM Pro-60F6:http-get:*:audio/wav:DLNA.ORG_PN=LPCM,http-get:*:audio/x-wav:DLNA.ORG_PN=LPCM,http-get:*:audio/mpeg:DLNA.ORG_PN=MP3,http-get:*:audio/mpeg:DLNA.ORG_PN=MP3X,http-get:*:audio/x-ms-wma:DLNA.ORG_PN=WMABASE,http-get:*:audio/x-ms-wma:DLNA.ORG_PN=WMAFULL,http-get:*:audio/x-ms-wma:DLNA.ORG_PN=WMAPRO,http-get:*:audio/mpeg:DLNA.ORG_PN=MP2_MPS,http-get:*:audio/mp3:*,http-get:*:audio/wma:*,http-get:*:audio/mpeg:*,http-get:*:audio/vnd.dlna.adts:DLNA.ORG_PN=AAC_ADTS,http-get:*:audio/vnd.dlna.adts:DLNA.ORG_PN=AAC_ADTS_320,http-get:*:audio/m4a:DLNA.ORG_PN=AAC_ISO,http-get:*:audio/aac:DLNA.ORG_PN=AAC_ISO,http-get:*:audio/ac3:DLNA.ORG_PN=AC3,http-get:*:audio/ogg:*,http-get:*:audio/ape:*,http-get:*:audio/x-ape:*,http-get:*:audio/flac:*
9699; 12 Play - D:\MusicBee Test\music\Stanton Warriors\2001 - The Stanton Session\01.01.flac (http://192.168.0.12:49382/files/C50AB82914AE234Dp.flac)
9987; 13 Profile - Generic Device, useragent=Lavf/58.45.100
9997; 14 GetFile[1] 192.168.0.12 - GET D:\MusicBee Test\music\Stanton Warriors\2001 - The Stanton Session\01.01.flac to 192.168.0.137
9998; 15 Profile - Generic Device, useragent=Lavf/58.45.100
10335; 16 GetFile[1] - exit=0, playtime=336
10349; 17 StateTimer - Playing,old=Stopped
10368; 18 SetNextAVTransportURI - Success - http://192.168.0.12:49382/files/0C2D7A04A970C9EEp.flac
31551; 19 Profile - Generic Device, useragent=Lavf/58.45.100
31557; 20 GetFile[2] 192.168.0.12 - GET D:\MusicBee Test\music\Stanton Warriors\2001 - The Stanton Session\01.02.flac to 192.168.0.137
31557; 21 Profile - Generic Device, useragent=Lavf/58.45.100
34473; 22 GetFile[2] - exit=0, playtime=2914
66856; 23 Seek - goto=0
66864; 24 Seek - pos=0
66899; 25 SetNextAVTransportURI - Success - http://192.168.0.12:49382/files/C0A8B86B104C228Fp.flac

Sonos

No album art, only track title and no track progress or technical details

Code
2321; 8 ProcessMessage 192.168.0.100 - device 'uuid:RINCON_000E58C5095001400_MR:192.168.0.100 - Sonos Play:1 - RINCON_000E58C5095001400',valid=True
2324; 9 Profile - Sonos, useragent=|Linux UPnP/1.0 Sonos/83.1-61240 (ZPS1)
2325; 10 Profile - Sonos, useragent=|Linux UPnP/1.0 Sonos/83.1-61240 (ZPS1)
2352; 11 Activate - 192.168.0.100 - Sonos Play:1 - RINCON_000E58C5095001400:http-get:*:audio/mp3:*,x-file-cifs:*:audio/mp3:*,http-get:*:audio/mp4:*,x-file-cifs:*:audio/mp4:*,http-get:*:audio/x-m4a:*,x-file-cifs:*:audio/x-m4a:*,http-get:*:audio/mpeg:*,x-file-cifs:*:audio/mpeg:*,http-get:*:audio/mpegurl:*,x-file-cifs:*:audio/mpegurl:*,file:*:audio/mpegurl:*,http-get:*:audio/x-mpegurl:*,x-file-cifs:*:audio/x-mpegurl:*,http-get:*:application/x-mpegurl:*,x-file-cifs:*:application/x-mpegurl:*,http-get:*:application/vnd.apple.mpegurl:*,x-file-cifs:*:application/vnd.apple.mpegurl:*,http-get:*:application/dash+xml:*,x-file-cifs:*:application/dash+xml:*,http-get:*:audio/mpeg3:*,x-file-cifs:*:audio/mpeg3:*,http-get:*:audio/wav:*,x-file-cifs:*:audio/wav:*,http-get:*:audio/x-wav:*,x-file-cifs:*:audio/x-wav:*,http-get:*:audio/wma:*,x-file-cifs:*:audio/wma:*,http-get:*:audio/x-ms-wma:*,x-file-cifs:*:audio/x-ms-wma:*,http-get:*:audio/aiff:*,x-file-cifs:*:audio/aiff:*,http-get:*:audio/x-aiff:*,x-file-cifs:*:audio/x-aiff:*,http-get:*:audio/flac:*,x-file-cifs:*:audio/flac:*,http-get:*:application/ogg:*,x-file-cifs:*:application/ogg:*,http-get:*:audio/ogg:*,x-file-cifs:*:audio/ogg:*,sonos.com-mms:*:audio/x-ms-wma:*,sonos.com-http:*:audio/mp3:*,sonos.com-http:*:audio/mpeg:*,sonos.com-http:*:audio/mpeg3:*,sonos.com-http:*:audio/wma:*,sonos.com-http:*:audio/mp4:*,sonos.com-http:*:audio/x-m4a:*,sonos.com-http:*:audio/wav:*,sonos.com-http:*:audio/aiff:*,sonos.com-http:*:audio/flac:*,sonos.com-http:*:application/ogg:*,sonos.com-http:*:application/x-mpegURL:*,sonos.com-http:*:application/dash+xml:*,sonos.com-spotify:*:audio/x-spotify:*,sonos.com-rtrecent:*:audio/x-sonos-recent:*,x-rincon:*:*:*,x-rincon-mp3radio:*:*:*,x-rincon-playlist:*:*:*,x-rincon-queue:*:*:*,x-rincon-stream:*:*:*,x-sonosapi-stream:*:*:*,x-sonosapi-hls:*:*:*,x-sonosapi-hls-static:*:*:*,x-sonosapi-radio:*:audio/x-sonosapi-radio:*,x-rincon-cpcontainer:*:*:*,
4658; 12 Play - D:\MusicBee Test\music\Stanton Warriors\2001 - The Stanton Session\01.01.flac (http://192.168.0.12:49382/files/C50AB82914AE234Dp.flac)
4777; 13 Profile - Sonos, useragent=Linux UPnP/1.0 Sonos/83.1-61240 (ZPS1)
4787; 14 GetFile[1] 192.168.0.12 - GET D:\MusicBee Test\music\Stanton Warriors\2001 - The Stanton Session\01.01.flac to 192.168.0.100
4788; 15 Profile - Sonos, useragent=Linux UPnP/1.0 Sonos/83.1-61240 (ZPS1)
5279; 16 StateTimer - Playing,old=Stopped
5893; 17 SetNextAVTransportURI - Success - http://192.168.0.12:49382/files/0C2D7A04A970C9EEp.flac
8167; 18 GetFile[1] - exit=0, playtime=3376
48529; 19 Profile - Sonos, useragent=Linux UPnP/1.0 Sonos/83.1-61240 (ZPS1)
48535; 20 GetFile[2] 192.168.0.12 - GET D:\MusicBee Test\music\Stanton Warriors\2001 - The Stanton Session\01.02.flac to 192.168.0.100
48536; 21 Profile - Sonos, useragent=Linux UPnP/1.0 Sonos/83.1-61240 (ZPS1)
60440; 22 Seek - goto=0
60546; 23 Seek - pos=0
60559; 24 GetFile[2] - exit=10054, playtime=12023
60600; 25 Profile - Sonos, useragent=Linux UPnP/1.0 Sonos/83.1-61240 (ZPS1)
60600; 26 GetFile[3] 192.168.0.12 - GET D:\MusicBee Test\music\Stanton Warriors\2001 - The Stanton Session\01.02.flac to 192.168.0.100
60601; 27 Profile - Sonos, useragent=Linux UPnP/1.0 Sonos/83.1-61240 (ZPS1)
60716; 28 GetFile[3] - exit=10054, playtime=114
60720; 29 Profile - Sonos, useragent=Linux UPnP/1.0 Sonos/83.1-61240 (ZPS1)
60722; 30 GetFile[4] 192.168.0.12 - GET D:\MusicBee Test\music\Stanton Warriors\2001 - The Stanton Session\01.02.flac to 192.168.0.100
60724; 31 GetFile - range=bytes 9043968-34723562/34723563
60724; 32 Profile - Sonos, useragent=Linux UPnP/1.0 Sonos/83.1-61240 (ZPS1)
62121; 33 SetNextAVTransportURI - Success - http://192.168.0.12:49382/files/C0A8B86B104C228Fp.flac
64904; 34 GetFile[4] - exit=10054, playtime=4179

jean.valjean

  • Jr. Member
  • **
  • Posts: 29
Hello

Quote
 There is very little chance this version will fix Marantz users with the white noise issue. I have got a theory on that but it would be good if I could get confirmation on whether native streams work for these devices.

yes, native streaming works with version 1.5

BoringName

  • Sr. Member
  • ****
  • Posts: 916
I installed it, but it's from scratch, I'll have to edit my library again :)

All you had to do was copy the files over the top of your existing files.

As for the UPNP,  this configuration had both the old and the new plugin, I had to disable the old one and restart MusicBee to make the new one work.
I've mentioned that previously. Although I'm not sure how you got the old one if you did an install from scratch.

With a Cambridge Audio MXN10 there's still a small gap between tracks, but much smaller than before (0..5 seconds maybe)
With an Auralic Aries S1, it plays on tracks and stops (with SetNext on or off).

I'll need log files to see what's going on there. Either PM me a link or post them here, just make sure to remove the networkaddress entries.

I'm afraid it's a similar story with WiiM and Sonos.

Disappointing. I assume the gap is smaller than previously? The log looks like it's functioning correctly. I'm not sure there is anything else I can do there.

I'll look up sonos and see if there is anything different I need to worry about. Apart from the seek issue I have mentioned previously.


yes, native streaming works with version 1.5

You have my hopes up there but I think there might be some terminology confusion.

When I say "native stream". I mean a track that is streamed without being encoded. I don't mean a continuous stream which is what I expect you are referring to.

So far all the logs you have provided show your streams are encoded because the correct profile was not getting applied.

It might be easier if I ask - do you still have the white noise issue with 1.5?
Last Edit: February 27, 2025, 09:50:21 PM by BoringName

BoringName

  • Sr. Member
  • ****
  • Posts: 916
I don't think I'm going to bother too much with trying to get Sonos working. With everything I've read they seem to be moving away from the UPnP standard and anyone reporting bugs around DLNA/UPnP is getting met with silence. If you're not using their software and/or a streaming service like spotify, you're probably out of luck.

This text in the Lyrion Music Server source code is probably telling - "Sonos is a pile of crap".

If it was having issues displaying information from an encoded stream, I would have a play around but everything I've tested plays and displays info for native streams without issue. I don't really want to be messing around with that code in case it breaks things for other users.

simbun

  • Jr. Member
  • **
  • Posts: 39
@BoringName,

Were you able to play gaplessly to foobar2000 and BubbleUPnP? Whilst the gap is small it's definitely there.

Is there any way I can validate my setup?

MusicBee.exe (3.6.9189)   51bbc079516c76b123a3c92a50858259fff4fd02
MusicBeeBass.dll                eaa52cc90d2aaaad3646bded888e96693a4ce43f
mb_Upnp2025.dll                 971729bc53ecc1b053a8af867ed582545416d18f

BoringName

  • Sr. Member
  • ****
  • Posts: 916
@BoringName,

Were you able to play gaplessly to foobar2000 and BubbleUPnP? Whilst the gap is small it's definitely there.


Foobar - Yes, it's a seamless transition between songs. But foobar is running off the same machine as Musicbee.

BubbleUPnP had a small delay but I just changed the setup and I think there might be a very tiny delay but it was around half a second previously.
I changed the useragent to "bubbleUPnP|stagefright|ffprobe" (note the pipe symbol between names) so that all the different ways it connects were using the same profile. This seemed to have improved things although it could be confirmation bias.... BubbleUPnP is running on my mobile phone which is connected to the wifi network.

For your WiiM try changing the useragent to - Linux|Lavf

I have a second machine here, I'll load up foobar on it and see how the track transitions are over the network. I think the fact it's instant on the same machine means the process is probably setup correctly, it's just network variables might cause a delay when it's not on the same machine. Also different devices may implement a different process.

I can confirm those Hashes are correct.

edit: Tested foobar over the network and it's gapless. So I think I've set it up correctly. Any delays will either be issues with the profile, device or network setup. You should also make sure your Antivirus and/or firewall programs are not interfering in any way.
Last Edit: March 01, 2025, 12:45:23 AM by BoringName

BoringName

  • Sr. Member
  • ****
  • Posts: 916
I've just noticed clicking the next track button on the player controls seems to mess things up.

With NextURI disabled - It will change to the next song but the progress bar will get jittery instead of moving smoothly. Once the next song ends it transitions to the next track and the progress bar moves normally again.
With NextURI enabled -  This does the same as above except when the next song ends it doesn't always transition to the next song, foobar does but Musicbee doesn't and starts playing the same track again from the start, the progress bar remains jittery.

I'll look into it.

jorgemg1984

  • Jr. Member
  • **
  • Posts: 31
Hi!

Sorry, I've been very busy with my Auralic test. I'll send you the log file via PM but ) could find anything there.

I also don't think the Auralic is a good test for this, it's more OpenHome based and that can be prone to erros. I can confirm with the MXN10, there's still that really small glitch between tracks.

Casual Tea

  • Jr. Member
  • **
  • Posts: 23
Upplay is a control point, I need a renderer. There is a link on their site to upmpdcli which appears to be a renderer so I'll see how that goes. its linux only.
Did you get Upmpdcli to work with your plugin?
Among my family we've got 5 raspberry pis (from 1 to 3B) with hifiberry dacs running Upmpdcli (for single target casting) + Snapcast (for synchronous multi-room casting) as headless upnp targets for Symfonium.
I wrote an ansible playbook to deploy and maintain all of these with ease if you want to check out (or recreate) my setup.

It would be neat if we could also play on all of these from MusicBee instead of Symfonium but so far I had no success with your plugin:
Code
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring>UPnPError</faultstring>
<detail>
<UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
<errorCode>501</errorCode>
<errorDescription>Action Failed</errorDescription>
</UPnPError>
</detail>
</s:Fault>
I'll gladly send you logs if that would help.

BoringName

  • Sr. Member
  • ****
  • Posts: 916
Sorry, I've been very busy with my Auralic test. I'll send you the log file via PM but ) could find anything there.

I need the plugin log file not the musicbee log file. It should be located in Musicbee\AppData\UpnpErrorLog.dat
Of if you run the installed version, something like
C:\Users\<username>\AppData\Roaming\MusicBee\UpnpErrorLog.dat

But the musicbee error log does show some problems with your install.
20/02 it was reporting no sound card detected.
27/02 shows you're trying to play files from a NAS but it errors because Interop.PortableDeviceApiLib is missing. Have you setup your NAS in musicbee as a portable device?
27/02 could not load the bass.dll because it looks like your trying to run musicbee from the unzipped patch folder?
27/02 could not load "MusicBeeIpod"

I don't know what you are doing but I don't think your issues are related to this plugin. You need to make sure you have installed Musicbee correctly.