Skip to content
This repository
Browse code

Merge pull request #1764 from elupus/udffolder

fixed: bluray iso playback selection dialog
  • Loading branch information...
commit bd0e2f5b436b08fbe07244e6a3f5958a02a67cd4 2 parents 7277a3a + e591cc2
Joakim Plate authored November 15, 2012
27  xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp
@@ -39,22 +39,6 @@
39 39
 using namespace std;
40 40
 using namespace XFILE;
41 41
 
42  
-static bool is_udf_iso_path(const char* filename)
43  
-{
44  
-  bool bResult = false;
45  
-
46  
-  const char* ptr = strcasestr(filename, ".iso");
47  
-  if(ptr)
48  
-  {
49  
-    ptr += strlen(".iso");
50  
-    if(*ptr == '/' && strlen(++ptr) > 0)
51  
-    {
52  
-      bResult = true;
53  
-    }
54  
-  }
55  
-  return bResult;
56  
-}
57  
-
58 42
 void DllLibbluray::file_close(BD_FILE_H *file)
59 43
 {
60 44
   if (file)
@@ -99,8 +83,9 @@ BD_FILE_H * DllLibbluray::file_open(const char* filename, const char *mode)
99 83
     BD_FILE_H *file = new BD_FILE_H;
100 84
 
101 85
     CStdString strFilename(filename);
102  
-
103  
-    if(is_udf_iso_path(filename))
  86
+    CStdString strExtension(URIUtils::GetExtension(filename));
  87
+    if(strExtension == ".iso"
  88
+    || strExtension == ".img")
104 89
     {
105 90
       CURL::Encode(strFilename);
106 91
       strFilename.Format("udf://%s", strFilename);
@@ -174,12 +159,6 @@ BD_DIR_H *DllLibbluray::dir_open(const char* dirname)
174 159
     SDirState *st = new SDirState();
175 160
 
176 161
     CStdString strDirname(dirname);
177  
-    if(is_udf_iso_path(dirname))
178  
-    {
179  
-      CURL::Encode(strDirname);
180  
-      strDirname.Format("udf://%s", strDirname);
181  
-      CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - Opening udf dir %s...", strDirname.c_str());
182  
-    }
183 162
 
184 163
     if(!CDirectory::GetDirectory(strDirname, st->list))
185 164
     {
33  xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
@@ -26,6 +26,7 @@
26 26
 #include "LangInfo.h"
27 27
 #include "utils/log.h"
28 28
 #include "guilib/Geometry.h"
  29
+#include "URIUtils.h"
29 30
 #if defined(TARGET_DARWIN)
30 31
 #include "osx/CocoaInterface.h"
31 32
 #endif
@@ -63,7 +64,6 @@ CDVDInputStreamNavigator::~CDVDInputStreamNavigator()
63 64
 
64 65
 bool CDVDInputStreamNavigator::Open(const char* strFile, const std::string& content)
65 66
 {
66  
-  char* strDVDFile;
67 67
   m_icurrentGroupId = 0;
68 68
   if (!CDVDInputStream::Open(strFile, "video/x-dvd-mpeg"))
69 69
     return false;
@@ -78,38 +78,29 @@ bool CDVDInputStreamNavigator::Open(const char* strFile, const std::string& cont
78 78
   // libdvdcss fails if the file path contains VIDEO_TS.IFO or VIDEO_TS/VIDEO_TS.IFO
79 79
   // libdvdnav is still able to play without, so strip them.
80 80
 
81  
-  // stripping only works 100% correctly for absolute paths.
82  
-  // relative paths are not expected here and wouldn't make sense, so it's safe to assume we'll have
83  
-  // at least one path separator character.
84  
-
85  
-  strDVDFile = strdup(strFile);
86  
-  int len = strlen(strDVDFile);
87  
-
88  
-  if(len >= 13  // +1 on purpose, to include a separator char before the searched string
89  
-  && strncasecmp(strDVDFile + len - 12, "VIDEO_TS.IFO", 12) == 0)
90  
-    strDVDFile[len - 13] = '\0';
91  
-
92  
-  len = strlen(strDVDFile);
93  
-  if(len >= 9  // +1 on purpose, to include a separator char before the searched string
94  
-  && strncasecmp(strDVDFile + len - 8, "VIDEO_TS", 8) == 0)
95  
-    strDVDFile[len - 9] = '\0';
  81
+  CStdString path = strFile;
  82
+  if(URIUtils::GetFileName(path) == "VIDEO_TS.IFO")
  83
+    path = URIUtils::GetParentPath(path);
  84
+  URIUtils::RemoveSlashAtEnd(path);
  85
+  if(URIUtils::GetFileName(path) == "VIDEO_TS")
  86
+    path = URIUtils::GetParentPath(path);
  87
+  URIUtils::RemoveSlashAtEnd(path);
96 88
 
97 89
 #if defined(TARGET_DARWIN_OSX)
98 90
   // if physical DVDs, libdvdnav wants "/dev/rdiskN" device name for OSX,
99 91
   // strDVDFile will get realloc'ed and replaced IF this is a physical DVD.
100  
-  strDVDFile = Cocoa_MountPoint2DeviceName(strDVDFile);
  92
+  char* strDVDFile = Cocoa_MountPoint2DeviceName(strdup(path.c_str()));
  93
+  path = strDVDFile;
  94
+  free(strDVDFile);
101 95
 #endif
102 96
 
103 97
   // open up the DVD device
104  
-  if (m_dll.dvdnav_open(&m_dvdnav, strDVDFile) != DVDNAV_STATUS_OK)
  98
+  if (m_dll.dvdnav_open(&m_dvdnav, path.c_str()) != DVDNAV_STATUS_OK)
105 99
   {
106  
-    free(strDVDFile);
107  
-
108 100
     CLog::Log(LOGERROR,"Error on dvdnav_open\n");
109 101
     Close();
110 102
     return false;
111 103
   }
112  
-  free(strDVDFile);
113 104
 
114 105
   int region = g_guiSettings.GetInt("dvds.playerregion");
115 106
   int mask = 0;
24  xbmc/filesystem/UDFDirectory.cpp
@@ -38,16 +38,26 @@ CUDFDirectory::~CUDFDirectory(void)
38 38
 bool CUDFDirectory::GetDirectory(const CStdString& strPath,
39 39
                                  CFileItemList &items)
40 40
 {
41  
-  CStdString strRoot = strPath;
42  
-  URIUtils::AddSlashAtEnd(strRoot);
43  
-
44  
-  CURL url(strPath);
  41
+  CStdString strRoot, strSub;
  42
+  CURL url;
  43
+  if(strPath.Left(6) == "udf://")
  44
+  {
  45
+    url.Parse(strPath);
  46
+    CURL url(strPath);
  47
+  }
  48
+  else
  49
+  {
  50
+    url.SetProtocol("udf");
  51
+    url.SetHostName(strPath);
  52
+  }
  53
+  strRoot  = url.Get();
  54
+  strSub   = url.GetFileName();
45 55
 
46  
-  CStdString strDirectory = url.GetHostName();
47  
-  CURL::Decode(strDirectory);
  56
+  URIUtils::AddSlashAtEnd(strRoot);
  57
+  URIUtils::AddSlashAtEnd(strSub);
48 58
 
49 59
   udf25 udfIsoReader;
50  
-  udf_dir_t *dirp = udfIsoReader.OpenDir(strDirectory);
  60
+  udf_dir_t *dirp = udfIsoReader.OpenDir(url.GetHostName(), strSub);
51 61
 
52 62
   if (dirp == NULL)
53 63
     return false;
23  xbmc/filesystem/UDFFile.cpp
@@ -48,11 +48,7 @@ CUDFFile::~CUDFFile()
48 48
 //*********************************************************************************************
49 49
 bool CUDFFile::Open(const CURL& url)
50 50
 {
51  
-  CStdString strFName = url.GetHostName();
52  
-
53  
-  CURL::Decode(strFName);
54  
-
55  
-  m_hFile = m_udfIsoReaderLocal.OpenFile((char*)strFName.c_str());
  51
+  m_hFile = m_udfIsoReaderLocal.OpenFile(url.GetHostName(), url.GetFileName());
56 52
   if (m_hFile == INVALID_HANDLE_VALUE)
57 53
   {
58 54
     m_bOpened = false;
@@ -106,29 +102,18 @@ int64_t CUDFFile::GetPosition()
106 102
 
107 103
 bool CUDFFile::Exists(const CURL& url)
108 104
 {
109  
-  string strFName = "\\";
110  
-  strFName += url.GetFileName();
111  
-  for (int i = 0; i < (int)strFName.size(); ++i )
112  
-  {
113  
-    if (strFName[i] == '/') strFName[i] = '\\';
114  
-  }
115  
-  m_hFile = m_udfIsoReaderLocal.OpenFile((char*)strFName.c_str());
  105
+  m_hFile = m_udfIsoReaderLocal.OpenFile(url.GetHostName(), url.GetFileName());
116 106
   if (m_hFile == INVALID_HANDLE_VALUE)
117 107
     return false;
118 108
 
119 109
   m_udfIsoReaderLocal.CloseFile(m_hFile);
  110
+  m_hFile = INVALID_HANDLE_VALUE;
120 111
   return true;
121 112
 }
122 113
 
123 114
 int CUDFFile::Stat(const CURL& url, struct __stat64* buffer)
124 115
 {
125  
-  string strFName = "\\";
126  
-  strFName += url.GetFileName();
127  
-  for (int i = 0; i < (int)strFName.size(); ++i )
128  
-  {
129  
-    if (strFName[i] == '/') strFName[i] = '\\';
130  
-  }
131  
-  m_hFile = m_udfIsoReaderLocal.OpenFile((char*)strFName.c_str());
  116
+  m_hFile = m_udfIsoReaderLocal.OpenFile(url.GetHostName(), url.GetFileName());
132 117
   if (m_hFile != INVALID_HANDLE_VALUE)
133 118
   {
134 119
     buffer->st_size = m_udfIsoReaderLocal.GetFileSize(m_hFile);
32  xbmc/filesystem/udf25.cpp
@@ -464,28 +464,6 @@ uint64_t DVDFileSeekForce(BD_FILE bdfile, uint64_t offset, int64_t force_size)
464 464
   return offset;
465 465
 }
466 466
 
467  
-int UDFSplitIsoFile(const char *fullFilename, char* iso, char* file)
468  
-{
469  
-  const char* filename = strcasestr(fullFilename, ".iso");
470  
-  if(!filename)
471  
-    return -1;
472  
-
473  
-  filename += strlen(".iso");
474  
-  if(*filename != '/')
475  
-    return -1;
476  
-
477  
-  size_t size = strlen(filename);
478  
-  memcpy(file, filename, size);
479  
-  file[size] = 0;
480  
-
481  
-  size = filename - fullFilename;
482  
-  memcpy(iso, fullFilename,  filename - fullFilename);
483  
-  iso[size] = 0;
484  
-
485  
-  return 0;
486  
-}
487  
-
488  
-
489 467
 int udf25::UDFScanDirX( udf_dir_t *dirp )
490 468
 {
491 469
   char filename[ MAX_UDF_FILE_NAME_LEN ];
@@ -1190,15 +1168,11 @@ UDF_FILE udf25::UDFFindFile( const char* filename, uint64_t *filesize )
1190 1168
   return result;
1191 1169
 }
1192 1170
 
1193  
-HANDLE udf25::OpenFile( const char* fullFilename )
  1171
+HANDLE udf25::OpenFile( const char* isoname, const char* filename )
1194 1172
 {
1195 1173
   uint64_t filesize;
1196 1174
   UDF_FILE file = NULL;
1197 1175
   BD_FILE bdfile = NULL;
1198  
-  char isoname[256], filename[256];
1199  
-
1200  
-  if(UDFSplitIsoFile(fullFilename, isoname, filename) !=0 )
1201  
-    return INVALID_HANDLE_VALUE;
1202 1176
 
1203 1177
   m_fp = file_open(isoname);
1204 1178
   if(m_fp)
@@ -1338,12 +1312,12 @@ int64_t udf25::GetFilePosition(HANDLE hFile)
1338 1312
   return bdfile->seek_pos;
1339 1313
 }
1340 1314
 
1341  
-udf_dir_t *udf25::OpenDir( const char *subdir )
  1315
+udf_dir_t *udf25::OpenDir(  const char *isofile, const char *subdir )
1342 1316
 {
1343 1317
   udf_dir_t *result;
1344 1318
   BD_FILE bd_file;
1345 1319
 
1346  
-  bd_file = (BD_FILE)OpenFile(subdir);
  1320
+  bd_file = (BD_FILE)OpenFile(isofile, subdir);
1347 1321
 
1348 1322
   if (bd_file == (BD_FILE)INVALID_HANDLE_VALUE)
1349 1323
   {
4  xbmc/filesystem/udf25.h
@@ -183,11 +183,11 @@ class udf25
183 183
   int64_t GetFileSize(HANDLE hFile);
184 184
   int64_t GetFilePosition(HANDLE hFile);
185 185
   int64_t Seek(HANDLE hFile, int64_t lOffset, int whence);
186  
-  HANDLE OpenFile( const char* filename );
  186
+  HANDLE OpenFile(  const char *isofile, const char* filename );
187 187
   long ReadFile(HANDLE fd, unsigned char *pBuffer, long lSize);
188 188
   void CloseFile(HANDLE hFile);
189 189
 
190  
-  udf_dir_t *OpenDir( const char *subdir );
  190
+  udf_dir_t *OpenDir( const char *isofile, const char *subdir );
191 191
   udf_dirent_t *ReadDir( udf_dir_t *dirp );
192 192
   int CloseDir( udf_dir_t *dirp );
193 193
 
3  xbmc/utils/URIUtils.cpp
@@ -231,7 +231,8 @@ bool URIUtils::ProtocolHasParentInHostname(const CStdString& prot)
231 231
 {
232 232
   return prot.Equals("zip")
233 233
       || prot.Equals("rar")
234  
-      || prot.Equals("bluray");
  234
+      || prot.Equals("bluray")
  235
+      || prot.Equals("udf");
235 236
 }
236 237
 
237 238
 bool URIUtils::ProtocolHasEncodedHostname(const CStdString& prot)
17  xbmc/video/windows/GUIWindowVideoBase.cpp
@@ -72,6 +72,7 @@
72 72
 #include "utils/EdenVideoArtUpdater.h"
73 73
 #include "GUIInfoManager.h"
74 74
 #include "utils/GroupUtils.h"
  75
+#include "File.h"
75 76
 
76 77
 using namespace std;
77 78
 using namespace XFILE;
@@ -1073,6 +1074,22 @@ bool CGUIWindowVideoBase::ShowPlaySelection(CFileItemPtr& item)
1073 1074
     }
1074 1075
   }
1075 1076
 
  1077
+  CStdString ext = URIUtils::GetExtension(item->GetPath());
  1078
+  ext.ToLower();
  1079
+  if (ext == ".iso" ||  ext == ".img")
  1080
+  {
  1081
+    CURL url2("udf://");
  1082
+    url2.SetHostName(item->GetPath());
  1083
+    url2.SetFileName("BDMV/index.bdmv");
  1084
+    if (CFile::Exists(url2.Get()))
  1085
+    {
  1086
+      url2.SetFileName("");
  1087
+
  1088
+      CURL url("bluray://");
  1089
+      url.SetHostName(url2.Get());
  1090
+      return ShowPlaySelection(item, url.Get());
  1091
+    }
  1092
+  }
1076 1093
   return true;
1077 1094
 }
1078 1095
 

1 note on commit bd0e2f5

Sascha Montellese
Collaborator

Please get your include paths straight next time (see c606dbf). Thanks :-)

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