Esempio n. 1
0
void XvWindow::setsize(int w, int h)
{
	CaptureWindow::setsize(w, h);
	/* Start the video display */
	Tk_MakeWindowExist(tk_);
	XvPutVideo(dpy_, grabID_, Tk_WindowId(tk_), gc_,
		   0, 0, base_width_, base_height_,
		   0, 0, width_, height_);
}
void
gst_v4l2_xoverlay_set_xwindow_id (GstV4l2Object * v4l2object, XID xwindow_id)
{
    GstV4l2Xv *v4l2xv;
    XWindowAttributes attr;
    gboolean change = (v4l2object->xwindow_id != xwindow_id);

    GST_LOG_OBJECT (v4l2object->element, "Setting XID to %lx",
                    (gulong) xwindow_id);

    if (!v4l2object->xv && GST_V4L2_IS_OPEN (v4l2object))
        gst_v4l2_xoverlay_open (v4l2object);

    v4l2xv = v4l2object->xv;

    if (v4l2xv)
        g_mutex_lock (v4l2xv->mutex);

    if (change) {
        if (v4l2object->xwindow_id && v4l2xv) {
            GST_DEBUG_OBJECT (v4l2object->element,
                              "Deactivating old port %lx", v4l2object->xwindow_id);

            XvSelectPortNotify (v4l2xv->dpy, v4l2xv->port, 0);
            XvSelectVideoNotify (v4l2xv->dpy, v4l2object->xwindow_id, 0);
            XvStopVideo (v4l2xv->dpy, v4l2xv->port, v4l2object->xwindow_id);
        }

        v4l2object->xwindow_id = xwindow_id;
    }

    if (!v4l2xv || xwindow_id == 0) {
        if (v4l2xv)
            g_mutex_unlock (v4l2xv->mutex);
        return;
    }

    if (change) {
        GST_DEBUG_OBJECT (v4l2object->element, "Activating new port %lx",
                          xwindow_id);

        /* draw */
        XvSelectPortNotify (v4l2xv->dpy, v4l2xv->port, 1);
        XvSelectVideoNotify (v4l2xv->dpy, v4l2object->xwindow_id, 1);
    }

    XGetWindowAttributes (v4l2xv->dpy, v4l2object->xwindow_id, &attr);
    XvPutVideo (v4l2xv->dpy, v4l2xv->port, v4l2object->xwindow_id,
                DefaultGC (v4l2xv->dpy, DefaultScreen (v4l2xv->dpy)),
                0, 0, attr.width, attr.height, 0, 0, attr.width, attr.height);

    if (v4l2xv->idle_id)
        g_source_remove (v4l2xv->idle_id);
    v4l2xv->idle_id = g_idle_add (idle_refresh, v4l2object);
    g_mutex_unlock (v4l2xv->mutex);
}
Esempio n. 3
0
static void
gst_v4l_xoverlay_set_window_handle (GstXOverlay * overlay, guintptr id)
{
  XID xwindow_id = id;
  GstV4lElement *v4lelement = GST_V4LELEMENT (overlay);
  GstV4lXv *v4lxv;
  XWindowAttributes attr;
  gboolean change = (v4lelement->xwindow_id != xwindow_id);

  GST_LOG_OBJECT (v4lelement, "Changing port to %lx", xwindow_id);

  if (!v4lelement->xv && GST_V4L_IS_OPEN (v4lelement))
    gst_v4l_xoverlay_open (v4lelement);

  v4lxv = v4lelement->xv;

  if (v4lxv)
    g_mutex_lock (v4lxv->mutex);

  if (change) {
    if (v4lelement->xwindow_id && v4lxv) {
      GST_DEBUG_OBJECT (v4lelement,
          "Disabling port %lx", v4lelement->xwindow_id);

      XvSelectPortNotify (v4lxv->dpy, v4lxv->port, 0);
      XvSelectVideoNotify (v4lxv->dpy, v4lelement->xwindow_id, 0);
      XvStopVideo (v4lxv->dpy, v4lxv->port, v4lelement->xwindow_id);
    }

    v4lelement->xwindow_id = xwindow_id;
  }

  if (!v4lxv || xwindow_id == 0) {
    if (v4lxv)
      g_mutex_unlock (v4lxv->mutex);
    return;
  }

  if (change) {
    GST_DEBUG_OBJECT (v4lelement, "Enabling port %lx", xwindow_id);

    /* draw */
    XvSelectPortNotify (v4lxv->dpy, v4lxv->port, 1);
    XvSelectVideoNotify (v4lxv->dpy, v4lelement->xwindow_id, 1);
  }

  XGetWindowAttributes (v4lxv->dpy, v4lelement->xwindow_id, &attr);
  XvPutVideo (v4lxv->dpy, v4lxv->port, v4lelement->xwindow_id,
      DefaultGC (v4lxv->dpy, DefaultScreen (v4lxv->dpy)),
      0, 0, attr.width, attr.height, 0, 0, attr.width, attr.height);

  if (v4lxv->idle_id)
    g_source_remove (v4lxv->idle_id);
  v4lxv->idle_id = g_idle_add (idle_refresh, v4lelement);
  g_mutex_unlock (v4lxv->mutex);
}
Esempio n. 4
0
static void
update_geometry (GstV4l2Object * v4l2object)
{
  GstV4l2Xv *v4l2xv = v4l2object->xv;
  GstVideoRectangle rect;
  if (!get_render_rect (v4l2object, &rect))
    return;
  /* note: we don't pass in valid video x/y/w/h.. currently the xserver
   * doesn't need to know these, as they come from v4l2 by setting the
   * crop..
   */
  XvPutVideo (v4l2xv->dpy, v4l2xv->port, v4l2object->xwindow_id,
      DefaultGC (v4l2xv->dpy, DefaultScreen (v4l2xv->dpy)),
      0, 0, rect.w, rect.h, rect.x, rect.y, rect.w, rect.h);
}
static gboolean
idle_refresh (gpointer data)
{
    GstV4l2Object *v4l2object = GST_V4L2_OBJECT (data);
    GstV4l2Xv *v4l2xv = v4l2object->xv;
    XWindowAttributes attr;

    if (v4l2xv) {
        g_mutex_lock (v4l2xv->mutex);

        XGetWindowAttributes (v4l2xv->dpy, v4l2object->xwindow_id, &attr);
        XvPutVideo (v4l2xv->dpy, v4l2xv->port, v4l2object->xwindow_id,
                    DefaultGC (v4l2xv->dpy, DefaultScreen (v4l2xv->dpy)),
                    0, 0, attr.width, attr.height, 0, 0, attr.width, attr.height);

        v4l2xv->idle_id = 0;
        g_mutex_unlock (v4l2xv->mutex);
    }

    /* once */
    return FALSE;
}