comparison libmpdemux/tvi_v4l.c @ 2841:7ff47d6ae6e9

updated audio and tuner checking
author alex
date Sun, 11 Nov 2001 16:28:12 +0000
parents c63562f5f56f
children bce9c945b29c
comparison
equal deleted inserted replaced
2840:808fe0767cf8 2841:7ff47d6ae6e9
41 /* general */ 41 /* general */
42 char *video_device; 42 char *video_device;
43 int fd; 43 int fd;
44 struct video_capability capability; 44 struct video_capability capability;
45 struct video_channel *channels; 45 struct video_channel *channels;
46 int act_channel;
46 struct video_tuner tuner; 47 struct video_tuner tuner;
47 48
48 /* video */ 49 /* video */
49 struct video_picture picture; 50 struct video_picture picture;
50 int format; /* output format */ 51 int format; /* output format */
62 struct video_audio audio; 63 struct video_audio audio;
63 } priv_t; 64 } priv_t;
64 65
65 #include "tvi_def.h" 66 #include "tvi_def.h"
66 67
67 static const char *device_cap[] = { 68 static const char *device_cap2name[] = {
68 "capture", "tuner", "teletext", "overlay", "chromakey", "clipping", 69 "capture", "tuner", "teletext", "overlay", "chromakey", "clipping",
69 "frameram", "scales", "monochrome", "subcapture", "mpeg-decoder", 70 "frameram", "scales", "monochrome", "subcapture", "mpeg-decoder",
70 "mpeg-encoder", "mjpeg-decoder", "mjpeg-encoder", NULL 71 "mpeg-encoder", "mjpeg-decoder", "mjpeg-encoder", NULL
71 }; 72 };
72 73
73 static const char *device_pal[] = { 74 static const char *device_palette2name[] = {
74 "-", "grey", "hi240", "rgb16", "rgb24", "rgb32", "rgb15", "yuv422", 75 "-", "grey", "hi240", "rgb16", "rgb24", "rgb32", "rgb15", "yuv422",
75 "yuyv", "uyvy", "yuv420", "yuv411", "raw", "yuv422p", "yuv411p", 76 "yuyv", "uyvy", "yuv420", "yuv411", "raw", "yuv422p", "yuv411p",
76 "yuv420p", "yuv410p", NULL 77 "yuv420p", "yuv410p", NULL
77 }; 78 };
78 #define PALETTE(x) ((x < sizeof(device_pal)/sizeof(char*)) ? device_pal[x] : "UNKNOWN") 79 #define PALETTE(x) ((x < sizeof(device_pal)/sizeof(char*)) ? device_pal[x] : "UNKNOWN")
80
81 static const char *audio_mode2name[] = {
82 "unknown", "mono", "stereo", "language1", "language2", NULL
83 };
79 84
80 static int palette2depth(int palette) 85 static int palette2depth(int palette)
81 { 86 {
82 switch(palette) 87 switch(palette)
83 { 88 {
256 printf("priv->input: %d\n", priv->input); 261 printf("priv->input: %d\n", priv->input);
257 #endif 262 #endif
258 263
259 mp_msg(MSGT_TV, MSGL_INFO, "Selected device: %s\n", priv->capability.name); 264 mp_msg(MSGT_TV, MSGL_INFO, "Selected device: %s\n", priv->capability.name);
260 mp_msg(MSGT_TV, MSGL_INFO, " Capabilites: "); 265 mp_msg(MSGT_TV, MSGL_INFO, " Capabilites: ");
261 for (i = 0; device_cap[i] != NULL; i++) 266 for (i = 0; device_cap2name[i] != NULL; i++)
262 if (priv->capability.type & (1 << i)) 267 if (priv->capability.type & (1 << i))
263 mp_msg(MSGT_TV, MSGL_INFO, "%s ", device_cap[i]); 268 mp_msg(MSGT_TV, MSGL_INFO, "%s ", device_cap2name[i]);
264 mp_msg(MSGT_TV, MSGL_INFO, "\n"); 269 mp_msg(MSGT_TV, MSGL_INFO, "\n");
265 mp_msg(MSGT_TV, MSGL_INFO, " Device type: %d\n", priv->capability.type); 270 mp_msg(MSGT_TV, MSGL_INFO, " Device type: %d\n", priv->capability.type);
266 mp_msg(MSGT_TV, MSGL_INFO, " Supported sizes: %dx%d => %dx%d\n", 271 mp_msg(MSGT_TV, MSGL_INFO, " Supported sizes: %dx%d => %dx%d\n",
267 priv->capability.minwidth, priv->capability.minheight, 272 priv->capability.minwidth, priv->capability.minheight,
268 priv->capability.maxwidth, priv->capability.maxheight); 273 priv->capability.maxwidth, priv->capability.maxheight);
273 priv->channels = (struct video_channel *)malloc(sizeof(struct video_channel)*priv->capability.channels); 278 priv->channels = (struct video_channel *)malloc(sizeof(struct video_channel)*priv->capability.channels);
274 memset(priv->channels, 0, sizeof(struct video_channel)*priv->capability.channels); 279 memset(priv->channels, 0, sizeof(struct video_channel)*priv->capability.channels);
275 for (i = 0; i < priv->capability.channels; i++) 280 for (i = 0; i < priv->capability.channels; i++)
276 { 281 {
277 priv->channels[i].channel = i; 282 priv->channels[i].channel = i;
278 ioctl(priv->fd, VIDIOCGCHAN, &priv->channels[i]); 283 if (ioctl(priv->fd, VIDIOCGCHAN, &priv->channels[i]) == -1)
284 {
285 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get channel failed: %s\n", strerror(errno));
286 break;
287 }
279 mp_msg(MSGT_TV, MSGL_INFO, " %d: %s: %s%s%s%s (tuner:%d, norm:%d)\n", i, 288 mp_msg(MSGT_TV, MSGL_INFO, " %d: %s: %s%s%s%s (tuner:%d, norm:%d)\n", i,
280 priv->channels[i].name, 289 priv->channels[i].name,
281 (priv->channels[i].flags & VIDEO_VC_TUNER) ? "tuner " : "", 290 (priv->channels[i].flags & VIDEO_VC_TUNER) ? "tuner " : "",
282 (priv->channels[i].flags & VIDEO_VC_AUDIO) ? "audio " : "", 291 (priv->channels[i].flags & VIDEO_VC_AUDIO) ? "audio " : "",
283 (priv->channels[i].flags & VIDEO_TYPE_TV) ? "tv " : "", 292 (priv->channels[i].flags & VIDEO_TYPE_TV) ? "tv " : "",
284 (priv->channels[i].flags & VIDEO_TYPE_CAMERA) ? "camera " : "", 293 (priv->channels[i].flags & VIDEO_TYPE_CAMERA) ? "camera " : "",
285 priv->channels[i].tuners, 294 priv->channels[i].tuners,
286 priv->channels[i].norm); 295 priv->channels[i].norm);
287 } 296 }
288 297
298 if (priv->capability.audios)
299 {
300 mp_msg(MSGT_TV, MSGL_INFO, " Audio devices: %d\n", priv->capability.audios);
301
302 for (i = 0; i < priv->capability.audios; i++)
303 {
304 priv->audio.audio = i;
305 if (ioctl(priv->fd, VIDIOCGAUDIO, &priv->audio) == -1)
306 {
307 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get audio failed: %s\n", strerror(errno));
308 break;
309 }
310
311 mp_msg(MSGT_TV, MSGL_V, " %d: %s: ", priv->audio.audio,
312 priv->audio.name);
313 if (priv->audio.flags & VIDEO_AUDIO_MUTABLE)
314 mp_msg(MSGT_TV, MSGL_V, "muted=%s ",
315 (priv->audio.flags & VIDEO_AUDIO_MUTE) ? "yes" : "no");
316 mp_msg(MSGT_TV, MSGL_V, "volume=%d bass=%d treble=%d balance=%d mode=%s\n",
317 priv->audio.volume, priv->audio.bass, priv->audio.treble,
318 priv->audio.balance, audio_mode2name[priv->audio.mode]);
319 }
320 }
321
289 if (!(priv->capability.type & VID_TYPE_CAPTURE)) 322 if (!(priv->capability.type & VID_TYPE_CAPTURE))
290 { 323 {
291 mp_msg(MSGT_TV, MSGL_ERR, "Only grabbing supported (for overlay use another program)\n"); 324 mp_msg(MSGT_TV, MSGL_ERR, "Only grabbing supported (for overlay use another program)\n");
292 goto err; 325 goto err;
293 } 326 }
314 priv->nbuf = priv->mbuf.frames; 347 priv->nbuf = priv->mbuf.frames;
315 348
316 /* video buffers */ 349 /* video buffers */
317 priv->buf = (struct video_mmap *)malloc(priv->nbuf * sizeof(struct video_mmap)); 350 priv->buf = (struct video_mmap *)malloc(priv->nbuf * sizeof(struct video_mmap));
318 memset(priv->buf, 0, priv->nbuf * sizeof(struct video_mmap)); 351 memset(priv->buf, 0, priv->nbuf * sizeof(struct video_mmap));
352
319 353
320 return(1); 354 return(1);
321 355
322 err: 356 err:
323 if (priv->fd != -1) 357 if (priv->fd != -1)
408 if (priv->capability.type & VID_TYPE_CAPTURE) 442 if (priv->capability.type & VID_TYPE_CAPTURE)
409 return(TVI_CONTROL_TRUE); 443 return(TVI_CONTROL_TRUE);
410 return(TVI_CONTROL_FALSE); 444 return(TVI_CONTROL_FALSE);
411 } 445 }
412 case TVI_CONTROL_IS_AUDIO: 446 case TVI_CONTROL_IS_AUDIO:
413 return(TVI_CONTROL_FALSE); /* IMPLEMENT CHECK! */ 447 #if 0 /* also disable audio for as it's not working! */
448 if (priv->channels[priv->act_channel].flags & VIDEO_VC_AUDIO)
449 return(TVI_CONTROL_TRUE);
450 #endif
451 return(TVI_CONTROL_FALSE);
414 case TVI_CONTROL_IS_TUNER: 452 case TVI_CONTROL_IS_TUNER:
415 { 453 {
416 if (priv->capability.type & VID_TYPE_TUNER) 454 // if (priv->capability.type & VID_TYPE_TUNER)
455 if (priv->channels[priv->act_channel].flags & VIDEO_VC_TUNER)
417 return(TVI_CONTROL_TRUE); 456 return(TVI_CONTROL_TRUE);
418 return(TVI_CONTROL_FALSE); 457 return(TVI_CONTROL_FALSE);
419 } 458 }
420 459
421 /* ========== VIDEO controls =========== */ 460 /* ========== VIDEO controls =========== */
610 for (i = 0; i < priv->capability.channels; i++) 649 for (i = 0; i < priv->capability.channels; i++)
611 { 650 {
612 if (priv->channels[i].channel == req_chan) 651 if (priv->channels[i].channel == req_chan)
613 break; 652 break;
614 } 653 }
654
655 priv->act_channel = i;
615 656
616 if (ioctl(priv->fd, VIDIOCGCHAN, &priv->channels[i]) == -1) 657 if (ioctl(priv->fd, VIDIOCGCHAN, &priv->channels[i]) == -1)
617 { 658 {
618 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get channel failed: %s\n", strerror(errno)); 659 mp_msg(MSGT_TV, MSGL_ERR, "ioctl get channel failed: %s\n", strerror(errno));
619 return(TVI_CONTROL_FALSE); 660 return(TVI_CONTROL_FALSE);
645 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set chan failed: %s\n", strerror(errno)); 686 mp_msg(MSGT_TV, MSGL_ERR, "ioctl set chan failed: %s\n", strerror(errno));
646 return(TVI_CONTROL_FALSE); 687 return(TVI_CONTROL_FALSE);
647 } 688 }
648 mp_msg(MSGT_TV, MSGL_INFO, "Using input '%s'\n", chan.name); 689 mp_msg(MSGT_TV, MSGL_INFO, "Using input '%s'\n", chan.name);
649 690
691 priv->act_channel = i;
692
650 /* update tuner state */ 693 /* update tuner state */
651 if (priv->capability.type & VID_TYPE_TUNER) 694 // if (priv->capability.type & VID_TYPE_TUNER)
695 if (priv->channels[priv->act_channel].flags & VIDEO_VC_TUNER)
652 control(priv, TVI_CONTROL_TUN_GET_TUNER, 0); 696 control(priv, TVI_CONTROL_TUN_GET_TUNER, 0);
653 697
654 /* update local channel list */ 698 /* update local channel list */
655 control(priv, TVI_CONTROL_SPC_GET_INPUT, &req_chan); 699 control(priv, TVI_CONTROL_SPC_GET_INPUT, &req_chan);
656 return(TVI_CONTROL_TRUE); 700 return(TVI_CONTROL_TRUE);