From a19f197cb14a0ceec4bc1fe977502b8f8ab8f94e Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 13 Oct 2012 17:09:35 +0200 Subject: 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. --- command.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'command.c') diff --git a/command.c b/command.c index 4afc2104e4..1619206689 100644 --- a/command.c +++ b/command.c @@ -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, -- cgit v1.2.3