summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-09 23:38:28 +0200
committerwm4 <wm4@nowhere>2014-06-11 00:34:41 +0200
commite033f3c8bcf66de44b0cc25e543a85f19fc9f964 (patch)
tree08cfecb3736fd7b6cc0803a4f28cc8c42651b53f /player
parent9420eb5a073da434c31f5123dff93c22e5ba32fa (diff)
downloadmpv-e033f3c8bcf66de44b0cc25e543a85f19fc9f964.tar.bz2
mpv-e033f3c8bcf66de44b0cc25e543a85f19fc9f964.tar.xz
command: redo ancient TV/DVB/PVR commands
Convert all these commands to properties. (Except tv_last_channel, not sure what to do with this.) Also, internally, don't access stream details directly, but dispatch commands with stream ctrls. Many of the new properties are a bit strange, because they're write- only. Also remove some OSD output these commands produced, because I couldn't be bothered to port these. In general, this makes everything much cleaner, and will also make it easier to e.g. move the demuxer to its own thread. Don't bother updating input.conf, but changes.rst documents how old commands map to the new ones. Mostly untested, due to lack of hardware.
Diffstat (limited to 'player')
-rw-r--r--player/command.c260
-rw-r--r--player/loadfile.c15
-rw-r--r--player/main.c1
3 files changed, 111 insertions, 165 deletions
diff --git a/player/command.c b/player/command.c
index e2788b76be..315013b0e8 100644
--- a/player/command.c
+++ b/player/command.c
@@ -59,11 +59,6 @@
#include "video/decode/dec_video.h"
#include "audio/decode/dec_audio.h"
#include "options/path.h"
-#include "stream/tv.h"
-#include "stream/pvr.h"
-#if HAVE_DVBIN
-#include "stream/dvbin.h"
-#endif
#include "screenshot.h"
#if HAVE_SYS_MMAN_H
#include <sys/mman.h>
@@ -2102,33 +2097,120 @@ static int mp_property_sub_pos(m_option_t *prop, int action, void *arg,
return property_osd_helper(prop, action, arg, mpctx);
}
-#if HAVE_TV
+static int demux_stream_control(struct MPContext *mpctx, int ctrl, void *arg)
+{
+ int r = STREAM_UNSUPPORTED;
+ if (mpctx->stream)
+ r = stream_control(mpctx->stream, ctrl, arg);
+ if (r == STREAM_UNSUPPORTED && mpctx->demuxer) {
+ struct demux_ctrl_stream_ctrl c = {ctrl, arg, STREAM_UNSUPPORTED};
+ demux_control(mpctx->demuxer, DEMUXER_CTRL_STREAM_CTRL, &c);
+ r = c.res;
+ }
+ return r;
+}
-static tvi_handle_t *get_tvh(struct MPContext *mpctx)
+static int prop_stream_ctrl(struct MPContext *mpctx, int ctrl, void *arg)
{
- if (!(mpctx->master_demuxer && mpctx->master_demuxer->type == DEMUXER_TYPE_TV))
- return NULL;
- return mpctx->master_demuxer->priv;
+ int r = demux_stream_control(mpctx, ctrl, arg);
+ switch (r) {
+ case STREAM_OK: return M_PROPERTY_OK;
+ case STREAM_UNSUPPORTED: return M_PROPERTY_UNAVAILABLE;
+ default: return M_PROPERTY_ERROR;
+ }
+}
+
+static int mp_property_tv_norm(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
+{
+ switch (action) {
+ case M_PROPERTY_SET:
+ return prop_stream_ctrl(mpctx, STREAM_CTRL_TV_SET_NORM, *(char **)arg);
+ case M_PROPERTY_SWITCH:
+ return prop_stream_ctrl(mpctx, STREAM_CTRL_TV_STEP_NORM, NULL);
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
+}
+
+static int mp_property_tv_scan(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
+{
+ switch (action) {
+ case M_PROPERTY_SET:
+ return prop_stream_ctrl(mpctx, STREAM_CTRL_TV_SET_SCAN, arg);
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
}
/// TV color settings (RW)
static int mp_property_tv_color(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
- tvi_handle_t *tvh = get_tvh(mpctx);
- if (!tvh)
- return M_PROPERTY_UNAVAILABLE;
+ int req[2] = {prop->offset};
+ switch (action) {
+ case M_PROPERTY_SET:
+ req[1] = *(int *)arg;
+ return prop_stream_ctrl(mpctx, STREAM_CTRL_SET_TV_COLORS, req);
+ case M_PROPERTY_GET: {
+ int r = prop_stream_ctrl(mpctx, STREAM_CTRL_GET_TV_COLORS, req);
+ if (r == M_PROPERTY_OK)
+ *(int *)arg = req[1];
+ return r;
+ }
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
+}
+static int mp_property_tv_freq(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
+{
switch (action) {
case M_PROPERTY_SET:
- return tv_set_color_options(tvh, prop->offset, *(int *) arg);
+ return prop_stream_ctrl(mpctx, STREAM_CTRL_SET_TV_FREQ, arg);
case M_PROPERTY_GET:
- return tv_get_color_options(tvh, prop->offset, arg);
+ return prop_stream_ctrl(mpctx, STREAM_CTRL_GET_TV_FREQ, arg);
}
return M_PROPERTY_NOT_IMPLEMENTED;
}
-#endif
+static int mp_property_tv_channel(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
+{
+ switch (action) {
+ case M_PROPERTY_SET:
+ return prop_stream_ctrl(mpctx, STREAM_CTRL_TV_SET_CHAN, *(char **)arg);
+ case M_PROPERTY_SWITCH: {
+ struct m_property_switch_arg *sa = arg;
+ int dir = sa->inc >= 0 ? 1 : -1;
+ return prop_stream_ctrl(mpctx, STREAM_CTRL_TV_STEP_CHAN, &dir);
+ }
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
+}
+
+static int mp_property_dvb_channel(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
+{
+ int r;
+ switch (action) {
+ case M_PROPERTY_SET:
+ mpctx->last_dvb_step = 1;
+ r = prop_stream_ctrl(mpctx, STREAM_CTRL_DVB_SET_CHANNEL, arg);
+ if (r == M_PROPERTY_OK)
+ mpctx->stop_play = PT_RELOAD_DEMUXER;
+ return r;
+ case M_PROPERTY_SWITCH: {
+ struct m_property_switch_arg *sa = arg;
+ int dir = sa->inc >= 0 ? 1 : -1;
+ mpctx->last_dvb_step = dir;
+ r = prop_stream_ctrl(mpctx, STREAM_CTRL_DVB_STEP_CHANNEL, &dir);
+ if (r == M_PROPERTY_OK)
+ mpctx->stop_play = PT_RELOAD_DEMUXER;
+ return r;
+ }
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
+}
static int mp_property_playlist_pos(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
@@ -2490,7 +2572,6 @@ static const m_option_t mp_properties[] = {
M_OPTION_PROPERTY_CUSTOM("vf", mp_property_vf),
M_OPTION_PROPERTY_CUSTOM("af", mp_property_af),
-#if HAVE_TV
{ "tv-brightness", mp_property_tv_color, CONF_TYPE_INT,
M_OPT_RANGE, -100, 100, .offset = TV_COLOR_BRIGHTNESS },
{ "tv-contrast", mp_property_tv_color, CONF_TYPE_INT,
@@ -2499,7 +2580,12 @@ static const m_option_t mp_properties[] = {
M_OPT_RANGE, -100, 100, .offset = TV_COLOR_SATURATION },
{ "tv-hue", mp_property_tv_color, CONF_TYPE_INT,
M_OPT_RANGE, -100, 100, .offset = TV_COLOR_HUE },
-#endif
+ { "tv-freq", mp_property_tv_freq, CONF_TYPE_FLOAT, },
+ { "tv-norm", mp_property_tv_norm, CONF_TYPE_STRING, },
+ { "tv-scan", mp_property_tv_scan, CONF_TYPE_FLAG,
+ M_OPT_RANGE, 0, 1 },
+ { "tv-channel", mp_property_tv_channel, CONF_TYPE_STRING, },
+ { "dvb-channel", mp_property_dvb_channel, &m_option_type_intpair, },
M_PROPERTY_ALIAS("video", "vid"),
M_PROPERTY_ALIAS("audio", "aid"),
@@ -3432,142 +3518,10 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
(bar_osd ? OSD_SEEK_INFO_BAR : 0);
break;
-#if HAVE_TV
- case MP_CMD_TV_START_SCAN:
- if (get_tvh(mpctx))
- tv_start_scan(get_tvh(mpctx), 1);
- break;
- case MP_CMD_TV_SET_FREQ:
- if (get_tvh(mpctx))
- tv_set_freq(get_tvh(mpctx), cmd->args[0].v.f * 16.0);
-#if HAVE_PVR
- else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
- pvr_set_freq(mpctx->stream, ROUND(cmd->args[0].v.f));
- set_osd_msg(mpctx, osdl, osd_duration, "%s: %s",
- pvr_get_current_channelname(mpctx->stream),
- pvr_get_current_stationname(mpctx->stream));
- }
-#endif /* HAVE_PVR */
- break;
-
- case MP_CMD_TV_STEP_FREQ:
- if (get_tvh(mpctx))
- tv_step_freq(get_tvh(mpctx), cmd->args[0].v.f * 16.0);
-#if HAVE_PVR
- else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
- pvr_force_freq_step(mpctx->stream, ROUND(cmd->args[0].v.f));
- set_osd_msg(mpctx, osdl, osd_duration, "%s: f %d",
- pvr_get_current_channelname(mpctx->stream),
- pvr_get_current_frequency(mpctx->stream));
- }
-#endif /* HAVE_PVR */
- break;
-
- case MP_CMD_TV_SET_NORM:
- if (get_tvh(mpctx))
- tv_set_norm(get_tvh(mpctx), cmd->args[0].v.s);
- break;
-
- case MP_CMD_TV_STEP_CHANNEL:
- if (get_tvh(mpctx)) {
- int v = cmd->args[0].v.i;
- if (v > 0) {
- tv_step_channel(get_tvh(mpctx), TV_CHANNEL_HIGHER);
- } else {
- tv_step_channel(get_tvh(mpctx), TV_CHANNEL_LOWER);
- }
- if (tv_channel_list) {
- set_osd_msg(mpctx, osdl, osd_duration,
- "Channel: %s", tv_channel_current->name);
- }
- }
-#if HAVE_PVR
- else if (mpctx->stream &&
- mpctx->stream->type == STREAMTYPE_PVR) {
- pvr_set_channel_step(mpctx->stream, cmd->args[0].v.i);
- set_osd_msg(mpctx, osdl, osd_duration, "%s: %s",
- pvr_get_current_channelname(mpctx->stream),
- pvr_get_current_stationname(mpctx->stream));
- }
-#endif /* HAVE_PVR */
-#if HAVE_DVBIN
- if (mpctx->stream && mpctx->stream->type == STREAMTYPE_DVB) {
- int dir;
- int v = cmd->args[0].v.i;
-
- mpctx->last_dvb_step = v;
- if (v > 0)
- dir = DVB_CHANNEL_HIGHER;
- else
- dir = DVB_CHANNEL_LOWER;
-
-
- if (dvb_step_channel(mpctx->stream, dir)) {
- mpctx->stop_play = PT_RELOAD_DEMUXER;
- }
- }
-#endif /* HAVE_DVBIN */
- break;
-
- case MP_CMD_TV_SET_CHANNEL:
- if (get_tvh(mpctx)) {
- tv_set_channel(get_tvh(mpctx), cmd->args[0].v.s);
- if (tv_channel_list) {
- set_osd_msg(mpctx, osdl, osd_duration,
- "Channel: %s", tv_channel_current->name);
- }
- }
-#if HAVE_PVR
- else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
- pvr_set_channel(mpctx->stream, cmd->args[0].v.s);
- set_osd_msg(mpctx, osdl, osd_duration, "%s: %s",
- pvr_get_current_channelname(mpctx->stream),
- pvr_get_current_stationname(mpctx->stream));
- }
-#endif /* HAVE_PVR */
- break;
-
-#if HAVE_DVBIN
- case MP_CMD_DVB_SET_CHANNEL:
- if (mpctx->stream && mpctx->stream->type == STREAMTYPE_DVB) {
- mpctx->last_dvb_step = 1;
-
- if (dvb_set_channel(mpctx->stream, cmd->args[1].v.i,
- cmd->args[0].v.i)) {
- mpctx->stop_play = PT_RELOAD_DEMUXER;
- }
- }
- break;
-#endif /* HAVE_DVBIN */
-
- case MP_CMD_TV_LAST_CHANNEL:
- if (get_tvh(mpctx)) {
- tv_last_channel(get_tvh(mpctx));
- if (tv_channel_list) {
- set_osd_msg(mpctx, osdl, osd_duration,
- "Channel: %s", tv_channel_current->name);
- }
- }
-#if HAVE_PVR
- else if (mpctx->stream && mpctx->stream->type == STREAMTYPE_PVR) {
- pvr_set_lastchannel(mpctx->stream);
- set_osd_msg(mpctx, osdl, osd_duration, "%s: %s",
- pvr_get_current_channelname(mpctx->stream),
- pvr_get_current_stationname(mpctx->stream));
- }
-#endif /* HAVE_PVR */
- break;
-
- case MP_CMD_TV_STEP_NORM:
- if (get_tvh(mpctx))
- tv_step_norm(get_tvh(mpctx));
+ case MP_CMD_TV_LAST_CHANNEL: {
+ demux_stream_control(mpctx, STREAM_CTRL_TV_LAST_CHAN, NULL);
break;
-
- case MP_CMD_TV_STEP_CHANNEL_LIST:
- if (get_tvh(mpctx))
- tv_step_chanlist(get_tvh(mpctx));
- break;
-#endif /* HAVE_TV */
+ }
case MP_CMD_SUB_ADD: {
struct track *sub = mp_add_subtitles(mpctx, cmd->args[0].v.s);
diff --git a/player/loadfile.c b/player/loadfile.c
index cc65aedd6d..26f6c3a0c5 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -1257,20 +1257,13 @@ goto_reopen_demuxer: ;
//==================== START PLAYING =======================
if (!mpctx->d_video && !mpctx->d_audio) {
+ struct stream *s = mpctx->stream;
MP_FATAL(mpctx, "No video or audio streams selected.\n");
-#if HAVE_DVBIN
- if (mpctx->stream->type == STREAMTYPE_DVB) {
- int dir;
- int v = mpctx->last_dvb_step;
- if (v > 0)
- dir = DVB_CHANNEL_HIGHER;
- else
- dir = DVB_CHANNEL_LOWER;
-
- if (dvb_step_channel(mpctx->stream, dir))
+ if (s->uncached_type == STREAMTYPE_DVB) {
+ int dir = mpctx->last_dvb_step;
+ if (stream_control(s, STREAM_CTRL_DVB_STEP_CHANNEL, &dir) > 0)
mpctx->stop_play = PT_RELOAD_DEMUXER;
}
-#endif
goto terminate_playback;
}
diff --git a/player/main.c b/player/main.c
index d7b34e0ef8..19c24c036b 100644
--- a/player/main.c
+++ b/player/main.c
@@ -303,7 +303,6 @@ struct MPContext *mp_create(void)
struct MPContext *mpctx = talloc(NULL, MPContext);
*mpctx = (struct MPContext){
- .last_dvb_step = 1,
.last_chapter = -2,
.term_osd_contents = talloc_strdup(mpctx, ""),
.osd_progbar = { .type = -1 },