summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Freyermuth <o.freyermuth@googlemail.com>2016-01-08 20:19:57 +0100
committerwm4 <wm4@nowhere>2016-01-14 00:36:53 +0100
commit62acd315ade4c95db5f88c9bda668677e9c6f438 (patch)
tree79628972e6797155158bd004ca242f8c63a2f2a8
parentc55b242b4ee89e91b4f9896e214c3bbe0ed46ea1 (diff)
downloadmpv-62acd315ade4c95db5f88c9bda668677e9c6f438.tar.bz2
mpv-62acd315ade4c95db5f88c9bda668677e9c6f438.tar.xz
player, stream_dvb: implement dvb-channel-name property.
On read, it returns the name of the current DVB program, on write, it triggers a channel-switch to the program if it is found in the channel list of the currently active card. Compared to the dvb-channel property which already exists and is a pair of integers (card + channel number) this has the limitation of not switching the card, but is probably of much more common use.
-rw-r--r--player/command.c22
-rw-r--r--stream/cache.c1
-rw-r--r--stream/stream.h2
-rw-r--r--stream/stream_dvb.c35
4 files changed, 59 insertions, 1 deletions
diff --git a/player/command.c b/player/command.c
index 941dd34ec5..470fcc7b0f 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2999,6 +2999,27 @@ static int mp_property_dvb_channel(void *ctx, struct m_property *prop,
return M_PROPERTY_NOT_IMPLEMENTED;
}
+static int mp_property_dvb_channel_name(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ int r;
+ switch (action) {
+ case M_PROPERTY_SET:
+ r = prop_stream_ctrl(mpctx, STREAM_CTRL_DVB_SET_CHANNEL_NAME, arg);
+ if (r == M_PROPERTY_OK && !mpctx->stop_play)
+ mpctx->stop_play = PT_RELOAD_FILE;
+ return r;
+ case M_PROPERTY_GET: {
+ return prop_stream_ctrl(mpctx, STREAM_CTRL_DVB_GET_CHANNEL_NAME, arg);
+ }
+ case M_PROPERTY_GET_TYPE:
+ *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_STRING};
+ return M_PROPERTY_OK;
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
+}
+
static int mp_property_playlist_pos(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -3626,6 +3647,7 @@ static const struct m_property mp_properties[] = {
{"tv-scan", mp_property_tv_scan},
{"tv-channel", mp_property_tv_channel},
{"dvb-channel", mp_property_dvb_channel},
+ {"dvb-channel-name", mp_property_dvb_channel_name},
{"cursor-autohide", mp_property_cursor_autohide},
diff --git a/stream/cache.c b/stream/cache.c
index 1f00fd85c9..ff5dd9fca6 100644
--- a/stream/cache.c
+++ b/stream/cache.c
@@ -418,6 +418,7 @@ static bool control_needs_flush(int stream_ctrl)
case STREAM_CTRL_SET_CURRENT_TITLE:
case STREAM_CTRL_RECONNECT:
case STREAM_CTRL_DVB_SET_CHANNEL:
+ case STREAM_CTRL_DVB_SET_CHANNEL_NAME:
case STREAM_CTRL_DVB_STEP_CHANNEL:
return true;
}
diff --git a/stream/stream.h b/stream/stream.h
index 28a6ba6bc9..11e70bcb7d 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -98,6 +98,8 @@ enum stream_ctrl {
STREAM_CTRL_TV_STEP_CHAN,
STREAM_CTRL_TV_LAST_CHAN,
STREAM_CTRL_DVB_SET_CHANNEL,
+ STREAM_CTRL_DVB_SET_CHANNEL_NAME,
+ STREAM_CTRL_DVB_GET_CHANNEL_NAME,
STREAM_CTRL_DVB_STEP_CHANNEL,
// Optical discs
diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c
index 450f8500d0..8bc6c4e200 100644
--- a/stream/stream_dvb.c
+++ b/stream/stream_dvb.c
@@ -792,6 +792,31 @@ static int dvbin_stream_control(struct stream *s, int cmd, void *arg)
}
return STREAM_ERROR;
}
+ case STREAM_CTRL_DVB_SET_CHANNEL_NAME: {
+ char *progname = *((char**)arg);
+ dvb_priv_t *priv = (dvb_priv_t *) s->priv;
+ dvb_state_t* state = priv->state;
+ int new_channel = -1;
+ for (int i=0; i < state->list->NUM_CHANNELS; ++i) {
+ if (!strcmp(state->list->channels[i].name, progname)) {
+ new_channel = i;
+ break;
+ }
+ }
+ if (new_channel == -1) {
+ MP_ERR(s, "Program '%s' not found for card %d!\n",
+ progname, state->card);
+ return STREAM_ERROR;
+ }
+ r = dvb_set_channel(s, state->card, new_channel);
+ if (r) {
+ // Stream will be pulled down after channel switch,
+ // persist state.
+ state->switching_channel = true;
+ return STREAM_OK;
+ }
+ return STREAM_ERROR;
+ }
case STREAM_CTRL_DVB_STEP_CHANNEL: {
r = dvb_step_channel(s, *(int *)arg);
if (r) {
@@ -804,6 +829,14 @@ static int dvbin_stream_control(struct stream *s, int cmd, void *arg)
}
return STREAM_ERROR;
}
+ case STREAM_CTRL_DVB_GET_CHANNEL_NAME: {
+ dvb_priv_t *priv = (dvb_priv_t *) s->priv;
+ dvb_state_t* state = priv->state;
+ int current_channel = state->list->current;
+ char* progname = state->list->channels[current_channel].name;
+ *(char **)arg = talloc_strdup(NULL, progname);
+ return STREAM_OK;
+ }
case STREAM_CTRL_GET_METADATA: {
struct mp_tags* metadata = talloc_zero(NULL, struct mp_tags);
dvb_priv_t *priv = (dvb_priv_t *) s->priv;
@@ -812,7 +845,7 @@ static int dvbin_stream_control(struct stream *s, int cmd, void *arg)
char* progname = state->list->channels[current_channel].name;
mp_tags_set_str(metadata, "title", progname);
*(struct mp_tags **)arg = metadata;
- return 1;
+ return STREAM_OK;
}
}
return STREAM_UNSUPPORTED;