Skip to content
This repository
Browse code

Merge pull request #1348 from SlrG/hddvdfix

FIX: Add HD DVD detection and handling for HD DVD specific external play...
  • Loading branch information...
commit 44174fc395f82a9605708f561a1d48334ed82557 2 parents 2661fb4 + 3f9b06f
authored October 07, 2012

Showing 1 changed file with 115 additions and 0 deletions. Show diff stats Hide diff stats

  1. 115  xbmc/Autorun.cpp
115  xbmc/Autorun.cpp
@@ -136,6 +136,9 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
136 136
     return false;
137 137
   }
138 138
 
  139
+  // Sorting necessary for easier HDDVD handling
  140
+  vecItems.Sort(SORT_METHOD_LABEL, SortOrderAscending);
  141
+
139 142
   bool bAllowVideo = true;
140 143
 //  bool bAllowPictures = true;
141 144
   bool bAllowMusic = true;
@@ -149,6 +152,9 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
149 152
   // is this a root folder we have to check the content to determine a disc type
150 153
   if( bRoot )
151 154
   {
  155
+    CStdString hddvdname = "";
  156
+    CFileItemPtr phddvdItem;
  157
+
152 158
     // check root folders next, for normal structured dvd's
153 159
     for (int i = 0; i < vecItems.Size(); i++)
154 160
     {
@@ -198,6 +204,115 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
198 204
           return true;
199 205
         }
200 206
 
  207
+        // Check if the current foldername indicates a HD DVD structure (default is "HVDVD_TS").
  208
+        // Most HD DVD will also include an "ADV_OBJ" folder for advanced content. This folder should be handled first.
  209
+        // ToDo: for the time beeing, the DVD autorun settings are used to determine if the HD DVD should be started automatically.
  210
+        CFileItemList items, sitems;
  211
+        
  212
+        // Advanced Content HD DVD (most discs?)
  213
+        if (name.Equals("ADV_OBJ"))
  214
+        {
  215
+          CLog::Log(LOGINFO,"HD DVD: Checking for playlist.");
  216
+          // find playlist file
  217
+          CDirectory::GetDirectory(pItem->GetPath(), items, "*.xpl");
  218
+          if (items.Size())
  219
+          {
  220
+            // HD DVD Standard says the highest numbered playlist has to be handled first.
  221
+            CLog::Log(LOGINFO,"HD DVD: Playlist found. Set filetypes to *.xpl for external player.");
  222
+            items.Sort(SORT_METHOD_LABEL, SortOrderDescending);
  223
+            phddvdItem = pItem; 
  224
+            hddvdname = URIUtils::GetFileName(items[0]->GetPath());
  225
+            CLog::Log(LOGINFO,"HD DVD: " + items[0]->GetPath());
  226
+          }
  227
+        }
  228
+
  229
+        // Standard Content HD DVD (few discs?)
  230
+        if (name.Equals("HVDVD_TS") && bAllowVideo
  231
+        && (bypassSettings || g_guiSettings.GetBool("dvds.autorun")))
  232
+        {
  233
+          if (hddvdname == "")
  234
+          {
  235
+            CLog::Log(LOGINFO,"HD DVD: Checking for ifo.");
  236
+            // find Video Manager or Title Set Information
  237
+            CDirectory::GetDirectory(pItem->GetPath(), items, "HV*.ifo");
  238
+            if (items.Size())
  239
+            {
  240
+              // HD DVD Standard says the lowest numbered ifo has to be handled first.
  241
+              CLog::Log(LOGINFO,"HD DVD: IFO found. Set filename to HV* and filetypes to *.ifo for external player.");
  242
+              items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
  243
+              phddvdItem = pItem; 
  244
+              hddvdname = URIUtils::GetFileName(items[0]->GetPath());
  245
+              CLog::Log(LOGINFO,"HD DVD: " + items[0]->GetPath());
  246
+            }
  247
+          }
  248
+          // Find and sort *.evo files for internal playback.
  249
+          // While this algorithm works for all of my HD DVDs, it may fail on other discs. If there are very large extras which are
  250
+          // alphabetically before the main movie they will be sorted to the top of the playlist and get played first.
  251
+          CDirectory::GetDirectory(pItem->GetPath(), items, "*.evo");
  252
+          if (items.Size())
  253
+          {
  254
+            // Sort *.evo files in alphabetical order.
  255
+            items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
  256
+            int64_t asize = 0;
  257
+            int ecount = 0;
  258
+            // calculate average size of elements above 1gb
  259
+            for (int j = 0; j < items.Size(); j++)
  260
+              if (items[j]->m_dwSize > 1000000000)
  261
+              {
  262
+                ecount++;
  263
+                asize = asize + items[j]->m_dwSize;
  264
+              }
  265
+            asize = asize / ecount;
  266
+            // Put largest files in alphabetical order to top of new list.
  267
+            for (int j = 0; j < items.Size(); j++)
  268
+              if (items[j]->m_dwSize >= asize)
  269
+                sitems.Add (items[j]);
  270
+            // Sort *.evo files by size.
  271
+            items.Sort(SORT_METHOD_SIZE, SortOrderDescending);
  272
+            // Add other files with descending size to bottom of new list.
  273
+            for (int j = 0; j < items.Size(); j++)
  274
+              if (items[j]->m_dwSize < asize)
  275
+                sitems.Add (items[j]);
  276
+            // Replace list with optimized list.
  277
+            items.Clear();
  278
+            items.Copy (sitems);
  279
+            sitems.Clear();
  280
+          }
  281
+          if (hddvdname != "")
  282
+          {
  283
+            CFileItem item(URIUtils::AddFileToFolder(phddvdItem->GetPath(), hddvdname), false);
  284
+            item.SetLabel(g_mediaManager.GetDiskLabel(strDrive));
  285
+            item.GetVideoInfoTag()->m_strFileNameAndPath = g_mediaManager.GetDiskUniqueId(strDrive);
  286
+
  287
+            if (!startFromBeginning && !item.GetVideoInfoTag()->m_strFileNameAndPath.IsEmpty())
  288
+            item.m_lStartOffset = STARTOFFSET_RESUME;
  289
+
  290
+            // get playername
  291
+            CStdString hddvdplayer = CPlayerCoreFactory::GetPlayerName(CPlayerCoreFactory::GetDefaultPlayer(item));
  292
+            
  293
+            // Single *.xpl or *.ifo files require an external player to handle playback.
  294
+            // If no matching rule was found, DVDPlayer will be default player.
  295
+            if (hddvdplayer != "DVDPlayer")
  296
+            {
  297
+              CLog::Log(LOGINFO,"HD DVD: External singlefile playback initiated: "+ hddvdname);
  298
+              g_application.PlayFile(item, false);
  299
+              bPlaying = true;
  300
+              return true;
  301
+            } else
  302
+              CLog::Log(LOGINFO,"HD DVD: No external player found. Fallback to internal one.");
  303
+          }
  304
+
  305
+          //  internal *.evo playback.
  306
+          CLog::Log(LOGINFO,"HD DVD: Internal multifile playback initiated.");
  307
+          g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO);
  308
+          g_playlistPlayer.SetShuffle (PLAYLIST_VIDEO, false);
  309
+          g_playlistPlayer.Add(PLAYLIST_VIDEO, items);
  310
+          g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_VIDEO);
  311
+          g_playlistPlayer.Play(0);
  312
+          bPlaying = true;
  313
+          return true;
  314
+        }
  315
+				
201 316
         // Video CDs can have multiple file formats. First we need to determine which one is used on the CD
202 317
         CStdString strExt;
203 318
         if (name.Equals("MPEGAV"))

0 notes on commit 44174fc

Please sign in to comment.
Something went wrong with that request. Please try again.