summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
Diffstat (limited to 'stream')
-rw-r--r--stream/stream.h21
-rw-r--r--stream/stream_bluray.c105
-rw-r--r--stream/stream_cdda.c32
-rw-r--r--stream/stream_dvdnav.c205
4 files changed, 8 insertions, 355 deletions
diff --git a/stream/stream.h b/stream/stream.h
index 971560f492..c575db4a10 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -63,6 +63,10 @@ enum stream_ctrl {
STREAM_CTRL_HAS_AVSEEK,
STREAM_CTRL_GET_METADATA,
+ // Garbage compatibility for obnoxious users
+ STREAM_CTRL_OPTICAL_CRAP_HACK1,
+ STREAM_CTRL_OPTICAL_CRAP_HACK2,
+
// TV
STREAM_CTRL_TV_SET_SCAN,
STREAM_CTRL_SET_TV_FREQ,
@@ -80,23 +84,6 @@ enum stream_ctrl {
STREAM_CTRL_DVB_GET_CHANNEL_NAME,
STREAM_CTRL_DVB_STEP_CHANNEL,
- // Optical discs
- STREAM_CTRL_GET_TIME_LENGTH,
- STREAM_CTRL_GET_DVD_INFO,
- 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 {
diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c
index f26420b56d..10562d6af4 100644
--- a/stream/stream_bluray.c
+++ b/stream/stream_bluray.c
@@ -175,119 +175,19 @@ static int bluray_stream_control(stream_t *s, int cmd, void *arg)
struct bluray_priv_s *b = s->priv;
switch (cmd) {
- case STREAM_CTRL_GET_NUM_CHAPTERS: {
- const BLURAY_TITLE_INFO *ti = b->title_info;
- if (!ti)
- return STREAM_UNSUPPORTED;
- *((unsigned int *) arg) = ti->chapter_count;
- return STREAM_OK;
- }
- case STREAM_CTRL_GET_CHAPTER_TIME: {
- const BLURAY_TITLE_INFO *ti = b->title_info;
- if (!ti)
- return STREAM_UNSUPPORTED;
- int chapter = *(double *)arg;
- double time = MP_NOPTS_VALUE;
- if (chapter >= 0 || chapter < ti->chapter_count)
- time = BD_TIME_TO_MP(ti->chapters[chapter].start);
- if (time == MP_NOPTS_VALUE)
- return STREAM_ERROR;
- *(double *)arg = time;
- return STREAM_OK;
- }
- case STREAM_CTRL_SET_CURRENT_TITLE: {
- const uint32_t title = *((unsigned int*)arg);
- if (title >= b->num_titles || !play_title(b, title))
- return STREAM_UNSUPPORTED;
- b->current_title = title;
- return STREAM_OK;
- }
- case STREAM_CTRL_GET_CURRENT_TITLE: {
- *((unsigned int *) arg) = b->current_title;
- return STREAM_OK;
- }
- case STREAM_CTRL_GET_NUM_TITLES: {
- *((unsigned int *)arg) = b->num_titles;
- return STREAM_OK;
- }
- case STREAM_CTRL_GET_TIME_LENGTH: {
+ case STREAM_CTRL_OPTICAL_CRAP_HACK1: {
const BLURAY_TITLE_INFO *ti = b->title_info;
if (!ti)
return STREAM_UNSUPPORTED;
*((double *) arg) = BD_TIME_TO_MP(ti->duration);
return STREAM_OK;
}
- case STREAM_CTRL_GET_CURRENT_TIME: {
- *((double *) arg) = BD_TIME_TO_MP(bd_tell_time(b->bd));
- return STREAM_OK;
- }
- case STREAM_CTRL_SEEK_TO_TIME: {
+ case STREAM_CTRL_OPTICAL_CRAP_HACK2: {
double pts = *((double *) arg);
bd_seek_time(b->bd, BD_TIME_FROM_MP(pts));
stream_drop_buffers(s);
- // API makes it hard to determine seeking success
- return STREAM_OK;
- }
- case STREAM_CTRL_GET_NUM_ANGLES: {
- const BLURAY_TITLE_INFO *ti = b->title_info;
- if (!ti)
- return STREAM_UNSUPPORTED;
- *((int *) arg) = ti->angle_count;
- return STREAM_OK;
- }
- case STREAM_CTRL_GET_ANGLE: {
- *((int *) arg) = b->current_angle;
- return STREAM_OK;
- }
- case STREAM_CTRL_SET_ANGLE: {
- const BLURAY_TITLE_INFO *ti = b->title_info;
- if (!ti)
- return STREAM_UNSUPPORTED;
- int angle = *((int *) arg);
- if (angle < 0 || angle > ti->angle_count)
- return STREAM_UNSUPPORTED;
- b->current_angle = angle;
- bd_seamless_angle_change(b->bd, angle);
return STREAM_OK;
}
- case STREAM_CTRL_GET_LANG: {
- const BLURAY_TITLE_INFO *ti = b->title_info;
- if (ti && ti->clip_count) {
- struct stream_lang_req *req = arg;
- BLURAY_STREAM_INFO *si = NULL;
- int count = 0;
- switch (req->type) {
- case STREAM_AUDIO:
- count = ti->clips[0].audio_stream_count;
- si = ti->clips[0].audio_streams;
- break;
- case STREAM_SUB:
- count = ti->clips[0].pg_stream_count;
- si = ti->clips[0].pg_streams;
- break;
- }
- for (int n = 0; n < count; n++) {
- BLURAY_STREAM_INFO *i = &si[n];
- if (i->pid == req->id) {
- snprintf(req->name, sizeof(req->name), "%.4s", i->lang);
- return STREAM_OK;
- }
- }
- }
- return STREAM_ERROR;
- }
- 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;
- }
- case STREAM_CTRL_GET_SIZE:
- *(int64_t *)arg = bd_get_title_size(b->bd);
- return STREAM_OK;
- default:
- break;
}
return STREAM_UNSUPPORTED;
@@ -456,7 +356,6 @@ static int bluray_stream_open_internal(stream_t *s)
s->control = bluray_stream_control;
s->sector_size = BLURAY_SECTOR_SIZE;
s->priv = b;
- s->demuxer = "+disc";
MP_VERBOSE(s, "Blu-ray successfully opened.\n");
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index 7fd461a361..e99db3eda1 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -226,42 +226,10 @@ static void close_cdda(stream_t *s)
cdda_close(p->cd);
}
-static int get_track_by_sector(cdda_priv *p, unsigned int sector)
-{
- int i;
- for (i = p->cd->tracks; i >= 0; --i)
- if (p->cd->disc_toc[i].dwStartSector <= sector)
- break;
- return i;
-}
-
static int control(stream_t *stream, int cmd, void *arg)
{
cdda_priv *p = stream->priv;
switch (cmd) {
- case STREAM_CTRL_GET_NUM_CHAPTERS:
- {
- int start_track = get_track_by_sector(p, p->start_sector);
- int end_track = get_track_by_sector(p, p->end_sector);
- if (start_track == -1 || end_track == -1)
- return STREAM_ERROR;
- *(unsigned int *)arg = end_track + 1 - start_track;
- return STREAM_OK;
- }
- case STREAM_CTRL_GET_CHAPTER_TIME:
- {
- int track = *(double *)arg;
- int start_track = get_track_by_sector(p, p->start_sector);
- int end_track = get_track_by_sector(p, p->end_sector);
- track += start_track;
- if (track > end_track)
- return STREAM_ERROR;
- int64_t sector = p->cd->disc_toc[track].dwStartSector;
- int64_t pos = sector * CDIO_CD_FRAMESIZE_RAW;
- // Assume standard audio CD: 44.1khz, 2 channels, s16 samples
- *(double *)arg = pos / (44100.0 * 2 * 2);
- return STREAM_OK;
- }
case STREAM_CTRL_GET_SIZE:
*(int64_t *)arg =
(p->end_sector + 1 - p->start_sector) * CDIO_CD_FRAMESIZE_RAW;
diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c
index 84d8c8b0f1..2aaccd5561 100644
--- a/stream/stream_dvdnav.c
+++ b/stream/stream_dvdnav.c
@@ -190,73 +190,6 @@ static int dvd_probe(const char *path, const char *ext, const char *sig)
return r;
}
-/**
- * \brief mp_dvdnav_lang_from_aid() returns the language corresponding to audio id 'aid'
- * \param stream: - stream pointer
- * \param sid: physical subtitle id
- * \return 0 on error, otherwise language id
- */
-static int mp_dvdnav_lang_from_aid(stream_t *stream, int aid)
-{
- uint8_t lg;
- uint16_t lang;
- struct priv *priv = stream->priv;
-
- if (aid < 0)
- return 0;
- lg = dvdnav_get_audio_logical_stream(priv->dvdnav, aid & 0x7);
- if (lg == 0xff)
- return 0;
- lang = dvdnav_audio_stream_to_lang(priv->dvdnav, lg);
- if (lang == 0xffff)
- return 0;
- return lang;
-}
-
-/**
- * \brief mp_dvdnav_lang_from_sid() returns the language corresponding to subtitle id 'sid'
- * \param stream: - stream pointer
- * \param sid: physical subtitle id
- * \return 0 on error, otherwise language id
- */
-static int mp_dvdnav_lang_from_sid(stream_t *stream, int sid)
-{
- uint8_t k;
- uint16_t lang;
- struct priv *priv = stream->priv;
- if (sid < 0)
- return 0;
- for (k = 0; k < 32; k++)
- if (dvdnav_get_spu_logical_stream(priv->dvdnav, k) == sid)
- break;
- if (k == 32)
- return 0;
- lang = dvdnav_spu_stream_to_lang(priv->dvdnav, k);
- if (lang == 0xffff)
- return 0;
- return lang;
-}
-
-/**
- * \brief mp_dvdnav_number_of_subs() returns the count of available subtitles
- * \param stream: - stream pointer
- * \return 0 on error, something meaningful otherwise
- */
-static int mp_dvdnav_number_of_subs(stream_t *stream)
-{
- struct priv *priv = stream->priv;
- uint8_t lg, k, n = 0;
-
- for (k = 0; k < 32; k++) {
- lg = dvdnav_get_spu_logical_stream(priv->dvdnav, k);
- if (lg == 0xff)
- continue;
- if (lg >= n)
- n = lg + 1;
- }
- return n;
-}
-
static int fill_buffer(stream_t *s, char *buf, int max_len)
{
struct priv *priv = s->priv;
@@ -340,92 +273,16 @@ static int control(stream_t *stream, int cmd, void *arg)
{
struct priv *priv = stream->priv;
dvdnav_t *dvdnav = priv->dvdnav;
- int tit, part;
switch (cmd) {
- case STREAM_CTRL_GET_NUM_CHAPTERS: {
- if (dvdnav_current_title_info(dvdnav, &tit, &part) != DVDNAV_STATUS_OK)
- break;
- if (dvdnav_get_number_of_parts(dvdnav, tit, &part) != DVDNAV_STATUS_OK)
- break;
- if (!part)
- break;
- *(unsigned int *)arg = part;
- return 1;
- }
- case STREAM_CTRL_GET_CHAPTER_TIME: {
- double *ch = arg;
- int chapter = *ch;
- if (dvdnav_current_title_info(dvdnav, &tit, &part) != DVDNAV_STATUS_OK)
- break;
- uint64_t *parts = NULL, duration = 0;
- int n = dvdnav_describe_title_chapters(dvdnav, tit, &parts, &duration);
- if (!parts)
- break;
- if (chapter < 0 || chapter + 1 > n)
- break;
- *ch = chapter > 0 ? parts[chapter - 1] / 90000.0 : 0;
- free(parts);
- return 1;
- }
- case STREAM_CTRL_GET_TIME_LENGTH: {
+ case STREAM_CTRL_OPTICAL_CRAP_HACK1: {
if (priv->duration) {
*(double *)arg = (double)priv->duration / 1000.0;
return 1;
}
break;
}
- case STREAM_CTRL_GET_ASPECT_RATIO: {
- uint8_t ar = dvdnav_get_video_aspect(dvdnav);
- *(double *)arg = !ar ? 4.0 / 3.0 : 16.0 / 9.0;
- return 1;
- }
- case STREAM_CTRL_GET_CURRENT_TIME: {
- double tm;
- tm = dvdnav_get_current_time(dvdnav) / 90000.0f;
- if (tm != -1) {
- *(double *)arg = tm;
- return 1;
- }
- break;
- }
- case STREAM_CTRL_GET_NUM_TITLES: {
- int32_t num_titles = 0;
- if (dvdnav_get_number_of_titles(dvdnav, &num_titles) != DVDNAV_STATUS_OK)
- break;
- *((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;
- *((unsigned int *) arg) = tit - 1;
- return STREAM_OK;
- }
- case STREAM_CTRL_SET_CURRENT_TITLE: {
- int title = *((unsigned int *) arg);
- if (dvdnav_title_play(priv->dvdnav, title + 1) != DVDNAV_STATUS_OK)
- break;
- stream_drop_buffers(stream);
- return STREAM_OK;
- }
- case STREAM_CTRL_SEEK_TO_TIME: {
+ case STREAM_CTRL_OPTICAL_CRAP_HACK2: {
double *args = arg;
double d = args[0]; // absolute target timestamp
int flags = args[1]; // from SEEK_* flags (demux.h)
@@ -449,63 +306,6 @@ static int control(stream_t *stream, int cmd, void *arg)
MP_VERBOSE(stream, "block: %lu\n", (unsigned long)pos);
return STREAM_OK;
}
- case STREAM_CTRL_GET_NUM_ANGLES: {
- uint32_t curr, angles;
- if (dvdnav_get_angle_info(dvdnav, &curr, &angles) != DVDNAV_STATUS_OK)
- break;
- *(int *)arg = angles;
- return 1;
- }
- case STREAM_CTRL_GET_ANGLE: {
- uint32_t curr, angles;
- if (dvdnav_get_angle_info(dvdnav, &curr, &angles) != DVDNAV_STATUS_OK)
- break;
- *(int *)arg = curr;
- return 1;
- }
- case STREAM_CTRL_SET_ANGLE: {
- uint32_t curr, angles;
- int new_angle = *(int *)arg;
- if (dvdnav_get_angle_info(dvdnav, &curr, &angles) != DVDNAV_STATUS_OK)
- break;
- if (new_angle > angles || new_angle < 1)
- break;
- if (dvdnav_angle_change(dvdnav, new_angle) != DVDNAV_STATUS_OK)
- return 1;
- }
- case STREAM_CTRL_GET_LANG: {
- struct stream_lang_req *req = arg;
- int lang = 0;
- switch (req->type) {
- case STREAM_AUDIO:
- lang = mp_dvdnav_lang_from_aid(stream, req->id);
- break;
- case STREAM_SUB:
- lang = mp_dvdnav_lang_from_sid(stream, req->id);
- break;
- }
- if (!lang)
- break;
- snprintf(req->name, sizeof(req->name), "%c%c", lang >> 8, lang);
- return STREAM_OK;
- }
- case STREAM_CTRL_GET_DVD_INFO: {
- struct stream_dvd_info_req *req = arg;
- memset(req, 0, sizeof(*req));
- req->num_subs = mp_dvdnav_number_of_subs(stream);
- assert(sizeof(uint32_t) == sizeof(unsigned int));
- memcpy(req->palette, priv->spu_clut, sizeof(req->palette));
- return STREAM_OK;
- }
- case STREAM_CTRL_GET_DISC_NAME: {
- const char *volume = NULL;
- if (dvdnav_get_title_string(dvdnav, &volume) != DVDNAV_STATUS_OK)
- break;
- if (!volume || !volume[0])
- break;
- *(char**)arg = talloc_strdup(NULL, volume);
- return STREAM_OK;
- }
}
return STREAM_UNSUPPORTED;
@@ -621,7 +421,6 @@ static int open_s_internal(stream_t *stream)
stream->fill_buffer = fill_buffer;
stream->control = control;
stream->close = stream_dvdnav_close;
- stream->demuxer = "+disc";
stream->lavf_type = "mpeg";
return STREAM_OK;