/*
* stream layer for hardware MPEG 1/2/4 encoders a.k.a PVR
* (such as WinTV PVR-150/250/350/500 (a.k.a IVTV), pvrusb2 and cx88)
* See http://ivtvdriver.org/index.php/Main_Page for more details on the
* cards supported by the ivtv driver.
*
* Copyright (C) 2006 Benjamin Zores
* Copyright (C) 2007 Sven Gothel (channel navigation)
*
* This file is part of MPlayer.
*
* MPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* MPlayer 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 General Public License along
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <strings.h>
#include <sys/time.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <inttypes.h>
#include <poll.h>
#include <linux/videodev2.h>
#include <libavutil/common.h>
#include <libavutil/avstring.h>
#include "osdep/io.h"
#include "common/msg.h"
#include "common/common.h"
#include "options/options.h"
#include "stream.h"
#include "tv.h"
#include "frequencies.h"
#define PVR_DEFAULT_DEVICE "/dev/video0"
#define PVR_MAX_CONTROLS 10
/* audio codec mode */
#define PVR_AUDIO_MODE_ARG_STEREO "stereo"
#define PVR_AUDIO_MODE_ARG_JOINT_STEREO "joint_stereo"
#define PVR_AUDIO_MODE_ARG_DUAL "dual"
#define PVR_AUDIO_MODE_ARG_MONO "mono"
/* video codec bitrate mode */
#define PVR_VIDEO_BITRATE_MODE_ARG_VBR "vbr"
#define PVR_VIDEO_BITRATE_MODE_ARG_CBR "cbr"
/* video codec stream type */
#define PVR_VIDEO_STREAM_TYPE_PS "ps"
#define PVR_VIDEO_STREAM_TYPE_TS "ts"
#define PVR_VIDEO_STREAM_TYPE_MPEG1 "mpeg1"
#define PVR_VIDEO_STREAM_TYPE_DVD "dvd"
#define PVR_VIDEO_STREAM_TYPE_VCD "vcd"
#define PVR_VIDEO_STREAM_TYPE_SVCD "svcd"
#define PVR_STATION_NAME_SIZE 256
/* command line arguments */
struct pvr_params {
int aspect_ratio;
int sample_rate;
int audio_layer;
int audio_bitrate;
char *audio_mode;
int bitrate;
char *bitrate_mode;
int bitrate_peak;
char *stream_type;
};
#define OPT_BASE_STRUCT struct pvr_params
const struct m_sub_options stream_pvr_conf = {
.opts = (const m_option_t[]) {
OPT_INT("aspect", aspect_ratio, 0),
OPT_INT("arate", sample_rate, 0),
OPT_INT("alayer", audio_layer, 0),
OPT_INT("abitrate", audio_bitrate, 0),
OPT_STRING("amode", audio_mode, 0),
OPT_INT("vbitrate", bitrate, 0),
OPT_STRING("vmode", bitrate_mode, 0),
OPT_INT("vpeak", bitrate_peak, 0),
OPT_STRING("fmt", stream_type, 0),
{0}
},
.size = sizeof(struct pvr_params),
};
#define BUFSTRCPY(d, s) av_strlcpy(d, s, sizeof(d))
#define BUFPRINTF(d, ...) snprintf(d, sizeof(d), __VA_ARGS__)
typedef struct station_elem_s {
char name[PVR_STATION_NAME_SIZE];
int freq;
char station[PVR_STATION_NAM
|