/* * test_av.c - Test for audio and video MPEG decoder API. * * Copyright (C) 2000 - 2002 convergence GmbH * Ralph Metzler * Marcus Metzler * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include int audioStop(int fd, char *arg) { if (arg) return -1; if (ioctl(fd, AUDIO_STOP) == -1) perror("AUDIO_STOP"); return 0; } int audioPlay(int fd, char *arg) { if (arg) return -1; if (ioctl(fd, AUDIO_PLAY) == -1) perror("AUDIO_PLAY"); return 0; } int audioPause(int fd, char *arg) { if (arg) return -1; if (ioctl(fd, AUDIO_PAUSE) == -1) perror("AUDIO_PAUSE"); return 0; } int audioContinue(int fd, char *arg) { if (arg) return -1; if (ioctl(fd, AUDIO_CONTINUE) == -1) perror("AUDIO_CONTINUE"); return 0; } int audioSelectSource(int fd, char *arg) { int source; if (!arg) return -1; source = atoi(arg); if (ioctl(fd, AUDIO_SELECT_SOURCE, source) == -1) perror("AUDIO_SELECT_SOURCE"); return 0; } int audioSetMute(int fd, char *arg) { int mute; if (!arg) return -1; mute = atoi(arg); if (ioctl(fd, AUDIO_SET_MUTE, mute) == -1) perror("AUDIO_SET_MUTE"); return 0; } int audioSetAVSync(int fd, char *arg) { int _sync; if (!arg) return -1; _sync = atoi(arg); if (ioctl(fd, AUDIO_SET_AV_SYNC, _sync) == -1) perror("AUDIO_SET_AV_SYNC"); return 0; } int audioSetBypassMode(int fd, char *arg) { int byp; if (!arg) return -1; byp = atoi(arg); if (ioctl(fd, AUDIO_SET_BYPASS_MODE, byp) == -1) perror("AUDIO_SET_BYPASS_MODE"); return 0; } int audioChannelSelect(int fd, char *arg) { int chan; if (!arg) return -1; chan = atoi(arg); if (ioctl(fd, AUDIO_CHANNEL_SELECT, chan) == -1) perror("AUDIO_CHANNEL_SELECT"); return 0; } int audioGetStatus(int fd, char *arg) { struct audio_status _stat; if (arg) return -1; if (ioctl(fd, AUDIO_GET_STATUS, &_stat) == -1) { perror("AUDIO_GET_STATUS"); return 0; } printf("Audio Status:\n"); printf(" Sync State : %s\n", (_stat.AV_sync_state ? "SYNC" : "NO SYNC")); printf(" Mute State : %s\n", (_stat.mute_state ? "muted" : "not muted")); printf(" Play State : "); switch ((int)_stat.play_state){ case AUDIO_STOPPED: printf("STOPPED (%d)\n",_stat.play_state); break; case AUDIO_PLAYING: printf("PLAYING (%d)\n",_stat.play_state); break; case AUDIO_PAUSED: printf("PAUSED (%d)\n",_stat.play_state); break; default: printf("unknown (%d)\n",_stat.play_state); break; } printf(" Stream Source : "); switch((int)_stat.stream_source){ case AUDIO_SOURCE_DEMUX: printf("DEMUX (%d)\n",_stat.stream_source); break; case AUDIO_SOURCE_MEMORY: printf("MEMORY (%d)\n",_stat.stream_source); break; default: printf("unknown (%d)\n",_stat.stream_source); break; } printf(" Channel Select
# DVB-T Revuca (Revuca, Slovak Republic)
# Created from http://www.dvbt.towercom.sk/odbornici.php
# T freq bw fec_hi fec_lo mod transmission-mode guard-interval hierarchy

# 2.st multiplex (commercial) - on channel 27
T 522000000 8MHz 2/3 NONE QAM64 8k 1/4 NONE

# 3.st multiplex (public) - on channel 54
T 738000000 8MHz 2/3 NONE QAM64 8k 1/4 NONE
1 memory", videoSelectSource }, { "blank", "n: 0 normal, 1 blank", videoSetBlank }, { "ff", "n: number of frames", videoFastForward }, { "slow", "n: number of frames", videoSlowMotion }, { "status", "", videoGetStatus }, { "size", "", videoGetSize }, { "stillpic", "filename", videoStillPicture}, { "format", "n: 0 4:3, 1 16:9", videoFormat}, { "dispformat", "n: 0 pan&scan, 1 letter box, 2 center cut out", videoDisplayFormat}, { NULL, NULL, NULL } }; int usage(void) { int i; printf ("commands begin with a for audio and v for video:\n\n" "q : quit\n"); for (i=0; audio_cmds[i].cmd; i++) printf("a %s %s\n", audio_cmds[i].cmd, audio_cmds[i].param_help); for (i=0; video_cmds[i].cmd; i++) printf("v %s %s\n", video_cmds[i].cmd, video_cmds[i].param_help); printf("\n"); return 0; } int syntax_error(void) { fprintf(stderr, "syntax error\n"); return 0; } int process_kbd_input(int vfd, int afd) { char buf[256], *cmd; int i; if (!fgets(buf, sizeof(buf), stdin)) return -1; cmd = strtok(buf, " \n\t"); if (!cmd) { printf("enter command or h + enter for help\n"); return 0; } if (cmd[0] == 'q' || !strcmp(cmd, "quit")) return -1; if (cmd[0] == 'h' || !strcmp(cmd, "help")) return usage(); if (cmd[0] == 'a' || !strcmp(cmd, "audio")) { cmd = strtok(NULL, " \n\t"); if (!cmd) return syntax_error(); for (i=0; audio_cmds[i].cmd; i++) { if (!strcmp(cmd, audio_cmds[i].cmd)) { cmd = strtok(NULL, " \n\t"); printf("calling '%s', arg '%s'\n", audio_cmds[i].cmd, cmd); if (audio_cmds[i].cmd_func(afd, cmd)) syntax_error(); return 0; } } return syntax_error(); } else if (buf[0] == 'v') { cmd = strtok(NULL, " \n\t"); if (!cmd) return usage(); for (i=0; video_cmds[i].cmd; i++) { if (!strcmp(cmd, video_cmds[i].cmd)) { cmd = strtok(NULL, " \n\t"); printf("calling '%s', arg '%s'\n", video_cmds[i].cmd, cmd); if (video_cmds[i].cmd_func(vfd, cmd)) syntax_error(); return 0; } } return syntax_error(); } else return syntax_error(); return 0; } int main(void) { int vfd, afd; char *videodev = "/dev/dvb/adapter0/video0"; char *audiodev = "/dev/dvb/adapter0/audio0"; if (getenv("VIDEO")) videodev = getenv("VIDEO"); if (getenv("AUDIO")) videodev = getenv("AUDIO"); printf("using video device '%s'\n", videodev); printf("using audio device '%s'\n", audiodev); printf("enter command or h + enter for help\n"); if ((vfd = open(videodev, O_RDWR | O_NONBLOCK)) < 0) { perror("open video device"); return 1; } if ((afd = open(audiodev, O_RDWR | O_NONBLOCK)) < 0) { perror("open audio device"); return 1; } while (process_kbd_input(vfd, afd) == 0) ; close(vfd); close(afd); return 0; }