Skip to content

Commit

Permalink
Merge pull request xbmc#6415 from ace20022/chap_new
Browse files Browse the repository at this point in the history
Show chapters in the bookmark dialog
  • Loading branch information
ace20022 committed Mar 2, 2015
2 parents 5a7ab40 + 45e003e commit 5acc641
Show file tree
Hide file tree
Showing 26 changed files with 316 additions and 49 deletions.
21 changes: 19 additions & 2 deletions language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -12888,7 +12888,12 @@ msgctxt "#25009"
msgid "The menu of this Blu-ray is not supported"
msgstr ""

#empty strings from id 25010 to 29799
#: xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp
msgctxt "#25010"
msgid "Chapter %u"
msgstr ""

#empty strings from id 25011 to 29799
#strings 29800 thru 29998 reserved strings used only in the default Project Mayhem III skin and not c++ code

#: skin.confluence
Expand Down Expand Up @@ -16312,7 +16317,19 @@ msgctxt "#37043"
msgid "Defines the time to wait for subsequent key presses before performing the skip. Only applies when using smart skipping (when using more than one skip step for a direction)."
msgstr ""

#empty strings from id 37044 to 38009
#. Setting #37044 Settings -> Video -> File lists -> Extract chapter thumbnails
#: system/settings/settings.xml
msgctxt "#37044"
msgid "Extract chapter thumbnails"
msgstr ""

#. Description of setting #37044 "Video -> File lists -> Extract chapter thumbnails"
#: system/settings/settings.xml
msgctxt "#37045"
msgid "Extract chapter thumbnails for presentation in the chapters/bookmarks dialog. This might increase CPU load."
msgstr ""

#empty strings from id 37046 to 38009

#: system/settings/rbp.xml
msgctxt "#38010"
Expand Down
5 changes: 5 additions & 0 deletions lib/libdvd/libdvdnav/src/dvdnav.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions lib/libdvd/libdvdnav/src/dvdnav/dvdnav.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
15 changes: 15 additions & 0 deletions lib/libdvd/patches/libdvdnav.diff
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
+
Expand Down
7 changes: 7 additions & 0 deletions system/settings/rbp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
</setting>
</group>
</category>
<category id="myvideos">
<group id="1">
<setting id="myvideos.extractchapterthumbs">
<default>false</default>
</setting>
</group>
</category>
</section>

<section id="system">
Expand Down
5 changes: 5 additions & 0 deletions system/settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,11 @@
<default>true</default>
<control type="toggle" />
</setting>
<setting id="myvideos.extractchapterthumbs" type="boolean" label="37044" help="37045">
<level>1</level>
<default>true</default>
<control type="toggle" />
</setting>
<setting id="myvideos.replacelabels" type="boolean" label="20419" help="36179">
<level>1</level>
<default>true</default>
Expand Down
14 changes: 12 additions & 2 deletions xbmc/ApplicationPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,21 @@ int CApplicationPlayer::GetChapterCount()
return 0;
}

void CApplicationPlayer::GetChapterName(std::string& strChapterName)
void CApplicationPlayer::GetChapterName(std::string& strChapterName,
int chapterIdx)
{
std::shared_ptr<IPlayer> player = GetInternal();
if (player)
player->GetChapterName(strChapterName);
player->GetChapterName(strChapterName, chapterIdx);
}

int64_t CApplicationPlayer::GetChapterPos(int chapterIdx)
{
std::shared_ptr<IPlayer> player = GetInternal();
if (player)
return player->GetChapterPos(chapterIdx);

return -1;
}

bool CApplicationPlayer::HasAudio() const
Expand Down
3 changes: 2 additions & 1 deletion xbmc/ApplicationPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ class CApplicationPlayer
float GetCachePercentage() const;
int GetChapterCount();
int GetChapter();
void GetChapterName(std::string& strChapterName);
void GetChapterName(std::string& strChapterName, int chapterIdx=-1);
int64_t GetChapterPos(int chapterIdx=-1);
void GetDeinterlaceMethods(std::vector<int> &deinterlaceMethods);
void GetDeinterlaceModes(std::vector<int> &deinterlaceModes);
void GetGeneralInfo(std::string& strVideoInfo);
Expand Down
3 changes: 2 additions & 1 deletion xbmc/cores/IPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ class IPlayer

virtual int GetChapterCount() { return 0; }
virtual int GetChapter() { return -1; }
virtual void GetChapterName(std::string& strChapterName) { return; }
virtual void GetChapterName(std::string& strChapterName, int chapterIdx = -1) { return; }
virtual int64_t GetChapterPos(int chapterIdx=-1) { return 0; }
virtual int SeekChapter(int iChapter) { return -1; }
// virtual bool GetChapterInfo(int chapter, SChapterInfo &info) { return false; }

Expand Down
12 changes: 10 additions & 2 deletions xbmc/cores/dvdplayer/DVDDemuxers/DVDDemux.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,17 @@ class CDVDDemux
virtual int GetChapter() { return 0; }

/*
* Get the name of the current chapter
* Get the name of a chapter
* \param strChapterName[out] Name of chapter
* \param chapterIdx -1 for current chapter, else a chapter index
*/
virtual void GetChapterName(std::string& strChapterName) {}
virtual void GetChapterName(std::string& strChapterName, int chapterIdx=-1) {}

/*
* Get the position of a chapter
* \param chapterIdx -1 for current chapter, else a chapter index
*/
virtual int64_t GetChapterPos(int chapterIdx=-1) { return 0; }

/*
* Set the playspeed, if demuxer can handle different
Expand Down
25 changes: 21 additions & 4 deletions xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1401,14 +1401,15 @@ int CDVDDemuxFFmpeg::GetChapter()
return 0;
}

void CDVDDemuxFFmpeg::GetChapterName(std::string& strChapterName)
void CDVDDemuxFFmpeg::GetChapterName(std::string& strChapterName, int chapterIdx)
{
if (chapterIdx <= 0 || chapterIdx > GetChapterCount())
chapterIdx = GetChapter();
CDVDInputStream::IChapter* ich = dynamic_cast<CDVDInputStream::IChapter*>(m_pInput);
if(ich)
ich->GetChapterName(strChapterName);
ich->GetChapterName(strChapterName, chapterIdx);
else
{
int chapterIdx = GetChapter();
if(chapterIdx <= 0)
return;

Expand All @@ -1419,6 +1420,20 @@ void CDVDDemuxFFmpeg::GetChapterName(std::string& strChapterName)
}
}

int64_t CDVDDemuxFFmpeg::GetChapterPos(int chapterIdx)
{
if (chapterIdx <= 0 || chapterIdx > GetChapterCount())
chapterIdx = GetChapter();
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);
}

bool CDVDDemuxFFmpeg::SeekChapter(int chapter, double* startpts)
{
if(chapter < 1)
Expand All @@ -1432,7 +1447,9 @@ bool CDVDDemuxFFmpeg::SeekChapter(int chapter, double* startpts)
return false;

if(startpts)
*startpts = DVD_NOPTS_VALUE;
{
*startpts = DVD_SEC_TO_TIME(ich->GetChapterPos(chapter));
}

Flush();
return true;
Expand Down
3 changes: 2 additions & 1 deletion xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class CDVDDemuxFFmpeg : public CDVDDemux
bool SeekChapter(int chapter, double* startpts = NULL);
int GetChapterCount();
int GetChapter();
void GetChapterName(std::string& strChapterName);
void GetChapterName(std::string& strChapterName, int chapterIdx=-1);
int64_t GetChapterPos(int chapterIdx=-1);
virtual void GetStreamCodecName(int iStreamId, std::string &strName);

bool Aborted();
Expand Down
4 changes: 2 additions & 2 deletions xbmc/cores/dvdplayer/DVDFileInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int DegreeToOrientation(int degrees)

bool CDVDFileInfo::ExtractThumb(const std::string &strPath,
CTextureDetails &details,
CStreamDetails *pStreamDetails)
CStreamDetails *pStreamDetails, int pos)
{
std::string redactPath = CURL::GetRedacted(strPath);
unsigned int nTime = XbmcThreads::SystemClockMillis();
Expand Down Expand Up @@ -216,7 +216,7 @@ bool CDVDFileInfo::ExtractThumb(const std::string &strPath,
if (pVideoCodec)
{
int nTotalLen = pDemuxer->GetStreamLength();
int nSeekTo = nTotalLen / 3;
int nSeekTo = (pos==-1?nTotalLen / 3:pos);

CLog::Log(LOGDEBUG,"%s - seeking to pos %dms (total: %dms) in %s", __FUNCTION__, nSeekTo, nTotalLen, redactPath.c_str());
if (pDemuxer->SeekTime(nSeekTo, true))
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/dvdplayer/DVDFileInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CDVDFileInfo
// Extract a thumbnail immage from the media at strPath, optionally populating a streamdetails class with the data
static bool ExtractThumb(const std::string &strPath,
CTextureDetails &details,
CStreamDetails *pStreamDetails);
CStreamDetails *pStreamDetails, int pos=-1);

// Probe the files streams and store the info in the VideoInfoTag
static bool GetFileStreamDetails(CFileItem *pItem);
Expand Down
3 changes: 2 additions & 1 deletion xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ class CDVDInputStream
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;
};

Expand Down
11 changes: 11 additions & 0 deletions xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamBluray.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ class CDVDInputStreamBluray

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();
Expand Down
23 changes: 23 additions & 0 deletions xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ class CDVDInputStreamNavigator

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
Expand Down
10 changes: 10 additions & 0 deletions xbmc/cores/dvdplayer/DVDInputStreams/DllDvdNav.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class DllDvdNavInterface
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)
Expand Down Expand Up @@ -231,6 +233,10 @@ class DllDvdNav : public DllDynamic, DllDvdNavInterface
{ 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; }
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
};

Expand Down
Loading

0 comments on commit 5acc641

Please sign in to comment.