changeset 36428:7766530caa76

Add new stream control command STREAM_CTRL_GET_CURRENT_CHANNEL. This provides the name of the currently selected DVB channel. (Unsupported for analog TV though.)
author ib
date Fri, 29 Nov 2013 12:34:21 +0000
parents 960593201c48
children 28ea255e40ce
files stream/cache2.c stream/stream.h stream/stream_dvb.c stream/stream_tv.c
diffstat 4 files changed, 37 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/stream/cache2.c	Fri Nov 29 00:26:17 2013 +0000
+++ b/stream/cache2.c	Fri Nov 29 12:34:21 2013 +0000
@@ -94,6 +94,7 @@
   volatile int control;
   volatile uint64_t control_uint_arg;
   volatile double control_double_arg;
+  volatile char *control_char_p_arg;
   volatile struct stream_lang_req control_lang_arg;
   volatile int control_res;
   volatile double stream_time_length;
@@ -327,6 +328,9 @@
     case STREAM_CTRL_GET_LANG:
       s->control_res = s->stream->control(s->stream, s->control, (void *)&s->control_lang_arg);
       break;
+    case STREAM_CTRL_GET_CURRENT_CHANNEL:
+      s->control_res = s->stream->control(s->stream, s->control, &s->control_char_p_arg);
+      break;
     default:
       s->control_res = STREAM_UNSUPPORTED;
       break;
@@ -654,6 +658,10 @@
     case -2:
       s->control = cmd;
       break;
+    case STREAM_CTRL_GET_CURRENT_CHANNEL:
+      s->control_char_p_arg = *(char **)arg;
+      s->control = cmd;
+      break;
     default:
       return STREAM_UNSUPPORTED;
   }
@@ -699,6 +707,9 @@
     case STREAM_CTRL_GET_LANG:
       *(struct stream_lang_req *)arg = s->control_lang_arg;
       break;
+    case STREAM_CTRL_GET_CURRENT_CHANNEL:
+      *(char **)arg = (char *)s->control_char_p_arg;
+      break;
   }
   return s->control_res;
 }
--- a/stream/stream.h	Fri Nov 29 00:26:17 2013 +0000
+++ b/stream/stream.h	Fri Nov 29 12:34:21 2013 +0000
@@ -97,6 +97,7 @@
 #define STREAM_CTRL_GET_NUM_TITLES 12
 #define STREAM_CTRL_GET_LANG 13
 #define STREAM_CTRL_GET_CURRENT_TITLE 14
+#define STREAM_CTRL_GET_CURRENT_CHANNEL 15
 
 enum stream_ctrl_type {
 	stream_ctrl_audio,
--- a/stream/stream_dvb.c	Fri Nov 29 00:26:17 2013 +0000
+++ b/stream/stream_dvb.c	Fri Nov 29 12:34:21 2013 +0000
@@ -656,6 +656,25 @@
 
 
 
+static int dvb_control(stream_t *stream, int cmd, void *arg)
+{
+    dvb_priv_t *priv = stream->priv;
+    dvb_channels_list *list;
+
+    switch (cmd) {
+    case STREAM_CTRL_GET_CURRENT_CHANNEL:
+        if (priv) {
+            list = priv->list;
+            *(char **)arg = list->channels[list->current].name;
+            return STREAM_OK;
+        } else
+            return STREAM_ERROR;
+    }
+
+    return STREAM_UNSUPPORTED;
+}
+
+
 
 static int dvb_open(stream_t *stream, int mode, void *opts, int *file_format)
 {
@@ -734,6 +753,7 @@
 
 	stream->type = STREAMTYPE_DVB;
 	stream->fill_buffer = dvb_streaming_read;
+	stream->control = dvb_control;
 	stream->close = dvbin_close;
 	m_struct_free(&stream_opts, opts);
 
--- a/stream/stream_tv.c	Fri Nov 29 00:26:17 2013 +0000
+++ b/stream/stream_tv.c	Fri Nov 29 12:34:21 2013 +0000
@@ -106,12 +106,17 @@
     m_struct_free(&stream_opts,stream->priv);
   stream->priv=NULL;
 }
+static int tv_stream_control(stream_t *stream, int cmd, void *arg)
+{
+    return STREAM_UNSUPPORTED;
+}
 static int
 tv_stream_open (stream_t *stream, int mode, void *opts, int *file_format)
 {
 
   stream->type = STREAMTYPE_TV;
   stream->priv = opts;
+  stream->control = tv_stream_control;
   stream->close=tv_stream_close;
   *file_format =  DEMUXER_TYPE_TV;