X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_filter%2Fremoteosd.c;h=e13cd64866b97dd41bf2279023e6eadfd9eabcf5;hb=5aa33f1fab766842d59a7dcb7aa462aab9c681cf;hp=bd3d0d0529ae65ce4aaa336b73f5eafa8544fa27;hpb=5a0ac45ff4813ab8b3fe1ac39f0c87489bd1fe30;p=vlc diff --git a/modules/video_filter/remoteosd.c b/modules/video_filter/remoteosd.c index bd3d0d0529..e13cd64866 100644 --- a/modules/video_filter/remoteosd.c +++ b/modules/video_filter/remoteosd.c @@ -115,14 +115,14 @@ static int CreateFilter ( vlc_object_t * ); static void DestroyFilter( vlc_object_t * ); -vlc_module_begin(); - set_description( N_("Remote-OSD over VNC") ); - set_capability( "sub filter", 100 ); - set_shortname( N_("Remote-OSD") ); - set_category( CAT_VIDEO ); - set_subcategory( SUBCAT_VIDEO_SUBPIC ); - add_shortcut( "rmtosd" ); - set_callbacks( CreateFilter, DestroyFilter ); +vlc_module_begin () + set_description( N_("Remote-OSD over VNC") ) + set_capability( "sub filter", 100 ) + set_shortname( N_("Remote-OSD") ) + set_category( CAT_VIDEO ) + set_subcategory( SUBCAT_VIDEO_SUBPIC ) + add_shortcut( "rmtosd" ) + set_callbacks( CreateFilter, DestroyFilter ) add_string( RMTOSD_CFG "host", "myvdr", NULL, RMTOSD_HOST_TEXT, RMTOSD_HOST_LONGTEXT, false ); @@ -142,7 +142,7 @@ vlc_module_begin(); add_integer_with_range( RMTOSD_CFG "alpha", 255, 0, 255, NULL, RMTOSD_ALPHA_TEXT, RMTOSD_ALPHA_LONGTEXT, true ); -vlc_module_end(); +vlc_module_end () /***************************************************************************** @@ -162,9 +162,9 @@ static int KeyEvent( vlc_object_t *p_this, char const *psz_var, static void stop_osdvnc ( filter_t *p_filter ); -static void vnc_worker_thread ( vlc_object_t *p_thread_obj ); +static void* vnc_worker_thread ( vlc_object_t *p_thread_obj ); -static void update_request_thread( vlc_object_t *p_thread_obj ); +static void* update_request_thread( vlc_object_t *p_thread_obj ); static bool open_vnc_connection ( filter_t *p_filter ); @@ -282,7 +282,7 @@ static int CreateFilter ( vlc_object_t *p_this ) p_sys->i_alpha = var_CreateGetIntegerCommand( p_this, RMTOSD_CFG "alpha" ); - /* in miliseconds, 0 disables polling, should not be lower than 100 */ + /* in milliseconds, 0 disables polling, should not be lower than 100 */ p_sys->i_vnc_poll_interval = var_CreateGetIntegerCommand( p_this, RMTOSD_CFG "update" ); if ( p_sys->i_vnc_poll_interval < 100) @@ -672,11 +672,12 @@ static bool handshaking ( filter_t *p_filter ) } -static void vnc_worker_thread( vlc_object_t *p_thread_obj ) +static void* vnc_worker_thread( vlc_object_t *p_thread_obj ) { filter_t* p_filter = (filter_t*)(p_thread_obj->p_parent); filter_sys_t *p_sys = p_filter->p_sys; vlc_object_t *p_update_request_thread; + int canc = vlc_savecancel (); msg_Dbg( p_filter, "VNC worker thread started" ); @@ -799,12 +800,15 @@ exit: vlc_mutex_unlock( &p_sys->lock ); msg_Dbg( p_filter, "VNC message reader thread ended" ); + vlc_restorecancel (canc); + return NULL; } -static void update_request_thread( vlc_object_t *p_thread_obj ) +static void* update_request_thread( vlc_object_t *p_thread_obj ) { filter_t* p_filter = (filter_t*)(p_thread_obj->p_parent); filter_sys_t *p_sys = p_filter->p_sys; + int canc = vlc_savecancel (); msg_Dbg( p_filter, "VNC update request thread started" ); @@ -821,7 +825,7 @@ static void update_request_thread( vlc_object_t *p_thread_obj ) { msg_Err( p_filter, "Could not write rfbFramebufferUpdateRequestMsg." ); p_sys->b_continue = false; - return; + return NULL; } udr.incremental = 1; @@ -847,6 +851,8 @@ static void update_request_thread( vlc_object_t *p_thread_obj ) } msg_Dbg( p_filter, "VNC update request thread ended" ); + vlc_restorecancel (canc); + return NULL; } static bool process_server_message ( filter_t *p_filter, @@ -1156,7 +1162,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) fmt.i_width = fmt.i_visible_width = p_pic->p[Y_PLANE].i_visible_pitch; fmt.i_height = fmt.i_visible_height = p_pic->p[Y_PLANE].i_visible_lines; fmt.i_x_offset = fmt.i_y_offset = 0; - p_region = p_spu->pf_create_region( VLC_OBJECT(p_filter), &fmt ); + p_region = subpicture_region_New( &fmt ); if( !p_region ) { msg_Err( p_filter, "cannot allocate SPU region" ); @@ -1165,19 +1171,20 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) return NULL; } - vout_CopyPicture( p_filter, &p_region->picture, p_pic ); + /* FIXME the copy is probably not needed anymore */ + picture_Copy( p_region->p_picture, p_pic ); p_sys->b_need_update = false; vlc_mutex_unlock( &p_sys->lock ); /* set to one of the 9 relative locations */ - p_region->i_align = 0; //=CENTER + p_region->i_align = 0; /* Center */ p_spu->b_absolute = false; - p_spu->i_x = 0; - p_spu->i_y = 0; + p_spu->i_original_picture_width = 0; /*Let vout core do the horizontal scaling */ + p_spu->i_original_picture_height = fmt.i_height; p_spu->p_region = p_region; @@ -1338,31 +1345,39 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var, int i_x, i_y; int i_v; - int v_h = p_vout->output.i_height; - int v_w = p_vout->output.i_width; i_v = var_GetInteger( p_sys->p_vout, "mouse-button-down" ); i_y = var_GetInteger( p_sys->p_vout, "mouse-y" ); i_x = var_GetInteger( p_sys->p_vout, "mouse-x" ); + vlc_mutex_lock( &p_sys->lock ); + + const int v_h = p_vout->fmt_in.i_visible_height; + const int v_w = p_sys->i_vnc_width * v_h / p_sys->i_vnc_height; + const int v_x = (p_vout->fmt_in.i_visible_width-v_w)/2; + + i_x -= v_x; + if( i_y < 0 || i_x < 0 || i_y >= v_h || i_x >= v_w ) { - msg_Dbg( p_this, "invalid mouse event? x=%d y=%d btn=%x", i_x, i_y, i_v ); - return VLC_SUCCESS; + vlc_mutex_unlock( &p_sys->lock ); + msg_Dbg( p_this, "invalid mouse event? x=%d y=%d btn=%x", i_x, i_y, i_v ); + return VLC_SUCCESS; } -#ifdef VNC_DEBUG - msg_Dbg( p_this, "mouse event x=%d y=%d btn=%x", i_x, i_y, i_v ); -#endif - - /* FIXME: calculate x and y coordinates for scaled output */ - - vlc_mutex_lock( &p_sys->lock ); if( !p_sys->b_connection_active ) { vlc_mutex_unlock( &p_sys->lock ); return VLC_SUCCESS; } +#ifdef VNC_DEBUG + msg_Dbg( p_this, "mouse event x=%d y=%d btn=%x", i_x, i_y, i_v ); +#endif + + /* */ + i_x = i_x * p_sys->i_vnc_width / v_w; + i_y = i_y * p_sys->i_vnc_height / v_h; + /* buttonMask bits 0-7 are buttons 1-8, 0=up, 1=down */ rfbPointerEventMsg ev; ev.type = rfbPointerEvent;