static void x11video_unprepare(MSFilter *f){ X11Video *s=(X11Video*)f->data; if (s->port!=-1){ XvStopVideo(s->display,s->port, s->window_id); XvUngrabPort(s->display,s->port,CurrentTime); s->port=-1; } if (s->shminfo.shmaddr!=NULL){ XShmDetach(s->display,&s->shminfo); shmdt(s->shminfo.shmaddr); shmctl(s->shminfo.shmid,IPC_RMID,NULL); memset(&s->shminfo,0,sizeof(s->shminfo)); } if (s->gc){ XFreeGC(s->display,s->gc); s->gc=NULL; } if (s->xv_image) { XFree(s->xv_image); s->xv_image=NULL; } if (s->sws2){ ms_scaler_context_free (s->sws2); s->sws2=NULL; } if (s->local_msg){ freemsg(s->local_msg); s->local_msg=NULL; } s->ready=FALSE; }
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); }
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); }
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); }
int BC_Bitmap::delete_data() { //printf("BC_Bitmap::delete_data 1\n"); if( last_pixmap_used && xv_portid >= 0 ) XvStopVideo(top_level->display, xv_portid, last_pixmap); update_buffers(0); if( xv_portid >= 0 ) XvUngrabPort(top_level->display, xv_portid, CurrentTime); last_pixmap_used = 0; active_bfr = 0; buffer_count = 0; max_buffer_count = 0; return 0; }
int BC_Bitmap::delete_data() { if(data[0]) { if(use_shm) { switch(color_model) { case BC_YUV420P: case BC_YUV422P: case BC_YUV422: //printf("BC_Bitmap::delete_data 1\n"); if(last_pixmap_used) XvStopVideo(top_level->display, xv_portid, last_pixmap); for(int i = 0; i < ring_buffers; i++) { XFree(xv_image[i]); } XShmDetach(top_level->display, &shm_info); XvUngrabPort(top_level->display, xv_portid, CurrentTime); shmdt(shm_info.shmaddr); shmctl(shm_info.shmid, IPC_RMID, 0); break; default: for(int i = 0; i < ring_buffers; i++) { XDestroyImage(ximage[i]); delete [] row_data[i]; } XShmDetach(top_level->display, &shm_info); shmdt(shm_info.shmaddr); shmctl(shm_info.shmid, IPC_RMID, 0); break; } } else { XDestroyImage(ximage[0]); delete [] row_data[0]; } // data is automatically freed by XDestroyImage data[0] = 0; last_pixmap_used = 0; } return 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); }
XvWindow::~XvWindow() { if (image_ != 0) XvStopVideo(dpy_, grabID_, Tk_WindowId(tk_)); }