Plugin development primer: AdditionalFolderAtRoot

Discuss issues related to PS3 Media Server development (only for programmers)

Re: Plugin development primer: AdditionalFolderAtRoot

Postby grolschie » Wed Aug 25, 2010 12:55 am

Yep. I am using XP though.
grolschie
 
Posts: 263
Joined: Thu Jun 10, 2010 7:05 am

Re: Plugin development primer: AdditionalFolderAtRoot

Postby venraij » Sat Sep 04, 2010 2:12 pm

I have some problems using the AdditionalFoldersAtRoot, because it is called too late after the root was initialized, when I am changing the source code of the media serve however it works.

PMS.init()
....
try {
ExternalFactory.lookup();
manageRoot(RendererConfiguration.getDefaultConf()); // XXX needed for additional roots ????
} catch (Exception e) {
PMS.error("Error in the plugins lookup", e);
}

That the way the roots will be reevaluated (already done three times yet) _after_ creating the plugins. By this way my folders are added the the root. Are I am doing something wrong or how do other developpers create such plugin?
venraij
 
Posts: 9
Joined: Mon Jul 26, 2010 9:26 pm

Re: Plugin development primer: AdditionalFolderAtRoot

Postby tomeko » Sun Feb 13, 2011 12:58 am

I've created patch that adds three new config parameters to PMS.conf:
Code: Select all
video_folders = d:\\media\\Media
audio_folders = d:\\media\\Music
image_folders = d:\\media\\Pictures

With this parameters, a folders are shown in appropriate XMB branch (BRAVIA).
Code: Select all
Index: net/pms/dlna/DLNAResource.java
===================================================================
--- net/pms/dlna/DLNAResource.java   (wersja 496)
+++ net/pms/dlna/DLNAResource.java   (kopia robocza)
@@ -111,6 +111,7 @@
       this.parent = parent;
    }
    protected Format ext;
+   protected String MediaClass;
    public DLNAMediaInfo media;
    public DLNAMediaAudio media_audio;
    public DLNAMediaSubtitle media_subtitle;
@@ -235,7 +236,12 @@
     * @param child DLNAResource to add to a container type.
     */
 
-   public void addChild(DLNAResource child) {
+   public void addChild(DLNAResource child){
+      addChild(child, null);
+   }
+   
+   
+   public void addChild(DLNAResource child, String childFormat) {
       //child.expert = expert;
       child.parent = this;
       if (parent != null)
@@ -248,6 +254,8 @@
 
          if (allChildrenAreFolders && !child.isFolder())
             allChildrenAreFolders = false;
+         child.MediaClass = childFormat;
+      
          
          children.add(child);
          childrenNumber++;
@@ -984,7 +992,7 @@
       }
       
       String thumbURL = getThumbnailURL();
-      if (!isFolder() && (ext == null || (ext != null && thumbURL != null))) {
+      if (!isFolder() && (ext == null || (ext != null && thumbURL != null)) && PMS.getConfiguration().getThumbnailsEnabled()) {
          openTag(sb, "upnp:albumArtURI");
          addAttribute(sb, "xmlns:dlna", "urn:schemas-dlna-org:metadata-1-0/");
          if (getThumbnailContentType().equals(PNG_TYPEMIME) && !mediaRenderer.isBRAVIA())
@@ -996,7 +1004,7 @@
          closeTag(sb, "upnp:albumArtURI");
       }
       
-      if ((isFolder() || mediaRenderer.isBRAVIA()) && thumbURL != null){
+      if ((isFolder() || mediaRenderer.isBRAVIA()) && thumbURL != null && PMS.getConfiguration().getThumbnailsEnabled()){
          openTag(sb, "res");
          if (getThumbnailContentType().equals(PNG_TYPEMIME) && !mediaRenderer.isBRAVIA())
             addAttribute(sb, "protocolInfo", "http-get:*:image/png:DLNA.ORG_PN=PNG_TN");
@@ -1039,8 +1047,29 @@
       if (uclass != null)
          addXMLTagAndAttribute(sb, "upnp:class", uclass);
       
-      if (isFolder())
+      if (isFolder()) {
+         if(MediaClass == "V") {
+            openTag(sb, "av:mediaClass");
+             addAttribute(sb, "xmlns:av", "urn:schemas-sony-com:av");
+             endTag(sb);
+             sb.append("V");
+             closeTag(sb, "av:mediaClass");
+         } else if(MediaClass == "A") {
+            openTag(sb, "av:mediaClass");
+             addAttribute(sb, "xmlns:av", "urn:schemas-sony-com:av");
+             endTag(sb);
+             sb.append("M");
+             closeTag(sb, "av:mediaClass");
+         } else if(MediaClass == "I") {
+            openTag(sb, "av:mediaClass");
+             addAttribute(sb, "xmlns:av", "urn:schemas-sony-com:av");
+             endTag(sb);
+             sb.append("P");
+             closeTag(sb, "av:mediaClass");
+         }
+         
          closeTag(sb, "container");
+      }
       else
          closeTag(sb, "item");
       
Index: net/pms/PMS.java
===================================================================
--- net/pms/PMS.java   (wersja 496)
+++ net/pms/PMS.java   (kopia robocza)
@@ -592,6 +592,9 @@
       File files [] = loadFoldersConf(configuration.getFolders());
       if (files == null || files.length == 0)
          files = File.listRoots();
+      File Audiofiles [] = loadFoldersConf(configuration.getAudioFolders());
+      File Videofiles [] = loadFoldersConf(configuration.getVideoFolders());
+      File Imagefiles [] = loadFoldersConf(configuration.getImageFolders());
       /*
        * initialize == false: make sure renderer.getRootFolder() doesn't call back into this method
        * if it creates a new root folder
@@ -602,6 +605,9 @@
       RootFolder rootFolder = getRootFolder(renderer, false);
 
       rootFolder.browse(files);
+      rootFolder.browse(Videofiles, "V");
+      rootFolder.browse(Audiofiles, "A");
+      rootFolder.browse(Imagefiles, "I");
       rootFolder.browse(MapFileConfiguration.parse(configuration.getVirtualFolders()));
 
       String strAppData = System.getenv("APPDATA");
Index: net/pms/dlna/RootFolder.java
===================================================================
--- net/pms/dlna/RootFolder.java   (wersja 496)
+++ net/pms/dlna/RootFolder.java   (kopia robocza)
@@ -45,8 +45,12 @@
    }
    
    public void browse(File startFolders []) {
+         browse(startFolders, null);
+   }
+   
+   public void browse(File startFolders [], String rootFormat) {
       for(File f:startFolders) {
-         addChild(new RealFile(f));
+         addChild(new RealFile(f), rootFormat);
       }
    }
 
Index: net/pms/configuration/PmsConfiguration.java
===================================================================
--- net/pms/configuration/PmsConfiguration.java   (wersja 496)
+++ net/pms/configuration/PmsConfiguration.java   (kopia robocza)
@@ -147,7 +147,10 @@
    private static final String CONFIGURATION_PATH_MAC = System.getProperty("user.home") + "/Library/Application Support/PS3 Media Server/";
    private static final char LIST_SEPARATOR = ',';
    private static final String KEY_FOLDERS = "folders";
-
+   private static final String KEY_VIDEO_FOLDERS = "video_folders";
+   private static final String KEY_AUDIO_FOLDERS = "audio_folders";
+   private static final String KEY_IMAGE_FOLDERS = "image_folders";
+   
    private final PropertiesConfiguration configuration;
    private final TempFolder tempFolder;
    private final ProgramPathDisabler programPaths;
@@ -853,6 +856,30 @@
       configuration.setProperty(KEY_FOLDERS, value);
    }   
    
+   public String getVideoFolders() {
+      return getString(KEY_VIDEO_FOLDERS, "");
+   }
+   
+   public void setVideoFolders(String value) {
+      configuration.setProperty(KEY_VIDEO_FOLDERS, value);
+   }   
+   
+   public String getAudioFolders() {
+      return getString(KEY_AUDIO_FOLDERS, "");
+   }
+   
+   public void setAudioFolders(String value) {
+      configuration.setProperty(KEY_AUDIO_FOLDERS, value);
+   }
+   
+   public String getImageFolders() {
+      return getString(KEY_IMAGE_FOLDERS, "");
+   }
+   
+   public void setImageFolders(String value) {
+      configuration.setProperty(KEY_IMAGE_FOLDERS, value);
+   }   
+   
    public String getNetworkInterface() {
       return getString(KEY_NETWORK_INTERFACE, "");
    }

I think, this code is very ugly (i'm not java programmer), but it works with my BRAVIA TV.
tomeko
Project Member
 
Posts: 154
Joined: Sat Jun 06, 2009 11:02 am

Re: Plugin development primer: AdditionalFolderAtRoot

Postby grolschie » Sun Feb 13, 2011 1:11 am

Very cool! Thanks for this! :-)

Any chance of adding the patch as a file attachment please? "CODE: SELECT ALL" and copy and paste seems to mess it up somehow.
grolschie
 
Posts: 263
Joined: Thu Jun 10, 2010 7:05 am

Re: Plugin development primer: AdditionalFolderAtRoot

Postby grolschie » Sat Mar 05, 2011 1:09 am

The patch doesn't work for the BDP-S370. I see all the folders on each XMB menu. Maybe this renderer is a bit different in how it communicates.
grolschie
 
Posts: 263
Joined: Thu Jun 10, 2010 7:05 am

Re: Plugin development primer: AdditionalFolderAtRoot

Postby tomeko » Sat Mar 05, 2011 10:10 pm

grolschie wrote:The patch doesn't work for the BDP-S370. I see all the folders on each XMB menu. Maybe this renderer is a bit different in how it communicates.

Is it only BRAVIA TV supports this extension? SonyEricsson phones uses it with their media server...
I modified my patch. Now mediaClass only are used when any "audio_folders" or "image_folders" are set (then "folders" are used as video source folders).
Attachments
r511_AVFolders.zip
(1.71 KiB) Downloaded 126 times
tomeko
Project Member
 
Posts: 154
Joined: Sat Jun 06, 2009 11:02 am

Re: Plugin development primer: AdditionalFolderAtRoot

Postby grolschie » Sun Mar 06, 2011 12:27 am

I am sure that my Sony BDP-S370 showed category specific items using WMP on XP.
grolschie
 
Posts: 263
Joined: Thu Jun 10, 2010 7:05 am

Re: Plugin development primer: AdditionalFolderAtRoot

Postby tomeko » Mon Mar 07, 2011 1:29 am

grolschie wrote:I am sure that my Sony BDP-S370 showed category specific items using WMP on XP.

My BRAVIA also :D
I've tested it... BRAVIA (and probably your Sony BD) checks server description, and if WMP is detected, then when Browsing, don't asking for ObjectID=0, but directly for ObjectID = 2 (WMP Video folder), ObjectID = 1 (WMP Audio folder) and ObjectID = 3 (WMP Image folder).
My BRAVIA detects server as WMP, when PMS.xml contains:
Code: Select all
<manufacturer>Microsoft</manufacturer>
<modelName>Windows Media Player Sharing</modelName>
<modelNumber>3.0</modelNumber>
...
   <service>
      <serviceType>urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1</serviceType>
      <serviceId>urn:microsoft.com:serviceId:X_MS_MediaReceiverRegistrar</serviceId>
      <controlURL>/upnp/mrr/control</controlURL>
      <eventSubURL>/upnp/mrr/eventsub</eventSubURL>
      <SCPDURL>/upnp/mrr/scpd</SCPDURL>
   </service>
</serviceList>

Maybe with some code modifications (something like xbox detection), it should be work.
tomeko
Project Member
 
Posts: 154
Joined: Sat Jun 06, 2009 11:02 am

Re: Plugin development primer: AdditionalFolderAtRoot

Postby grolschie » Mon Mar 07, 2011 1:37 am

Good one. Thanks for that. I wonder what happens on the PS3?
grolschie
 
Posts: 263
Joined: Thu Jun 10, 2010 7:05 am

Previous

Return to Developers

Who is online

Users browsing this forum: No registered users and 2 guests