summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-01-06 20:27:36 +0100
committerwm4 <wm4@nowhere>2015-01-06 20:27:36 +0100
commit12910da66a47465a9bb335f29b5838f440a2b954 (patch)
tree624ed5c13dc3c42d55ff0310032d546695b9026b /stream
parentc915b0b0ecb9bbe66252ab96113c8c3bc9c70eb3 (diff)
downloadmpv-12910da66a47465a9bb335f29b5838f440a2b954.tar.bz2
mpv-12910da66a47465a9bb335f29b5838f440a2b954.tar.xz
stream_pvr: uncrustify
Mostly automatic, with some manual changes.
Diffstat (limited to 'stream')
-rw-r--r--stream/stream_pvr.c2494
1 files changed, 1188 insertions, 1306 deletions
diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c
index 829151ba28..9a18b29591 100644
--- a/stream/stream_pvr.c
+++ b/stream/stream_pvr.c
@@ -109,116 +109,114 @@ const struct m_sub_options stream_pvr_conf = {
#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_NAME_SIZE];
- int enabled;
- int priority;
+ char name[PVR_STATION_NAME_SIZE];
+ int freq;
+ char station[PVR_STATION_NAME_SIZE];
+ int enabled;
+ int priority;
} station_elem_t;
typedef struct stationlist_s {
- char name[PVR_STATION_NAME_SIZE];
- station_elem_t *list;
- int total; /* total number */
- int used; /* used number */
- int enabled; /* enabled number */
+ char name[PVR_STATION_NAME_SIZE];
+ station_elem_t *list;
+ int total; /* total number */
+ int used; /* used number */
+ int enabled; /* enabled number */
} stationlist_t;
struct pvr_t {
- struct mp_log *log;
- tv_param_t *tv_params;
- struct pvr_params *params;
- int dev_fd;
- char *video_dev;
- int chantab;
-
- /* v4l2 params */
- int mute;
- int input;
- int normid;
- int brightness;
- int contrast;
- int hue;
- int saturation;
- int width;
- int height;
- int freq;
- int chan_idx;
- int chan_idx_last;
- stationlist_t stationlist;
- /* dups the tv_param_channel, or the url's channel param */
- char *param_channel;
-
- /* encoder params */
- int aspect;
- int samplerate;
- int layer;
- int audio_rate;
- int audio_mode;
- int bitrate;
- int bitrate_mode;
- int bitrate_peak;
- int stream_type;
+ struct mp_log *log;
+ tv_param_t *tv_params;
+ struct pvr_params *params;
+ int dev_fd;
+ char *video_dev;
+ int chantab;
+
+ /* v4l2 params */
+ int mute;
+ int input;
+ int normid;
+ int brightness;
+ int contrast;
+ int hue;
+ int saturation;
+ int width;
+ int height;
+ int freq;
+ int chan_idx;
+ int chan_idx_last;
+ stationlist_t stationlist;
+ /* dups the tv_param_channel, or the url's channel param */
+ char *param_channel;
+
+ /* encoder params */
+ int aspect;
+ int samplerate;
+ int layer;
+ int audio_rate;
+ int audio_mode;
+ int bitrate;
+ int bitrate_mode;
+ int bitrate_peak;
+ int stream_type;
};
static int pvr_stream_control(struct stream *s, int cmd, void *arg);
-static struct pvr_t *
-pvr_init (void)
+static struct pvr_t *pvr_init(void)
{
- struct pvr_t *pvr = NULL;
-
- pvr = calloc (1, sizeof (struct pvr_t));
- pvr->dev_fd = -1;
- pvr->video_dev = strdup (PVR_DEFAULT_DEVICE);
- pvr->chantab = 5;
-
- /* v4l2 params */
- pvr->mute = 0;
- pvr->input = 0;
- pvr->normid = -1;
- pvr->brightness = 0;
- pvr->contrast = 0;
- pvr->hue = 0;
- pvr->saturation = 0;
- pvr->width = -1;
- pvr->height = -1;
- pvr->freq = -1;
- pvr->chan_idx = -1;
- pvr->chan_idx_last = -1;
-
- /* set default encoding settings
- * may be overlapped by user parameters
- * Use VBR MPEG_PS encoding at 6 Mbps (peak at 9.6 Mbps)
- * with 48 KHz L2 384 kbps audio.
- */
- pvr->aspect = V4L2_MPEG_VIDEO_ASPECT_4x3;
- pvr->samplerate = V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000;
- pvr->layer = V4L2_MPEG_AUDIO_ENCODING_LAYER_2;
- pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_384K;
- pvr->audio_mode = V4L2_MPEG_AUDIO_MODE_STEREO;
- pvr->bitrate = 6000000;
- pvr->bitrate_mode = V4L2_MPEG_VIDEO_BITRATE_MODE_VBR;
- pvr->bitrate_peak = 9600000;
- pvr->stream_type = V4L2_MPEG_STREAM_TYPE_MPEG2_PS;
-
- return pvr;
+ struct pvr_t *pvr = NULL;
+
+ pvr = calloc(1, sizeof (struct pvr_t));
+ pvr->dev_fd = -1;
+ pvr->video_dev = strdup(PVR_DEFAULT_DEVICE);
+ pvr->chantab = 5;
+
+ /* v4l2 params */
+ pvr->mute = 0;
+ pvr->input = 0;
+ pvr->normid = -1;
+ pvr->brightness = 0;
+ pvr->contrast = 0;
+ pvr->hue = 0;
+ pvr->saturation = 0;
+ pvr->width = -1;
+ pvr->height = -1;
+ pvr->freq = -1;
+ pvr->chan_idx = -1;
+ pvr->chan_idx_last = -1;
+
+ /* set default encoding settings
+ * may be overlapped by user parameters
+ * Use VBR MPEG_PS encoding at 6 Mbps (peak at 9.6 Mbps)
+ * with 48 KHz L2 384 kbps audio.
+ */
+ pvr->aspect = V4L2_MPEG_VIDEO_ASPECT_4x3;
+ pvr->samplerate = V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000;
+ pvr->layer = V4L2_MPEG_AUDIO_ENCODING_LAYER_2;
+ pvr->audio_rate = V4L2_MPEG_AUDIO_L2_BITRATE_384K;
+ pvr->audio_mode = V4L2_MPEG_AUDIO_MODE_STEREO;
+ pvr->bitrate = 6000000;
+ pvr->bitrate_mode = V4L2_MPEG_VIDEO_BITRATE_MODE_VBR;
+ pvr->bitrate_peak = 9600000;
+ pvr->stream_type = V4L2_MPEG_STREAM_TYPE_MPEG2_PS;
+
+ return pvr;
}
-static void
-pvr_uninit (struct pvr_t *pvr)
+static void pvr_uninit(struct pvr_t *pvr)
{
- if (!pvr)
- return;
+ if (!pvr)
+ return;
- /* close device */
- if (pvr->dev_fd != -1)
- close (pvr->dev_fd);
+ /* close device */
+ if (pvr->dev_fd != -1)
+ close(pvr->dev_fd);
- free (pvr->video_dev);
- free (pvr->stationlist.list);
- free (pvr->param_channel);
- free (pvr);
+ free(pvr->video_dev);
+ free(pvr->stationlist.list);
+ free(pvr->param_channel);
+ free(pvr);
}
/**
@@ -226,64 +224,61 @@ pvr_uninit (struct pvr_t *pvr)
*
* @see parse_setup_stationlist
*/
-static int
-copycreate_stationlist (struct pvr_t *pvr, stationlist_t *stationlist, int num)
+static int copycreate_stationlist(struct pvr_t *pvr, stationlist_t *stationlist,
+ int num)
{
- int i;
+ int i;
- if (pvr->chantab < 0 || !stationlist)
- return -1;
+ if (pvr->chantab < 0 || !stationlist)
+ return -1;
- num = FFMAX (num, chanlists[pvr->chantab].count);
+ num = FFMAX(num, chanlists[pvr->chantab].count);
- free (stationlist->list);
- stationlist->list = NULL;
+ free(stationlist->list);
+ stationlist->list = NULL;
- stationlist->total = 0;
- stationlist->enabled = 0;
- stationlist->used = 0;
- stationlist->list = calloc (num, sizeof (station_elem_t));
+ stationlist->total = 0;
+ stationlist->enabled = 0;
+ stationlist->used = 0;
+ stationlist->list = calloc(num, sizeof (station_elem_t));
- if (!stationlist->list)
- {
- MP_ERR(pvr, "No memory allocated for station list, giving up\n");
- return -1;
- }
-
- /* transport the channel list data to our extented struct */
- stationlist->total = num;
- BUFSTRCPY(stationlist->name, chanlists[pvr->chantab].name);
-
- for (i = 0; i < chanlists[pvr->chantab].count; i++)
- {
- stationlist->list[i].station[0]= '\0'; /* no station name yet */
- BUFSTRCPY(stationlist->list[i].name, chanlists[pvr->chantab].list[i].name);
- stationlist->list[i].freq = chanlists[pvr->chantab].list[i].freq;
- stationlist->list[i].enabled = 1; /* default enabled */
- stationlist->enabled++;
- stationlist->used++;
- }
-
- return 0;
+ if (!stationlist->list) {
+ MP_ERR(pvr, "No memory allocated for station list, giving up\n");
+ return -1;
+ }
+
+ /* transport the channel list data to our extented struct */
+ stationlist->total = num;
+ BUFSTRCPY(stationlist->name, chanlists[pvr->chantab].name);
+
+ for (i = 0; i < chanlists[pvr->chantab].count; i++) {
+ stationlist->list[i].station[0] = '\0'; /* no station name yet */
+ BUFSTRCPY(stationlist->list[i].name,
+ chanlists[pvr->chantab].list[i].name);
+ stationlist->list[i].freq = chanlists[pvr->chantab].list[i].freq;
+ stationlist->list[i].enabled = 1; /* default enabled */
+ stationlist->enabled++;
+ stationlist->used++;
+ }
+
+ return 0;
}
-static int
-print_all_stations (struct pvr_t *pvr)
+static int print_all_stations(struct pvr_t *pvr)
{
- int i;
+ int i;
- if (!pvr || !pvr->stationlist.list)
- return -1;
+ if (!pvr || !pvr->stationlist.list)
+ return -1;
- for (i = 0; i < pvr->stationlist.total; i++)
- {
- MP_VERBOSE(pvr, "%3d: [%c] channel: %8s - freq: %8d - station: %s\n",
- i, (pvr->stationlist.list[i].enabled) ? 'X' : ' ',
- pvr->stationlist.list[i].name, pvr->stationlist.list[i].freq,
- pvr->stationlist.list[i].station);
- }
+ for (i = 0; i < pvr->stationlist.total; i++) {
+ MP_VERBOSE(pvr, "%3d: [%c] channel: %8s - freq: %8d - station: %s\n",
+ i, (pvr->stationlist.list[i].enabled) ? 'X' : ' ',
+ pvr->stationlist.list[i].name, pvr->stationlist.list[i].freq,
+ pvr->stationlist.list[i].station);
+ }
- return 0;
+ return 0;
}
/**
@@ -291,14 +286,13 @@ print_all_stations (struct pvr_t *pvr)
*
* @see parse_setup_stationlist
*/
-static void
-disable_all_stations (struct pvr_t *pvr)
+static void disable_all_stations(struct pvr_t *pvr)
{
- int i;
+ int i;
- for (i = 0; i < pvr->stationlist.total; i++)
- pvr->stationlist.list[i].enabled = 0;
- pvr->stationlist.enabled = 0;
+ for (i = 0; i < pvr->stationlist.total; i++)
+ pvr->stationlist.list[i].enabled = 0;
+ pvr->stationlist.enabled = 0;
}
/**
@@ -306,108 +300,101 @@ disable_all_stations (struct pvr_t *pvr)
*
* @see parse_setup_stationlist
*/
-static int
-set_station (struct pvr_t *pvr, const char *station,
- const char *channel, int freq, int priority)
+static int set_station(struct pvr_t *pvr, const char *station,
+ const char *channel, int freq, int priority)
{
- int i;
+ int i;
- if (!pvr || !pvr->stationlist.list)
- return -1;
+ if (!pvr || !pvr->stationlist.list)
+ return -1;
- if (0 >= pvr->stationlist.total || (!channel && !freq))
- return -1;
+ if (0 >= pvr->stationlist.total || (!channel && !freq))
+ return -1;
+
+ /* select channel */
+ for (i = 0; i < pvr->stationlist.used; i++) {
+ if (channel && !strcasecmp(pvr->stationlist.list[i].name, channel))
+ break; /* found existing channel entry */
- /* select channel */
- for (i = 0; i < pvr->stationlist.used; i++)
- {
- if (channel && !strcasecmp (pvr->stationlist.list[i].name, channel))
- break; /* found existing channel entry */
+ if (freq > 0 && pvr->stationlist.list[i].freq == freq)
+ break; /* found existing frequency entry */
+ }
- if (freq > 0 && pvr->stationlist.list[i].freq == freq)
- break; /* found existing frequency entry */
- }
+ if (i < pvr->stationlist.used) {
+ /**
+ * found an existing entry,
+ * which is about to change with the user data.
+ * it is also enabled ..
+ */
+ if (!pvr->stationlist.list[i].enabled) {
+ pvr->stationlist.list[i].enabled = 1;
+ pvr->stationlist.enabled++;
+ }
- if (i < pvr->stationlist.used)
- {
- /**
- * found an existing entry,
- * which is about to change with the user data.
- * it is also enabled ..
- */
- if (!pvr->stationlist.list[i].enabled)
- {
- pvr->stationlist.list[i].enabled = 1;
- pvr->stationlist.enabled++;
+ if (station)
+ BUFSTRCPY(pvr->stationlist.list[i].station, station);
+ else if (channel)
+ BUFSTRCPY(pvr->stationlist.list[i].station, channel);
+ else
+ BUFPRINTF(pvr->stationlist.list[i].station, "F %d", freq);
+
+ pvr->stationlist.list[i].priority = priority;
+
+ MP_DBG(pvr, "Set user station channel: %8s - freq: %8d - station: %s\n",
+ pvr->stationlist.list[i].name,
+ pvr->stationlist.list[i].freq,
+ pvr->stationlist.list[i].station);
+ return 0;
}
- if (station)
- BUFSTRCPY(pvr->stationlist.list[i].station, station);
- else if (channel)
- BUFSTRCPY(pvr->stationlist.list[i].station, channel);
- else
- BUFPRINTF(pvr->stationlist.list[i].station, "F %d", freq);
+ /* from here on, we have to create a new entry, frequency is mandatory */
+ if (freq < 0) {
+ MP_ERR(pvr, "Cannot add new station/channel without frequency\n");
+ return -1;
+ }
+ if (pvr->stationlist.total < i) {
+ /**
+ * we have to extend the stationlist about
+ * an arbitrary size, even though this path is not performance critical
+ */
+ pvr->stationlist.total += 10;
+ pvr->stationlist.list =
+ realloc(pvr->stationlist.list,
+ pvr->stationlist.total * sizeof (station_elem_t));
+
+ if (!pvr->stationlist.list) {
+ MP_ERR(pvr, "No memory allocated for station list, giving up\n");
+ return -1;
+ }
+
+ /* clear the new space ..*/
+ memset(&(pvr->stationlist.list[pvr->stationlist.used]), 0,
+ (pvr->stationlist.total - pvr->stationlist.used)
+ * sizeof (station_elem_t));
+ }
+
+ /* here we go, our actual new entry */
+ pvr->stationlist.used++;
+ pvr->stationlist.list[i].enabled = 1;
pvr->stationlist.list[i].priority = priority;
+ pvr->stationlist.enabled++;
- MP_DBG(pvr, "Set user station channel: %8s - freq: %8d - station: %s\n",
- pvr->stationlist.list[i].name,
- pvr->stationlist.list[i].freq,
- pvr->stationlist.list[i].station);
- return 0;
- }
+ if (station)
+ BUFSTRCPY(pvr->stationlist.list[i].station, station);
+ if (channel)
+ BUFSTRCPY(pvr->stationlist.list[i].name, channel);
+ else
+ BUFPRINTF(pvr->stationlist.list[i].name, "F %d", freq);
- /* from here on, we have to create a new entry, frequency is mandatory */
- if (freq < 0)
- {
- MP_ERR(pvr, "Cannot add new station/channel without frequency\n");
- return -1;
- }
+ pvr->stationlist.list[i].freq = freq;
- if (pvr->stationlist.total < i)
- {
- /**
- * we have to extend the stationlist about
- * an arbitrary size, even though this path is not performance critical
- */
- pvr->stationlist.total += 10;
- pvr->stationlist.list =
- realloc (pvr->stationlist.list,
- pvr->stationlist.total * sizeof (station_elem_t));
-
- if (!pvr->stationlist.list)
- {
- MP_ERR(pvr, "No memory allocated for station list, giving up\n");
- return -1;
- }
+ MP_DBG(pvr, "Add user station channel: %8s - freq: %8d - station: %s\n",
+ pvr->stationlist.list[i].name,
+ pvr->stationlist.list[i].freq,
+ pvr->stationlist.list[i].station);
- /* clear the new space ..*/
- memset (&(pvr->stationlist.list[pvr->stationlist.used]), 0,
- (pvr->stationlist.total - pvr->stationlist.used)
- * sizeof (station_elem_t));
- }
-
- /* here we go, our actual new entry */
- pvr->stationlist.used++;
- pvr->stationlist.list[i].enabled = 1;
- pvr->stationlist.list[i].priority = priority;
- pvr->stationlist.enabled++;
-
- if (station)
- BUFSTRCPY(pvr->stationlist.list[i].station, station);
- if (channel)
- BUFSTRCPY(pvr->stationlist.list[i].name, channel);
- else
- BUFPRINTF(pvr->stationlist.list[i].name, "F %d", freq);
-
- pvr->stationlist.list[i].freq = freq;
-
- MP_DBG(pvr, "Add user station channel: %8s - freq: %8d - station: %s\n",
- pvr->stationlist.list[i].name,
- pvr->stationlist.list[i].freq,
- pvr->stationlist.list[i].station);
-
- return 0;
+ return 0;
}
static int compare_priority(const void *pa, const void *pb)
@@ -431,1278 +418,1173 @@ static int compare_priority(const void *pa, const void *pb)
* - disable all stations
* - update and/or create entries in the stationlist and enable them
*/
-static int
-parse_setup_stationlist (struct pvr_t *pvr)
+static int parse_setup_stationlist(struct pvr_t *pvr)
{
- int i;
+ int i;
- if (!pvr)
- return -1;
+ if (!pvr)
+ return -1;
- /* Create our station/channel list */
- if (pvr->tv_params->chanlist)
- {
- /* select channel list */
- for (i = 0; chanlists[i].name != NULL; i++)
- {
- if (!strcasecmp (chanlists[i].name, pvr->tv_params->chanlist))
- {
- pvr->chantab = i;
- break;
- }
- }
- if (!chanlists[i].name)
- {
- MP_ERR(pvr, "unable to find channel list %s, using default %s\n",
- pvr->tv_params->chanlist, chanlists[pvr->chantab].name);
+ /* Create our station/channel list */
+ if (pvr->tv_params->chanlist) {
+ /* select channel list */
+ for (i = 0; chanlists[i].name != NULL; i++) {
+ if (!strcasecmp(chanlists[i].name, pvr->tv_params->chanlist)) {
+ pvr->chantab = i;
+ break;
+ }
+ }
+ if (!chanlists[i].name) {
+ MP_ERR(pvr, "unable to find channel list %s, using default %s\n",
+ pvr->tv_params->chanlist, chanlists[pvr->chantab].name);
+ } else {
+ MP_INFO(pvr, "select channel list %s, entries %d\n",
+ chanlists[pvr->chantab].name, chanlists[pvr->chantab].count);
+ }
}
- else
- {
- MP_INFO(pvr, "select channel list %s, entries %d\n",
- chanlists[pvr->chantab].name, chanlists[pvr->chantab].count);
+
+ if (0 > pvr->chantab) {
+ MP_FATAL(pvr, "No channel list selected, giving up\n");
+ return -1;
}
- }
- if (0 > pvr->chantab)
- {
- MP_FATAL(pvr, "No channel list selected, giving up\n");
- return -1;
- }
+ if (copycreate_stationlist(pvr, &(pvr->stationlist), -1) < 0) {
+ MP_FATAL(pvr, "No memory allocated for station list, giving up\n");
+ return -1;
+ }
- if (copycreate_stationlist (pvr,&(pvr->stationlist), -1) < 0)
- {
- MP_FATAL(pvr, "No memory allocated for station list, giving up\n");
- return -1;
- }
+ /* Handle user channel mappings */
+ if (pvr->tv_params->channels) {
+ char channel[PVR_STATION_NAME_SIZE];
+ char station[PVR_STATION_NAME_SIZE];
+ char **channels = pvr->tv_params->channels;
- /* Handle user channel mappings */
- if (pvr->tv_params->channels)
- {
- char channel[PVR_STATION_NAME_SIZE];
- char station[PVR_STATION_NAME_SIZE];
- char **channels = pvr->tv_params->channels;
+ disable_all_stations(pvr);
- disable_all_stations (pvr);
+ int prio = 0;
+ for (i = 0; i < pvr->stationlist.total; i++)
+ pvr->stationlist.list[i].priority = ++prio;
- int prio = 0;
- for (i = 0; i < pvr->stationlist.total; i++)
- pvr->stationlist.list[i].priority = ++prio;
+ while (*channels) {
+ char *tmp = *(channels++);
+ char *sep = strchr(tmp, '-');
+ int freq = -1;
- while (*channels)
- {
- char *tmp = *(channels++);
- char *sep = strchr (tmp, '-');
- int freq=-1;
+ if (!sep)
+ continue; /* Wrong syntax, but mplayer should not crash */
- if (!sep)
- continue; /* Wrong syntax, but mplayer should not crash */
+ BUFSTRCPY(station, sep + 1);
- BUFSTRCPY(station, sep + 1);
+ sep[0] = '\0';
+ BUFSTRCPY(channel, tmp);
- sep[0] = '\0';
- BUFSTRCPY(channel, tmp);
+ while ((sep = strchr(station, '_')))
+ sep[0] = ' ';
- while ((sep = strchr (station, '_')))
- sep[0] = ' ';
+ /* if channel number is a number and larger than 1000 treat it as
+ * frequency tmp still contain pointer to null-terminated string with
+ * channel number here
+ */
+ if ((freq = atoi(channel)) <= 1000)
+ freq = -1;
- /* if channel number is a number and larger than 1000 treat it as
- * frequency tmp still contain pointer to null-terminated string with
- * channel number here
- */
- if ((freq = atoi (channel)) <= 1000)
- freq = -1;
+ if (set_station(pvr, station, (freq <= 0) ? channel : NULL, freq,
+ ++prio) < 0)
+ {
+ MP_ERR(pvr, "Unable to set user station channel: %8s - "
+ "freq: %8d - station: %s\n", channel, freq, station);
+ }
+ }
- if (set_station (pvr, station, (freq <= 0) ? channel : NULL, freq, ++prio) < 0)
- {
- MP_ERR(pvr, "Unable to set user station channel: %8s - freq: %8d - station: %s\n",
- channel, freq, station);
- }
+ qsort(pvr->stationlist.list, pvr->stationlist.total,
+ sizeof(station_elem_t), compare_priority);
}
- qsort(pvr->stationlist.list, pvr->stationlist.total,
- sizeof(station_elem_t), compare_priority);
- }
-
- return print_all_stations (pvr);
+ return print_all_stations(pvr);
}
-static int
-get_v4l2_freq (struct pvr_t *pvr)
+static int get_v4l2_freq(struct pvr_t *pvr)
{
- int freq;
- struct v4l2_frequency vf;
- struct v4l2_tuner vt;
+ int freq;
+ struct v4l2_frequency vf;
+ struct v4l2_tuner vt;
- if (!pvr)
- return -1;
+ if (!pvr)
+ return -1;
- if (pvr->dev_fd < 0)
- return -1;
+ if (pvr->dev_fd < 0)
+ return -1;
- memset (&vt, 0, sizeof (vt));
- memset (&vf, 0, sizeof (vf));
+ memset(&vt, 0, sizeof (vt));
+ memset(&vf, 0, sizeof (vf));
- if (ioctl (pvr->dev_fd, VIDIOC_G_TUNER, &vt) < 0)
- {
- MP_ERR(pvr, "can't set tuner (%s).\n", mp_strerror (errno));
- return -1;
- }
+ if (ioctl(pvr->dev_fd, VIDIOC_G_TUNER, &vt) < 0) {
+ MP_ERR(pvr, "can't set tuner (%s).\n", mp_strerror(errno));
+ return -1;
+ }
- if (ioctl (pvr->dev_fd, VIDIOC_G_FREQUENCY, &vf) < 0)
- {
- MP_ERR(pvr, "can't get frequency (%s).\n", mp_strerror(errno));
- return -1;
- }
- freq = vf.frequency;
- if (!(vt.capability & V4L2_TUNER_CAP_LOW))
- freq *= 1000;
- freq /= 16;
+ if (ioctl(pvr->dev_fd, VIDIOC_G_FREQUENCY, &vf) < 0) {
+ MP_ERR(pvr, "can't get frequency (%s).\n", mp_strerror(errno));
+ return -1;
+ }
+ freq = vf.frequency;
+ if (!(vt.capability & V4L2_TUNER_CAP_LOW))
+ freq *= 1000;
+ freq /= 16;
- return freq;
+ return freq;
}
-static int
-set_v4l2_freq (struct pvr_t *pvr)
+static int set_v4l2_freq(struct pvr_t *pvr)
{
- struct v4l2_frequency vf;
- struct v4l2_tuner vt;
+ struct v4l2_frequency vf;
+ struct v4l2_tuner vt;
- if (!pvr)
- return -1;
+ if (!pvr)
+ return -1;
- if (0 >= pvr->freq)
- {
- MP_ERR(pvr, "Frequency invalid %d !!!\n", pvr->freq);
- return -1;
- }
-
- /* don't set the frequency, if it's already set.
- * setting it here would interrupt the stream.
- */
- if (get_v4l2_freq (pvr) == pvr->freq)
- {
- MP_INFO(pvr, "Frequency %d already set.\n", pvr->freq);
- return 0;
- }
+ if (0 >= pvr->freq) {
+ MP_ERR(pvr, "Frequency invalid %d !!!\n", pvr->freq);
+ return -1;
+ }
- if (pvr->dev_fd < 0)
- return -1;
+ /* don't set the frequency, if it's already set.
+ * setting it here would interrupt the stream.
+ */
+ if (get_v4l2_freq(pvr) == pvr->freq) {
+ MP_INFO(pvr, "Frequency %d already set.\n", pvr->freq);
+ return 0;
+ }
- memset (&vf, 0, sizeof (vf));
- memset (&vt, 0, sizeof (vt));
+ if (pvr->dev_fd < 0)
+ return -1;
- if (ioctl (pvr->dev_fd, VIDIOC_G_TUNER, &vt) < 0)
- {
- MP_ERR(pvr, "can't get tuner (%s).\n", mp_strerror (errno));
- return -1;
- }
+ memset(&vf, 0, sizeof (vf));
+ memset(&vt, 0, sizeof (vt));
+
+ if (ioctl(pvr->dev_fd, VIDIOC_G_TUNER, &vt) < 0) {
+ MP_ERR(pvr, "can't get tuner (%s).\n", mp_strerror(errno));
+ return -1;
+ }
- vf.type = vt.type;
- vf.frequency = pvr->freq * 16;
+ vf.type = vt.type;
+ vf.frequency = pvr->freq * 16;
- if (!(vt.capability & V4L2_TUNER_CAP_LOW))
- vf.frequency /= 1000;
+ if (!(vt.capability & V4L2_TUNER_CAP_LOW))
+ vf.frequency /= 1000;
- if (ioctl (pvr->dev_fd, VIDIOC_S_FREQUENCY, &vf) < 0)
- {
- MP_ERR(pvr, "can't set frequency (%s).\n", mp_strerror (errno));
- return -1;
- }
+ if (ioctl(pvr->dev_fd, VIDIOC_S_FREQUENCY, &vf) < 0) {
+ MP_ERR(pvr, "can't set frequency (%s).\n", mp_strerror(errno));
+ return -1;
+ }
- memset (&vt, 0, sizeof(vt));
- if (ioctl (pvr->dev_fd, VIDIOC_G_TUNER, &vt) < 0)
- {
- MP_ERR(pvr, "can't set tuner (%s).\n", mp_strerror (errno));
- return -1;
- }
+ memset(&vt, 0, sizeof(vt));
+ if (ioctl(pvr->dev_fd, VIDIOC_G_TUNER, &vt) < 0) {
+ MP_ERR(pvr, "can't set tuner (%s).\n", mp_strerror(errno));
+ return -1;
+ }
- /* just a notification */
- if (!vt.signal)
- MP_ERR(pvr, "NO SIGNAL at frequency %d (%d)\n", pvr->freq, vf.frequency);
- else
- MP_INFO(pvr, "Got signal at frequency %d (%d)\n", pvr->freq, vf.frequency);
+ /* just a notification */
+ if (!vt.signal) {
+ MP_ERR(pvr, "NO SIGNAL at frequency %d (%d)\n", pvr->freq, vf.frequency);
+ } else {
+ MP_INFO(pvr, "Got signal at frequency %d (%d)\n", pvr->freq,
+ vf.frequency);
+ }
- return 0;
+ return 0;
}
-static int
-set_station_by_step (struct pvr_t *pvr, int step, int v4lAction)
+static int set_station_by_step(struct pvr_t *pvr, int step, int v4lAction)
{
- if (!pvr || !pvr->stationlist.list)
- return -1;
-
- if (pvr->stationlist.enabled >= abs (step))
- {
- int gotcha = 0;
- int chidx = pvr->chan_idx + step;
+ if (!pvr || !pvr->stationlist.list)
+ return -1;
- while (!gotcha)
- {
- chidx = (chidx + pvr->stationlist.used) % pvr->stationlist.used;
+ if (pvr->stationlist.enabled >= abs(step)) {
+ int gotcha = 0;
+ int chidx = pvr->chan_idx + step;
+
+ while (!gotcha) {
+ chidx = (chidx + pvr->stationlist.used) % pvr->stationlist.used;
+
+ MP_DBG(pvr, "Offset switch: current %d, enabled %d, step %d -> %d\n",
+ pvr->chan_idx, pvr->stationlist.enabled, step,
+ chidx);
+
+ if (!pvr->stationlist.list[chidx].enabled) {
+ MP_DBG(pvr, "Switch disabled to user station channel: %8s - "
+ "freq: %8d - station: %s\n",
+ pvr->stationlist.list[chidx].name,
+ pvr->stationlist.list[chidx].freq,
+ pvr->stationlist.list[chidx].station);
+ chidx += FFSIGN(step);
+ } else {
+ gotcha = 1;
+ }
+ }
- MP_DBG(pvr, "Offset switch: current %d, enabled %d, step %d -> %d\n",
- pvr->chan_idx, pvr->stationlist.enabled, step, chidx);
+ pvr->freq = pvr->stationlist.list[chidx].freq;
+ pvr->chan_idx_last = pvr->chan_idx;
+ pvr->chan_idx = chidx;
- if (!pvr->stationlist.list[chidx].enabled)
- {
- MP_DBG(pvr, "Switch disabled to user station channel: %8s - freq: %8d - station: %s\n",
+ MP_INFO(pvr, "Switch to user station channel: %8s - freq: %8d - station: %s\n",
pvr->stationlist.list[chidx].name,
pvr->stationlist.list[chidx].freq,
pvr->stationlist.list[chidx].station);
- chidx += FFSIGN (step);
- }
- else
- gotcha = 1;
+
+ if (v4lAction)
+ return set_v4l2_freq(pvr);
+
+ return (pvr->freq > 0) ? 0 : -1;
}
- pvr->freq = pvr->stationlist.list[chidx].freq;
- pvr->chan_idx_last = pvr->chan_idx;
- pvr->chan_idx = chidx;
+ MP_ERR(pvr, "Ooops couldn't set freq by channel entry step %d to "
+ "current %d, enabled %d\n",
+ step, pvr->chan_idx, pvr->stationlist.enabled);
- MP_INFO(pvr, "Switch to user station channel: %8s - freq: %8d - station: %s\n",
- pvr->stationlist.list[chidx].name,
- pvr->stationlist.list[chidx].freq,
- pvr->stationlist.list[chidx].station);
+ return -1;
+}
- if (v4lAction)
- return set_v4l2_freq (pvr);
+static int set_station_by_channelname_or_freq(struct pvr_t *pvr,
+ const char *channel,
+ int freq, int v4lAction)
+{
+ int i = 0;
- return (pvr->freq > 0) ? 0 : -1;
- }
+ if (!pvr || !pvr->stationlist.list)
+ return -1;
- MP_ERR(pvr, "Ooops couldn't set freq by channel entry step %d to current %d, enabled %d\n",
- step, pvr->chan_idx, pvr->stationlist.enabled);
+ if (0 >= pvr->stationlist.enabled) {
+ MP_WARN(pvr, "No enabled station, cannot switch channel/frequency\n");
+ return -1;
+ }
- return -1;
-}
+ if (channel) {
+ /* select by channel */
+ for (i = 0; i < pvr->stationlist.used; i++) {
+ if (!strcasecmp(pvr->stationlist.list[i].name, channel)) {
+ if (!pvr->stationlist.list[i].enabled) {
+ MP_WARN(pvr, "Switch disabled to user station channel: %8s "
+ "- freq: %8d - station: %s\n",
+ pvr->stationlist.list[i].name,
+ pvr->stationlist.list[i].freq,
+ pvr->stationlist.list[i].station);
+
+ return -1;
+ }
+
+ pvr->freq = pvr->stationlist.list[i].freq;
+ pvr->chan_idx_last = pvr->chan_idx;
+ pvr->chan_idx = i;
+ break;
+ }
+ }
+ } else if (freq >= 0) {
+ /* select by freq */
+ for (i = 0; i < pvr->stationlist.used; i++) {
+ if (pvr->stationlist.list[i].freq == freq) {
+ if (!pvr->stationlist.list[i].enabled) {
+ MP_WARN(pvr, "Switch disabled to user station channel: "
+ "%8s - freq: %8d - station: %s\n",
+ pvr->stationlist.list[i].name,
+ pvr->stationlist.list[i].freq,
+ pvr->stationlist.list[i].station);
+
+ return -1;
+ }
+
+ pvr->freq = pvr->stationlist.list[i].freq;
+ pvr->chan_idx_last = pvr->chan_idx;
+ pvr->chan_idx = i;
+ break;
+ }
+ }
+ }
-static int
-set_station_by_channelname_or_freq (struct pvr_t *pvr, const char *channel,
- int freq, int v4lAction)
-{
- int i = 0;
+ if (i >= pvr->stationlist.used) {
+ if (channel) {
+ MP_WARN(pvr, "unable to find channel %s\n", channel);
+ } else {
+ MP_WARN(pvr, "unable to find frequency %d\n", freq);
+ }
+ return -1;
+ }
- if (!pvr || !pvr->stationlist.list)
- return -1;
+ MP_INFO(pvr, "Switch to user station channel: %8s - freq: %8d - station: %s\n",
+ pvr->stationlist.list[i].name,
+ pvr->stationlist.list[i].freq,
+ pvr->stationlist.list[i].station);
- if (0 >= pvr->stationlist.enabled)
- {
- MP_WARN(pvr, "No enabled station, cannot switch channel/frequency\n");
- return -1;
- }
-
- if (channel)
- {
- /* select by channel */
- for (i = 0; i < pvr->stationlist.used ; i++)
- {
- if (!strcasecmp (pvr->stationlist.list[i].name, channel))
- {
- if (!pvr->stationlist.list[i].enabled)
- {
- MP_WARN(pvr, "Switch disabled to user station channel: %8s - freq: %8d - station: %s\n",
- pvr->stationlist.list[i].name,
- pvr->stationlist.list[i].freq,
- pvr->stationlist.list[i].station);
+ if (v4lAction)
+ return set_v4l2_freq(pvr);
+
+ return (pvr->freq > 0) ? 0 : -1;
+}
- return -1;
+static void parse_encoder_options(struct pvr_t *pvr)
+{
+ if (!pvr)
+ return;
+
+ /* -pvr aspect=digit */
+ if (pvr->params->aspect_ratio >= 0 && pvr->params->aspect_ratio <= 3)