mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
dvd, bluray, cdda: add demux_disc containing all related hacks
DVD and Bluray (and to some extent cdda) require awful hacks all over the codebase to make them work. The main reason is that they act like container, but are entirely implemented on the stream layer. The raw mpeg data resulting from these streams must be "extended" with the container-like metadata transported via STREAM_CTRLs. The result were hacks all over demux.c and some higher-level parts. Add a "disc" pseudo-demuxer, and move all these hacks and special-cases to it.
This commit is contained in:
@@ -112,7 +112,6 @@ struct priv {
|
||||
double stream_time_length;
|
||||
double stream_start_time;
|
||||
int64_t stream_size;
|
||||
bool stream_manages_timeline;
|
||||
unsigned int stream_num_chapters;
|
||||
int stream_cache_idle;
|
||||
int stream_cache_fill;
|
||||
@@ -381,9 +380,6 @@ static void update_cached_controls(struct priv *s)
|
||||
s->stream_start_time = MP_NOPTS_VALUE;
|
||||
if (stream_control(s->stream, STREAM_CTRL_GET_START_TIME, &d) == STREAM_OK)
|
||||
s->stream_start_time = d;
|
||||
s->stream_manages_timeline = false;
|
||||
if (stream_control(s->stream, STREAM_CTRL_MANAGES_TIMELINE, NULL) == STREAM_OK)
|
||||
s->stream_manages_timeline = true;
|
||||
s->stream_num_chapters = 0;
|
||||
if (stream_control(s->stream, STREAM_CTRL_GET_NUM_CHAPTERS, &ui) == STREAM_OK)
|
||||
s->stream_num_chapters = ui;
|
||||
@@ -428,8 +424,6 @@ static int cache_get_cached_control(stream_t *cache, int cmd, void *arg)
|
||||
return STREAM_UNSUPPORTED;
|
||||
*(int64_t *)arg = s->stream_size;
|
||||
return STREAM_OK;
|
||||
case STREAM_CTRL_MANAGES_TIMELINE:
|
||||
return s->stream_manages_timeline ? STREAM_OK : STREAM_UNSUPPORTED;
|
||||
case STREAM_CTRL_GET_NUM_CHAPTERS:
|
||||
*(unsigned int *)arg = s->stream_num_chapters;
|
||||
return STREAM_OK;
|
||||
|
||||
@@ -968,11 +968,6 @@ struct bstr stream_read_complete(struct stream *s, void *talloc_ctx,
|
||||
return (struct bstr){buf, total_read};
|
||||
}
|
||||
|
||||
bool stream_manages_timeline(struct stream *s)
|
||||
{
|
||||
return stream_control(s, STREAM_CTRL_MANAGES_TIMELINE, NULL) == STREAM_OK;
|
||||
}
|
||||
|
||||
void stream_print_proto_list(struct mp_log *log)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
@@ -39,6 +39,7 @@ enum streamtype {
|
||||
STREAMTYPE_MF,
|
||||
STREAMTYPE_EDL,
|
||||
STREAMTYPE_AVDEVICE,
|
||||
STREAMTYPE_CDDA,
|
||||
};
|
||||
|
||||
#define STREAM_BUFFER_SIZE 2048
|
||||
@@ -80,8 +81,6 @@ enum stream_ctrl {
|
||||
STREAM_CTRL_GET_CACHE_IDLE,
|
||||
STREAM_CTRL_RESUME_CACHE,
|
||||
STREAM_CTRL_RECONNECT,
|
||||
// DVD/Bluray, signal general support for GET_CURRENT_TIME etc.
|
||||
STREAM_CTRL_MANAGES_TIMELINE,
|
||||
STREAM_CTRL_GET_START_TIME,
|
||||
STREAM_CTRL_GET_CHAPTER_TIME,
|
||||
STREAM_CTRL_GET_DVD_INFO,
|
||||
@@ -243,8 +242,6 @@ stream_t *open_memory_stream(void *data, int len);
|
||||
|
||||
bool stream_check_interrupt(struct stream *s);
|
||||
|
||||
bool stream_manages_timeline(stream_t *s);
|
||||
|
||||
void mp_url_unescape_inplace(char *buf);
|
||||
char *mp_url_escape(void *talloc_ctx, const char *s, const char *ok);
|
||||
|
||||
|
||||
@@ -584,8 +584,6 @@ static int bluray_stream_control(stream_t *s, int cmd, void *arg)
|
||||
*((double *)arg) = 0;
|
||||
return STREAM_OK;
|
||||
}
|
||||
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])
|
||||
@@ -801,6 +799,7 @@ static int bluray_stream_open(stream_t *s)
|
||||
s->end_pos = bd_get_title_size(bd);
|
||||
s->sector_size = BLURAY_SECTOR_SIZE;
|
||||
s->priv = b;
|
||||
s->demuxer = "+disc";
|
||||
|
||||
MP_VERBOSE(s, "Blu-ray successfully opened.\n");
|
||||
|
||||
|
||||
@@ -396,7 +396,8 @@ static int open_cdda(stream_t *st)
|
||||
st->control = control;
|
||||
st->close = close_cdda;
|
||||
|
||||
st->demuxer = "rawaudio";
|
||||
st->type = STREAMTYPE_CDDA;
|
||||
st->demuxer = "+disc";
|
||||
|
||||
print_cdtext(st, 0);
|
||||
|
||||
|
||||
@@ -619,8 +619,6 @@ static int control(stream_t *stream,int cmd,void* arg)
|
||||
snprintf(req->name, sizeof(req->name), "%c%c", lang >> 8, lang);
|
||||
return STREAM_OK;
|
||||
}
|
||||
case STREAM_CTRL_MANAGES_TIMELINE:
|
||||
return STREAM_OK;
|
||||
case STREAM_CTRL_GET_DVD_INFO:
|
||||
{
|
||||
struct stream_dvd_info_req *req = arg;
|
||||
@@ -899,6 +897,8 @@ static int open_s(stream_t *stream)
|
||||
// ... (unimplemented)
|
||||
// return NULL;
|
||||
stream->type = STREAMTYPE_DVD;
|
||||
stream->demuxer = "+disc";
|
||||
stream->lavf_type = "mpeg";
|
||||
stream->sector_size = 2048;
|
||||
stream->fill_buffer = fill_buffer;
|
||||
stream->control = control;
|
||||
|
||||
@@ -597,8 +597,6 @@ static int control(stream_t *stream, int cmd, void *arg)
|
||||
snprintf(req->name, sizeof(req->name), "%c%c", lang >> 8, lang);
|
||||
return STREAM_OK;
|
||||
}
|
||||
case STREAM_CTRL_MANAGES_TIMELINE:
|
||||
return STREAM_OK;
|
||||
case STREAM_CTRL_GET_DVD_INFO: {
|
||||
struct stream_dvd_info_req *req = arg;
|
||||
memset(req, 0, sizeof(*req));
|
||||
@@ -733,7 +731,7 @@ static int open_s(stream_t *stream)
|
||||
stream->control = control;
|
||||
stream->close = stream_dvdnav_close;
|
||||
stream->type = STREAMTYPE_DVD;
|
||||
stream->demuxer = "lavf";
|
||||
stream->demuxer = "+disc";
|
||||
stream->lavf_type = "mpeg";
|
||||
stream->allow_caching = false;
|
||||
|
||||
|
||||
@@ -1228,7 +1228,6 @@ static int demux_tv_control(demuxer_t *demuxer, int cmd, void *arg)
|
||||
const demuxer_desc_t demuxer_desc_tv = {
|
||||
.name = "tv",
|
||||
.desc = "TV card demuxer",
|
||||
.type = DEMUXER_TYPE_TV,
|
||||
.fill_buffer = demux_tv_fill_buffer,
|
||||
.control = demux_tv_control,
|
||||
.open = demux_open_tv,
|
||||
|
||||
Reference in New Issue
Block a user