Jump to content

XBMC UPNP client


marcjero

Recommended Posts

marcjero

Hello,

 

I found that linking XMBC... err Kodi to MB is basically possible throught DLNA/UPNP. I created a custom XBMC DLNA profile that transcodes nothing. Some features are working, others are not.

 

remote control of XBMC renderer from MB

-you can start playing a movie from MB UI (great)

-you can mute XBMC from MB UI (interesting)

-you can't pause, stop, rewind, etc : all the buttons are grayed in the MB UI

 

browsing MB library from XBMC

-I was surprised about the good metadata compatibility (good enough for me) : browsing of library is excellent, much better than expected and fast (xbmc is running on a PI)

-but movie playback doesn't start when initiated from XBMC UI (XBMC is starting an infinite query loop with server because I guess MB is not returning exactly what was expected)

 

I have the feeling that it could be very possible to make these 2 great projects natively compatibles. Do you think this makes sense ?

I know that XBMC doesn't implement DLNA. Do you think MB can serve simple UPNP clients ?

 

I have dev skills so I can help on this topic.

 

Thanks.

  • Like 2
Link to comment
Share on other sites

Hi there,

Thanks for the report.

 

Yea we'd love to have your help on this. Can you find out exactly what the problem is in regards to the xml responses being returned by the server? We can start with that and then look at the remote control buttons. Thanks!

Link to comment
Share on other sites

marcjero

Hi Luke,

 

I got a server log in debug mode. Where would you like me to upload this ?

 

EDIT : I'm not familiar with UPNP/DLNA protocol. But I see in the server payload that the playback URL is returned to client. I suppose xbmc doesn't recognize this DLNA metadata.

Edited by marcjero
Link to comment
Share on other sites

Well it's not so  much the log but really we need someone to find the issue with the xml response .so comparing that to another player that works would be a good start. maybe you use one xbmc instance to act as a upnp server, use another xbmc to browse, then grab that xml.

Link to comment
Share on other sites

marcjero

Yes I understand. I can use another XBMC instance as UPNP server and compare the payload returned with this one. We should find what XBMC is expecting in the message and then we can try to fix that on the MB side if possible. I will do this tomorrow !

  • Like 1
Link to comment
Share on other sites

marcjero

Ok I think I found something interesting. Look what is returning mediabrowser to Kodi when browsing a movie object :

 

<u:BrowseResponse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1"><Result><DIDL-Lite .......</DIDL-Lite></Result><NumberReturned>1</NumberReturned><TotalMatches>0</TotalMatches><UpdateID>2337</UpdateID></u:BrowseResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

 

I removed the DIDL message because I don't think the issue is here.

 

Mediabrowser is returning 1 for NumberReturned but 0 for TotalMatches. TotalMatches should be set to 1 here. I think that when TotalMatches <> NumberReturned Kodi is trying to iterate browse requests and enters an infinite loop.

Kodi UPNP server is returning 1 for both.

 

Does it make sense for you ?

Edited by marcjero
Link to comment
Share on other sites

I'll  look at it. This was a tricky one though that @@7illusions and I fixed a few months ago. Changing it could affect other upnp clients, so I'm unlikely to throw it in last minute before a server release. But certainly at the beginning of the next cycle we can add it and see how it goes.

Link to comment
Share on other sites

steve1977

I found that linking XMBC... err Kodi to MB is basically possible throught DLNA/UPNP. I created a custom XBMC DLNA profile that transcodes nothing. Some features are working, others are not.

 

remote control of XBMC renderer from MB

-you can start playing a movie from MB UI (great)

-you can mute XBMC from MB UI (interesting)

-you can't pause, stop, rewind, etc : all the buttons are grayed in the MB UI

 

Thanks marcjero to supporting with your dev skills. It sounds like this is getting some traction again. Thanks again!

 

There is a long threat on the issue you are stating above about not being able to pause, stop, etc. Any further thoughts are appreciated!!!

 

http://mediabrowser.tv/community/index.php?/topic/10416-xbmc-as-receiver/page-4

Link to comment
Share on other sites

i'm putting the change up in a server dev build so that you can play with it. i'll decide later if it goes into the release or not.

  • Like 2
Link to comment
Share on other sites

Happy2Play

How can I get the dev version ? I suppose I have to build it ?

 

Go to Dashboard-Advanced-Auto Update and change level to Dev and click save.  This will auto update to Dev build.

Link to comment
Share on other sites

marcjero

You are welcome. Just a newbie question : how can I get the dev version ? I suppose I have to build it ?

I saw your fix and I'm pretty sure it will work fine now.

 I understand now that when an UPNP client is doing a BrowseMetadata request server can return several results. Returning 0 fro TotalMatches confuses XBMC and then it tries to get all the results using an index. I can clearly see that in the log file. And for each request MB returns exactly the same payload so this can run forever...

Link to comment
Share on other sites

marcjero

Well this doesn't seem to work for me, nothing happens even if I restart the service. I running a headless Ubuntu server and installed from PPA...

Link to comment
Share on other sites

Well this doesn't seem to work for me, nothing happens even if I restart the service. I running a headless Ubuntu server and installed from PPA...

 

The auto-updates are only for windows right now

Link to comment
Share on other sites

  • 2 weeks later...
marcjero

Hi Luke,

 

I just tested 5445.6 (that should include the fix) but unfortunately TotalMatches is still set to 0.

 

I took a look at the code you fixed, please read my comments inside

if (string.Equals(flag, "BrowseMetadata"))
// OK the query is really BrowseMetadata
{
if (item.IsFolder || serverItem.StubType.HasValue)
{
var childrenResult = (await GetUserItems(item, serverItem.StubType, user, sortCriteria, start, requested).ConfigureAwait(false));
totalCount = 1;
result.DocumentElement.AppendChild(_didlBuilder.GetFolderElement(result, item, serverItem.StubType, null, childrenResult.TotalRecordCount, filter, id));
// Here totalCount = 1 so it looks fine
}
else
{
// Here totalCount = 0 I guess we just fall here...
result.DocumentElement.AppendChild(_didlBuilder.GetItemElement(result, item, null, null, deviceId, filter));
}
provided++;
//Maybe you just need to add something like totalCount++; here and remove totalCount = 1;
}
else...
  • Like 2
Link to comment
Share on other sites

Thanks I'll look at it. Yes movies initially come back with a folder container that contains the actual movie, trailers, extras, cast/crew, etc.

Link to comment
Share on other sites

marcjero

Ok it works better now but there are other issues.

 

Did you change the behaviour of browsing in the last few days ?

Because now when I select a movie a BrowseDirectChildren query is issued so I think XBMC is thinking the movie is just a folder. Inside this folder I can see 2 items : the real movie object and another item called "Movie Team". I can play the movie object.

 

But it's strange because for some movies I can't just enter the movie folder at all. BrowseDirectChildren fails with this exception :

System.AggregateException
	  at System.Threading.Tasks.Task`1[System.Collections.Generic.IEnumerable`1[System.Collections.Generic.KeyValuePair`2[System.String,System.String]]].get_Result () [0x00000] in <filename unknown>:0 
	  at MediaBrowser.Dlna.ContentDirectory.ControlHandler.GetResult (System.String methodName, MediaBrowser.Dlna.Server.Headers methodParams) [0x00000] in <filename unknown>:0 
	  at MediaBrowser.Dlna.Service.BaseControlHandler.ProcessControlRequestInternal (MediaBrowser.Controller.Dlna.ControlRequest request) [0x00000] in <filename unknown>:0 
	  at MediaBrowser.Dlna.Service.BaseControlHandler.ProcessControlRequest (MediaBrowser.Controller.Dlna.ControlRequest request) [0x00000] in <filename unknown>:0 
	InnerException: System.ArgumentException
	Argument not supported: http://192.168.0.14:8096/mediabrowser/videos/1757f360122bb19dcc459b49fe0f15a9/stream
	  at MediaBrowser.Common.Net.MimeTypes.GetMimeType (System.String path) [0x00000] in <filename unknown>:0 
	  at MediaBrowser.Dlna.Didl.DidlBuilder.AddVideoResource (System.Xml.XmlElement container, IHasMediaSources video, System.String deviceId, MediaBrowser.Dlna.Didl.Filter filter, System.String contentFeatures, MediaBrowser.Model.Dlna.StreamInfo streamInfo) [0x00000] in <filename unknown>:0 
	  at MediaBrowser.Dlna.Didl.DidlBuilder.AddVideoResource (System.Xml.XmlElement container, IHasMediaSources video, System.String deviceId, MediaBrowser.Dlna.Didl.Filter filter, MediaBrowser.Model.Dlna.StreamInfo streamInfo) [0x00000] in <filename unknown>:0 
	  at MediaBrowser.Dlna.Didl.DidlBuilder.GetItemElement (System.Xml.XmlDocument doc, MediaBrowser.Controller.Entities.BaseItem item, MediaBrowser.Controller.Entities.BaseItem context, Nullable`1 contextStubType, System.String deviceId, MediaBrowser.Dlna.Didl.Filter filter, MediaBrowser.Model.Dlna.StreamInfo streamInfo) [0x00000] in <filename unknown>:0 
	  at MediaBrowser.Dlna.ContentDirectory.ControlHandler+<HandleBrowse>c__async0.MoveNext () [0x00000] in <filename unknown>:0 
	

Is the movie folder a normal item I should get ?

 

I noticed this error as well : Error - NotFoundHttpHandler: 192.168.0.14:8096 Request not found: /mediabrowser/Dlna/icons/people480.jpg

 

 

I can build the dev sources and test easily so I can do any testing you need now. :)

I can share a basic Kodi profile with no transcoding if interested.

Edited by marcjero
Link to comment
Share on other sites

marcjero

Ok I think that the correct playback URL should be

http://192.168.0.14:8096/mediabrowser/videos/1757f360122bb19dcc459b49fe0f15a9/stream.mkv

Extension is missing so video type isn't resolved. It's strange because I looked into the library db file and movies paths are correct.

 

update : all metadata for all movies are displayed correctly in the dashboard. I was expecting a problem when extracting metadata from media files but it doesn't seem to be the cause of the error.

Edited by marcjero
Link to comment
Share on other sites

you are correct, although that method should really be named IsEligibleForDirectStream, because there is no direct play with dlna, only direct stream. what you've commented out will result in no subtitles, because if the subtitle method is encode, but you force direct stream, there won't be any subs. instead you should adjust the dlna profile so that the subtitle method ends up being external or embed.

Link to comment
Share on other sites

marcjero

Luke,

 

I think I found where the problem is (was)

 

Look at this code (StreamBuilder.cs) :

       private bool IsEligibleForDirectPlay(MediaSourceInfo item,
            int? maxBitrate,
            MediaStream subtitleStream,
            VideoOptions options)
        {
            if (subtitleStream != null)
            {
                if (!subtitleStream.IsTextSubtitleStream)
                {
                    return false;
                }

                /*SubtitleDeliveryMethod subtitleMethod = GetSubtitleDeliveryMethod(subtitleStream, options);

                if (subtitleMethod != SubtitleDeliveryMethod.External && subtitleMethod != SubtitleDeliveryMethod.Embed)
                {
                    return false;
                }*/
            }

            return IsAudioEligibleForDirectPlay(item, maxBitrate);
        }

I understand you do some testing about the subtitles. Some of my files fail at the second test, I don't really know why. Just to be sure to understand what is the difference with DirectPlay and Direct Stream ? DirectStream is for HTTP without transcoding (my use case), DirectPlay for direct access to filesystem (smb, nfs) ? Am I correct ?

 

 

 

Link to comment
Share on other sites

marcjero

Oh I see I will look at the DLNA profile then. Do you think it's possible to implement direct play for UPNP ?

 

UPDATE : I did few hacks and was able to play video using nfs (DirectPlay) I found that you already enabled DirectPlay for DLNA only for HTTP protocol correct ? Do you plan to support other protocols in the future ? Doesn't require many changes, the main problem is to provide an additional configuration option for DLNA profiles.

Edited by marcjero
  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...
steve1977

Any update on this? Allowing XBMC to play directly without any transcoding over SMB (triggered by MBS or the IOS app) would be heaven! This would basically make the IOS device a client on its own and at the same time a remote for XBMC.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...