Skip to content
Browse files

[bluray] Add directory class listing all titles on disk/image

  • Loading branch information...
1 parent c852c0d commit a04efb7f56ceee95f9242c6b6e8194f87c21b154 @elupus committed
View
2 project/VS2010Express/XBMC.vcxproj
@@ -346,6 +346,7 @@
<ClCompile Include="..\..\xbmc\filesystem\AFPDirectory.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\AFPFile.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\ASAPFileDirectory.cpp" />
+ <ClCompile Include="..\..\xbmc\filesystem\BlurayDirectory.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\CacheStrategy.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\CDDADirectory.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\CDDAFile.cpp" />
@@ -907,6 +908,7 @@
<ClInclude Include="..\..\xbmc\filesystem\AFPDirectory.h" />
<ClInclude Include="..\..\xbmc\filesystem\AFPFile.h" />
<ClInclude Include="..\..\xbmc\filesystem\ASAPFileDirectory.h" />
+ <ClInclude Include="..\..\xbmc\filesystem\BlurayDirectory.h" />
<ClInclude Include="..\..\xbmc\filesystem\CacheStrategy.h" />
<ClInclude Include="..\..\xbmc\filesystem\CDDADirectory.h" />
<ClInclude Include="..\..\xbmc\filesystem\CDDAFile.h" />
View
6 project/VS2010Express/XBMC.vcxproj.filters
@@ -2345,6 +2345,9 @@
<ClCompile Include="..\..\xbmc\filesystem\ASAPFileDirectory.cpp">
<Filter>filesystem</Filter>
</ClCompile>
+ <ClCompile Include="..\..\xbmc\filesystem\BlurayDirectory.cpp">
+ <Filter>filesystem</Filter>
+ </ClCompile>
<ClCompile Include="..\..\xbmc\filesystem\CacheStrategy.cpp">
<Filter>filesystem</Filter>
</ClCompile>
@@ -5206,6 +5209,9 @@
<ClInclude Include="..\..\xbmc\filesystem\FileCache.h">
<Filter>filesystem</Filter>
</ClInclude>
+ <ClInclude Include="..\..\xbmc\filesystem\BlurayDirectory.h">
+ <Filter>filesystem</Filter>
+ </ClInclude>
<ClInclude Include="..\..\xbmc\utils\Base64.h">
<Filter>utils</Filter>
</ClInclude>
View
2 xbmc/FileItem.cpp
@@ -2859,6 +2859,7 @@ CStdString CFileItem::GetLocalFanart() const
// no local fanart available for these
if (IsInternetStream()
|| URIUtils::IsUPnP(strFile)
+ || URIUtils::IsBluray(strFile)
|| IsLiveTV()
|| IsPlugin()
|| IsAddonsPath()
@@ -3119,6 +3120,7 @@ CStdString CFileItem::FindTrailer() const
// no local trailer available for these
if (IsInternetStream()
|| URIUtils::IsUPnP(strFile)
+ || URIUtils::IsBluray(strFile)
|| IsLiveTV()
|| IsPlugin()
|| IsDVD())
View
1 xbmc/Util.cpp
@@ -1258,6 +1258,7 @@ CStdString CUtil::ValidatePath(const CStdString &path, bool bFixDoubleSlashes /*
path.Left(4).Equals("zip:") ||
path.Left(4).Equals("rar:") ||
path.Left(6).Equals("stack:") ||
+ path.Left(7).Equals("bluray:") ||
path.Left(10).Equals("multipath:") ))
return result;
View
2 xbmc/cores/dvdplayer/DVDInputStreams/DVDFactoryInputStream.cpp
@@ -53,7 +53,7 @@ CDVDInputStream* CDVDFactoryInputStream::CreateInputStream(IDVDPlayer* pPlayer,
return (new CDVDInputStreamNavigator(pPlayer));
}
#ifdef HAVE_LIBBLURAY
- else if (item.IsType(".bdmv") || item.IsType(".mpls") || content == "bluray/iso")
+ else if (item.IsType(".bdmv") || item.IsType(".mpls") || content == "bluray/iso" || file.substr(0, 7) == "bluray:")
return new CDVDInputStreamBluray(pPlayer);
#endif
else if(file.substr(0, 6) == "rtp://"
View
38 xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp
@@ -273,20 +273,34 @@ bool CDVDInputStreamBluray::Open(const char* strFile, const std::string& content
if(m_player == NULL)
return false;
- CStdString strPath;
- URIUtils::GetDirectory(strFile,strPath);
- URIUtils::RemoveSlashAtEnd(strPath);
+ CStdString strPath(strFile);
+ CStdString filename;
+ CStdString root;
- if(URIUtils::GetFileName(strPath) == "PLAYLIST")
+ if(strPath.Left(7).Equals("bluray:"))
{
- URIUtils::GetDirectory(strPath,strPath);
- URIUtils::RemoveSlashAtEnd(strPath);
+ CURL url(strPath);
+ root = url.GetHostName();
+ filename = URIUtils::GetFileName(url.GetFileName());
}
-
- if(URIUtils::GetFileName(strPath) == "BDMV")
+ else
{
URIUtils::GetDirectory(strPath,strPath);
URIUtils::RemoveSlashAtEnd(strPath);
+
+ if(URIUtils::GetFileName(strPath) == "PLAYLIST")
+ {
+ URIUtils::GetDirectory(strPath,strPath);
+ URIUtils::RemoveSlashAtEnd(strPath);
+ }
+
+ if(URIUtils::GetFileName(strPath) == "BDMV")
+ {
+ URIUtils::GetDirectory(strPath,strPath);
+ URIUtils::RemoveSlashAtEnd(strPath);
+ }
+ root = strPath;
+ filename = URIUtils::GetFileName(strFile);
}
if (!m_dll)
@@ -297,12 +311,12 @@ bool CDVDInputStreamBluray::Open(const char* strFile, const std::string& content
m_dll->bd_set_debug_handler(DllLibbluray::bluray_logger);
m_dll->bd_set_debug_mask(DBG_CRIT | DBG_BLURAY | DBG_NAV);
- CLog::Log(LOGDEBUG, "CDVDInputStreamBluray::Open - opening %s", strPath.c_str());
- m_bd = m_dll->bd_open(strPath.c_str(), NULL);
+ CLog::Log(LOGDEBUG, "CDVDInputStreamBluray::Open - opening %s", root.c_str());
+ m_bd = m_dll->bd_open(root.c_str(), NULL);
if(!m_bd)
{
- CLog::Log(LOGERROR, "CDVDInputStreamBluray::Open - failed to open %s", strPath.c_str());
+ CLog::Log(LOGERROR, "CDVDInputStreamBluray::Open - failed to open %s", root.c_str());
return false;
}
@@ -345,8 +359,6 @@ bool CDVDInputStreamBluray::Open(const char* strFile, const std::string& content
return false;
}
-
- CStdString filename = URIUtils::GetFileName(strFile);
if(filename.Equals("index.bdmv"))
{
m_navmode = false;
View
184 xbmc/filesystem/BlurayDirectory.cpp
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 2005-2008 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "BlurayDirectory.h"
+#include "utils/log.h"
+#include "utils/URIUtils.h"
+#include "URL.h"
+#include "DllLibbluray.h"
+#include "FileItem.h"
+#include "video/VideoInfoTag.h"
+
+namespace XFILE
+{
+
+#define MAIN_TITLE_LENGTH_PERCENT 70 /** Minumum length of main titles, based on longest title */
+
+CBlurayDirectory::CBlurayDirectory()
+ : m_dll(NULL)
+ , m_bd(NULL)
+{
+}
+
+CBlurayDirectory::~CBlurayDirectory()
+{
+ Dispose();
+}
+
+void CBlurayDirectory::Dispose()
+{
+ if(m_bd)
+ {
+ m_dll->bd_close(m_bd);
+ m_bd = NULL;
+ }
+ delete m_dll;
+ m_dll = NULL;
+}
+
+CFileItemPtr CBlurayDirectory::GetTitle(const BLURAY_TITLE_INFO* title, const CStdString& label)
+{
+ CStdString buf;
+ CFileItemPtr item(new CFileItem("", false));
+ CURL path(m_url);
+ buf.Format("BDMV/PLAYLIST/%05d.mpls", title->playlist);
+ path.SetFileName(buf);
+ item->SetPath(path.Get());
+ item->GetVideoInfoTag()->m_strRuntime.Format("%d",title->duration / 90000);
+ item->GetVideoInfoTag()->m_iTrack = title->playlist;
+ buf.Format("%s %d", label.c_str(), title->playlist);
+ item->m_strTitle = buf;
+ item->SetLabel(buf);
+ item->m_dwSize = 0;
+ item->SetIconImage("DefaultVideo.png");
+ for(unsigned int i = 0; i < title->clip_count; ++i)
+ item->m_dwSize += title->clips[i].pkt_count * 192;
+
+ return item;
+}
+
+void CBlurayDirectory::GetTitles(bool main, CFileItemList &items)
+{
+ unsigned titles = m_dll->bd_get_titles(m_bd, TITLES_RELEVANT, 0);
+ CStdString buf;
+
+ std::vector<BLURAY_TITLE_INFO*> buffer;
+
+ uint64_t duration = 0;
+
+ for(unsigned i=0; i < titles; i++)
+ {
+ BLURAY_TITLE_INFO *t = m_dll->bd_get_title_info(m_bd, i, 0);
+ if(!t)
+ {
+ CLog::Log(LOGDEBUG, "CBlurayDirectory - unable to get title %d", i);
+ continue;
+ }
+ if(t->duration > duration)
+ duration = t->duration;
+
+ buffer.push_back(t);
+ }
+
+ if(main)
+ duration = duration * MAIN_TITLE_LENGTH_PERCENT / 100;
+ else
+ duration = 0;
+
+ for(std::vector<BLURAY_TITLE_INFO*>::iterator it = buffer.begin(); it != buffer.end(); ++it)
+ {
+ if((*it)->duration < duration)
+ continue;
+ items.Add(GetTitle(*it, main ? "Main Title" : "Title"));
+ }
+
+
+ for(std::vector<BLURAY_TITLE_INFO*>::iterator it = buffer.begin(); it != buffer.end(); ++it)
+ m_dll->bd_free_title_info(*it);
+}
+
+void CBlurayDirectory::GetRoot(CFileItemList &items)
+{
+ GetTitles(true, items);
+
+ CURL path(m_url);
+ CFileItemPtr item;
+
+ path.SetFileName(URIUtils::AddFileToFolder(m_url.GetFileName(), "titles"));
+ item.reset(new CFileItem());
+ item->SetPath(path.Get());
+ item->m_bIsFolder = true;
+ item->SetLabel("All Titles");
+ item->SetIconImage("DefaultVideoPlaylists.png");
+ items.Add(item);
+
+ path.SetFileName("BDMV/MovieObject.bdmv");
+ item.reset(new CFileItem());
+ item->SetPath(path.Get());
+ item->m_bIsFolder = false;
+ item->SetLabel("Menus");
+ item->SetIconImage("DefaultProgram.png");
+ items.Add(item);
+}
+
+bool CBlurayDirectory::GetDirectory(const CStdString& path, CFileItemList &items)
+{
+ Dispose();
+ m_url.Parse(path);
+ CStdString root = m_url.GetHostName();
+ CStdString file = m_url.GetFileName();
+ URIUtils::RemoveSlashAtEnd(file);
+
+ m_dll = new DllLibbluray();
+ if (!m_dll->Load())
+ {
+ CLog::Log(LOGERROR, "CBlurayDirectory::GetDirectory - failed to load dll");
+ return false;
+ }
+
+ m_dll->bd_register_dir(DllLibbluray::dir_open);
+ m_dll->bd_register_file(DllLibbluray::file_open);
+ m_dll->bd_set_debug_handler(DllLibbluray::bluray_logger);
+ m_dll->bd_set_debug_mask(DBG_CRIT | DBG_BLURAY | DBG_NAV);
+
+ m_bd = m_dll->bd_open(root.c_str(), NULL);
+
+ if(!m_bd)
+ {
+ CLog::Log(LOGERROR, "CBlurayDirectory::GetDirectory - failed to open %s", root.c_str());
+ return false;
+ }
+
+ if(file == "")
+ GetRoot(items);
+ else if(file == "titles")
+ GetTitles(false, items);
+ else
+ return false;
+
+ items.AddSortMethod(SORT_METHOD_TRACKNUM , 554, LABEL_MASKS("%L", "%D", "%L", "")); // FileName, Duration | Foldername, empty
+ items.AddSortMethod(SORT_METHOD_SIZE , 553, LABEL_MASKS("%L", "%I", "%L", "%I")); // FileName, Size | Foldername, Size
+
+ return true;
+}
+
+
+} /* namespace XFILE */
View
53 xbmc/filesystem/BlurayDirectory.h
@@ -0,0 +1,53 @@
+#pragma once
+
+/*
+ * Copyright (C) 2005-2008 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "Directory.h"
+#include "FileItem.h"
+#include "URL.h"
+
+class DllLibbluray;
+typedef struct bluray BLURAY;
+typedef struct bd_title_info BLURAY_TITLE_INFO;
+
+namespace XFILE
+{
+
+class CBlurayDirectory: public XFILE::IDirectory
+{
+public:
+ CBlurayDirectory();
+ virtual ~CBlurayDirectory();
+ virtual bool GetDirectory(const CStdString& path, CFileItemList &items);
+
+private:
+
+ void Dispose();
+ void GetRoot (CFileItemList &items);
+ void GetTitles(bool main, CFileItemList &items);
+ CFileItemPtr GetTitle(const BLURAY_TITLE_INFO* title, const CStdString& label);
+ CURL m_url;
+ DllLibbluray* m_dll;
+ BLURAY* m_bd;
+};
+
+}
View
6 xbmc/filesystem/DirectoryFactory.cpp
@@ -100,6 +100,9 @@
#ifdef HAS_FILESYSTEM_AFP
#include "AFPDirectory.h"
#endif
+#ifdef HAVE_LIBBLURAY
+#include "BlurayDirectory.h"
+#endif
using namespace XFILE;
@@ -198,6 +201,9 @@ IDirectory* CDirectoryFactory::Create(const CStdString& strPath)
#ifdef HAS_FILESYSTEM_AFP
if (strProtocol == "afp") return new CAFPDirectory();
#endif
+#ifdef HAVE_LIBBLURAY
+ if (strProtocol == "bluray") return new CBlurayDirectory();
+#endif
}
CLog::Log(LOGWARNING, "%s - Unsupported protocol(%s) in %s", __FUNCTION__, strProtocol.c_str(), url.Get().c_str() );
View
4 xbmc/filesystem/Makefile.in
@@ -112,6 +112,10 @@ SRCS+=AFPFile.cpp
SRCS+=AFPDirectory.cpp
endif
+ifeq (@HAVE_LIBBLURAY@,1)
+SRCS+=BlurayDirectory.cpp
+endif
+
INCLUDES+=-I@abs_top_srcdir@/lib/libUPnP/Platinum/Source/Core \
-I@abs_top_srcdir@/lib/libUPnP/Platinum/Source/Platinum \
-I@abs_top_srcdir@/lib/libUPnP/Platinum/Source/Devices/MediaServer \
View
8 xbmc/utils/URIUtils.cpp
@@ -231,7 +231,8 @@ void URIUtils::GetCommonPath(CStdString& strParent, const CStdString& strPath)
bool URIUtils::ProtocolHasParentInHostname(const CStdString& prot)
{
return prot.Equals("zip")
- || prot.Equals("rar");
+ || prot.Equals("rar")
+ || prot.Equals("bluray");
}
bool URIUtils::ProtocolHasEncodedHostname(const CStdString& prot)
@@ -777,6 +778,11 @@ bool URIUtils::IsLastFM(const CStdString& strFile)
return strFile.Left(7).Equals("lastfm:");
}
+bool URIUtils::IsBluray(const CStdString& strFile)
+{
+ return strFile.Left(7).Equals("bluray:");
+}
+
bool URIUtils::IsDOSPath(const CStdString &path)
{
if (path.size() > 1 && path[1] == ':' && isalpha(path[0]))
View
1 xbmc/utils/URIUtils.h
@@ -88,6 +88,7 @@ class URIUtils
static bool IsVideoDb(const CStdString& strFile);
static bool IsVTP(const CStdString& strFile);
static bool IsZIP(const CStdString& strFile);
+ static bool IsBluray(const CStdString& strFile);
static void AddSlashAtEnd(CStdString& strFolder);
static bool HasSlashAtEnd(const CStdString& strFile);

0 comments on commit a04efb7

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