aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Morten Kvarving <cptspiff@gmail.com>2014-04-22 16:46:04 +0200
committerace20022 <ace20022@ymail.com>2015-03-01 23:05:01 +0100
commit828b42ec8ebf8f14f9db6e5f3ccf1fdf7f94efff (patch)
treea0ba0a548845ac12406f8f3d317302edd839e572
parent1e987d235c72192336623dc206e75407724b3d98 (diff)
added: support grabbing chapter name and position from bluray/dvds
-rw-r--r--lib/libdvd/libdvdnav/src/dvdnav.c5
-rw-r--r--lib/libdvd/libdvdnav/src/dvdnav/dvdnav.h1
-rw-r--r--lib/libdvd/patches/libdvdnav.diff15
-rw-r--r--xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp6
-rw-r--r--xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h3
-rw-r--r--xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp11
-rw-r--r--xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.h3
-rw-r--r--xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp23
-rw-r--r--xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.h3
-rw-r--r--xbmc/cores/dvdplayer/DVDInputStreams/DllDvdNav.h10
10 files changed, 76 insertions, 4 deletions
diff --git a/lib/libdvd/libdvdnav/src/dvdnav.c b/lib/libdvd/libdvdnav/src/dvdnav.c
index 7b2ff892a4..b261b3e359 100644
--- a/lib/libdvd/libdvdnav/src/dvdnav.c
+++ b/lib/libdvd/libdvdnav/src/dvdnav.c
@@ -1230,6 +1230,11 @@ int dvdnav_get_button_info(dvdnav_t* this, int alpha[2][4], int color[2][4])
return 0;
}
+void dvdnav_free(void* pdata)
+{
+ free(pdata);
+}
+
#undef printerr
#define printerr(str) strncpy(self->err_str, str, MAX_ERR_LEN);
diff --git a/lib/libdvd/libdvdnav/src/dvdnav/dvdnav.h b/lib/libdvd/libdvdnav/src/dvdnav/dvdnav.h
index bf6aae9d2a..8b9d75ea2b 100644
--- a/lib/libdvd/libdvdnav/src/dvdnav/dvdnav.h
+++ b/lib/libdvd/libdvdnav/src/dvdnav/dvdnav.h
@@ -697,6 +697,7 @@ int8_t dvdnav_is_domain_vtsm(dvdnav_t *self);
*/
int8_t dvdnav_is_domain_vts(dvdnav_t *self);
+void dvdnav_free(void* pdata);
#ifdef __cplusplus
}
diff --git a/lib/libdvd/patches/libdvdnav.diff b/lib/libdvd/patches/libdvdnav.diff
index cb702a4b38..42bad876b0 100644
--- a/lib/libdvd/patches/libdvdnav.diff
+++ b/lib/libdvd/patches/libdvdnav.diff
@@ -149,6 +149,16 @@ diff -uwr ../libdvdnav-4.2.1/src/dvdnav/dvdnav.h lib/libdvd/libdvdnav/src/dvdnav
/*
* Stop playing the current position and start playback of the title
+ * from the specified timecode.
+ *
+@@ -695,6 +697,7 @@
+ */
+ int8_t dvdnav_is_domain_vts(dvdnav_t *self);
+
++void dvdnav_free(void* pdata);
+
+ #ifdef __cplusplus
+ }
diff -uwr ../libdvdnav-4.2.1/src/dvdnav.c lib/libdvd/libdvdnav/src/dvdnav.c
--- ../libdvdnav-4.2.1/src/dvdnav.c Thu Oct 3 23:39:38 2013
+++ lib/libdvd/libdvdnav/src/dvdnav.c Fri Feb 7 19:24:42 2014
@@ -284,6 +294,11 @@ diff -uwr ../libdvdnav-4.2.1/src/dvdnav.c lib/libdvd/libdvdnav/src/dvdnav.c
+ return 0;
+}
+
++void dvdnav_free(void* pdata)
++{
++ free(pdata);
++}
++
+#undef printerr
+#define printerr(str) strncpy(self->err_str, str, MAX_ERR_LEN);
+
diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
index f051b4677f..66a4a244a4 100644
--- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
@@ -1407,7 +1407,7 @@ void CDVDDemuxFFmpeg::GetChapterName(std::string& strChapterName, int chapterIdx
chapterIdx = GetChapter();
CDVDInputStream::IChapter* ich = dynamic_cast<CDVDInputStream::IChapter*>(m_pInput);
if(ich)
- ich->GetChapterName(strChapterName);
+ ich->GetChapterName(strChapterName, chapterIdx);
else
{
if(chapterIdx <= 0)
@@ -1427,6 +1427,10 @@ int64_t CDVDDemuxFFmpeg::GetChapterPos(int chapterIdx)
if(chapterIdx <= 0)
return 0;
+ CDVDInputStream::IChapter* ich = dynamic_cast<CDVDInputStream::IChapter*>(m_pInput);
+ if(ich)
+ return ich->GetChapterPos(chapterIdx);
+
return m_pFormatContext->chapters[chapterIdx-1]->start*av_q2d(m_pFormatContext->chapters[chapterIdx-1]->time_base);
}
diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h
index 72af2ddeaf..e8bae5ecf5 100644
--- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h
+++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h
@@ -101,7 +101,8 @@ public:
virtual ~IChapter() {};
virtual int GetChapter() = 0;
virtual int GetChapterCount() = 0;
- virtual void GetChapterName(std::string& name) = 0;
+ virtual void GetChapterName(std::string& name, int ch=-1) = 0;
+ virtual int64_t GetChapterPos(int ch=-1) = 0;
virtual bool SeekChapter(int ch) = 0;
};
diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp
index 2ef5f95d7f..61667bd7ee 100644
--- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp
+++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp
@@ -935,6 +935,17 @@ bool CDVDInputStreamBluray::SeekChapter(int ch)
return true;
}
+int64_t CDVDInputStreamBluray::GetChapterPos(int ch)
+{
+ if (ch == -1 || ch > GetChapterCount())
+ ch = GetChapter();
+
+ if (m_title && m_title->chapters)
+ return m_title->chapters[ch - 1].start / 90000;
+ else
+ return 0;
+}
+
int64_t CDVDInputStreamBluray::Seek(int64_t offset, int whence)
{
#if LIBBLURAY_BYTESEEK
diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.h b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.h
index 1f5f926652..1107ed2282 100644
--- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.h
+++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.h
@@ -96,7 +96,8 @@ public:
int GetChapter();
int GetChapterCount();
- void GetChapterName(std::string& name) {};
+ void GetChapterName(std::string& name, int ch=-1) {};
+ int64_t GetChapterPos(int ch);
bool SeekChapter(int ch);
int GetTotalTime();
diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
index 3fd9a07458..c7a6e4c159 100644
--- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
+++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
@@ -1455,3 +1455,26 @@ bool CDVDInputStreamNavigator::GetDVDSerialString(std::string& serialStr)
serialStr.assign(str);
return true;
}
+
+int64_t CDVDInputStreamNavigator::GetChapterPos(int ch)
+{
+ if (ch == -1 || ch > GetChapterCount())
+ ch = GetChapter();
+
+ if (ch <= 1)
+ return 0;
+
+ uint64_t* times = NULL;
+ uint64_t duration;
+
+ m_dll.dvdnav_describe_title_chapters(m_dvdnav, m_iTitle, &times, &duration);
+
+ int64_t result = 0;
+
+ if (times)
+ {
+ result = times[ch - 2] / 90000;
+ m_dll.dvdnav_free(times);
+ }
+ return result;
+}
diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.h b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.h
index f9a6d0f6ee..d7e967cf21 100644
--- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.h
+++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.h
@@ -127,7 +127,8 @@ public:
int GetChapter() { return m_iPart; } // the current part in the current title
int GetChapterCount() { return m_iPartCount; } // the number of parts in the current title
- void GetChapterName(std::string& name) {};
+ void GetChapterName(std::string& name, int idx=-1) {};
+ int64_t GetChapterPos(int ch=-1);
bool SeekChapter(int iChapter);
int GetTotalTime(); // the total time in milli seconds
diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DllDvdNav.h b/xbmc/cores/dvdplayer/DVDInputStreams/DllDvdNav.h
index ecacd978f3..dcbf829cd8 100644
--- a/xbmc/cores/dvdplayer/DVDInputStreams/DllDvdNav.h
+++ b/xbmc/cores/dvdplayer/DVDInputStreams/DllDvdNav.h
@@ -106,6 +106,8 @@ public:
virtual dvdnav_status_t dvdnav_mouse_select(dvdnav_t *self, pci_t *pci, int32_t x, int32_t y)=0;
virtual dvdnav_status_t dvdnav_get_title_string(dvdnav_t *self, const char **title_str)=0;
virtual dvdnav_status_t dvdnav_get_serial_string(dvdnav_t *self, const char **serial_str)=0;
+ virtual uint32_t dvdnav_describe_title_chapters(dvdnav_t* self, uint32_t title, uint64_t** times, uint64_t* duration)=0;
+ virtual void dvdnav_free(void* pdata) = 0;
};
#if (defined USE_STATIC_LIBDVDNAV)
@@ -231,6 +233,10 @@ public:
{ return ::dvdnav_get_title_string(self, title_str); }
virtual dvdnav_status_t dvdnav_get_serial_string(dvdnav_t *self, const char **serial_str)
{ return ::dvdnav_get_serial_string(self, serial_str); }
+ virtual uint32_t dvdnav_describe_title_chapters(dvdnav_t* self, uint32_t title, uint64_t** times, uint64_t* duration)
+ { return ::dvdnav_describe_title_chapters(self, title, times, duration); }
+ virtual void dvdnav_free(void* data)
+ { return ::dvdnav_free(data); }
// DLL faking.
virtual bool ResolveExports() { return true; }
@@ -303,6 +309,8 @@ class DllDvdNav : public DllDynamic, DllDvdNavInterface
DEFINE_METHOD4(dvdnav_status_t, dvdnav_mouse_select, (dvdnav_t *p1, pci_t *p2, int32_t p3, int32_t p4))
DEFINE_METHOD2(dvdnav_status_t, dvdnav_get_title_string, (dvdnav_t *p1, const char **p2))
DEFINE_METHOD2(dvdnav_status_t, dvdnav_get_serial_string, (dvdnav_t *p1, const char **p2))
+ DEFINE_METHOD4(uint32_t, dvdnav_describe_title_chapters, (dvdnav_t* p1, uint32_t p2, uint64_t** p3, uint64_t* p4))
+ DEFINE_METHOD1(void, dvdnav_free, (void *p1))
BEGIN_METHOD_RESOLVE()
RESOLVE_METHOD(dvdnav_open)
RESOLVE_METHOD(dvdnav_close)
@@ -363,6 +371,8 @@ class DllDvdNav : public DllDynamic, DllDvdNavInterface
RESOLVE_METHOD(dvdnav_mouse_select)
RESOLVE_METHOD(dvdnav_get_title_string)
RESOLVE_METHOD(dvdnav_get_serial_string)
+ RESOLVE_METHOD(dvdnav_describe_title_chapters)
+ RESOLVE_METHOD(dvdnav_free)
END_METHOD_RESOLVE()
};