diff options
author | wm4 <wm4@nowhere> | 2013-06-27 18:21:07 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-06-28 15:47:35 +0200 |
commit | 5f664d78e6e9bd5809dc7d0f12c4099e76582cb3 (patch) | |
tree | 618ad84b255a8f99afbb196a71d0d29eec90faac /core/mplayer.c | |
parent | ac79eb733741d8d22bbd550be39fe63c28a575f9 (diff) | |
download | mpv-5f664d78e6e9bd5809dc7d0f12c4099e76582cb3.tar.bz2 mpv-5f664d78e6e9bd5809dc7d0f12c4099e76582cb3.tar.xz |
core: add libquvi 0.9 support
This adds support for libquvi 0.9.x, and these features:
- start time (part of youtube URL)
- youtube subtitles
- alternative source switching ('l' and 'L' keys)
- youtube playlists
Note that libquvi 0.9 is still in development. Although this seems to
be API stable now, it looks like there will be a 1.0 release, which is
supposed to be the next stable release and the actual successor of
libquvi 0.4.x.
Diffstat (limited to 'core/mplayer.c')
-rw-r--r-- | core/mplayer.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/core/mplayer.c b/core/mplayer.c index fa0723f022..4377f9f9bc 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -3890,6 +3890,9 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename, if (!filename) return NULL; int format = 0; + char *disp_filename = filename; + if (strncmp(disp_filename, "memory://", 9) == 0) + disp_filename = "memory://"; // avoid noise struct stream *stream = open_stream(filename, &mpctx->opts, &format); if (!stream) goto err_out; @@ -3920,7 +3923,7 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename, if (stream->type == filter) { struct track *t = add_stream_track(mpctx, stream, false); t->is_external = true; - t->title = talloc_strdup(t, filename); + t->title = talloc_strdup(t, disp_filename); t->external_filename = talloc_strdup(t, filename); first = t; } @@ -3928,7 +3931,7 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename, if (!first) { free_demuxer(demuxer); mp_msg(MSGT_CPLAYER, MSGL_WARN, "No streams added from file %s.\n", - filename); + disp_filename); goto err_out; } MP_TARRAY_APPEND(NULL, mpctx->sources, mpctx->num_sources, demuxer); @@ -3936,7 +3939,7 @@ static struct track *open_external_file(struct MPContext *mpctx, char *filename, err_out: mp_msg(MSGT_CPLAYER, MSGL_ERR, "Can not open external file %s.\n", - filename); + disp_filename); return false; } @@ -3954,6 +3957,25 @@ struct track *mp_add_subtitles(struct MPContext *mpctx, char *filename, int noer STREAM_SUB); } +static void open_subtitles_from_resolve(struct MPContext *mpctx) +{ + struct MPOpts *opts = &mpctx->opts; + struct mp_resolve_result *res = mpctx->resolve_result; + if (!res) + return; + for (int n = 0; n < res->num_subs; n++) { + struct mp_resolve_sub *sub = res->subs[n]; + char *s = talloc_strdup(NULL, sub->url); + if (!s) + s = talloc_asprintf(NULL, "memory://%s", sub->data); + struct track *t = + open_external_file(mpctx, s, opts->sub_demuxer_name, 0, STREAM_SUB); + talloc_free(s); + if (t) + t->lang = talloc_strdup(t, sub->lang); + } +} + static void print_timeline(struct MPContext *mpctx) { if (mpctx->timeline) { @@ -4005,7 +4027,7 @@ static void add_subtitle_fonts_from_sources(struct MPContext *mpctx) static struct mp_resolve_result *resolve_url(const char *filename, struct MPOpts *opts) { -#ifdef CONFIG_LIBQUVI +#if defined(CONFIG_LIBQUVI) || defined(CONFIG_LIBQUVI9) return mp_resolve_quvi(filename, opts); #else return NULL; @@ -4138,8 +4160,17 @@ static void play_current_file(struct MPContext *mpctx) char *stream_filename = mpctx->filename; mpctx->resolve_result = resolve_url(stream_filename, opts); - if (mpctx->resolve_result) + if (mpctx->resolve_result) { + if (mpctx->resolve_result->playlist) { + // Replace entry with playlist contents + playlist_transfer_entries(mpctx->playlist, + mpctx->resolve_result->playlist); + if (mpctx->playlist->current) + playlist_remove(mpctx->playlist, mpctx->playlist->current); + goto terminate_playback; + } stream_filename = mpctx->resolve_result->url; + } int file_format = DEMUXER_TYPE_UNKNOWN; mpctx->stream = open_stream(stream_filename, opts, &file_format); if (!mpctx->stream) { // error... @@ -4253,6 +4284,7 @@ goto_reopen_demuxer: ; add_subtitle_fonts_from_sources(mpctx); open_subtitles_from_options(mpctx); + open_subtitles_from_resolve(mpctx); open_audiofiles_from_options(mpctx); check_previous_track_selection(mpctx); @@ -4366,6 +4398,12 @@ goto_reopen_demuxer: ; queue_seek(mpctx, MPSEEK_ABSOLUTE, startpos, 0); execute_queued_seek(mpctx); } + if (startpos == -1 && mpctx->resolve_result && + mpctx->resolve_result->start_time > 0) + { + queue_seek(mpctx, MPSEEK_ABSOLUTE, mpctx->resolve_result->start_time, 0); + execute_queued_seek(mpctx); + } if (opts->chapterrange[0] > 0) { if (mp_seek_chapter(mpctx, opts->chapterrange[0] - 1)) execute_queued_seek(mpctx); |