summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authoralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-12-03 16:38:40 +0000
committeralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-12-03 16:38:40 +0000
commit1b902e0a669fb109962f8d13801d9fca80e21760 (patch)
tree5804eb834a7958513f1d61c0d2d3c26be4406ef1 /libmpdemux
parentbdde3d5657cf87c6c63390aa0c159ad57e6732c9 (diff)
downloadmpv-1b902e0a669fb109962f8d13801d9fca80e21760.tar.bz2
mpv-1b902e0a669fb109962f8d13801d9fca80e21760.tar.xz
update (audio support is coming:)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3285 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/tv.c58
-rw-r--r--libmpdemux/tvi_v4l.c40
2 files changed, 55 insertions, 43 deletions
diff --git a/libmpdemux/tv.c b/libmpdemux/tv.c
index a01c449a48..192fc09092 100644
--- a/libmpdemux/tv.c
+++ b/libmpdemux/tv.c
@@ -1,7 +1,9 @@
/*
- TV subsystem for libMPDemux by Alex
+ TV Interface for MPlayer
- API idea based on libvo2's
+ (C) Alex Beregszaszi <alex@naxine.org>
+
+ API idea based on libvo2
UNDER HEAVY DEVELOPEMENT, NO FEATURE REQUESTS PLEASE! :)
*/
@@ -33,7 +35,7 @@ int tv_param_on = 0;
/* some default values */
char *tv_param_freq = NULL;
-char *tv_param_channel = "26"; /* hungarian national tv channel 1 */
+char *tv_param_channel = NULL;
char *tv_param_norm = "pal";
char *tv_param_chanlist = "europe-east";
char *tv_param_device = NULL;
@@ -152,19 +154,6 @@ int stream_open_tv(stream_t *stream, tvi_handle_t *tvh)
/* set some params got from cmdline */
funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tv_param_input);
- /* we need to set frequency */
- if (tv_param_freq && (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE))
- {
- unsigned long freq = atof(tv_param_freq)*16;
-
- /* set freq in MHz */
- funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
-
- funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
- mp_msg(MSGT_TV, MSGL_INFO, "Current frequency: %lu (%.3f)\n",
- freq, (float)freq/16);
- }
-
/* select video norm */
if (!strcasecmp(tv_param_norm, "pal"))
tvh->norm = TV_NORM_PAL;
@@ -175,6 +164,12 @@ int stream_open_tv(stream_t *stream, tvi_handle_t *tvh)
mp_msg(MSGT_TV, MSGL_INFO, "Selected norm: %s\n", tv_param_norm);
+ if (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE)
+ {
+ mp_msg(MSGT_TV, MSGL_WARN, "Selected input hasn't got a tuner!\n");
+ goto start_device;
+ }
+
/* select channel list */
for (i = 0; chanlists[i].name != NULL; i++)
{
@@ -189,16 +184,34 @@ int stream_open_tv(stream_t *stream, tvi_handle_t *tvh)
if (tvh->chanlist == -1)
mp_msg(MSGT_TV, MSGL_WARN, "Unable to find selected channel list! (%s)\n",
tv_param_chanlist);
-
- mp_msg(MSGT_TV, MSGL_INFO, "Selected channel list: %s (including %d channels)\n",
- chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count);
+ else
+ mp_msg(MSGT_TV, MSGL_INFO, "Selected channel list: %s (including %d channels)\n",
+ chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count);
if (tv_param_freq && tv_param_channel)
- mp_msg(MSGT_TV, MSGL_HINT, "You can't set frequency and channel simultanly!\n");
+ {
+ mp_msg(MSGT_TV, MSGL_WARN, "You can't set frequency and channel simultanly!\n");
+ goto start_device;
+ }
- if (!tv_param_freq && tv_param_channel)
+ /* we need to set frequency */
+ if (tv_param_freq)
+ {
+ unsigned long freq = atof(tv_param_freq)*16;
+
+ /* set freq in MHz */
+ funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
+
+ funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
+ mp_msg(MSGT_TV, MSGL_INFO, "Selected frequency: %lu (%.3f)\n",
+ freq, (float)freq/16);
+ }
+
+ if (tv_param_channel)
{
struct CHANLIST cl;
+
+ mp_msg(MSGT_TV, MSGL_V, "Requested channel: %s\n", tv_param_channel);
for (i = 0; i < chanlists[tvh->chanlist].count; i++)
{
cl = tvh->chanlist_s[i];
@@ -214,7 +227,8 @@ int stream_open_tv(stream_t *stream, tvi_handle_t *tvh)
}
}
}
-
+
+start_device:
/* also start device! */
return(funcs->start(tvh->priv));
}
diff --git a/libmpdemux/tvi_v4l.c b/libmpdemux/tvi_v4l.c
index 36394592f7..1547ff5e00 100644
--- a/libmpdemux/tvi_v4l.c
+++ b/libmpdemux/tvi_v4l.c
@@ -1,5 +1,5 @@
/*
- v4l interface for libmpemux/tvi
+ Video 4 Linux input
(C) Alex Beregszaszi <alex@naxine.org>
@@ -62,7 +62,8 @@ typedef struct {
int queue;
/* audio */
- struct video_audio audio;
+ struct video_audio *audio;
+ int act_audio;
} priv_t;
#include "tvi_def.h"
@@ -261,16 +262,6 @@ static int init(priv_t *priv, tvi_param_t *params)
}
fcntl(priv->fd, F_SETFD, FD_CLOEXEC);
-// siginit();
-
-#if 0
- for (i=0; params[i].opt; i++)
- {
- if (!strcmp(params[i].opt, "input"))
- priv->input = (int)*(void **)params[i].value;
- }
- printf("priv->input: %d\n", priv->input);
-#endif
mp_msg(MSGT_TV, MSGL_INFO, "Selected device: %s\n", priv->capability.name);
mp_msg(MSGT_TV, MSGL_INFO, " Capabilites: ");
@@ -309,24 +300,31 @@ static int init(priv_t *priv, tvi_param_t *params)
if (priv->capability.audios)
{
mp_msg(MSGT_TV, MSGL_INFO, " Audio devices: %d\n", priv->capability.audios);
+
+ priv->act_audio = 0;
for (i = 0; i < priv->capability.audios; i++)
{
- priv->audio.audio = i;
- if (ioctl(priv->fd, VIDIOCGAUDIO, &priv->audio) == -1)
+ priv->audio = realloc(priv->audio, sizeof(struct video_audio)*(i+1));
+ priv->audio[i].audio = i;
+ if (ioctl(priv->fd, VIDIOCGAUDIO, &priv->audio[i]) == -1)
{
mp_msg(MSGT_TV, MSGL_ERR, "ioctl get audio failed: %s\n", strerror(errno));
break;
}
- mp_msg(MSGT_TV, MSGL_V, " %d: %s: ", priv->audio.audio,
- priv->audio.name);
- if (priv->audio.flags & VIDEO_AUDIO_MUTABLE)
+ mp_msg(MSGT_TV, MSGL_V, " %d: %s: ", priv->audio[i].audio,
+ priv->audio[i].name);
+ if (priv->audio[i].flags & VIDEO_AUDIO_MUTABLE)
mp_msg(MSGT_TV, MSGL_V, "muted=%s ",
- (priv->audio.flags & VIDEO_AUDIO_MUTE) ? "yes" : "no");
+ (priv->audio[i].flags & VIDEO_AUDIO_MUTE) ? "yes" : "no");
mp_msg(MSGT_TV, MSGL_V, "volume=%d bass=%d treble=%d balance=%d mode=%s\n",
- priv->audio.volume, priv->audio.bass, priv->audio.treble,
- priv->audio.balance, audio_mode2name[priv->audio.mode]);
+ priv->audio[i].volume, priv->audio[i].bass, priv->audio[i].treble,
+ priv->audio[i].balance, audio_mode2name[priv->audio[i].mode]);
+
+ /* un-mute channels */
+ priv->audio[i].flags &= ~VIDEO_AUDIO_MUTE;
+ ioctl(priv->fd, VIDIOCGAUDIO, &priv->audio[i]);
}
}
@@ -738,7 +736,7 @@ static int grab_video_frame(priv_t *priv, char *buffer, int len)
int frame = priv->queue % priv->nbuf;
int nextframe = (priv->queue+1) % priv->nbuf;
- mp_dbg(MSGT_TV, MSGL_DBG2, "grab_video_frame(priv=%p, buffer=%p, len=%d\n",
+ mp_dbg(MSGT_TV, MSGL_DBG2, "grab_video_frame(priv=%p, buffer=%p, len=%d)\n",
priv, buffer, len);
mp_dbg(MSGT_TV, MSGL_DBG3, "buf: %p + frame: %d => %p\n",