diff options
author | wm4 <wm4@nowhere> | 2012-10-13 17:09:35 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-10-14 22:26:41 +0200 |
commit | a19f197cb14a0ceec4bc1fe977502b8f8ab8f94e (patch) | |
tree | b4de459e097301d352b6a46e5086c51dfd682231 /command.c | |
parent | 9dfcd3e9a24a2d88578909233e2db24863f27b89 (diff) | |
download | mpv-a19f197cb14a0ceec4bc1fe977502b8f8ab8f94e.tar.bz2 mpv-a19f197cb14a0ceec4bc1fe977502b8f8ab8f94e.tar.xz |
core: show quvi page title in window title, clean up libquvi handling
Clean up handling of libquvi (which resolves URLs of streaming sites
into URLs to the actual media playable by mpv). Move the code out of
open.c to quvi.c, and invoke it explicitly from mplayer.c, instead of
trying to resolve every filename passed to open_stream().
This allows easily passing metadata from the quvi context to the
frontend. Expose QUVIPROP_PAGETITLE as "media-title" property, and use
that instead of "filename" for the mplayer window title. (For YouTube,
this is the video title.) It's cleaner too.
Handle a potential reliability issue: check quvi_getprop return values.
Since open.c contains barely anything but the open_stream() stub, move
that to stream.c and delete open.c.
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -162,6 +162,8 @@ static int mp_property_playback_speed(m_option_t *prop, int action, static int mp_property_path(m_option_t *prop, int action, void *arg, MPContext *mpctx) { + if (!mpctx->filename) + return M_PROPERTY_UNAVAILABLE; if (action == M_PROPERTY_GET) { *(char **)arg = talloc_strdup(NULL, mpctx->filename); return M_PROPERTY_OK; @@ -169,6 +171,34 @@ static int mp_property_path(m_option_t *prop, int action, void *arg, return M_PROPERTY_NOT_IMPLEMENTED; } +static int mp_property_media_title(m_option_t *prop, int action, void *arg, + MPContext *mpctx) +{ + char *name = mpctx->filename; + if (mpctx->resolve_result) + name = mpctx->resolve_result->title; + if (!name) + return M_PROPERTY_UNAVAILABLE; + if (action == M_PROPERTY_GET) { + *(char **)arg = talloc_strdup(NULL, name); + return M_PROPERTY_OK; + } + return M_PROPERTY_NOT_IMPLEMENTED; +} + +static int mp_property_stream_path(m_option_t *prop, int action, void *arg, + MPContext *mpctx) +{ + struct stream *stream = mpctx->stream; + if (!stream || !stream->url) + return M_PROPERTY_UNAVAILABLE; + if (action == M_PROPERTY_GET) { + *(char **)arg = talloc_strdup(NULL, stream->url); + return M_PROPERTY_OK; + } + return M_PROPERTY_NOT_IMPLEMENTED; +} + /// filename without path (RO) static int mp_property_filename(m_option_t *prop, int action, void *arg, MPContext *mpctx) @@ -1364,6 +1394,10 @@ static const m_option_t mp_properties[] = { 0, 0, 0, NULL }, { "path", mp_property_path, CONF_TYPE_STRING, 0, 0, 0, NULL }, + { "media-title", mp_property_media_title, CONF_TYPE_STRING, + 0, 0, 0, NULL }, + { "stream-path", mp_property_stream_path, CONF_TYPE_STRING, + 0, 0, 0, NULL }, { "demuxer", mp_property_demuxer, CONF_TYPE_STRING, 0, 0, 0, NULL }, { "stream-pos", mp_property_stream_pos, CONF_TYPE_INT64, |