Re: Original Xbox clients hacks



Responding to myself since I've found out what was the problem. The server server just sends "options" to the client, and it's up to the client to decide and make use of whichever resource it finds suitable.

The trick off invalidating the resource mime_type only works because the Xbox 360 will seemingly make its decision on the mime_type and thus any resource having incorrect/unsupported mime_type will be discarded.

Reading xbmc4xbox code I've found that it will just take the very first resource available for each item. Easy to do. I've also found that xbmc4xbox doesn't always advertise itself as such: during browsing it uses the User-Agent of its underlying library: platinium.

Would have been easier and better to patch xbmc4xbox, however it means having a Win32 machine along with visual studio and the XDK, which I don't have.

What I've done:
-Client hack to make the MPEG_TS_SD_EU_ISO first in list
-Try xbmc4xbox client hack before the XBox360 client hack to avoid conficts
-Use the specific version of platinium in the agent string to avoid conflicts with recent versions of Kodi.

Here is the patch:

diff -Nur rygel-0.32.1.orig/src/librygel-server/filelist.am rygel-0.32.1.mine/src/librygel-server/filelist.am --- rygel-0.32.1.orig/src/librygel-server/filelist.am 2016-06-26 17:10:17.000000000 +0200 +++ rygel-0.32.1.mine/src/librygel-server/filelist.am 2017-01-22 10:56:03.590051674 +0100
@@ -80,6 +80,7 @@
        rygel-thumbnailer.vala \
        rygel-wmp-hacks.vala \
        rygel-xbmc-hacks.vala \
+       rygel-xbmc4xbox-hacks.vala \
        rygel-xbox-hacks.vala \
        rygel-phillips-hacks.vala \
        rygel-data-sink.vala \
diff -Nur rygel-0.32.1.orig/src/librygel-server/rygel-client-hacks.vala rygel-0.32.1.mine/src/librygel-server/rygel-client-hacks.vala --- rygel-0.32.1.orig/src/librygel-server/rygel-client-hacks.vala 2016-06-26 17:10:17.000000000 +0200 +++ rygel-0.32.1.mine/src/librygel-server/rygel-client-hacks.vala 2017-01-22 10:55:06.490051057 +0100
@@ -64,6 +64,10 @@
         } catch (Error error) { }

         try {
+            return new XBMC4XBoxHacks (message);
+        } catch (Error error) { }
+
+        try {
             return new XBoxHacks (message);
         } catch (Error error) { }

diff -Nur rygel-0.32.1.orig/src/librygel-server/rygel-xbmc4xbox-hacks.vala rygel-0.32.1.mine/src/librygel-server/rygel-xbmc4xbox-hacks.vala --- rygel-0.32.1.orig/src/librygel-server/rygel-xbmc4xbox-hacks.vala 1970-01-01 01:00:00.000000000 +0100 +++ rygel-0.32.1.mine/src/librygel-server/rygel-xbmc4xbox-hacks.vala 2017-01-22 10:54:07.460050420 +0100
@@ -0,0 +1,28 @@
+using Soup;
+using GUPnP;
+
+
+internal class Rygel.XBMC4XBoxHacks : ClientHacks {
+
+       private const string AGENT = "(.*XBMC.*Xbox.*)|(Platinum/0.5.3.0)";
+
+       public XBMC4XBoxHacks (Message? message = null) throws ClientHacksError {
+               base (AGENT, message);
+       }
+
+       public override void apply (MediaObject object) {
+               MediaResource right_one = null;
+               foreach (var resource in object.get_resource_list ()) {
+                       if(resource.dlna_profile == "MPEG_TS_SD_EU_ISO"){
+                               right_one = resource;
+                               break;
+                       }
+               }
+
+               if(right_one != null){
+ /*Makes the right_one the first_one, that will be picked up by XBMC4XBOX*/
+                       object.get_resource_list().set(0,right_one);
+               }
+       }
+
+}


On 20/01/17 19:11, Samuel CUELLA wrote:
Hi list,

I've been trying to get transcoding working for my original xbox running
xbmc4xbox. This is old hardware that can't decode x264 and aac.

What I want to achieve: Have rygel transcode any video to a lower
definition/codec when using that device.
By looking at the code, I think the right profile is MPEG_TS_SD_EU_ISO.

For what I understand, I need enforce some kind of client detection
using the user-agent in a ClientHacks derived class and tell
rygel to transcode everything to MPEG_TS_SD_EU_ISO. Correct ?


Looking at the code in other client hacks, I've found in
rygel-xbox-hacks.vala which targets Xbox 360 that one way to that would be
to redefine the mime_type to something incorrect:

foreach (var resource in object.get_resource_list ()) {
     if (resource.mime_type == "video/x-msvideo") {
         resource.mime_type = "video/avi";
     } else if (resource.mime_type == "video/mpeg") {
         // Force transcoding for MPEG files
         resource.mime_type = "invalid/content";
     }
}

I've done that in my xbmc4xbox client hack as such:

foreach (var resource in object.get_resource_list ()) {
     if(resource.dlna_profile != "MPEG_TS_SD_EU_ISO"){
         resource.mime_type = "invalid/content";
     }
}

and it does work... with Kodi on a linux box (I set AGENT = ".*" to
catch all for tests). I can seen in the debug logs that the transcoding
machinery is triggered and works as expected. However, if I try the very
same thing using XBMC4XBOX, _it doesn't work_. It just show up playing
the "normal" file in the logs 'res/primary_http" with the
'invalid/content' in the 'Content Type'.

I'm obviously doing something/everything wrong. I don't fully understand
how the request is processed at and which state the apply() and
modify_headers() hooks are triggered.

How can I force rygel to transcode to a certain dlna_profile once I've
caught the client with the right user-agent ?




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]