예제 #1
0
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);
}
예제 #2
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);
}
예제 #3
0
void
gst_v4l2_xoverlay_set_window_handle (GstV4l2Object * v4l2object, guintptr id)
{
  GstV4l2Xv *v4l2xv;
  XID xwindow_id = id;
  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);
  }

  update_geometry (v4l2object);

  if (v4l2xv->idle_id)
    g_source_remove (v4l2xv->idle_id);
  v4l2xv->idle_id = g_idle_add (idle_refresh, v4l2object);
  g_mutex_unlock (v4l2xv->mutex);
}
예제 #4
0
void
gst_v4l2_xoverlay_set_window_handle (GstV4l2Object * v4l2object, guintptr id)
{
  GstV4l2Xv *v4l2xv;
  XID xwindow_id = id;
  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 (v4l2object->xwindow_id && v4l2xv) {
      long event_mask;

      GST_DEBUG_OBJECT (v4l2object->element, "Setting up event mask");

      event_mask = ExposureMask | StructureNotifyMask;
      if (GST_IS_NAVIGATION (v4l2object->element)) {
        event_mask |= PointerMotionMask | KeyPressMask | KeyReleaseMask;
        if (v4l2xv->internal_window)
          event_mask |= ButtonPressMask | ButtonReleaseMask;
      }
      XSelectInput (v4l2xv->dpy, v4l2object->xwindow_id, event_mask);

      if (v4l2xv->event_id)
        g_source_remove (v4l2xv->event_id);
      v4l2xv->event_id = g_timeout_add (45, event_refresh, v4l2object);
    }
  }

  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);
  }

  update_geometry (v4l2object);

  if (v4l2xv->idle_id)
    g_source_remove (v4l2xv->idle_id);
  v4l2xv->idle_id = g_idle_add (idle_refresh, v4l2object);
  g_mutex_unlock (v4l2xv->mutex);
}