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

BoringName

  • Sr. Member
  • ****
  • Posts: 916
This is what you have explained on your "edit" above.

What you just described is exactly what I expected.

I think I have BubbleUPnP sorted out for NextURI so I should be able to use that for testing and get this nonsense working.

jorgemg1984

  • Jr. Member
  • **
  • Posts: 31

simbun

  • Jr. Member
  • **
  • Posts: 39
I think I have BubbleUPnP sorted out for NextURI so I should be able to use that for testing and get this nonsense working.
How did you achieve that? I tested it after seeing your comment this morning and I'm seeing the same behaviour.

Have you looked at Upplay? It's open source, robust and provides a lot of logging which may assist you with your development. The Windows version does require a donation but it's worth it.

jean.valjean

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

Quote
 Have you set up the AvegaMediaServer profile correctly? I'd be interested to know if you can play a flac file natively and if it produces the same noise  

I've put the same data on the Marantz profile as on the AvegaMediaServer profile, so I don't know what more I can do.

The plug'in is recognized by the device with its remote control and when using the HEOS application with the right information (format and encoding). The server function works.

With MusicBee, streaming only in PCM and not at all without (only noise).

I'll try it with a USB cord to see if it works.

same with version 1.4.1

Translated with DeepL.com (free version)

BoringName

  • Sr. Member
  • ****
  • Posts: 916
I've put the same data on the Marantz profile as on the AvegaMediaServer profile, so I don't know what more I can do.
Can you link the log here so I can confirm it's matching the profile correctly. If you're getting white noise I'm almost certain it's not.

same with version 1.4.1
So just to confirm, continuous streaming still works with 1.4.1?

How did you achieve that? I tested it after seeing your comment this morning and I'm seeing the same behaviour.

You need to go into the renderer settings in BubbleUPnP and enable gapless playback. But if you run a GetMediaInfo command it will return "NOT_IMPLEMENTED" for NextURI if you haven't set a NextURI yet. That's why I initially thought BubbleUPnP didn't support NextURI. But if you query the device XML it does list SetNextAVTransport as a supported command and GetMediaInfo will report the correct NextURI value once it's been set.

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.

So I can see why Steven gave up on this thing. So bloody frustrating.

I've got NextURI working with bubbleUPnP. Well kind of. Here is what happens.
SetAVTransportURI and tell it to play.
BubbleUPnP does two GET commands with ffprobe and then a third GET command with stagefright (bubbleUPnP useragent for actually playing a stream) and starts playing.
SetNextAVTransportURI
BubbleUPnP does two GET commands with ffprobe and then a third GET command with stagefright then closes the stream after less than 100 milliseconds. This all occurs while the first song is playing. So it appears to be caching in the background like it should, except for closing the stream.....

When the first song ends, it needs to GET the stream again for the NextURI because it closed it so the delay is still there /grr edit: I've just noticed it doesn't do the 2 x ffprobe when transitioning and getting the stream again so there is a small time saving there for what it's worth.

So it all seems to be working as intended except for the early stream closure and I don't know if this is some stupid quirk of BubbleUPnP or something I've done wrong.

edit: Foobar also accepts NextURI but doesn't transition to it when the song ends....and doesn't appear to attempt any caching so that makes it bloody pointless.. Actually it does seem to work as long as the stream isn't PCM. It caches the nexturl a second or two before the first song ends and transitions cleanly and quickly. PCM seems to be the root cause of a lot of issues while testing all this out.

I need to clean up some code, I had to do a lot of stupid crap to get this working and then I'll chuck out a new version so someone can test it on a WiiM and see if gapless works.
Last Edit: February 22, 2025, 06:20:45 AM by BoringName

jorgemg1984

  • Jr. Member
  • **
  • Posts: 31
I'm going to have my Cambridge Audio back today, I'll do all the testing you need.

simbun

  • Jr. Member
  • **
  • Posts: 39
How did you achieve that? I tested it after seeing your comment this morning and I'm seeing the same behaviour.

You need to go into the renderer settings in BubbleUPnP and enable gapless playback. But if you run a GetMediaInfo command it will return "NOT_IMPLEMENTED" for NextURI if you haven't set a NextURI yet. That's why I initially thought BubbleUPnP didn't support NextURI. But if you query the device XML it does list SetNextAVTransport as a supported command and GetMediaInfo will report the correct NextURI value once it's been set.
I installed BubbleUPnP on a tablet this morning - thinking that it may have been a BubbleUPnP setting I had on my phone that was causing the problem - and everything worked with Upplay and Hi-Fi Cast, so I tried Upplay to my phone and it worked, and finally - replicating my setup from yesterday - Hi-Fi Cast to BubbleUPnP which also worked! No idea what happended yesterday but playback wasn't even gapless, and I'd restarted the apps and put them both into gapless mode. I suppose I should have tried, turning it off and on again!


I've got NextURI working with bubbleUPnP. Well kind of. Here is what happens.
SetAVTransportURI and tell it to play.
BubbleUPnP does two GET commands with ffprobe and then a third GET command with stagefright (bubbleUPnP useragent for actually playing a stream) and starts playing.
I assume that's BubbleUPnP probing to see if it needs to transcode the stream, that or retrieve tags, and it doesn't look like there's a way to disable that.


I need to clean up some code, I had to do a lot of stupid crap to get this working and then I'll chuck out a new version so someone can test it on a WiiM and see if gapless works.
I've got Sonos and WiiM renderers, both of which appear to have very good UPnP implementations so happy to test with those.

BoringName

  • Sr. Member
  • ****
  • Posts: 916
I assume that's BubbleUPnP probing to see if it needs to transcode the stream, that or retrieve tags, and it doesn't look like there's a way to disable that.

I believe so. The main frustrating thing is you can't set it to never encode. I can't really test PCM streams because it always wants to encode on my mobile for some reason. The one good thing about BubbleUPnP is I can enable a log which helps troubleshoot problems but it's not always clear what it's doing. I may have been wrong about the delay still being there for gapless playback as I was using a workaround to get the next track to play and I think that was screwing things up. But for now I'm going avoid testing on BubbleUPnP until I have it working with Foobar as that seems to do less silly stuff, at least when streaming natively. Encoded stream of any format seem to give it grief, not sure if that's a foobar issue or maybe the way Bass encodes the streams.

I've got Sonos and WiiM renderers, both of which appear to have very good UPnP implementations so happy to test with those.

All good, it might be a week or two before I get all this sorted out, just got some surprise guests for a few days so I'm not sure how much time I will have.

I have read there is an issue with how Sonos implements Seek commands. From what I've read I probably won't fix that. I don't think seek functionality is a high priority, I doubt many users streaming to another device are going to be using seek that often. But it is helpful for testing as I can seek to the end of a track to test out track transitions instead of waiting for it to play all the way through.




hiccup

  • Hero Member
  • *****
  • Posts: 9107
But it is helpful for testing as I can seek to the end of a track to test out track transitions instead of waiting for it to play all the way through.
You could create a test track by cutting up a song in several pieces of e.g. 5 seconds.
(using something like Audacity)

simbun

  • Jr. Member
  • **
  • Posts: 39
But for now I'm going avoid testing on BubbleUPnP until I have it working with Foobar as that seems to do less silly stuff, at least when streaming natively. Encoded stream of any format seem to give it grief, not sure if that's a foobar issue or maybe the way Bass encodes the streams.
You could try Audiophile UPnP Renderer. The only caveat is that it doesn't work with Hi-Fi Cast in gapless mode, but does with BubbleUPnP and interestingly mconnect. It also doesn't accept mono tracks.

I have read there is an issue with how Sonos implements Seek commands. From what I've read I probably won't fix that. I don't think seek functionality is a high priority, I doubt many users streaming to another device are going to be using seek that often. But it is helpful for testing as I can seek to the end of a track to test out track transitions instead of waiting for it to play all the way through.
I haven't tried seeking, so I'll agree completely on that front :)

I use sox to create short tracks for testing transitions:
Code
sox "input.flac" "01.%2n.flac" trim 0 10 : newfile : restart
It's part of a bigger script that tags the files too, but it's written in bash so unless you have WSL installed it probably won't be of any use.
Last Edit: February 23, 2025, 12:46:22 PM by simbun

BoringName

  • Sr. Member
  • ****
  • Posts: 916
You could try Audiophile UPnP Renderer.

I was using that for testing but it would open a bunch of streams and not close them causing the plugin to crash. I initially thought it was an audiophile issue but after more testing today with multiple renderers, it has to be a problem with the plugin or the BASS library (the bass library is what creates the streams). So far foobar, audiophile and bubbleUPnP all behave the same way when I send an encoded PCM stream. They open a bunch of streams that never get closed.

I haven't tested audiophile for this yet but foobar and bubbleUPnP also display the same behaviour with MP3 encoded streams. They just open less streams so it takes a bit longer to crash.

If I configure the plugin to send a native MP3 stream (not encoded) they all work as they should.

Going through the setup in the plugin, nothing is really standing out between the HTTP headers set for a native vs encoded stream. I'm having a hard time believing it's a BASS issue as you would think others would have reported a problem, especially when it seems so prevalent. I need to look into it more,  I'm probably just missing something....

Gapless playback using NextURI for bubbleUPnP does work correctly (with native MP3 streams).

So the main takeaway here is, make sure to setup your profiles correctly so the plugin doesn't encode the tracks. Unfortunately if you are using replaygain or dsp plugins that forces an encode...

I use sox to create short tracks for testing transitions:

I'm fairly well versed with ffmpeg. I should just create a suite of test files in multiple formats. For whatever reason it hadn't really occurred to me to do that until now...


simbun

  • Jr. Member
  • **
  • Posts: 39
If I configure the plugin to send a native MP3 stream (not encoded) they all work as they should.
If you're saying that you have gapless playback (NextURI) of native files working, I think that's a massive step forward.

I was using that for testing but it would open a bunch of streams and not close them causing the plugin to crash. I initially thought it was an audiophile issue but after more testing today with multiple renderers, it has to be a problem with the plugin or the BASS library (the bass library is what creates the streams). So far foobar, audiophile and bubbleUPnP all behave the same way when I send an encoded PCM stream. They open a bunch of streams that never get closed.
I'm well out of my depth here, but using my other server for its logging capabilities I saw AUR connect only twice to the server, once for the album artwork and once for the encoded stream.
Do you send Content-Length with the encoded stream? I've heard that can cause issues, but that's typically when sending a continuous stream.

I use sox to create short tracks for testing transitions:

I'm fairly well versed with ffmpeg. I should just create a suite of test files in multiple formats. For whatever reason it hadn't really occurred to me to do that until now...
I tried to use ffmpeg initially but I couldn't get it working; the resulting files seemed to be missing technical details (including length) so playback was inconsistent.
Code
ffmpeg -i 01.01.flac -f segment -segment_time 10 -reset_timestamps 1 output_%02d.flac
If you know the ffmpeg incantation to produce valid tracks please do let me know.

BoringName

  • Sr. Member
  • ****
  • Posts: 916
If you're saying that you have gapless playback (NextURI) of native files working, I think that's a massive step forward.

It seems to be working in bubbleUPnP and Foobar. I still have to sort out a few things but the core functionality is working.
I'm well out of my depth here, but using my other server for its logging capabilities I saw AUR connect only twice to the server, once for the album artwork and once for the encoded stream.
Do you send Content-Length with the encoded stream? I've heard that can cause issues, but that's typically when sending a continuous stream.
We're both swimming in the deep end.... Different renderers do different things. Foobar opens 5 or 6 streams before beginning playback. No idea why. With bubbleUPnP you can see it's using ffprobe which would just be checking the details of the stream. Currently the content-length isn't always set, it depends on the file format. I've fixed some of those up and added a config setting to force it to different values. I have noticed foobar opens less streams if I set it to a fixed value for PCM streams but that's the only difference I've noticed. There is also some other metadata that isn't always set for encoded streams which I'm currently fixing up. I've noticed that's improving what BubbleUPnP displays for encoded streams, eg) the correct duration for mp3 streams but it's not doing much for foobar.

I tried to use ffmpeg initially but I couldn't get it working; the resulting files seemed to be missing technical details (including length) so playback was inconsistent.
Code
ffmpeg -i 01.01.flac -f segment -segment_time 10 -reset_timestamps 1 output_%02d.flac
If you know the ffmpeg incantation to produce valid tracks please do let me know.
From what I've read there is a problem with flac files using the -segment flag. Give this a shot
Code
ffmpeg -ss 0 -t 10 -i 01.01.flac output_.flac

This will create 1 output file that's the first 10 seconds of the source file. If you want to get the 10 second snippet from a different part of the source file, set a start time eg) to get 10 sec at the 1 minute mark, use this
Code
ffmpeg -ss 00:01:00 -t 10 -i 01.01.flac output_.flac

simbun

  • Jr. Member
  • **
  • Posts: 39
We're both swimming in the deep end.... Different renderers do different things. Foobar opens 5 or 6 streams before beginning playback. No idea why.
I see the same behaviour. When a file is being served only the one connection is made, but with an encoded stream I see 4. Bizarre indeed!

From what I've read there is a problem with flac files using the -segment flag. Give this a shot
Code
ffmpeg -ss 0 -t 10 -i 01.01.flac output_.flac
I hadn't even considered it could be flac related. Thanks