Using Active Item

niz23
2008-09-04
2013-05-30
1 2 > >> (Page 1 of 2)
  • niz23
    niz23
    2008-09-04

    Hi.

    Im new to this project.
    I have evaluated several uPnP servers and find mediatomb best suited.
    Mediatomb have many features that is not other servers and PS3 suport seem pretty solid.

    I am looking into what can be accomplished with the "active item" feature.
    In terms of integration against an existing database where metadata are located.
    However it lack documentation even though there are references to "Active Item documentation" in some places.

    What I want to know is which preferences/metadata can be modified through python scripting?
    Some comments in trunk source code indicate that everything except some DB IDs can be changed.

    Is it possible to send command line arguments to the python script?

    Can I add my own custom xml tags that I connect to db column that I have added?
    Please give me some hint where too look in the code.

    One other solution to above would be some type of remote procedure call/soap interface against mediatomb that can be used. Is there one?

    /niz23

     
    • Jin
      Jin
      2008-09-07

      Hi,

      well, the active items feature has always been very experimental. I do not think that anyone is using it, so we did not improve it any further; actually I only added it because I did some demo where I was controlling a light bulb from a UPnP player by triggering an active item on MediaTomb (which then launched a script that turned on/off the lightbulb switch that was connected to my notebook).

      From my memory I can tell that you can change the title, mimetype, upnp class, description, location and "state" of the object via the active item XML. That's it, you can not access the database directly, you can not change the object ID, you can not mess around with resources, etc. So its really simple.

      Main purpose is: you trigger an item and it launches some script (a python, shell, perl, whatever script), which gets the XML on stdin and spits out XML on stdout, giving you the possibility to save the "state" of whatever the script was doing and to change the properties of the object listed above. This allows the implementation of "on-off" triggers (i.e. where the name of the item changes from on to off each time it has been played).

      So basically - no, there is no RPC interface or anything like that, it's just a very simple feature which could be used to add some simple items to do stuff on your PC, like shut it down when you finished watching or turn on some lights or whatever.

      Kind regards,
      Jin

       
    • Frisco
      Frisco
      2008-09-18

      Hi Jin,

      sorry for jumping in, but I'm quite interested in the active item feature. I simply do not find any documentation on how to implement it. I guess it should be done by modifying the config.xml (but how?) and adding a file to the database as the trigger, right?

      I would like to use it to restart mediatomb with a different database. Stopping the server machine would be nice too, as it is two floors above the media client.

      One could even think about a combination with sophisticated scripting, thus allowing you to read your emails in the client: One titel for each email, playing the titel would show (or even read!) the email's content.

      So, if you could give me a clue on how to start or where to find more information, I'd be happy to try an implementation and share my findings.

      Cheers, Frisco

       
    • Jin
      Jin
      2008-09-18

      You are right - it seems we dropped the documentation for this feature. I am not aware of anyone using it, so it remains experimental and is not too well tested. I used it for a lights control demo (toggling lights on and off), that's it.

      If you notice that it fails in 0.11 you could try SVN, I remember I was doing some clean up before summer holidays, so it should work there.

      I found the old documentation for it:
      http://mediatomb.svn.sourceforge.net/viewvc/mediatomb/tags/RELEASE_0_8_1/mediaserver/web/help.html?revision=371#active_item

      Let me know if it still works ;)

      Kind regards,
      Jin

       
    • Bill
      Bill
      2008-10-06

      The service just crashes when I tried the example. I pulled demo_toggle.py from .11 but I'm just running the standard fedora binary. Excuse my ignorance but just what is meant my SVN? I see SVN in the url for the source code so I'll assume you are saying to download and compile a different version. If that's the case, which one?

      I checked the mediatomb log and nothing there. How would I go about debugging this? I'm not even sure the problem is in the python script and it is seeing the script because mediatomb would complain if the location and action script paths are not correct.

       
    • Jin
      Jin
      2008-10-06

      Ehm.. by SVN I mean subversion and by that I mean the latest development code:

      http://mediatomb.cc/pages/download#dev_code

      ...which means - you will have to compile it yourself. If you are not comfortable with that you should probably wait for the 0.12 release which is planned for this year.

       
    • Bill
      Bill
      2008-10-07

      I got this when I went to compile (the end part - did you want to see the whole config.log??):

      configure: WARNING: Automatic database creation not possible due to missing zlib headers/libraries
      checking sqlite3.h usability... no
      checking sqlite3.h presence... no
      checking for sqlite3.h... no
      checking /usr/local/include/sqlite3.h usability... no
      checking /usr/local/include/sqlite3.h presence... no
      checking for /usr/local/include/sqlite3.h... no
      checking for mysql_config... /usr/bin/mysql_config
      checking mysql cflags... -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv
      checking mysql libs... -L/usr/lib/mysql -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread -L/usr/lib -lssl -lcrypto
      checking mysql.h usability... no
      checking mysql.h presence... no
      checking for mysql.h... no
      configure: error: Support of at least one of mysql or sqlite3 must be configured

       
      • Bill
        Bill
        2008-10-07

        Never mind last. I guess I needed gcc-c++ installed.

        I also needed sqlite-devel.i386 and expat-devel.i386. Maybe the list of Requirements could be updated? Or maybe they just expect people to already have those things. They do mention those last two (not the compiler) but not the need for the devel package. Probably just my ignorance showing.

        Now I don't get any errors. I assume this is OK:

        CONFIGURATION SUMMARY ----

        sqlite3               : yes
        mysql                 : missing
        libjs                 : missing
        libmagic              : missing
        inotify               : yes
        libexif               : missing
        id3lib                : disabled
        taglib                : missing
        libmp4v2              : missing
        ffmpeg                : missing
        ffmpegthumbnailer     : missing
        external transcoding  : yes
        curl                  : missing
        YouTube               : missing
        SopCast               : disabled
        libextractor          : disabled
        db-autocreate         : disabled

         
    • Jin
      Jin
      2008-10-07

      Maybe you should read more carefully, the very first note in the "Requirements" section tells you to install the development packages ;)

      Also note, that the docs are for 0.11, so new features (like libmp4v2 support) will not yet be listed there.

       
    • Bill
      Bill
      2008-10-09

      After all the downloads of -devel libs and even getting ffThumbNailer (the hardest for me), it finally compiled. Did the make, and the make install, ran it (as a service) and it still failed to call the Active Item without crashing the server. When the Active Item is clicked it creates a new tab in FireFox with this url - but it was blank:

      http://192.168.1.9:50500/content/media/object_id=2579&res_id=0

      I did a diff on /usr/local/bin/mediatomb against the mediatomb in the build directory and they were the same.

      I noticed when I ran mediatomb from the shell that it still said it was version .11. Did the version number not get changed yet in the code? I thought it would say .12.

       
    • Jin
      Jin
      2008-10-09

      You basically answered your own question already - you are not running the new version.

      Either invoke mediatomb explicitly: /usr/local/bin/mediatomb or uninstall the 0.11 version that is still around on your system.

       
    • Bill
      Bill
      2008-10-09

      Like I had said, I used diff to compare the /usr/local/bin version to that of what I compiled and they were the same.

      I used your link above for SVN to get the code:

      svn co https://svn.mediatomb.cc/svnroot/mediatomb/trunk/mediatomb mediatomb

      Should I be going to somewhere besides trunk to pick up the latest? OK, I know that trunk has v .12 because it's in the change log (not at home to confirm to see if it's in the change log of the code I have).

      I checked for mediatomb in the path, the version that I ran from the shell was identical to that I built (in the build directory under the mediatomb project), when I ran it from the shell it said it was v .11.

      Anything you can think of that I can check?

       
    • Jin
      Jin
      2008-10-09

      > Like I had said, I used diff to compare the
      > /usr/local/bin version to that of what I compiled and
      > they were the same.

      Doh.. what I mean is that you already have an installation of MT on your system - 0.11 - which is probably located in /usr/bin, so I assume that when you simply start "mediatomb" you get the old version from /usr/bin. Which again means that your diff does not mean much, because you were comparing two correct versions, but none of those version was launched.

      If you run the correct version it will tell you that it is 0.12 and not 0.11, so whatever you have been doing - you were not running it.

      An even simplier solution may be to go to the build directory (i.e. mediatomb/build) and run ./mediatomb from there (note the dot slash).

       
    • Bill
      Bill
      2008-10-10

      I should never doubt you! There was a copy in /usr/bin. My problem (between my ears) was that the "which" command (without options) behaves differently than I'm used to. The one I have for Windows gives all paths where the files is found.

      An the other thing you implied that is different from Windows is that the "./" forces it to run the local copy rather than the one in the path. In Windows it will always try the local one first. I think I like it with the "./", it's more explicit.

      With a lot of help from you (Jin), I finally see  version .12. I had a little trouble with ffmpegthumbnailer library not being found. The only way I could find to get the ffmpegthumbnailer library was to download the source from google and compile it myself. The install put it in /usr/local/lib. When I ran mediatomb .12 it complained about not finding the libffmpegtumbnailer files. All the libs on my box seem to be in /usr/lib so I copied them there. It was quick and dirty and now if you could tell me what the proper way to do it is??? An install option ?? env var ??

      Thanks 

       
    • Bill
      Bill
      2008-10-10

      It no longer crashes when I click the Active Item but it does give a 404 error. I tried testing to see if it was even running demo_toggle.py by adding some code at the top that would write something to a file and it never did.

      Any suggestions?

       
    • Jin
      Jin
      2008-10-10

      I do not remember for sure, but I think that active items can not be triggered from the UI - they only work if the request is made to the  UPnP URL (i.e. by pressing play on the device, alternatively find out the URL using Cidero and wget from this URL).

      Also, make sure that the demo_toggle.py is executable.

      Regarding ffmpegthumbnailer - well, first question is - do you need it? I do not remember which player device you are using, for the DSM-510 or the PS3 it would make sense.

      You'd have to install the library in a "usual" way, i.e.:
      ./configure
      make
      sudo make install

      It will probably go to /usr/local/lib and the headers to /usr/local/include - that's where MT will search for them by default.

      Also run ldconfig after installing the library (I assume that /usr/local/lib is already set up in /etc/ld.so.conf).

      Generally, if configure complains about something you can look for more details in the config.log file.

      Kind regards,
      Jin

       
    • Bill
      Bill
      2008-10-11

      I don't even see the Active Item on the player (yes, PS3). Nothing to hit "play" on.
      Changing demo_toggle.py to executable did not make it work.
      No active item shows up in Cidero either.

      I wonder if the jpeg I'm using is too big or something. I stole one from mediatomb called mt_icon32.jpeg. The web page always let's me know if I don't get the path correct for Location or Active Script so it's checking its existence.

      -Bill

       
    • Jin
      Jin
      2008-10-11

      PS3 is very picky, so it will not show stuff with a upnp class that it does now know. Change the upnp class of your active item to object.item.imageItem, then the PS3 should show it.

       
    • Bill
      Bill
      2008-10-14

      I did as you prescribed above and I did get something to show up with the given name on the PS3 (wasn't using the jpeg I defined though). But it still didn't trigger the script.

      I figure at the very least the web server should go off with a 404 error when an Active Item is clicked (even if it isn't meant to fire the script). So...

      I was trying to step through the webserver.h file in the genlib but get this in gnb (ddd):
      /home/.../projects/mediatomb/upnp/src/genlib/net/http/webserver.h: No such file or directory.
      As you know the path is now ...mediatomb/tombupnp/upnp/...   How do I compile the code so gnb know where the real source is and not the "used to be" source?

      As this is a compile question and not about Active Items directly, maybe someone can guide me as to what thread I should be using.

      Thanks

      -Bill

       
    • Bill
      Bill
      2008-10-16

      Got it. I just needed to install libupnp-devel.

       
    • Jin
      Jin
      2008-10-16

      Aem, no, we do not use the package, libupnp is integrated into our trunk.

      You need to compile with -g -O0 (use the devconf script from SVN to run configure with the appropriate options).

      Anyway, the script gets triggered here.

      You can check this easily:
      - add an active item in the web ui
      - get Cidero (see FAQ) and find out the UPnP URL for this item
      - wget the URL

      You should see that your script gets executed, it gets executed here.

       
    • Bill
      Bill
      2008-10-17

      Thanks so much for giving me these tips.

      I must have done other things to get debugging working and just thought that it was the libupnp-devel that did it. I figured out you had replaced it when I read the comments. It was tombupnp that replaced it I think. I'll try the devconf script anyway since it may help. I used the option --enable-debugupnp (or something) but it didn't appear to do it - on its own anyway.

      I tried Cidero after the last time you mentioned it but could never get it to activate the "play" on the active item either. I thought it might be because I needed a renderer before I could play anything. I can get the URL from firebug anyway can't I?

      While debugging I noticed that the Active Item URL as seen from inside the web server code is the same as that for a container (req_type=update) where as you get one that looks like this:
      /content/media/object_id/1234/resid/0
      for things like AVI's. I would have thought that the Active Item would have had this format also.

      You seem certain clicking an Active Item in .12 executes the script. I'll I get is a 404 error when I do it. I'm thinking I have something wrong with the way I installed. Maybe I should start over.

      Thanks again,

      -Bill

       
    • Bill
      Bill
      2008-10-17

      Hi,

      Here's the results of the wget call. It is however from the browser that I clicked the item. I was unable to find an AV renderer to use Cidero (the Intel site only has MSI downloads for windows that I could find).

      cmd:
      wget http://192.168.1.9:50500/content/interface?req_type=update&sid=3e5dee43a71cdfbd3b77ed9ccbe8161b&force_update=0&get_update_ids=1

      response:
      <?xml version="1.0" encoding="UTF-8"?>
      <root><redirect>/</redirect></root>
                                       
      Got the URL for wget from firebug.

      Thanks,

      -Bill

       
    • Jin
      Jin
      2008-10-17

      Bill,

      please read my previous post carefully. I never said that clicking an item executes the script. Why did you get the URL from firebug? I wrote to use Cidero and I did so for a reason, only the UPnP URL (and this is the one that you can get from Cidero) triggers the script.
      Why would you look for an AV device that works with Cidero? I wrote - see FAQ - and I did that for a reason, it explains how to debug with Cidero.

      Kind regards,
      Jin

       
    • Bill
      Bill
      2008-10-19

      Sorry. Not good not reading instructions closely, I apologize. I did run Cidero prior to all this but is was just not intuitive to me that you would have to click the parent folder of the item. I was thinking you would have to click or "play" the item itself. I guess I needed to think of it from the perspective of the upnp player, huh.

      Here's what I've found out so far. To detect that I have fired the script, I added some logging.

      1) The Active Item will go off (and fires the script) - meaning the demo script will go from "Turn On" to "Turn Off" - but will never toggle back to "Turn On". Works great first time after you create it. I also tried manually setting all the properties back to the "Turn On" state and it still did not toggle back to "Turn Off".

      2) On the PS3, the Active Item will only show up under Photos even though I added it to Video and it shows up as "Unsupported Data". Clicking or playing the item from the PS3 does not fire the script even if it has just been created. Makes no difference if you use a class type of object.item.activeItem or object.item.imageItem.

      3) Once the instructions for Cidero were understood, I went back and tried to do what was suggested. Here is the debug output for that item from Cidero:

          <item id="3001" parentID="2596" restricted="1">
            <dc:title>Turn OFF</dc:title>
            <upnp:class>object.item.activeItem</upnp:class>
            <dc:description>Your toggle item is turned ON, press PLAY to turn it OFF.</dc:description>
            <res protocolInfo="http-get:*:Your toggle item is turned OFF, press PLAY to turn it ON.:DLNA.ORG_OP=01;DLNA.ORG_CI=0" size="944" resolution="32x32">http://192.168.1.9:50500/content/media/object_id/3001/res_id/0/ext/file.jpeg</res>
            <res protocolInfo="http-get:*:Your toggle item is turned OFF, press PLAY to turn it ON.:DLNA.ORG_OP=01;DLNA.ORG_CI=0" size="944" resolution="32x32">http://192.168.1.9:50500/content/media/object_id/3001/res_id/1/ext/file.jpeg</res>
          </item>

      The wget on http://192.168.1.9:50500/content/media/object_id/3001/res_id/1/ext/file.jpeg simply downloads the jpeg that was defined in the Active Item Location property.

      Thanks so much for your help,
      -Bill

       
1 2 > >> (Page 1 of 2)