static int control (uint32_t request, void *data) { switch (request) { case VOCTRL_PAUSE: case VOCTRL_RESUME: return ivtv_reset (0); case VOCTRL_RESET: return ivtv_reset (1); case VOCTRL_QUERY_FORMAT: return query_format (*((uint32_t*) data)); } return VO_NOTIMPL; }
static void uninit (void) { if (ivtv_fd < 0) return; /* clear output */ ivtv_reset (1); /* close device */ close (ivtv_fd); ivtv_fd = -1; }
static int preinit (const char *arg) { struct v4l2_output vout; int err; if (subopt_parse (arg, subopts) != 0) { mp_msg (MSGT_VO, MSGL_FATAL, "\n-vo ivtv command line help:\n" "Example: mplayer -vo ivtv:device=/dev/video16:output=2\n" "\nOptions:\n" " device=/dev/videoX\n" " Name of the MPEG decoder device file.\n" " output=<0-...>\n" " V4L2 id of the TV output.\n" "\n" ); return -1; } if (!device) device = strdup (DEFAULT_MPEG_DECODER); ivtv_fd = open (device, O_RDWR); if (ivtv_fd < 0) { free (device); mp_msg (MSGT_VO, MSGL_FATAL, "%s %s\n", IVTV_VO_HDR, strerror (errno)); return -1; } /* list available outputs */ vout.index = 0; err = 1; mp_msg (MSGT_VO, MSGL_INFO, "%s Available video outputs: ", IVTV_VO_HDR); while (ioctl (ivtv_fd, VIDIOC_ENUMOUTPUT, &vout) >= 0) { err = 0; mp_msg (MSGT_VO, MSGL_INFO, "'#%d, %s' ", vout.index, vout.name); vout.index++; } if (err) { mp_msg (MSGT_VO, MSGL_INFO, "none\n"); free (device); return -1; } else mp_msg (MSGT_VO, MSGL_INFO, "\n"); /* set user specified output */ if (output != -1) { if (ioctl (ivtv_fd, VIDIOC_S_OUTPUT, &output) < 0) { mp_msg (MSGT_VO, MSGL_ERR, "%s can't set output (%s)\n", IVTV_VO_HDR, strerror (errno)); free (device); return -1; } } /* display device name */ mp_msg (MSGT_VO, MSGL_INFO, "%s using %s\n", IVTV_VO_HDR, device); free (device); /* display current video output */ if (ioctl (ivtv_fd, VIDIOC_G_OUTPUT, &output) == 0) { vout.index = output; if (ioctl (ivtv_fd, VIDIOC_ENUMOUTPUT, &vout) < 0) { mp_msg (MSGT_VO, MSGL_ERR, "%s can't get output (%s).\n", IVTV_VO_HDR, strerror (errno)); return -1; } else mp_msg (MSGT_VO, MSGL_INFO, "%s video output: %s\n", IVTV_VO_HDR, vout.name); } else { mp_msg (MSGT_VO, MSGL_ERR, "%s can't get output (%s).\n", IVTV_VO_HDR, strerror (errno)); return -1; } /* clear output */ ivtv_reset (1); return 0; }