ARG_DEVICE_IS_MPEG_PLAYBACK,
ARG_DISPLAY,
ARG_VIDEOWINDOW,
- ARG_CLIPPING,
ARG_DO_OVERLAY,
};
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VIDEOWINDOW,
g_param_spec_pointer("videowindow","videowindow","videowindow",
G_PARAM_WRITABLE));
- g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CLIPPING,
- g_param_spec_pointer("videowindowclip","videowindowclip","videowindowclip",
- G_PARAM_WRITABLE));
gobject_class->set_property = gst_v4lelement_set_property;
gobject_class->get_property = gst_v4lelement_get_property;
break;
case ARG_VIDEOWINDOW:
if (GST_V4L_IS_OPEN(v4lelement))
- gst_v4l_set_window(v4lelement,
- ((GstV4lRect*)g_value_get_pointer(value))->x,
- ((GstV4lRect*)g_value_get_pointer(value))->y,
- ((GstV4lRect*)g_value_get_pointer(value))->w,
- ((GstV4lRect*)g_value_get_pointer(value))->h);
- break;
- case ARG_CLIPPING:
- if (GST_V4L_IS_OPEN(v4lelement))
{
- gint i;
- struct video_clip *clips;
- GList *list = (GList*)g_value_get_pointer(value);
- clips = g_malloc(sizeof(struct video_clip) * g_list_length(list));
- for (i=0;i<g_list_length(list);i++)
- {
- clips[i].x = ((GstV4lRect*)g_list_nth_data(list, i))->x;
- clips[i].y = ((GstV4lRect*)g_list_nth_data(list, i))->y;
- clips[i].width = ((GstV4lRect*)g_list_nth_data(list, i))->w;
- clips[i].height = ((GstV4lRect*)g_list_nth_data(list, i))->h;
- }
- gst_v4l_set_clips(v4lelement, clips, g_list_length(list));
- g_free(clips);
+ GByteArray *array = (GByteArray *) g_value_get_pointer(value);
+ struct video_clip *clips = (struct video_clip *) array->data;
+ gst_v4l_set_window(v4lelement,
+ clips->x, clips->y, clips->width, clips->height,
+ &clips[1], array->len/sizeof(struct video_clip)-1);
}
break;
default:
/* some more info about the current input's capabilities */
struct video_channel vchan;
- /* and last but not least, the current video window */
- struct video_window vwin;
-
/* caching values */
gint channel;
gint norm;
/******************************************************
- * gst_v4l_set_vwin():
- * does the VIDIOCSVWIN ioctl()
- * return value: TRUE on success, FALSE on error
- ******************************************************/
-
-static gboolean
-gst_v4l_set_vwin (GstV4lElement *v4lelement)
-{
- if (ioctl(v4lelement->video_fd, VIDIOCSWIN, &(v4lelement->vwin)) < 0)
- {
- gst_element_error(GST_ELEMENT(v4lelement),
- "Failed to set the video window: %s",
- sys_errlist[errno]);
- return FALSE;
- }
- return TRUE;
-}
-
-
-/******************************************************
* gst_v4l_set_window():
* sets the window where to display the video overlay
* return value: TRUE on success, FALSE on error
******************************************************/
gboolean
-gst_v4l_set_window (GstV4lElement *v4lelement,
- gint x, gint y,
- gint w, gint h)
+gst_v4l_set_window (GstV4lElement *v4lelement,
+ gint x,
+ gint y,
+ gint w,
+ gint h,
+ struct video_clip *clips,
+ gint num_clips)
{
+ struct video_window vwin;
+
DEBUG("setting video window to position (x,y/wxh) = %d,%d/%dx%d",
x, y, w, h);
+ GST_V4L_CHECK_OPEN(v4lelement);
GST_V4L_CHECK_OVERLAY(v4lelement);
- v4lelement->vwin.clipcount = 0;
- v4lelement->vwin.x = x;
- v4lelement->vwin.y = y;
- v4lelement->vwin.width = w;
- v4lelement->vwin.height = h;
- v4lelement->vwin.flags = 0;
-
- return gst_v4l_set_vwin(v4lelement);
-}
-
-
-/******************************************************
- * gst_v4l_set_clips():
- * sets video overlay clips
- * return value: TRUE on success, FALSE on error
- ******************************************************/
+ vwin.x = x;
+ vwin.y = y;
+ vwin.width = w;
+ vwin.height = h;
+ vwin.flags = 0;
-gboolean
-gst_v4l_set_clips (GstV4lElement *v4lelement,
- struct video_clip *clips,
- gint num_clips)
-{
- DEBUG("setting video window clips");
- GST_V4L_CHECK_OPEN(v4lelement);
- GST_V4L_CHECK_OVERLAY(v4lelement);
+ if (clips && !(v4lelement->vcap.type & VID_TYPE_CLIPPING))
+ {
+ DEBUG("Device \'%s\' doesn't do clipping",
+ v4lelement->videodev?v4lelement->videodev:"/dev/video");
+ vwin.clips = 0;
+ }
+ else
+ {
+ vwin.clips = clips;
+ vwin.clipcount = num_clips;
+ }
- if (!(v4lelement->vcap.type & VID_TYPE_CLIPPING))
+ if (ioctl(v4lelement->video_fd, VIDIOCSWIN, &vwin) < 0)
{
gst_element_error(GST_ELEMENT(v4lelement),
- "Device \'%s\' doesn't do clipping",
- v4lelement->videodev?v4lelement->videodev:"/dev/video");
+ "Failed to set the video window: %s",
+ sys_errlist[errno]);
return FALSE;
}
- v4lelement->vwin.clips = clips;
- v4lelement->vwin.clipcount = num_clips;
-
- return gst_v4l_set_vwin(v4lelement);
+ return TRUE;
}
return FALSE;
}
- /* and get the video window */
- if (GST_V4L_IS_OVERLAY(v4lelement))
- {
- if (ioctl(v4lelement->video_fd, VIDIOCGWIN, &(v4lelement->vwin)) < 0)
- {
- close(v4lelement->video_fd);
- v4lelement->video_fd = -1;
- gst_element_error(GST_ELEMENT(v4lelement),
- "Failed to get video window properties of \'%s\': %s",
- v4lelement->videodev, sys_errlist[errno]);
- return FALSE;
- }
- }
-
gst_info("Opened device \'%s\' (\'%s\') successfully\n",
v4lelement->vcap.name, v4lelement->videodev);
/* overlay */
gboolean gst_v4l_set_overlay (GstV4lElement *v4lelement, gchar *display);
-gboolean gst_v4l_set_window (GstV4lElement *v4lelement, gint x, gint y, gint w, gint h);
-gboolean gst_v4l_set_clips (GstV4lElement *v4lelement, struct video_clip *clips, gint num_clips);
+gboolean gst_v4l_set_window (GstV4lElement *v4lelement, gint x, gint y,
+ gint w, gint h,
+ struct video_clip *clips, gint num_clips);
gboolean gst_v4l_enable_overlay (GstV4lElement *v4lelement, gboolean enable);