UPnP

From LinuxMCE
Revision as of 20:33, 10 September 2008 by Niz23 (Talk | contribs) (UpdateMedia)

Jump to: navigation, search

UPnP Server Notes

The UPnP service provided by fuppesd is used to serve all the media on a LinuxMCE system to a UPnP client. BUT, right now, the UPnP service does not know, when things change. Whenever media is added to the system, the fuppesd database need to be rebuild.

Rebuilding UPnP Database

To rebuild the UPnP database, the web admin provides the UPnP page under Advanced / UPnP Server. Under Options click on Rebuild Database, to update the upnp database with current list of files in the system.

Hopefully, this will change in the future, and there is going to be a tie between UpdateMedia and the UPnP server.


Development changes for UPnP server in LMCE

We are working on a replacement that will be better integrated with LinuxMCE. The proposed server is MediaTomb. There are a couple of reasons why we change to another UPnP server.

  • Better support for transcoding
  • Fuppes maintainer is nowhere to be found. Project forked into Fuppex.
  • Fuppes lack mySQL support.
  • No concrete development direction.

MediaTomb feature: (lot more of them then listed here)

  • It support mySQL.
  • Support for transcoding.
  • Will have support for streaming of ISO files in version 0.12
  • Transcoding can be scripted.
  • Bad support for Xbox360. Open question? I guess we cannot have good support for everything.

Development Notes

Add information that are nice to know during the time we integrate MediaTomb.

UpdateMedia

UpdateMedia is probably the best place to integrate another media server in.

All logic to handle new, modified and deleted media files are already in UpdateMedia.

We can extend the basic configuration file handling in UpdateMedia to handle UPnP config too. It´s not used at the moment. Looks for a config /etc/UpdateMedia.conf on startup. We can extend it to have UPnP config options. Only option that cen be set so far is,


UpdateMedia startup:

UpdateMedia::UpdateMedia(string host, string user, string pass, int port, string sDirectory, bool bSyncFilesOnly)
{
 PlutoMediaFilE::SetDefaultSyncMode(bSyncFilesOnly ? modeDbToFile : modeBoth)
 ReadConfigFile();
 // Set variables. Like which database to use.
 // Connect to database().
 LoadExtensions(); // What does this do? Pugins?
 SetupInstallation();  // Get installation ID? Old pluto reliec?
 // Load info about modificationData, AttrCount, AttrDate, attributes, timestamp for all files.
 MediaState::Instance().loadDbInfo(m_pDatabase_pluto_media, FileUtils::ExcludeTrailingSlsh(m_sDirectory)); // Seem to load the media attr into RAM.
}

Method that scan subfolders.

bool UpdateMedia::ScanSubFolders(string sDirectory, FolderType& folder_type)
{
 list<string> listSubDirectories;
 // Check if there are some dirs to scan through?
 // Is this a special folder?
   // Is this a ripped DVD?
     // Checks for AUDIO_TS and VIDEO_TS folders.
   // Is it a HDDVD?
     // Check for HDDVD_TS
   // Check if a ripped blueray?
     // Look for directory BDMV
 // Check if normal directory. if it is then return true.
 for (list of subdirs)
 {
   // Handle mounted uPnP shares. Skip metadata folders.
   // Named .debug & _search & .metadata
   // Skip "MythTV AV Media Server".
   // Skip LMCE uPnP mounted shares
    
 }
} 

Pseudo code for ScanFiles method.

UpdateMedia::ScanFiles(string sDirectory)
{
 // Build a list of files on disk, and a map of those in the database
 list<string> listFilesOndisk;
 FileUtils::FindFiles(listFilesOnDisk, sDirectory, m_sExtensions, false,false, 0, "");
 // Now start matching them up.
 for(list<string>::iterator it=listFilesOndisk.begin(); it=!listFilesOnDisk.end(); ++it)
 {
   // Compare with data in DB.
   if (modeNone)
     continue;
   if (modeFileToDb)
     sync_mode = modeFileToDb;
   if(modeDBtoFile)
     sync_mode = modeDbToFile;
   SetSyncMode(sync_mode);
   
   // Is in database?
   if(!AlreadyInDatabase(sDirectory, sFile)
   {
     PK_File = PlutoMediaFile_.HandleFilenotFoundIndatabase();
   }
   else
   {
     // Its in the db already.
     PK_File = GetFileID(sDirectory, sFile);
   }
   int PK_Picture = 0;
   if (PK_File !=0)
   {
     PlutoMediaFile_.GetPicAttribute(PK_File);
   }
   else
   {}
   if (PK_Picture && PK_File)
   {
     // Handle picture attributes.
   }
     
   }
 }
 return true;
}

Method checks if file should scanned or not.

bool UpdateMedia::AnyReasonToSkip(string sDirectory, string sFile)
{
  // Check for files to ignore.
  // Like a directory.
  // ignore "id3" and "lock" files.
  // ignore "info.vdr" and "index.vdr"
  // Check if there is a ".folderlock" file
  // Automatically delete a lock if >2h old. Check modifiedTimeStamp.
  // Skip UPnP stuff.
} 

Method check if file is in database already.

bool updateMedia::AlreadyInDatabase(string sDirectory, string sFile)
{
  Check Directory and File name if they exist in database.
  Seem to always return !vectRow_File.emtpy();
}

TODO list

  • Map sql statements that MediaTomb use.
    • Add media file.
    • Remove media file.
    • Modify existing media file.
    • Handle metadata for media files. MediaTomb scan for it itself. We need to override that functionality to be sure metadata prestend in lmce correspond to metadata presented to UPnP clients.
  • Disable webUI in MediaTomb. We only need one way to add media files.
  • Document main loop in UpdateMedia. Partially done. Need to add it here or in UpdateMedia wiki page.