[MPlayer-cvslog] r37746 - trunk/stream/stream_pvr.c

reimar subversion at mplayerhq.hu
Sat Feb 20 11:47:34 CET 2016


Author: reimar
Date: Sat Feb 20 11:47:34 2016
New Revision: 37746

Log:
stream_pvr: validate extended v4l2 controls before setting them

An hdpvr device does not support the extended v4l2 controls

	V4L2_CID_MPEG_VIDEO_ASPECT
	V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ
	V4L2_CID_MPEG_AUDIO_L1_BITRATE
	V4L2_CID_MPEG_AUDIO_L2_BITRATE
	V4L2_CID_MPEG_AUDIO_L3_BITRATE
	V4L2_CID_MPEG_AUDIO_MODE

Also, it supports only a subset of the menu options for

	V4L2_CID_MPEG_AUDIO_ENCODING
	V4L2_CID_MPEG_STREAM_TYPE

This results in the mplayer error

	[encoder] Error setting MPEG controls (Invalid argument).

Change add_v4l2_ext_control to do basic validation of a control/value pair
before adding it.

Signed-off-by: Reza Arbab <arbab at panix.com>

Patch by Reza Arbab [arbab panix.com]

Modified:
   trunk/stream/stream_pvr.c

Modified: trunk/stream/stream_pvr.c
==============================================================================
--- trunk/stream/stream_pvr.c	Sat Feb 20 11:47:32 2016	(r37745)
+++ trunk/stream/stream_pvr.c	Sat Feb 20 11:47:34 2016	(r37746)
@@ -1021,6 +1021,31 @@ static void
 add_v4l2_ext_control (struct v4l2_ext_controls *ctrls, struct pvr_t *pvr,
                       uint32_t id, int32_t value)
 {
+  struct v4l2_query_ext_ctrl qctrl = { .id = id };
+
+  /* add only if the device supports this control */
+  if (ioctl (pvr->dev_fd, VIDIOC_QUERY_EXT_CTRL, &qctrl) < 0)
+  {
+    mp_msg (MSGT_OPEN, MSGL_V,
+            "%s can't set control %d (unsupported)\n",
+            LOG_LEVEL_ENCODER, qctrl.id);
+    return;
+  }
+
+  if (qctrl.type == V4L2_CTRL_TYPE_MENU)
+  {
+    struct v4l2_querymenu qmenu = { .id = id, .index = value };
+
+    /* add only if the value is a valid menu choice */
+    if (ioctl (pvr->dev_fd, VIDIOC_QUERYMENU, &qmenu) < 0)
+    {
+      mp_msg (MSGT_OPEN, MSGL_ERR,
+              "%s can't set %s to %d (invalid menu choice)\n",
+              LOG_LEVEL_ENCODER, qctrl.name, value);
+      return;
+    }
+  }
+
   ctrls->controls[ctrls->count].id = id;
   ctrls->controls[ctrls->count].value = value;
   ctrls->count++;


More information about the MPlayer-cvslog mailing list