1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-11 04:01:31 +00:00

command: set 'media-title' property for bluray disc with meta-data

This commit is contained in:
xylosper 2014-03-12 14:41:34 +09:00 committed by wm4
parent d80dc885c6
commit 2f72eecd89
6 changed files with 34 additions and 16 deletions

View File

@ -182,6 +182,19 @@ static int mp_property_filename(m_option_t *prop, int action, void *arg,
return r;
}
static int media_title_from_stream(struct stream *stream, char **name)
{
if (!stream)
return false;
switch (stream->type) {
case STREAMTYPE_DVD:
case STREAMTYPE_BLURAY:
return stream_control(stream, STREAM_CTRL_GET_DISC_NAME, name);
default:
return false;
}
}
static int mp_property_media_title(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
@ -194,11 +207,8 @@ static int mp_property_media_title(m_option_t *prop, int action, void *arg,
name = demux_info_get(mpctx->master_demuxer, "title");
if (name && name[0])
return m_property_strdup_ro(prop, action, arg, name);
struct stream *stream = mpctx->master_demuxer->stream;
if (stream && stream->type == STREAMTYPE_DVD &&
stream_control(stream, STREAM_CTRL_GET_DVD_VOLUME_ID, &name) &&
name)
{
if (media_title_from_stream(mpctx->master_demuxer->stream, &name)
&& name) {
int r = m_property_strdup_ro(prop, action, arg, name);
talloc_free(name);
return r;

View File

@ -113,7 +113,7 @@ struct priv {
int stream_cache_idle;
int stream_cache_fill;
char **stream_metadata;
char *dvd_volume_id;
char *disc_name;
};
// Store additional per-byte metadata. Since per-byte would be way too
@ -319,10 +319,10 @@ static void update_cached_controls(struct priv *s)
talloc_free(s->stream_metadata);
s->stream_metadata = talloc_steal(s, m);
}
if (stream_control(s->stream, STREAM_CTRL_GET_DVD_VOLUME_ID, &t) == STREAM_OK)
if (stream_control(s->stream, STREAM_CTRL_GET_DISC_NAME, &t) == STREAM_OK)
{
talloc_free(s->dvd_volume_id);
s->dvd_volume_id = talloc_steal(s, t);
talloc_free(s->disc_name);
s->disc_name = talloc_steal(s, t);
}
stream_update_size(s->stream);
s->stream_size = s->stream->end_pos;
@ -389,10 +389,10 @@ static int cache_get_cached_control(stream_t *cache, int cmd, void *arg)
}
return STREAM_UNSUPPORTED;
}
case STREAM_CTRL_GET_DVD_VOLUME_ID: {
if (!s->dvd_volume_id)
case STREAM_CTRL_GET_DISC_NAME: {
if (!s->disc_name)
return STREAM_UNSUPPORTED;
*(char **)arg = talloc_strdup(NULL, s->dvd_volume_id);
*(char **)arg = talloc_strdup(NULL, s->disc_name);
return STREAM_OK;
}
case STREAM_CTRL_RESUME_CACHE:

View File

@ -99,7 +99,7 @@ enum stream_ctrl {
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_DVD_VOLUME_ID,
STREAM_CTRL_GET_DISC_NAME
};
struct stream_lang_req {

View File

@ -33,6 +33,7 @@
#include <assert.h>
#include <libbluray/bluray.h>
#include <libbluray/meta_data.h>
#include <libavutil/common.h>
#include "config.h"
@ -277,7 +278,14 @@ static int bluray_stream_control(stream_t *s, int cmd, void *arg)
}
case STREAM_CTRL_MANAGES_TIMELINE:
return STREAM_OK;
case STREAM_CTRL_GET_DISC_NAME:
{
const struct meta_dl *meta = bd_get_meta(b->bd);
if (!meta || !meta->di_name || !meta->di_name[0])
break;
*(char**)arg = talloc_strdup(NULL, meta->di_name);
return STREAM_OK;
}
default:
break;
}

View File

@ -727,7 +727,7 @@ static int control(stream_t *stream,int cmd,void* arg)
memcpy(req->palette, d->cur_pgc->palette, sizeof(req->palette));
return STREAM_OK;
}
case STREAM_CTRL_GET_DVD_VOLUME_ID:
case STREAM_CTRL_GET_DISC_NAME:
{
char buffer[128];
if (DVDUDFVolumeInfo(d->dvd, buffer, sizeof(buffer), NULL, 0) < 0 &&

View File

@ -602,7 +602,7 @@ static int control(stream_t *stream, int cmd, void *arg)
handle_cmd(stream, (struct mp_nav_cmd *)arg);
return STREAM_OK;
}
case STREAM_CTRL_GET_DVD_VOLUME_ID: {
case STREAM_CTRL_GET_DISC_NAME: {
const char *volume = NULL;
if (dvdnav_get_title_string(dvdnav, &volume) != DVDNAV_STATUS_OK)
break;