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

BoringName

  • Sr. Member
  • ****
  • Posts: 916
Does anyone have the 1.6 file? 1.8.3 behaves erratically (repeats tracks, skips tracks, etc...), 1.6 was perfect. Thanks!

mb_Upnp2025_1.6.zip

I'll have another version out later today that should fix the 1.8.3 issues.


BoringName

  • Sr. Member
  • ****
  • Posts: 916
New version - mb_Upnp2025_1.9

Changes
- Fixed issues introduced with 1.8.3 and improved progress bar syncing further. It seems a lot better to me than previous versions.
- Progress bar will now re-sync after Seeking. Previously seeking could result in it going out of sync by half a second due to the UPnP limitation of only returning seconds for the play position.
- Radio streams will automatically switch to continuous play even if continuous play is unchecked. Unfortunately the 2 renderers I have for testing just will not play a radio stream. They drop out after a few seconds. So I can't really test it. The logic for deciding if it's a stream is if the file property kind flag's last 6 characters equal "Stream".

This version runs well for me, barring any serious problems for other users I'm going to let this version sit for a while and stop pushing out constant updates.


jean.valjean

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

version 1.9
Everything is working now.

music with “force nature stream "
Flac in 24bits, MP3
Streaming radio

many thank's

jorgemg1984

  • Jr. Member
  • **
  • Posts: 31
In my case, 1.9 is still erratic, back to 1.6 - just playing flac files to a MXN10 streamer.

BoringName

  • Sr. Member
  • ****
  • Posts: 916
In my case, 1.9 is still erratic, back to 1.6 - just playing flac files to a MXN10 streamer.

I guess it will stay that way. I left my psychic powers in my other pants.



jorgemg1984

  • Jr. Member
  • **
  • Posts: 31
In my case, 1.9 is still erratic, back to 1.6 - just playing flac files to a MXN10 streamer.

I guess it will stay that way. I left my psychic powers in my other pants.



It's great as it is :)

BoringName

  • Sr. Member
  • ****
  • Posts: 916
It's great as it is :)

Fair call. I've certainly broken my fair share of things by installing an update even though it was already working fine.

I'm looking at you Emby!

jorgemg1984

  • Jr. Member
  • **
  • Posts: 31
It's great as it is :)

Fair call. I've certainly broken my fair share of things by installing an update even though it was already working fine.

I'm looking at you Emby!

Great!

simbun

  • Jr. Member
  • **
  • Posts: 39
New version - mb_Upnp2025_1.9

With 1.9 Sonos and WiiM (I haven't tried Volumio) stop after track 2. I've only tested with 'force native stream' as I'm a bit tight on time and both were working with 1.8.1.

WiiM log
Code
0; 1 Initialise - 17/03/2025 13:56:47
101; 7 ProcessMessage 192.168.1.137 - device 'uuid:FF98F09C-E144-D1DA-CB98-6867FF98F09C:WiiM Pro-60F6',valid=True
105; 8 Profile - WiiM Home App, useragent=|Linux/4.9.113
105; 9 Profile - WiiM Home App, useragent=|Linux/4.9.113
128; 10 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:*
5797; 11 Play - Input - D:\MUSIC_EXAMPLE\MusicBee Test\music\LatestTest\LONG_TONE#01.flac Output - (http://192.168.1.12:49382/files/FBB0A689829191C4p.flac)
6066; 12 Profile - WiiM Pro, useragent=Lavf/58.45.100
6076; 13 GetFile[1] 192.168.1.12 - GET D:\MUSIC_EXAMPLE\MusicBee Test\music\LatestTest\LONG_TONE#01.flac to 192.168.1.137
6077; 14 Profile - WiiM Pro, useragent=Lavf/58.45.100
6094; 15 GetFile[1] - exit=0, playtime=15
6167; 16 StateTimer - Loading,old=Stopped
6390; 17 StateTimer - Playing,old=Loading
8773; 18 SetNextAVTransportURI - Success - http://192.168.1.12:49382/files/F06F2D2A7BFC8927p.flac:D:\MUSIC_EXAMPLE\MusicBee Test\music\LatestTest\LONG_TONE#02.flac
8884; 19 Profile - WiiM Pro, useragent=Lavf/58.45.100
8886; 20 GetFile[2] 192.168.1.12 - GET D:\MUSIC_EXAMPLE\MusicBee Test\music\LatestTest\LONG_TONE#02.flac to 192.168.1.137
8889; 21 Profile - WiiM Pro, useragent=Lavf/58.45.100
8902; 22 GetFile[2] - exit=0, playtime=11
40887; 23 StateTimer - Stopped,old=Playing
40888; 24 SyncNewPlayState - Stopped,mb=Playing

Casual Tea

  • Jr. Member
  • **
  • Posts: 23
New version - mb_Upnp2025_1.9

Changes
- Fixed issues introduced with 1.8.3 and improved progress bar syncing further. It seems a lot better to me than previous versions.
- Progress bar will now re-sync after Seeking. Previously seeking could result in it going out of sync by half a second due to the UPnP limitation of only returning seconds for the play position.
- Radio streams will automatically switch to continuous play even if continuous play is unchecked. Unfortunately the 2 renderers I have for testing just will not play a radio stream. They drop out after a few seconds. So I can't really test it. The logic for deciding if it's a stream is if the file property kind flag's last 6 characters equal "Stream".

This version runs well for me, barring any serious problems for other users I'm going to let this version sit for a while and stop pushing out constant updates.
Is the syncing supposed to happen nonstop?
The sync doesn't drift but with synced lyrics it's a bit of a wild ride to read along haha.


The playback itself works flawlessly for me (with force original quality). Listened to 3 albums in a row like that today.

Might be related to the fact that it's still spamming the log with tens of thousands of errors.

To be exact, the error spamming only occurs when the last track in Upcoming Tracks is playing. I think it infinitely tries and fails to set an empty SetNextAVTransportURI.

Here's me playing 2 songs and as soon as the 2nd starts playing, the spam commences.
Code
25739142; 1142 Play - Input - Z:\M3\Debney, John\The Halloween Tree (Original Motion Picture Score)\01 Main Title  Introduction.flac Output - (http://192.168.1.5:49382/files/0706C28B2CCB0D09p.flac)
25739163; 1143 Profile - Generic Device, useragent=Music Player Daemon 0.23.12
25739171; 1144 GetFile[38] 192.168.1.5 - GET Z:\M3\Debney, John\The Halloween Tree (Original Motion Picture Score)\01 Main Title  Introduction.flac to 192.168.1.13
25739184; 1145 Profile - Generic Device, useragent=Music Player Daemon 0.23.12
25739390; 1146 StateTimer - Playing,old=Paused
25740099; 1147 GetFile[38] - exit=0, playtime=896
25740255; 1148 SetNextAVTransportURI - Success - http://192.168.1.5:49382/files/7CA19E0E9577FDCCp.flac:Z:\M3\Debney, John\The Halloween Tree (Original Motion Picture Score)\02 Getting Ready For Halloween.flac
25824977; 1149 Profile - Generic Device, useragent=Music Player Daemon 0.23.12
25824983; 1150 GetFile[39] 192.168.1.5 - GET Z:\M3\Debney, John\The Halloween Tree (Original Motion Picture Score)\02 Getting Ready For Halloween.flac to 192.168.1.13
25825079; 1151 Profile - Generic Device, useragent=Music Player Daemon 0.23.12
25826059; 1152 GetFile[39] - exit=0, playtime=976
25846620; 1153 PostSoapRequest - 500,send=POST /uuid-677a63db-6686-01d7-34a0-b827eb0b7fae/ctl-urn-schemas-upnp-org-service-AVTransport-1 HTTP/1.1
Host: 192.168.1.13:49152
User-Agent: MusicBee UPnP Plugin
Content-Type: text/xml; charset="utf-8"
SOAPAction: "urn:schemas-upnp-org:service:AVTransport:1#SetNextAVTransportURI"
Content-Length: 352

<?xml version="1.0" encoding="UTF-8"?><s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><u:SetNextAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><NextURI /><NextURIMetaData /></u:SetNextAVTransportURI></s:Body></s:Envelope>
25846626; 1154 SoapRequest:SetNextAVTransportURI:urn:schemas-upnp-org:service:AVTransport:1:InstanceID=0,NextURI=,NextURIMetaData= - <?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<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>
</s:Body>
</s:Envelope>

25846631; 1155 SetNextAVTransportURI - Failed -

When there is at least 1 more track in the Upcoming Tracks, the sync works as intended and doesn't go back and forth. So I think the syncing part should be fine. The error spam also starts when I remove all but the playing track from Upcoming Tracks.
Last Edit: March 17, 2025, 10:28:20 PM by Casual Tea

BoringName

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

Changes
- Some small changes to hopefully fix simbun's issues.

Here is mb_Upnp2025_1.8.1.zip if you need to roll back to that version.

1.9.1 will not fix Casual Tea's problem.

I suspect the issue there is your device doesn't accept receiving a blank NextURI which is what the plugin sends when there is no next track to play. Once the device errors it's not responding correctly for the sync information. Actually it looks like the NextURIMetadata field is being set as a dash when the NextURI is blank. That could be the problem.

edit: Actually the dash is only added when it's logging the error, NextURIMetadata is sent through as an empty string. I still think attempting to set a blank NextURI is the issue for you though. I'll see what I can do there.
Last Edit: March 17, 2025, 11:15:02 PM by BoringName

BoringName

  • Sr. Member
  • ****
  • Posts: 916
I went through the source code of upmpdcli. I hate trying to navigate C++ code.... Looks like this is the problem in upmpd.cxx starting at line 621

Code
it = setnext? sc.args.find("NextURI") : sc.args.find("CurrentURI");
if (it == sc.args.end() || it->second.empty()) {
return UPNP_E_INVALID_PARAM;
}

It's returning "UPNP_E_INVALID_PARAM if the NextURI string is empty.

The problem is "UPNP_E_INVALID_PARAM" is never declared anywhere else in the code, it doesn't have a value linked to it anywhere and I can't see any handling of a call and what it does when that value is returned. As upmpdcli is a front end for Music Player Deamon, I figured it must be something MPD uses. I went through the MPD source code and there is no reference to that response at all. I guess it's some fixed value in Linux?

None of that answers why the plugin creates thousands of log entries. It's configured so if the response to the SetNextAVTransportURI is not 200, it will only try 3 times before it stops trying completely. And even if that failsafe didn't kick in, it's set to run on a fixed System Timer so the absolute most it should be logging is 10x per second. I just can't see any way for the SetNext code to be executed thousands of times. It's bizarre.

All I can do is ad an option so the plugin doesn't send a blank NextURI but that might cause the player to just repeat the last song over and over again. Musicbee is supposed to stop if I call NextTrackPlayStarted and there is no next track in the now playing list so that might make everything work ok for you.

edit: looks like that response code is part of libupnp, it's a neverending rabbit hole....
Last Edit: March 18, 2025, 01:31:18 AM by BoringName