Author Topic: UPnP/ DLNA device support  (Read 302109 times)

zigzag10

  • Jr. Member
  • **
  • Posts: 60
Yup, the likes of SWYH could be used, but that’s going to be limited to PCM L16 and I doubt you’ll have ‘gapless playback’.  Though a good quality third-party UPnP audio server can overcome these limitations, so how about setting one up, that sits alongside MB, instead?  In this case MB remains to mange your collection and is used for local playback et al, while a UPnP audio server (together with a control point) take care of streaming to the DLNA\UPnP device.

IMHO both Asset UPnP and Minimserver are excellent in this regard, as is Linn’s Kazoo Server, which incidentally can easily replicate the contents of MB, including playlists, as it supports the XML library file.  (To enable this, you will need to link Kazoo Server to the XML file MB generates if the ‘export the library as an iTunes formatted XML file’ is selected, but this is a straightforward process).  From what I recall Universal Media Server features this capability as well and its open source...
Last Edit: October 12, 2020, 11:05:00 PM by zigzag10

Dofin

  • Newbie
  • *
  • Posts: 5
Hi,
I've been using musicbee for a year aprox. I started by using it as a player, quickly moved on to have it manage the whole library of some  20k songs, then i moved on to rip again my cd collection, this time in flac instead of mp3, and lately I've generated the usb sticks containing music that i plug in the car.
Moving on, I've recently purchaded a pair of speakers with integrated amps. They are the Kef LS50w II.
Apart from diverse cable connections (hdmi, optical, coax) they are network enabled and support multiple streaming solutons, amazon music, spotify, tidal, chromecast, roon, and, going to the point...upnp/dlna.
I expected to manage them from musicbee using DLNA...but unfortunately they aren't recognised.
I've gone through the process of verifying that everything is properly setup.
First of all, I connected them to the network by wire in order to avoid any hassle with wifi (they do work over wifi, but since I had the nework connection nearby i prefered to stay on the safe side).
I went on to try diverse network streaming solutions. I easily succeeded with amazon music, spotify, and chromecast.
I tried upnp with musicbee...and they were not recognized.
Following other posts in this forum i checked that actually upnp works using other solutions. I suceedent playing from vlc using the speakers as renderers and also using BlubbleUPnP as upnp controller and streaming to the speakers (upnp render) from either Universal Media Server or even from musicbee (as upnp media server).
Nevertheless I'm unable to stream directly from Musicbee to the speakers, which is really a pity, since playing from musicbee allows much easier access to playlists or to actions like rating the song beign played.
I've tried to narrow down the issue:
Options in the plugin configurations:
- enable musicbee to play to a upnp device: checked
- output as a continuous stream: unchecked
- enable upnp devices to browse and play from the musicbee library: Checked (also checked bucket tree nodes...and update play statistics. Rest of the section unchecked
- Server settings
   Server Name: Musicbee Medid Library
   ip address: automàtic port: 49382
   DLNA device profiles: Generic with settings updated as follows (to mach the speakers capabilities)
      max picture size: 160 px (actually they cannot show anything)
      output sample rate 44100 to 192000 (actually for network files they can go up to 384k)
      channels stereo only: checked
       maximum bit depth: 24
       when transcoding output format: PCM 24 (note, transcoding should be a very rare case since they understant almost any format
                                                               MP3, M4A, AAC, FLAC, WAV, AIFF, ALAC, WMA, LPCM and Ogg Vorbis
                                                               as well as MQA DSF: DSD64, DSD128, DSD256 DFF: DSD64
                                  output sample rate: same as source
Going to the more interesting part...i checked the log debug information and this is what it shows

7; 1 Initialise - 17/10/2020 22:34:39
99; 2 GetNetworkAddresses - 192.168.10.232,dns=True,name=Ethernet,speed=1000000000
100; 3 GetNetworkAddresses - 192.168.182.1,dns=True,name=VMware Network Adapter VMnet1,speed=100000000
100; 4 GetNetworkAddresses - 192.168.8.1,dns=True,name=VMware Network Adapter VMnet8,speed=100000000
101; 5 GetNetworkAddresses - 127.0.0.1,dns=False,name=Loopback Pseudo-Interface 1,speed=1073741824
103; 6 GetNetworkAddresses - http://192.168.10.232:49382
208; 7 ProcessMessage 192.168.10.137 - device 'uuid:55186c28-4c2d-4c37-b460-207fd8ecc91c:Estudi',valid=False

As far as I understand the plugin reviews my machine network setup, concludes that the newtok address where the upnp should be hooked is 192.168.10.137 which is correct ans starts it in port 192.168.10.232

Then the problem arises in the last line. Musicbee properly identifies a upnp devide at 192.168.10.137 that's the speaker. The text Estudi is the "human" name I gave to the speakers...but shomehow considers this is not a valid device.
Well this is as far as I can go. I understand that something needs to be defined or declared in either the code or a config file in order to properly recognize the device.
To add som context, the veresion I of these speakers was really popular and well considered in the audiophile world. Version two enhaces the network capabilities and has already earnet the Product of the Year award from WhatHiFi so its possible that solving this can help not just me but also other musibee users.

Can someone help with this issue?
I've had a first look at the plugin code. While i can manage with .net development in either visual basic or c# my experience is more related to "conventional" user applications updating databases. I know nothing in the upnp arena. Neither in the audio programming.
Of course I can run debugging code and collect results.

I've seen in the forum that thera are versions of the plugin with debugging code and suposely fixing some of the issues in cpu usage but so far I've stayed with the "official" version from the plugins download page.

Well, any help will be greatly appreciate.
Thants a lot in advance.





phred

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 9304
While it's possible someone may come along and offer some suggestions, it's also possible you didn't notice that this plugin is no longer supported. It has worked for some folks, but not for everyone. In addition it can become a memory hog. To the point of freezing or blue-screening your PC. Even if it is not being used. Simply having the .dll on your PC. But again, some folks haven't experienced that.

I can't offer you any suggestions, but wanted you to be aware of those things in case a) your PC freezes or other wise becomes unresponsive, and b) no one is able to help you.
Download the latest MusicBee v3.5 or 3.6 patch from here.
Unzip into your MusicBee directory and overwrite existing files.

----------
The FAQ
The Wiki
Posting screenshots is here
Searching the forum with Google is  here

Dofin

  • Newbie
  • *
  • Posts: 5
I realized it's not supported later on....but have managed to have it running almost everytime.
Fot the benefit of anyone running into similar issues....I explain what I did

Downloaded the source code from the links in the forum....compiled it and got to the same point.
Then uncommented some debug instructions amb realized that the xml looks as follows

<root xmlns="urn:schemas-upnp-org:device-1-0" xmlns:dlna="urn:schemas-dlna-org:device-1-0" xmlns:qq="http://www.tencent.com">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<qq:X_QPlay_SoftwareCapability>QPlay:2.1</qq:X_QPlay_SoftwareCapability>
<deviceType>urn:schemas-upnp-org:device:MediaRenderer:2</deviceType>
<friendlyName>Estudi</friendlyName>
<manufacturer>KEF</manufacturer>
<manufacturerURL>http://www.kef.com/</manufacturerURL>
<modelDescription>LS50 Wireless II</modelDescription>
<modelName>LS50 Wireless II</modelName>
<modelNumber>SP4025</modelNumber>
<modelURL>http://www.kef.com/</modelURL>
<serialNumber>149df9b3-c5fc-44fe-8908-39939da6c870</serialNumber>
<UDN>uuid:55186c28-4c2d-4c37-b460-207fd8ecc91c</UDN>
<iconList>
<icon>
<mimetype>image/png</mimetype>
<width>120</width>
<height>120</height>
<depth>24</depth>
<url>/LibRygelRenderer-120x120x24.png</url>
</icon>
<icon>
<mimetype>image/png</mimetype>
<width>48</width>
<height>48</height>
<depth>24</depth>
<url>/LibRygelRenderer-48x48x24.png</url>
</icon>
<icon>
<mimetype>image/jpeg</mimetype>
<width>120</width>
<height>120</height>
<depth>24</depth>
<url>/LibRygelRenderer-120x120x24.jpg</url>
</icon>
<icon>
<mimetype>image/jpeg</mimetype>
<width>48</width>
<height>48</height>
<depth>24</depth>
<url>/LibRygelRenderer-48x48x24.jpg</url>
</icon>
</iconList>
<serviceList>
<service>
<serviceType>urn:schemas-upnp-org:service:ConnectionManager:2</serviceType>
<serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
<SCPDURL>/xml/ConnectionManager.xml</SCPDURL>
<controlURL>/Control/LibRygelRenderer/RygelSinkConnectionManager</controlURL>
<eventSubURL>/Event/LibRygelRenderer/RygelSinkConnectionManager</eventSubURL>
</service>
<service>
<serviceType>urn:schemas-upnp-org:service:AVTransport:2</serviceType>
<serviceId>urn:upnp-org:serviceId:AVTransport</serviceId>
<SCPDURL>/xml/AVTransport2.xml</SCPDURL>
<controlURL>/Control/LibRygelRenderer/RygelAVTransport</controlURL>
<eventSubURL>/Event/LibRygelRenderer/RygelAVTransport</eventSubURL>
</service>
<service>
<serviceType>urn:schemas-upnp-org:service:RenderingControl:2</serviceType>
<serviceId>urn:upnp-org:serviceId:RenderingControl</serviceId>
<SCPDURL>/xml/RenderingControl2.xml</SCPDURL>
<controlURL>/Control/LibRygelRenderer/RygelRenderingControl</controlURL>
<eventSubURL>/Event/LibRygelRenderer/RygelRenderingControl</eventSubURL>
</service>
<service>
<serviceType>urn:schemas-tencent-com:service:QPlay:1</serviceType>
<serviceId>urn:tencent-com:serviceId:QPlay</serviceId>
<SCPDURL>/xml/QPlayDescription.xml</SCPDURL>
<controlURL>/Control/LibRygelRenderer/QPlay</controlURL>
<eventSubURL>/Event/LibRygelRenderer/QPlay</eventSubURL>
</service>
</serviceList>
<presentationURL>http://192.168.10.14:80/</presentationURL>
<dlna:X_DLNADOC>DMR-1.51</dlna:X_DLNADOC>
</device>
</root>

Looking at the code I realized that it's looking in the XML for the version 1 of the protocols
For example the plugin looks for urn:schemas-upnp-org:service:ConnectionManager:1 but the xml actually reports urn:schemas-upnp-org:service:ConnectionManager:2 therefore it never loads the variables with the needed managing urls and considers the device invalid.

So I went ahead and modified the code to accept both versions hoping that the actual urls would be compatible enough....and they did.
The plugin works...mostly.
- It recognizes the speakers on startup
- It plays anyting i thow at it...which is to say that it sends the file to the speakers. Since they understant pretty much any format no transcoding is needed, which likely prevents a lot of issues
- If I select the speakers as output device the selection is remembered next time I start musicbee.
- Have no issues with playlist, etc. Work as expected.
- on a laptop with i7 having 2 cores and HT enabled musicbee CPU stays at 2% and memory at around 90 to 950M. I see small spkies when changing from one song to the next, like goung up at cpu like 4% amb memory to 110M. Once playback begins it goes back no lower levels.

Now for the glitches (unfortunately there are some).
- No way of doing fastforward or backward clicking the progress line. It just restarts the song (and then finishes before time). Thats neglecteble as far as I'm concernet.
- Now and then a song is not played. Like one in 20 or so. Have'nt fond a pattern for that. But it's related to the actual song. A song that fails will fail always even if I play otjhers nomally ang get back to that one.

So how we wrap up
- I'm not sure if i've used the latest versions of the source since I've seen several unofficial ones in the forum. If you post one such version i can replicate the changes I did there for the benefit of anyone runnin into similar troubles.

Moving on...I don't know if there are any plans for musicbee concerting network speakers. They seem to be all the rage...and I rather expect a growing demand for such suport. Of course the landscape is a complete mess. Not only we have newer specifications for upnp but also have airplay, chromecast, spotify connect, roon....you name it. Any plans for musicbee on this arena?

Whatever the case...thanks a lot for such a great product.




Dofin

  • Newbie
  • *
  • Posts: 5
Sorry, I have to made a small correction but actually a good one.
It seems I messed to much changing options with the plugin.
I did a cleanup, deleted and reinstall the version I compiled and so far it never fails. Neither with the songs previously failing nor with a buch I threw at it. Including DSF files by the way.
Not only this... I can also click on the progress var an it actually jumps to the righ point (it goes there but the progress bar is not updated)
I'll be using it for some days and see what happens.

hiccup

  • Sr. Member
  • ****
  • Posts: 7790
I'll be using it for some days and see what happens.

Thank you for diving into this and reporting about it!
I am sure many users will be interested if you are able to make some improvents on the workings of the plugin.

Dofin

  • Newbie
  • *
  • Posts: 5
just found out the small piece that was messing the initial tests.
I was running musicbee on a laptop connected by wifi. The actual music files are on a server wired to the network. Just by configuring Musicbee to load the complete files before starting the playback was the thing that took care of the ocassional problems.
For the rest....so far so good.
I'll be running it during the week and see if anything else arises.
On the other side I'll be glad to contribute the code changes, just don't know how to.
If someone publishes the latest version of the source I'll apply the changes and post them wherever appropiate both in source and as executable.
Would prefer not to create as a new plugin since that would bring confussion and also the vast majority of the code is not mine, just made a very minor change.

hiccup

  • Sr. Member
  • ****
  • Posts: 7790
Would prefer not to create as a new plugin since that would bring confussion and also the vast majority of the code is not mine, just made a very minor change.

This is me talking about stuff I have no real understanding of:

Would it be an idea to publish the plugin on github?
While this (MusicBee) forum is mainly frequented by end-users, github is the place-to-be universe for coders.
Perhaps it is visible there, some talented coders will pick up the challenge and contribute to it?

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34313
When you are happy with the code, if you send it to me then i will update the compiled version on the plugins page.
@hiccup, Good idea
Last Edit: October 19, 2020, 08:34:29 AM by Steven

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34313
I have updated the plugin code and .dll file based on what I understand Dofin did.
Download links available in the first post

Dofin

  • Newbie
  • *
  • Posts: 5
Hi,
Sorry it took me a while to get back. Really busy week.
Anyway, here's some info:
I've been runing the version of the pluging I modified during the week with only the following issues:
- When clicking on the player progress bar to advance playback it does jump to the selected point but the progress bar is not updated accordingly.
- When assigning a rate to the song being played sometimes a message pops up stating that the file cannont be updated because it's locked by another process.

Actually I don't think any of these are related to the changes I made and are rather related to the overall behavior of the plugin.
Out of this playback is smooth and doesn't eats up resources.
I guess I'm not experiencing the problems other people had because
- I have set in the player the option of fully loading the file before starting playback
- I don't think that playback needs to do any transcoding since the speakers understant all formats I thow at them. For referènce I've tried through the plugin the following formats: AAC, ALAC, DSF, FLAC and MP3.

Concerning the changes I made, I just modified the ControPointManager.vb and within it the MediaRendererDevice class, more specifically the new method as follows (you can find my changes searching for the *** string)


        Public Sub New(deviceLocationUrl As Uri)
            'Me.deviceLocationUrl = deviceLocationUrl
            Dim xml As String = GetXmlDocument(deviceLocationUrl)
            For retry As Integer = 1 To 2
                Try
                    If retry = 2 Then
                        xml = GetCleanedXml(xml)
                    End If
                    ' LogInformation("NewMediaRendererDevice:" & deviceLocationUrl.ToString(), xml) '***
                    Using reader As New XmlTextReader(xml, XmlNodeType.Document, Nothing)
                        Do While reader.Read()
                            If reader.NodeType = XmlNodeType.Element Then
                                Dim name As String = reader.Name
                                If String.Compare(name, "friendlyName", StringComparison.OrdinalIgnoreCase) = 0 Then
                                    If FriendlyName IsNot Nothing Then
                                        reader.ReadString()
                                    Else
                                        FriendlyName = reader.ReadString()
                                    End If
                                ElseIf String.Compare(name, "modelDescription", StringComparison.OrdinalIgnoreCase) = 0 Then
                                    If modelDescription IsNot Nothing Then
                                        reader.ReadString()
                                    Else
                                        modelDescription = reader.ReadString()
                                    End If
                                ElseIf String.Compare(name, "UDN", StringComparison.OrdinalIgnoreCase) = 0 Then
                                    Udn.Add(reader.ReadString())
                                ElseIf String.Compare(name, "service", StringComparison.OrdinalIgnoreCase) = 0 Then
                                    Using serviceReader As XmlReader = reader.ReadSubtree()
                                        Dim serviceType As String
                                        Do While serviceReader.Read()
                                            If serviceReader.NodeType = XmlNodeType.Element Then
                                                name = serviceReader.Name
                                                If String.Compare(name, "serviceType", StringComparison.OrdinalIgnoreCase) = 0 Then
                                                    serviceType = serviceReader.ReadString()
                                                    ' LogInformation("NewMediaRendererDevice:" & deviceLocationUrl.ToString(), "*** New Service") '***
                                                ElseIf String.Compare(name, "SCPDURL", StringComparison.OrdinalIgnoreCase) = 0 Then
                                                    If (String.Compare(serviceType, "urn:schemas-upnp-org:service:AVTransport:1", StringComparison.OrdinalIgnoreCase) = 0) Or String.Compare(serviceType, "urn:schemas-upnp-org:service:AVTransport:2", StringComparison.OrdinalIgnoreCase) = 0 Then '***
                                                        avTransportSCPDUri = New Uri(deviceLocationUrl, serviceReader.ReadString())
                                                    ElseIf (String.Compare(serviceType, "urn:schemas-upnp-org:service:RenderingControl:1", StringComparison.OrdinalIgnoreCase) = 0) Or (String.Compare(serviceType, "urn:schemas-upnp-org:service:RenderingControl:2", StringComparison.OrdinalIgnoreCase) = 0) Then '***
                                                        renderingControlSCPDUri = New Uri(deviceLocationUrl, serviceReader.ReadString())
                                                    End If
                                                ElseIf String.Compare(name, "controlURL", StringComparison.OrdinalIgnoreCase) = 0 Then
                                                    If (String.Compare(serviceType, "urn:schemas-upnp-org:service:ConnectionManager:1", StringComparison.OrdinalIgnoreCase) = 0) Or (String.Compare(serviceType, "urn:schemas-upnp-org:service:ConnectionManager:2", StringComparison.OrdinalIgnoreCase) = 0) Then '***
                                                        connectionManagerUrl = New Uri(deviceLocationUrl, serviceReader.ReadString())
                                                    ElseIf (String.Compare(serviceType, "urn:schemas-upnp-org:service:AVTransport:1", StringComparison.OrdinalIgnoreCase) = 0) Or (String.Compare(serviceType, "urn:schemas-upnp-org:service:AVTransport:2", StringComparison.OrdinalIgnoreCase) = 0) Then '***
                                                        avTransportControlUrl = New Uri(deviceLocationUrl, serviceReader.ReadString())
                                                    ElseIf (String.Compare(serviceType, "urn:schemas-upnp-org:service:RenderingControl:1", StringComparison.OrdinalIgnoreCase) = 0) Or (String.Compare(serviceType, "urn:schemas-upnp-org:service:RenderingControl:2", StringComparison.OrdinalIgnoreCase) = 0) Then '***
                                                        renderingControlUrl = New Uri(deviceLocationUrl, serviceReader.ReadString())
                                                    End If
                                                ElseIf String.Compare(name, "eventSubURL", StringComparison.OrdinalIgnoreCase) = 0 Then
                                                    If (String.Compare(serviceType, "urn:schemas-upnp-org:service:AVTransport:1", StringComparison.OrdinalIgnoreCase) = 0) Or (String.Compare(serviceType, "urn:schemas-upnp-org:service:AVTransport:2", StringComparison.OrdinalIgnoreCase) = 0) Then '***
                                                        avTransportEventUrl = New Uri(deviceLocationUrl, serviceReader.ReadString())
                                                    ElseIf (String.Compare(serviceType, "urn:schemas-upnp-org:service:RenderingControl:1", StringComparison.OrdinalIgnoreCase) = 0) Or (String.Compare(serviceType, "urn:schemas-upnp-org:service:RenderingControl:2", StringComparison.OrdinalIgnoreCase) = 0) Then '***
                                                        renderingControlEventUrl = New Uri(deviceLocationUrl, serviceReader.ReadString())
                                                    End If
                                                End If
                                            End If
                                        Loop
                                    End Using
                                End If
                            End If
                        Loop
                    End Using
                    Exit For
                Catch ex As XmlException
                    If retry = 2 Then
                        Throw LogError(ex, "NewMediaRendererDevice:" & deviceLocationUrl.ToString(), xml)
                    End If
                End Try
            Next retry
        End Sub

Today I've downloaded the updated version of the plugin posted by Steven, rerun the tests and so far it also behaves the same way. Playback runs smoothly for all the file formats.
If there's any particular test you want me to run I would be happy to do so.

Otherwise I guess this version can be published in the plugins page as current one.

Thanks a lot for such excellent player!!!

Ralf

  • Newbie
  • *
  • Posts: 19
Hey @Dofin and @Steven
great that you got some work done on the plugin! Much appreciated.

As I've noted before, I've got the problem that playback is stopping erratically to my Auna 150.

While testing the new plugin version I noticed that this seems to be happening only when playing songs from big album files instead of single songs.

I only can circumvent this when playing as "continous stream" thereby losin' all info on the song.

Do you see anyway to get around this?


hiccup

  • Sr. Member
  • ****
  • Posts: 7790
a snotter
Are you describing yourself?
No, come on, you are more than that. Elevate yourself, you are worth it.

johnnyboy

  • Jr. Member
  • **
  • Posts: 80
 8)
Oops the Jack Daniels was on the desk when I posted. The post means nothing and is not aimed at anyone. If I meant it I would started with a capital A. lol