added: bd iso support. credit boxee
authorspiff <spiff@xbmc.org>
Mon, 13 Dec 2010 17:44:12 +0000 (18:44 +0100)
committerspiff <spiff@xbmc.org>
Tue, 4 Jan 2011 22:08:30 +0000 (23:08 +0100)
XBMC.xcodeproj/project.pbxproj
project/VS2010Express/XBMC.vcxproj
project/VS2010Express/XBMC.vcxproj.filters
xbmc/cores/dvdplayer/DVDInputStreams/DVDFactoryInputStream.cpp
xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp
xbmc/cores/dvdplayer/DVDPlayer.cpp
xbmc/win32/PlatformDefs.h
xbmc/win32/WIN32Util.cpp

index 81629f6..2bf8758 100644 (file)
                F56A084B0F4A18FB003F9F87 /* karaokewindowbackground.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56A084A0F4A18FB003F9F87 /* karaokewindowbackground.cpp */; };
                F56A08E00F4D3C20003F9F87 /* GUITexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56A08DF0F4D3C20003F9F87 /* GUITexture.cpp */; };
                F56A08E50F4D3C2E003F9F87 /* GUITextureGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56A08E20F4D3C2E003F9F87 /* GUITextureGL.cpp */; };
+               F57A83E912D3C713000525C5 /* FileUDF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F57A83E812D3C713000525C5 /* FileUDF.cpp */; };
+               F57A83F812D3C764000525C5 /* UDFDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F57A83F712D3C764000525C5 /* UDFDirectory.cpp */; };
+               F57A840112D3C775000525C5 /* udf25.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F57A840012D3C775000525C5 /* udf25.cpp */; };
+               F57A840C12D3C7CD000525C5 /* udf25.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F57A840012D3C775000525C5 /* udf25.cpp */; };
+               F57A840D12D3C7D5000525C5 /* UDFDirectory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F57A83F712D3C764000525C5 /* UDFDirectory.cpp */; };
+               F57A840E12D3C7E1000525C5 /* FileUDF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F57A83E812D3C713000525C5 /* FileUDF.cpp */; };
                F57B6F801071B8B500079ACB /* JobManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F57B6F7E1071B8B500079ACB /* JobManager.cpp */; };
                F57B6F811071B8B500079ACB /* JobManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F57B6F7E1071B8B500079ACB /* JobManager.cpp */; };
                F57E213F0E3C3AB300700C9D /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F57E213E0E3C3AB200700C9D /* libiconv.dylib */; };
                F56A08DF0F4D3C20003F9F87 /* GUITexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUITexture.cpp; sourceTree = "<group>"; };
                F56A08E20F4D3C2E003F9F87 /* GUITextureGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUITextureGL.cpp; sourceTree = "<group>"; };
                F56A08E30F4D3C2E003F9F87 /* GUITextureGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUITextureGL.h; sourceTree = "<group>"; };
+               F57A83E712D3C713000525C5 /* FileUDF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileUDF.h; sourceTree = "<group>"; };
+               F57A83E812D3C713000525C5 /* FileUDF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileUDF.cpp; sourceTree = "<group>"; };
+               F57A83F612D3C764000525C5 /* UDFDirectory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UDFDirectory.h; sourceTree = "<group>"; };
+               F57A83F712D3C764000525C5 /* UDFDirectory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UDFDirectory.cpp; sourceTree = "<group>"; };
+               F57A83FF12D3C775000525C5 /* udf25.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = udf25.h; sourceTree = "<group>"; };
+               F57A840012D3C775000525C5 /* udf25.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = udf25.cpp; sourceTree = "<group>"; };
                F57B6F7E1071B8B500079ACB /* JobManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JobManager.cpp; sourceTree = "<group>"; };
                F57B6F7F1071B8B500079ACB /* JobManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JobManager.h; sourceTree = "<group>"; };
                F57E213E0E3C3AB200700C9D /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = /opt/local/lib/libiconv.dylib; sourceTree = "<absolute>"; };
                                F584E1280F257BD800DB26A5 /* FileSpecialProtocol.h */,
                                E38E16DE0D25F9FA00618676 /* FileTuxBox.cpp */,
                                E38E16DF0D25F9FA00618676 /* FileTuxBox.h */,
+                               F57A83E812D3C713000525C5 /* FileUDF.cpp */,
+                               F57A83E712D3C713000525C5 /* FileUDF.h */,
                                F5DC880E110A4A0B00EE1B15 /* FileXBMSP.cpp */,
                                F5DC880D110A4A0B00EE1B15 /* FileXBMSP.h */,
                                E38E16E20D25F9FA00618676 /* FileZip.cpp */,
                                E38E17560D25F9FA00618676 /* SMBDirectory.h */,
                                E38E17590D25F9FA00618676 /* StackDirectory.cpp */,
                                E38E175A0D25F9FA00618676 /* StackDirectory.h */,
+                               F57A840012D3C775000525C5 /* udf25.cpp */,
+                               F57A83FF12D3C775000525C5 /* udf25.h */,
+                               F57A83F712D3C764000525C5 /* UDFDirectory.cpp */,
+                               F57A83F612D3C764000525C5 /* UDFDirectory.h */,
                                E38E175B0D25F9FA00618676 /* UPnPDirectory.cpp */,
                                E38E175C0D25F9FA00618676 /* UPnPDirectory.h */,
                                F5FAB0750EFABE2C00BAD4AE /* VTPDirectory.cpp */,
                                C8D0B2AF1265A9A800F0C0AC /* SystemGlobals.cpp in Sources */,
                                7CBEBB8412912BA400431822 /* fstrcmp.c in Sources */,
                                184C472F1296BC6E0006DB3E /* Service.cpp in Sources */,
+                               F57A83E912D3C713000525C5 /* FileUDF.cpp in Sources */,
+                               F57A83F812D3C764000525C5 /* UDFDirectory.cpp in Sources */,
+                               F57A840112D3C775000525C5 /* udf25.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                C8D0B2B01265A9A800F0C0AC /* SystemGlobals.cpp in Sources */,
                                7CBEBB8312912BA300431822 /* fstrcmp.c in Sources */,
                                184C47301296BC6E0006DB3E /* Service.cpp in Sources */,
+                               F57A840C12D3C7CD000525C5 /* udf25.cpp in Sources */,
+                               F57A840D12D3C7D5000525C5 /* UDFDirectory.cpp in Sources */,
+                               F57A840E12D3C7E1000525C5 /* FileUDF.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 9b3f96c..81fed4f 100644 (file)
     <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Video\CrystalHD.cpp" />
     <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDInputStreams\DVDInputStreamBluray.cpp" />
     <ClCompile Include="..\..\xbmc\cores\VideoRenderers\VideoShaders\WinVideoFilter.cpp" />
+    <ClCompile Include="..\..\xbmc\FileSystem\FileUDF.cpp" />
+    <ClCompile Include="..\..\xbmc\FileSystem\udf25.cpp" />
+    <ClCompile Include="..\..\xbmc\FileSystem\UDFDirectory.cpp" />
     <ClCompile Include="..\..\xbmc\FileSystem\VideoDatabaseDirectory\DirectoryNodeCountry.cpp" />
     <ClCompile Include="..\..\xbmc\GUIDialogAddonInfo.cpp" />
     <ClCompile Include="..\..\xbmc\GUIDialogTextViewer.cpp" />
     <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Video\CrystalHD.h" />
     <ClInclude Include="..\..\xbmc\cores\dvdplayer\DVDInputStreams\DVDInputStreamBluray.h" />
     <ClInclude Include="..\..\xbmc\cores\VideoRenderers\VideoShaders\WinVideoFilter.h" />
+    <ClInclude Include="..\..\xbmc\FileSystem\FileUDF.h" />
+    <ClInclude Include="..\..\xbmc\FileSystem\udf25.h" />
+    <ClInclude Include="..\..\xbmc\FileSystem\UDFDirectory.h" />
     <ClInclude Include="..\..\xbmc\FileSystem\VideoDatabaseDirectory\DirectoryNodeCountry.h" />
     <ClInclude Include="..\..\xbmc\GUIDialogAddonInfo.h" />
     <ClInclude Include="..\..\xbmc\GUIDialogTextViewer.h" />
index b88ff6a..9858303 100644 (file)
     <ClCompile Include="..\..\xbmc\addons\Service.cpp">
       <Filter>Source Files\Addons</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\xbmc\FileSystem\FileUDF.cpp">
+      <Filter>Source Files\Filesystem</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\xbmc\FileSystem\udf25.cpp">
+      <Filter>Source Files\Filesystem</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\xbmc\FileSystem\UDFDirectory.cpp">
+      <Filter>Source Files\Filesystem</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\xbmc\win32\NetworkWin32.h">
     <ClInclude Include="..\..\xbmc\addons\Service.h">
       <Filter>Source Files\Addons</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\xbmc\FileSystem\FileUDF.h">
+      <Filter>Source Files\Filesystem</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\xbmc\FileSystem\udf25.h">
+      <Filter>Source Files\Filesystem</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\xbmc\FileSystem\UDFDirectory.h">
+      <Filter>Source Files\Filesystem</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\xbmc\win32\XBMC.ico">
index 580e198..5fbf33a 100644 (file)
 CDVDInputStream* CDVDFactoryInputStream::CreateInputStream(IDVDPlayer* pPlayer, const std::string& file, const std::string& content)
 {
   CFileItem item(file.c_str(), false);
-  if (item.IsDVDFile(false, true) || item.IsDVDImage() ||
+  if (content != "bluray/iso" && (item.IsDVDFile(false, true) || item.IsDVDImage() ||
 #ifdef HAS_DVD_DRIVE
-    file.compare(g_mediaManager.TranslateDevicePath("")) == 0 )
+    file.compare(g_mediaManager.TranslateDevicePath("")) == 0 ))
 #else
-  0 )
+  0 ))
 #endif
   {
     return (new CDVDInputStreamNavigator(pPlayer));
   }
 #ifdef HAVE_LIBBLURAY
-  else if (item.IsType(".bdmv") || item.IsType(".mpls"))
+  else if (item.IsType(".bdmv") || item.IsType(".mpls") || content == "bluray/iso")
     return new CDVDInputStreamBluray();
 #endif
   else if(file.substr(0, 6) == "rtp://"
index 6891330..76e547f 100644 (file)
@@ -127,6 +127,22 @@ class DllLibbluray : public DllDynamic, DllLibblurayInterface
 using namespace std;
 using namespace XFILE;
 
+static bool is_udf_iso_path(const char* filename)
+{
+  bool bResult = false;
+
+  const char* ptr = strcasestr(filename, ".iso");
+  if(ptr)
+  {
+    ptr += strlen(".iso");
+    if(*ptr == '/' && strlen(++ptr) > 0)
+    {
+      bResult = true;
+    }
+  }
+  return bResult;
+}
+
 static void file_close(BD_FILE_H *file)
 {
   if (file)
@@ -170,7 +186,19 @@ static BD_FILE_H *file_open(const char* filename, const char *mode)
 {
     BD_FILE_H *file = new BD_FILE_H;
 
-    CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - Opening file %s... (%p)", filename, file);
+    CStdString strFilename(filename);
+
+    if(is_udf_iso_path(filename))
+    {
+      CUtil::URLEncode(strFilename);
+      strFilename.Format("udf://%s", strFilename);
+      CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - Opening file udf iso file %s... (%p)", strFilename.c_str(), file);
+    }
+    else
+    {
+      CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - Opening file %s... (%p)", strFilename.c_str(), file);
+    }
+
     file->close = file_close;
     file->seek  = file_seek;
     file->read  = file_read;
@@ -179,7 +207,7 @@ static BD_FILE_H *file_open(const char* filename, const char *mode)
     file->eof   = file_eof;
 
     CFile* fp = new CFile();
-    if(fp->Open(filename))
+    if(fp->Open(strFilename))
     {
       file->internal = (void*)fp;
       return file;
@@ -195,7 +223,7 @@ static BD_FILE_H *file_open(const char* filename, const char *mode)
 
 struct SDirState
 {
-  SDirState() 
+  SDirState()
     : curr(0)
   {}
 
@@ -231,11 +259,17 @@ static int dir_read(BD_DIR_H *dir, BD_DIRENT *entry)
 static BD_DIR_H *dir_open(const char* dirname)
 {
     CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - Opening dir %s\n", dirname);
-
-
     SDirState *st = new SDirState();
 
-    if(!CDirectory::GetDirectory(dirname, st->list))
+    CStdString strDirname(dirname);
+    if(is_udf_iso_path(dirname))
+    {
+      CUtil::URLEncode(strDirname);
+      strDirname.Format("udf://%s", strDirname);
+      CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - Opening udf dir %s...", strDirname.c_str());
+    }
+
+    if(!CDirectory::GetDirectory(strDirname, st->list))
     {
       CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - Error opening dir! (%s)\n", dirname);
       delete st;
@@ -348,7 +382,7 @@ bool CDVDInputStreamBluray::Open(const char* strFile, const std::string& content
         t = m_dll->bd_get_title_info(m_bd, i);;
         if(!t)
         {
-          CLog::Log(LOGDEBUG, "get_playlist_title - unable to get title %d", i);        
+          CLog::Log(LOGDEBUG, "get_playlist_title - unable to get title %d", i);
           continue;
         }
         if(t->playlist == playlist)
@@ -466,12 +500,12 @@ __int64 CDVDInputStreamBluray::Seek(__int64 offset, int whence)
   int64_t pos = m_dll->bd_seek(m_bd, offset);
   if(pos < 0)
   {
-    CLog::Log(LOGERROR, "CDVDInputStreamBluray::Seek - seek to %"PRId64", failed with %"PRId64, offset, pos); 
+    CLog::Log(LOGERROR, "CDVDInputStreamBluray::Seek - seek to %"PRId64", failed with %"PRId64, offset, pos);
     return -1;
   }
 
   if(pos != offset)
-    CLog::Log(LOGWARNING, "CDVDInputStreamBluray::Seek - seek to %"PRId64", ended at %"PRId64, offset, pos); 
+    CLog::Log(LOGWARNING, "CDVDInputStreamBluray::Seek - seek to %"PRId64", ended at %"PRId64, offset, pos);
 
   return offset;
 #else
index fe701db..c44772e 100644 (file)
@@ -426,7 +426,7 @@ bool CDVDPlayer::OpenInputStream()
   {
     m_filename = g_mediaManager.TranslateDevicePath("");
   }
-
+retry:
   m_pInputStream = CDVDFactoryInputStream::CreateInputStream(this, m_filename, m_mimetype);
   if(m_pInputStream == NULL)
   {
@@ -438,6 +438,19 @@ bool CDVDPlayer::OpenInputStream()
 
   if (!m_pInputStream->Open(m_filename.c_str(), m_mimetype))
   {
+      if(m_pInputStream->IsStreamType(DVDSTREAM_TYPE_DVD))
+      {
+        CLog::Log(LOGERROR, "CDVDPlayer::OpenInputStream - failed to open [%s] as DVD ISO, trying Bluray", m_filename.c_str());
+        m_mimetype = "bluray/iso";
+        filename = m_filename;
+        filename = filename + "/BDMV/index.bdmv";
+        int title = m_item.GetPropertyInt("BlurayStartingTitle");
+        if( title )
+          filename.AppendFormat("?title=%d",title);
+        
+        m_filename = filename;
+        goto retry;
+      }
     CLog::Log(LOGERROR, "CDVDPlayer::OpenInputStream - error opening [%s]", m_filename.c_str());
     return false;
   }
index 93fc554..34ac53d 100644 (file)
@@ -42,6 +42,9 @@ typedef unsigned long ThreadIdentifier;
 #ifndef strcasecmp
 #define strcasecmp strcmpi
 #endif
+#ifndef strncasecmp
+#define strncasecmp strnicmp
+#endif
 
 #define INT16_MAX SHRT_MAX
 #define INT16_MIN SHRT_MIN
@@ -89,6 +92,7 @@ typedef unsigned long ThreadIdentifier;
 
 extern "C" char * strptime(const char *buf, const char *fmt, struct tm *tm);
 extern "C" int strverscmp (const char *s1, const char *s2);
+extern "C" char * strcasestr(const char* haystack, const char* needle);
 
 #endif // _WIN32
 
index d707470..94591f0 100644 (file)
@@ -1420,3 +1420,29 @@ void CWinIdleTimer::StartZero()
   SetThreadExecutionState(ES_SYSTEM_REQUIRED);
   CStopWatch::StartZero();
 }
+
+extern "C"
+{
+  /* case-independent string matching, similar to strstr but
+  * matching */
+  char * strcasestr(const char* haystack, const char* needle) 
+  {
+    int i;
+    int nlength = (int) strlen (needle);
+    int hlength = (int) strlen (haystack);
+
+    if (nlength > hlength) return NULL;
+    if (hlength <= 0) return NULL;
+    if (nlength <= 0) return (char *)haystack;
+    /* hlength and nlength > 0, nlength <= hlength */
+    for (i = 0; i <= (hlength - nlength); i++) 
+    {
+      if (strncasecmp (haystack + i, needle, nlength) == 0) 
+      {
+        return (char *)haystack + i;
+      }
+    }
+    /* substring not found */
+    return NULL;
+  }
+}