static void android_display_process(MSFilter *f){ AndroidDisplay *ad=(AndroidDisplay*)f->data; MSPicture pic; mblk_t *m; ms_filter_lock(f); if (ad->android_video_window){ if ((m=ms_queue_peek_last(f->inputs[0]))!=NULL){ if (ms_yuv_buf_init_from_mblk (&pic,m)==0){ /* schedule display of frame */ if (!ad->ogl || !ad->ogl_free_ready) { /* m is dupb'ed inside ogl_display */ ogl_display_set_yuv_to_display(ad->ogl, m); } else { ms_warning("%s: opengldisplay not ready (%p)", __FUNCTION__, ad->ogl); } JNIEnv *jenv=ms_get_jni_env(); (*jenv)->CallVoidMethod(jenv,ad->android_video_window,ad->request_render_id); } } } ms_filter_unlock(f); ms_queue_flush(f->inputs[0]); if (f->inputs[1] != NULL) ms_queue_flush(f->inputs[1]); }
static void glxvideo_process(MSFilter *f){ GLXVideo *obj=(GLXVideo*)f->data; mblk_t *inm; MSPicture src={0}; XWindowAttributes wa; XGetWindowAttributes(obj->display,obj->window_id,&wa); if (wa.width!=obj->wsize.width || wa.height!=obj->wsize.height){ ms_warning("Resized to %ix%i", wa.width,wa.height); obj->wsize.width=wa.width; obj->wsize.height=wa.height; ogl_display_init(obj->glhelper, wa.width, wa.height); } ms_filter_lock(f); if (!obj->show) { goto end; } if (!obj->ready) glxvideo_prepare(f); if (!obj->ready){ goto end; } glXMakeCurrent( obj->display, obj->window_id, obj->glContext ); if (f->inputs[0]!=NULL && (inm=ms_queue_peek_last(f->inputs[0]))!=0) { if (ms_yuv_buf_init_from_mblk(&src,inm)==0){ ogl_display_set_yuv_to_display(obj->glhelper, inm); } } if (f->inputs[1]!=NULL && (inm=ms_queue_peek_last(f->inputs[1]))!=0) { if (ms_yuv_buf_init_from_mblk(&src,inm)==0){ ogl_display_set_preview_yuv_to_display(obj->glhelper, inm); } } ogl_display_render(obj->glhelper, 0); glXSwapBuffers ( obj->display, obj->window_id ); end: ms_filter_unlock(f); if (f->inputs[0]!=NULL) ms_queue_flush(f->inputs[0]); if (f->inputs[1]!=NULL) ms_queue_flush(f->inputs[1]); }
static void glxvideo_process(MSFilter *f){ GLXVideo *obj=(GLXVideo*)f->data; mblk_t *inm; MSPicture src={0}; bool_t precious=FALSE; XWindowAttributes wa; XGetWindowAttributes(obj->display,obj->window_id,&wa); if (wa.width!=obj->wsize.width || wa.height!=obj->wsize.height){ ms_warning("Resized to %ix%i", wa.width,wa.height); obj->wsize.width=wa.width; obj->wsize.height=wa.height; ogl_display_init(obj->glhelper, wa.width, wa.height); } ms_filter_lock(f); if (!obj->show) { goto end; } if (!obj->ready) glxvideo_prepare(f); if (!obj->ready){ goto end; } glXMakeCurrent( obj->display, obj->window_id, obj->glContext ); if (f->inputs[0]!=NULL && (inm=ms_queue_peek_last(f->inputs[0]))!=0) { if (ms_yuv_buf_init_from_mblk(&src,inm)==0){ MSVideoSize newsize; newsize.width=src.w; newsize.height=src.h; precious=mblk_get_precious_flag(inm); if (!ms_video_size_equal(newsize,obj->vsize) ) { ms_message("received size is %ix%i",newsize.width,newsize.height); obj->vsize=newsize; if (obj->autofit){ MSVideoSize new_window_size; static const MSVideoSize min_size=MS_VIDEO_SIZE_QVGA; /*don't resize less than QVGA, it is too small*/ if (min_size.width*min_size.height>newsize.width*newsize.height){ new_window_size.width=newsize.width*2; new_window_size.height=newsize.height*2; }else new_window_size=newsize; obj->wsize=new_window_size; ms_message("autofit: new window size should be %ix%i",new_window_size.width,new_window_size.height); XResizeWindow(obj->display,obj->window_id,new_window_size.width,new_window_size.height); XSync(obj->display,FALSE); } glxvideo_unprepare(f); glxvideo_prepare(f); if (!obj->ready) goto end; } if (obj->mirror && !precious) ms_yuv_buf_mirror(&src); ogl_display_set_yuv_to_display(obj->glhelper, inm); } } if (f->inputs[1]!=NULL && (inm=ms_queue_peek_last(f->inputs[1]))!=0) { if (ms_yuv_buf_init_from_mblk(&src,inm)==0){ ogl_display_set_preview_yuv_to_display(obj->glhelper, inm); } } ogl_display_render(obj->glhelper, 0); glXSwapBuffers ( obj->display, obj->window_id ); end: ms_filter_unlock(f); if (f->inputs[0]!=NULL) ms_queue_flush(f->inputs[0]); if (f->inputs[1]!=NULL) ms_queue_flush(f->inputs[1]); }