command, dvd: add property which returns list of DVD titles

This was requested.

It seems libdvdread can't get the duration for titlesets other than the
currently opened title. The data structures contain dangling pointers
for these, and MPlayer works this around by opening every title
separately for the purpose of dumping the title list.
This commit is contained in:
wm4
2014-12-13 20:25:31 +01:00
parent c3275f7e53
commit 5b618ef629
5 changed files with 123 additions and 22 deletions

View File

@@ -65,33 +65,28 @@ enum streamtype {
#define STREAM_OK 1
enum stream_ctrl {
STREAM_CTRL_GET_TIME_LENGTH = 1,
STREAM_CTRL_GET_NUM_CHAPTERS,
STREAM_CTRL_GET_CURRENT_TIME,
STREAM_CTRL_SEEK_TO_TIME,
STREAM_CTRL_GET_SIZE,
STREAM_CTRL_GET_ASPECT_RATIO,
STREAM_CTRL_GET_NUM_ANGLES,
STREAM_CTRL_GET_ANGLE,
STREAM_CTRL_SET_ANGLE,
STREAM_CTRL_GET_NUM_TITLES,
STREAM_CTRL_GET_LANG,
STREAM_CTRL_GET_CURRENT_TITLE,
STREAM_CTRL_SET_CURRENT_TITLE,
STREAM_CTRL_GET_SIZE = 1,
// Cache
STREAM_CTRL_GET_CACHE_SIZE,
STREAM_CTRL_SET_CACHE_SIZE,
STREAM_CTRL_GET_CACHE_FILL,
STREAM_CTRL_GET_CACHE_IDLE,
STREAM_CTRL_RESUME_CACHE,
STREAM_CTRL_RECONNECT,
STREAM_CTRL_GET_CHAPTER_TIME,
STREAM_CTRL_GET_DVD_INFO,
// stream_memory.c
STREAM_CTRL_SET_CONTENTS,
STREAM_CTRL_GET_METADATA,
// stream_rar.c
STREAM_CTRL_GET_BASE_FILENAME,
STREAM_CTRL_GET_NAV_EVENT, // struct mp_nav_event**
STREAM_CTRL_NAV_CMD, // struct mp_nav_cmd*
STREAM_CTRL_GET_DISC_NAME,
// Certain network protocols
STREAM_CTRL_RECONNECT,
STREAM_CTRL_AVSEEK,
STREAM_CTRL_HAS_AVSEEK,
STREAM_CTRL_GET_METADATA,
// TV
STREAM_CTRL_TV_SET_SCAN,
STREAM_CTRL_SET_TV_FREQ,
STREAM_CTRL_GET_TV_FREQ,
@@ -104,8 +99,26 @@ enum stream_ctrl {
STREAM_CTRL_TV_LAST_CHAN,
STREAM_CTRL_DVB_SET_CHANNEL,
STREAM_CTRL_DVB_STEP_CHANNEL,
STREAM_CTRL_AVSEEK,
STREAM_CTRL_HAS_AVSEEK,
// Optical discs
STREAM_CTRL_GET_TIME_LENGTH,
STREAM_CTRL_GET_DVD_INFO,
STREAM_CTRL_GET_NAV_EVENT, // struct mp_nav_event**
STREAM_CTRL_NAV_CMD, // struct mp_nav_cmd*
STREAM_CTRL_GET_DISC_NAME,
STREAM_CTRL_GET_NUM_CHAPTERS,
STREAM_CTRL_GET_CURRENT_TIME,
STREAM_CTRL_GET_CHAPTER_TIME,
STREAM_CTRL_SEEK_TO_TIME,
STREAM_CTRL_GET_ASPECT_RATIO,
STREAM_CTRL_GET_NUM_ANGLES,
STREAM_CTRL_GET_ANGLE,
STREAM_CTRL_SET_ANGLE,
STREAM_CTRL_GET_NUM_TITLES,
STREAM_CTRL_GET_TITLE_LENGTH, // double* (in: title number, out: len)
STREAM_CTRL_GET_LANG,
STREAM_CTRL_GET_CURRENT_TITLE,
STREAM_CTRL_SET_CURRENT_TITLE,
};
struct stream_lang_req {

View File

@@ -541,6 +541,18 @@ static int control(stream_t *stream,int cmd,void* arg)
*((unsigned int *)arg) = d->vmg_file->tt_srpt->nr_of_srpts;
return 1;
}
case STREAM_CTRL_GET_TITLE_LENGTH:
{
int t = *(double *)arg;
if (t < 0 || t >= d->vmg_file->tt_srpt->nr_of_srpts)
break;
if (d->tt_srpt->title[t].title_set_nr !=
d->tt_srpt->title[d->dvd_title].title_set_nr)
break;
*(double *)arg =
mp_get_titleset_length(d->vts_file, d->tt_srpt, t) / 1000.0;
return 1;
}
case STREAM_CTRL_GET_NUM_CHAPTERS:
{
int r;

View File

@@ -535,6 +535,22 @@ static int control(stream_t *stream, int cmd, void *arg)
*((unsigned int*)arg)= num_titles;
return STREAM_OK;
}
case STREAM_CTRL_GET_TITLE_LENGTH: {
int t = *(double *)arg;
int32_t num_titles = 0;
if (dvdnav_get_number_of_titles(dvdnav, &num_titles) != DVDNAV_STATUS_OK)
break;
if (t < 0 || t >= num_titles)
break;
uint64_t duration = 0;
uint64_t *parts = NULL;
dvdnav_describe_title_chapters(dvdnav, t + 1, &parts, &duration);
if (!parts)
break;
free(parts);
*(double *)arg = duration / 90000.0;
return STREAM_OK;
}
case STREAM_CTRL_GET_CURRENT_TITLE: {
if (dvdnav_current_title_info(dvdnav, &tit, &part) != DVDNAV_STATUS_OK)
break;