Small updates to avimux and the v4l plugins for usability in general
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>
Wed, 20 Feb 2002 07:25:40 +0000 (07:25 +0000)
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>
Wed, 20 Feb 2002 07:25:40 +0000 (07:25 +0000)
Original commit message from CVS:
Small updates to avimux and the v4l plugins for usability in general

sys/v4l/TODO
sys/v4l/gstv4lelement.c
sys/v4l/gstv4lmjpegsrc.c
sys/v4l/v4l_calls.c
sys/v4l/v4l_calls.h
sys/v4l/v4lmjpegsink_calls.c
sys/v4l/v4lmjpegsrc_calls.c
sys/v4l/v4lsrc_calls.c

index 05af58dab4006723158009f49f08bef52e2882b0..7e91b3b73c865303d346352f67055bbab156cb73 100644 (file)
@@ -3,11 +3,13 @@ TODO list (short term):
 * as soon as we've trashed Gtk-1.2, change 'gint palette'
     to 'guint16 palette' in gstv4lsrc.[ch]
 * v4lsrc: actually try the format out on capsnego
+* all plugins: on try_set_caps(), loop try_set_caps() per caps
+    instead of using a multi-caps so we know the end-format
 * all three: fix interlacing (not handled at all...)
 * add overlay handling in v4lelement
 * libgstrec
 * avidemux: add events (seek)
-* avimux: fps calculations
+* avimux: fps calculations (or make that a set/get_property()?)
 
 TODO list (long term):
 ======================
index ff5c73a602c1d9d4d310162affca02d4ec1c5f54..d8991cdd66cfd89dcebe45f8511012d48deb7826 100644 (file)
@@ -37,9 +37,9 @@ enum {
 enum {
   ARG_0,
   ARG_CHANNEL,
-  ARG_CHANNEL_NAME,
+  ARG_CHANNEL_NAMES,
   ARG_NORM,
-  ARG_NORM_NAME,
+  ARG_NORM_NAMES,
   ARG_HAS_TUNER,
   ARG_FREQUENCY,
   ARG_HAS_AUDIO,
@@ -119,15 +119,15 @@ gst_v4lelement_class_init (GstV4lElementClass *klass)
   g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CHANNEL,
     g_param_spec_int("channel","channel","channel",
     G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
-  g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CHANNEL_NAME,
-    g_param_spec_string("channel_name","channel_name","channel_name",
-    NULL, G_PARAM_READABLE));
+  g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CHANNEL_NAMES,
+    g_param_spec_pointer("channel_names","channel_names","channel_names",
+    G_PARAM_READABLE));
   g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NORM,
     g_param_spec_int("norm","norm","norm",
     G_MININT,G_MAXINT,0,G_PARAM_READWRITE));
-  g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NORM_NAME,
-    g_param_spec_string("norm_name","norm_name","norm_name",
-    NULL, G_PARAM_READABLE));
+  g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NORM_NAMES,
+    g_param_spec_pointer("norm_names","norm_names","norm_names",
+    G_PARAM_READABLE));
 
   g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_HAS_TUNER,
     g_param_spec_boolean("has_tuner","has_tuner","has_tuner",
@@ -346,6 +346,7 @@ gst_v4lelement_get_property (GObject    *object,
   GstV4lElement *v4lelement;
   gint temp_i = 0;
   gulong temp_ul = 0;
+  GList *list = NULL;
 
   /* it's not null if we got it, but it might not be ours */
   g_return_if_fail(GST_IS_V4LELEMENT(object));
@@ -358,25 +359,20 @@ gst_v4lelement_get_property (GObject    *object,
         gst_v4l_get_chan_norm(v4lelement, &temp_i, NULL);
       g_value_set_int(value, temp_i);
       break;
-    case ARG_CHANNEL_NAME:
+    case ARG_CHANNEL_NAMES:
       if (GST_V4L_IS_OPEN(v4lelement))
-        g_value_set_string(value, g_strdup(v4lelement->vchan.name));
-      else
-        g_value_set_string(value, g_strdup("Unknown"));
+        list = gst_v4l_get_chan_names(v4lelement);
+      g_value_set_pointer(value, (gpointer)list);
       break;
     case ARG_NORM:
       if (GST_V4L_IS_OPEN(v4lelement))
         gst_v4l_get_chan_norm(v4lelement, NULL, &temp_i);
       g_value_set_int(value, temp_i);
       break;
-    case ARG_NORM_NAME:
-      if (GST_V4L_IS_OPEN(v4lelement))
-      {
-        gst_v4l_get_chan_norm(v4lelement, NULL, &temp_i);
-        g_value_set_string(value, g_strdup(norm_name[temp_i]));
-      }
-      else
-        g_value_set_string(value, g_strdup("Unknwon"));
+    case ARG_NORM_NAMES:
+      for (temp_i=0;norm_name[temp_i]!=NULL;temp_i++)
+        list = g_list_append(list, (gpointer)g_strdup(norm_name[temp_i]));
+      g_value_set_pointer(value, (gpointer)list);
       break;
     case ARG_HAS_TUNER:
       g_value_set_boolean(value, FALSE);
index 3a9469ffb7be286456c677b061eedbac25cafa68..383e63bc07665face65e5911fca77830f4b54685 100644 (file)
@@ -313,6 +313,27 @@ gst_v4lmjpegsrc_get_property (GObject    *object,
     case ARG_HEIGHT:
       g_value_set_int(value, v4lmjpegsrc->end_height);
       break;
+    case ARG_X_OFFSET:
+      g_value_set_int(value, v4lmjpegsrc->x_offset);
+      break;
+    case ARG_Y_OFFSET:
+      g_value_set_int(value, v4lmjpegsrc->y_offset);
+      break;
+    case ARG_F_WIDTH:
+      g_value_set_int(value, v4lmjpegsrc->frame_width);
+      break;
+    case ARG_F_HEIGHT:
+      g_value_set_int(value, v4lmjpegsrc->frame_height);
+      break;
+    case ARG_H_DECIMATION:
+      g_value_set_int(value, v4lmjpegsrc->horizontal_decimation);
+      break;
+    case ARG_V_DECIMATION:
+      g_value_set_int(value, v4lmjpegsrc->vertical_decimation);
+      break;
+    case ARG_QUALITY:
+      g_value_set_int(value, v4lmjpegsrc->quality);
+      break;
     case ARG_NUMBUFS:
       g_value_set_int(value, v4lmjpegsrc->breq.count);
       break;
index 93df52f9386170dce03f6982aeb7177068a3120a..e01701c3954fb42ffc01423863ab42d1e3d97509 100644 (file)
 #include "v4l_calls.h"
 
 
-char *picture_name[] = { "Hue", "Brightness", "Contrast", "Saturation" };
+char *picture_name[] = { "Hue", "Brightness", "Contrast", "Saturation", NULL };
 
-char *audio_name[] = { "Volume", "Mute", "Mode" };
+char *audio_name[] = { "Volume", "Mute", "Mode", NULL };
 
-char *norm_name[] = { "PAL", "NTSC", "SECAM", "Autodetect" };
+char *norm_name[] = { "PAL", "NTSC", "SECAM", NULL };
 
 /******************************************************
  * gst_v4l_get_capabilities():
@@ -100,7 +100,7 @@ gst_v4l_open (GstV4lElement *v4lelement)
     return FALSE;
   }
 
-  g_message("Opened device \'%s\' (\'%s\') successfully\n",
+  gst_info("Opened device \'%s\' (\'%s\') successfully\n",
     v4lelement->vcap.name, v4lelement->videodev);
 
   return TRUE;
@@ -148,6 +148,37 @@ gst_v4l_get_num_chans (GstV4lElement *v4lelement)
 }
 
 
+/******************************************************
+ * gst_v4l_get_chan_names()
+ * return value: a GList containing the channel names
+ ******************************************************/
+
+GList *
+gst_v4l_get_chan_names (GstV4lElement *v4lelement)
+{
+  struct video_channel vchan;
+  GList *list = NULL;
+  gint i;
+
+#ifdef DEBUG
+  fprintf(stderr, "V4L: gst_v4l_get_chan_names()\n");
+#endif
+
+  if (!GST_V4L_IS_OPEN(v4lelement))
+    return NULL;
+
+  for (i=0;i<gst_v4l_get_num_chans(v4lelement);i++)
+  {
+    vchan.channel = i;
+    if (ioctl(v4lelement->video_fd, VIDIOCGCHAN, &vchan) < 0)
+      return NULL;
+    list = g_list_append(list, (gpointer)g_strdup(vchan.name));
+  }
+
+  return list;
+}
+
+
 /******************************************************
  * gst_v4l_get_chan_norm():
  *   get the currently active video-channel and it's
index e69674ed08858496736685378bbe936cfcc8ec46..2622e7a8327c02207a3651b6cb656059d189e162 100644 (file)
@@ -100,6 +100,7 @@ gboolean gst_v4l_close          (GstV4lElement *v4lelement);
 gint     gst_v4l_get_num_chans  (GstV4lElement *v4lelement);
 gboolean gst_v4l_get_chan_norm  (GstV4lElement *v4lelement, gint *channel,          gint *norm);
 gboolean gst_v4l_set_chan_norm  (GstV4lElement *v4lelement, gint  channel,          gint  norm);
+GList   *gst_v4l_get_chan_names (GstV4lElement *v4lelement);
 
 /* frequency control */
 gboolean gst_v4l_has_tuner      (GstV4lElement *v4lelement);
index c6ae2476361b85d5a1d27eecd10946a0976cc8df..cce98bb2cabb769d4c3b04d89a03ccd508ac82a4 100644 (file)
@@ -363,7 +363,7 @@ gst_v4lmjpegsink_playback_init (GstV4lMjpegSink *v4lmjpegsink)
     return FALSE;
   }
 
-  g_message("Got %ld buffers of size %ld KB\n",
+  gst_info("Got %ld buffers of size %ld KB\n",
     v4lmjpegsink->breq.count, v4lmjpegsink->breq.size/1024);
 
   /* Map the buffers */
index 34e72b047c6370471c7c149dfeb4b9e03d6423e7..8cf87e90789a84d5852cfa921a1df64f7675865f 100644 (file)
@@ -120,7 +120,7 @@ gst_v4lmjpegsrc_set_input_norm (GstV4lMjpegSrc       *v4lmjpegsrc,
 
     for (n=V4L_MJPEG_INPUT_COMPOSITE;n<V4L_MJPEG_INPUT_AUTO;n++)
     {
-      g_message("Trying %s as input...\n",
+      gst_info("Trying %s as input...\n",
         input_name[n]);
       bstat.input = n;
 
@@ -137,7 +137,7 @@ gst_v4lmjpegsrc_set_input_norm (GstV4lMjpegSrc       *v4lmjpegsrc,
         input = bstat.input;
         if (norm == VIDEO_MODE_AUTO)
           norm = bstat.norm;
-        g_message("Signal found: on input %s, norm %s\n",
+        gst_info("Signal found: on input %s, norm %s\n",
           input_name[bstat.input], norm_name[bstat.norm]);
         break;
       }
@@ -170,7 +170,7 @@ gst_v4lmjpegsrc_set_input_norm (GstV4lMjpegSrc       *v4lmjpegsrc,
     if (bstat.signal)
     {
       norm = bstat.norm;
-      g_message("Norm %s detected on input %s\n",
+      gst_info("Norm %s detected on input %s\n",
         norm_name[bstat.norm], input_name[input]);
       GST_V4LELEMENT(v4lmjpegsrc)->norm = norm;
     }
@@ -435,7 +435,7 @@ gst_v4lmjpegsrc_capture_init (GstV4lMjpegSrc *v4lmjpegsrc)
     return FALSE;
   }
 
-  g_message("Got %ld buffers of size %ld KB\n",
+  gst_info("Got %ld buffers of size %ld KB\n",
     v4lmjpegsrc->breq.count, v4lmjpegsrc->breq.size/1024);
 
   /* Map the buffers */
index cd0eb9c5fefd76b39e374cb99a1ccf01a3fb3abc..64c112033979fcc070983f5b9ecf37915844bf55 100644 (file)
@@ -292,7 +292,7 @@ gst_v4lsrc_capture_init (GstV4lSrc *v4lsrc)
     return FALSE;
   }
 
-  g_message("Got %d buffers (\'%s\') of size %d KB\n",
+  gst_info("Got %d buffers (\'%s\') of size %d KB\n",
     v4lsrc->mbuf.frames, palette_name[v4lsrc->mmap.format],
     v4lsrc->mbuf.size/(v4lsrc->mbuf.frames*1024));