# include "config.h"
#endif
-#include <errno.h> /* ENOMEM */
#include <fcntl.h> /* open() */
#include <unistd.h> /* close() */
/* Embedded window handling */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
-#include <X11/keysym.h>
-
-#ifdef HAVE_OSSO
-#include <libosso.h>
-#endif
#include <vlc_common.h>
#include <vlc_plugin.h>
-#include <vlc_keys.h>
#include <vlc_vout.h>
-#include <vlc_window.h>
+#include <vlc_vout_window.h>
#include <vlc_playlist.h>
+#include <vlc_fs.h>
/*****************************************************************************
* Local prototypes
static void CreateWindow ( vout_sys_t * );
static void ToggleFullScreen ( vout_thread_t * );
-#ifdef HAVE_OSSO
-static const int i_backlight_on_interval = 300;
-#endif
-
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define DEVICE_LONGTEXT N_( \
"OMAP Framebuffer device to use for rendering (usually /dev/fb0).")
-#define CHROMA_TEXT N_("Chroma used.")
+#define CHROMA_TEXT N_("Chroma used")
#define CHROMA_LONGTEXT N_( \
"Force use of a specific chroma for output. Default is Y420 (specific to N770/N8xx hardware)." )
"Embed the framebuffer overlay into a X11 window" )
vlc_module_begin();
- set_shortname( "OMAP framebuffer" );
+ set_shortname( N_("OMAP framebuffer") );
set_category( CAT_VIDEO );
set_subcategory( SUBCAT_VIDEO_VOUT );
add_file( FB_DEV_VAR, "/dev/fb0", NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
uint32_t i_video_height; /* video height */
vlc_fourcc_t i_chroma;
int i_color_format; /* OMAPFB_COLOR_* */
- bool b_embed;
bool b_video_enabled; /* Video must be displayed? */
picture_t *p_output_picture;
/* Dummy memory */
int i_null_fd;
uint8_t *p_null;
-
-#ifdef HAVE_OSSO
- osso_context_t *p_octx;
- int i_backlight_on_counter;
-#endif
};
/*****************************************************************************
p_vout->pf_render = NULL;
p_vout->pf_display = DisplayVideo;
p_vout->pf_control = Control;
-
- p_sys->b_embed = var_CreateGetInteger( p_vout, "omap-embedded" );
p_sys->b_video_enabled = true;
if( OpenDisplay( p_vout ) )
return VLC_EGENERIC;
}
-#ifdef HAVE_OSSO
- p_vout->p_sys->i_backlight_on_counter = i_backlight_on_interval;
- p_vout->p_sys->p_octx = osso_initialize( "vlc", VERSION, 0, NULL );
- if ( p_vout->p_sys->p_octx == NULL ) {
- msg_Err( p_vout, "Could not get osso context" );
- } else {
- msg_Dbg( p_vout, "Initialized osso context" );
- }
-#endif
-
return VLC_SUCCESS;
}
CloseDisplay( p_vout );
- if( p_vout->p_sys->b_embed )
+ if( p_vout->p_sys->owner_window )
{
- vout_ReleaseWindow( p_vout->p_sys->owner_window );
- if( p_vout->b_fullscreen )
- XDestroyWindow( p_vout->p_sys->p_display, p_vout->p_sys->window );
+ vout_window_Delete( p_vout->p_sys->owner_window );
XCloseDisplay( p_vout->p_sys->p_display );
}
-#ifdef HAVE_OSSO
- if ( p_vout->p_sys->p_octx != NULL ) {
- msg_Dbg( p_vout, "Deinitializing osso context" );
- osso_deinitialize( p_vout->p_sys->p_octx );
- }
-#endif
-
/* Destroy structure */
free( p_vout->p_sys );
}
vout_sys_t *p_sys = (vout_sys_t *)p_vout->p_sys;
// We want to keep the same aspect
- p_vout->fmt_out.i_aspect = p_vout->output.i_aspect = p_vout->render.i_aspect;
+ p_vout->output.i_aspect = p_vout->render.i_aspect;
+ p_vout->fmt_out.i_sar_num = p_vout->render.i_aspect * p_vout->render.i_height;
+ p_vout->fmt_out.i_sar_den = VOUT_ASPECT_FACTOR * p_vout->render.i_width;
// We ask where the video should be displayed in the video area
vout_PlacePicture( p_vout, p_sys->main_window.i_width,
p_sys->main_window.i_height,
}
p_vout->output.i_chroma =
- p_vout->fmt_out.i_chroma = VLC_CODEC_I420;
+ p_vout->fmt_out.i_chroma = VLC_FOURCC( 'Y','4','2','0' );
p_sys->i_color_format = OMAPFB_COLOR_YUV420;
// place in the framebuffer where we have to write
p_vout->p_sys->i_time_button_last_pressed =
((XButtonEvent *)&xevent)->time;
}
- else if( xevent.type == KeyPress )
- {
- KeySym x_key_symbol;
- vlc_value_t val;
-
- x_key_symbol = XKeycodeToKeysym( p_vout->p_sys->p_display,
- xevent.xkey.keycode, 0 );
-
- switch( x_key_symbol )
- {
- case XK_Return:
- val.i_int = ACTIONID_PLAY_PAUSE; break;
- case XK_Escape:
- val.i_int = ACTIONID_QUIT; break;
- case XK_Down:
- val.i_int = ACTIONID_JUMP_BACKWARD_MEDIUM; break;
- case XK_Up:
- val.i_int = ACTIONID_JUMP_FORWARD_MEDIUM; break;
- case XK_Right:
- val.i_int = ACTIONID_JUMP_FORWARD_SHORT; break;
- case XK_Left:
- val.i_int = ACTIONID_JUMP_BACKWARD_SHORT; break;
- case XK_F6:
- val.i_int = ACTIONID_TOGGLE_FULLSCREEN; break;
- case XK_F7:
- val.i_int = ACTIONID_VOL_UP; break;
- case XK_F8:
- val.i_int = ACTIONID_VOL_DOWN; break;
- }
- var_SetInteger( p_vout->p_libvlc, "key-action", val.i_int );
- }
- else if( ( xevent.type == VisibilityNotify &&
- xevent.xvisibility.state == VisibilityUnobscured ) ||
- xevent.type == FocusIn )
- {
- p_vout->p_sys->b_video_enabled = true;
- p_vout->p_sys->p_output_picture->p->p_pixels =
- p_vout->p_sys->p_center;
- XSetInputFocus( p_vout->p_sys->p_display, p_vout->p_sys->window,
- RevertToParent, CurrentTime );
- }
else if( ( xevent.type == VisibilityNotify &&
xevent.xvisibility.state != VisibilityUnobscured ) ||
- xevent.type == FocusOut || xevent.type == UnmapNotify )
+ xevent.type == UnmapNotify )
{
UpdateScreen( p_vout, 0, 0,
p_vout->p_sys->fb_vinfo.xres,
if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
{
/* Update the object variable and trigger callback */
- var_SetBool( p_vout, "fullscreen", !p_vout->b_fullscreen );
+ p_vout->b_fullscreen = !p_vout->b_fullscreen;
+ var_SetBool( p_vout, "fullscreen", p_vout->b_fullscreen );
- if( p_vout->p_sys->b_embed )
- ToggleFullScreen( p_vout );
+ if( p_vout->p_sys->owner_window )
+ vout_window_SetFullscreen( p_vout->p_sys->owner_window,
+ p_vout->b_fullscreen );
p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
}
return VLC_EGENERIC;
}
}
-
-
-#ifdef HAVE_OSSO
- if ( p_vout->p_sys->p_octx != NULL ) {
- if ( p_vout->p_sys->i_backlight_on_counter == i_backlight_on_interval ) {
- if ( osso_display_blanking_pause( p_vout->p_sys->p_octx ) != OSSO_OK ) {
- msg_Err( p_vout, "Could not disable backlight blanking" );
- } else {
- msg_Dbg( p_vout, "Backlight blanking disabled" );
- }
- p_vout->p_sys->i_backlight_on_counter = 0;
- } else {
- p_vout->p_sys->i_backlight_on_counter ++;
- }
- }
-#endif
-
return VLC_SUCCESS;
}
char *psz_device; /* framebuffer device path */
/* Open framebuffer device */
- if( !(psz_device = config_GetPsz( p_vout, FB_DEV_VAR )) )
+ if( !(psz_device = var_CreateGetNonEmptyString( p_vout, FB_DEV_VAR )) )
{
msg_Err( p_vout, "don't know which fb device to open" );
return VLC_EGENERIC;
}
- p_sys->i_fd = open( psz_device, O_RDWR );
+ p_sys->i_fd = vlc_open( psz_device, O_RDWR );
if( p_sys->i_fd == -1 )
{
msg_Err( p_vout, "cannot open %s (%m)", psz_device );
if( ioctl( p_sys->i_fd, FBIOGET_VSCREENINFO, &p_sys->fb_vinfo ) )
{
- msg_Err( p_vout, "Can't get VSCREENINFO: %s", strerror(errno) );
+ msg_Err( p_vout, "Can't get VSCREENINFO: %m" );
close( p_sys->i_fd );
return VLC_EGENERIC;
}
if( ioctl( p_sys->i_fd, FBIOGET_FSCREENINFO, &p_sys->fb_finfo ) )
{
- msg_Err( p_vout, "Can't get FSCREENINFO: %s", strerror(errno) );
+ msg_Err( p_vout, "Can't get FSCREENINFO: %m" );
close( p_sys->i_fd );
return VLC_EGENERIC;
}
if( (p_sys->p_video = (uint8_t *)mmap( 0, p_sys->i_page_size, PROT_READ | PROT_WRITE, MAP_SHARED,
p_sys->i_fd, 0 )) == MAP_FAILED )
{
- msg_Err( p_vout, "Can't mmap: %s", strerror(errno) );
+ msg_Err( p_vout, "Can't mmap: %m" );
close( p_sys->i_fd );
return VLC_EGENERIC;
}
p_sys->p_display = XOpenDisplay( NULL );
/* Open /dev/null and map it */
- p_sys->i_null_fd = open( "/dev/zero", O_RDWR );
+ p_sys->i_null_fd = vlc_open( "/dev/zero", O_RDWR );
if( p_sys->i_null_fd == -1 )
{
msg_Err( p_vout, "cannot open /dev/zero (%m)" );
if( (p_sys->p_null = (uint8_t *)mmap( 0, p_sys->i_page_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE, p_sys->i_null_fd, 0 )) == MAP_FAILED )
{
- msg_Err( p_vout, "Can't mmap 2: %s", strerror(errno) );
+ msg_Err( p_vout, "Can't mmap 2: %m" );
munmap( p_sys->p_video, p_sys->i_page_size );
close( p_sys->i_null_fd );
close( p_sys->i_fd );
{
vout_sys_t *p_sys = (vout_sys_t *)p_vout->p_sys;
- if( p_sys->b_embed )
+ if( var_CreateGetBool( p_vout, "omap-embedded" ) )
{
p_sys->p_display = XOpenDisplay( NULL );
// Request window from interface
- p_sys->owner_window =
- vout_RequestXWindow( p_vout,
- &p_sys->embedded_window.i_x,
- &p_sys->embedded_window.i_y,
- &p_sys->embedded_window.i_width,
- &p_sys->embedded_window.i_height );
+ vout_window_cfg_t wnd_cfg;
+
+ memset( &wnd_cfg, 0, sizeof(wnd_cfg) );
+ wnd_cfg.type = VOUT_WINDOW_TYPE_XID;
+ wnd_cfg.x = p_sys->embedded_window.i_x;
+ wnd_cfg.y = p_sys->embedded_window.i_y;
+ wnd_cfg.width = p_sys->embedded_window.i_width;
+ wnd_cfg.height = p_sys->embedded_window.i_height;
+
+ p_sys->owner_window = vout_window_New( VLC_OBJECT(p_vout), NULL, &wnd_cfg );
p_sys->main_window = p_sys->embedded_window;
// We have to create a new window to get some events
- // (ButtonPress for example)
CreateWindow( p_sys );
}
else
xwindow_attributes.backing_store = Always;
xwindow_attributes.background_pixel =
BlackPixel( p_sys->p_display, DefaultScreen(p_sys->p_display) );
- xwindow_attributes.event_mask = ExposureMask | StructureNotifyMask;
+ xwindow_attributes.event_mask = ExposureMask | StructureNotifyMask
+ | VisibilityChangeMask;
p_sys->window = XCreateWindow( p_sys->p_display,
p_sys->owner_window->handle.xid,
0, 0,
&xwindow_attributes );
XMapWindow( p_sys->p_display, p_sys->window );
- XSelectInput( p_sys->p_display, p_sys->window,
- KeyPressMask | ButtonPressMask | StructureNotifyMask |
- VisibilityChangeMask | FocusChangeMask );
XSelectInput( p_sys->p_display, p_sys->owner_window->handle.xid,
StructureNotifyMask );
- XSetInputFocus( p_sys->p_display, p_sys->window, RevertToParent, CurrentTime );
}
-static void ToggleFullScreen ( vout_thread_t * p_vout )
-{
- p_vout->b_fullscreen = !p_vout->b_fullscreen;
-
- if( p_vout->b_fullscreen )
- {
- msg_Dbg( p_vout, "Entering fullscreen mode" );
- XReparentWindow( p_vout->p_sys->p_display,
- p_vout->p_sys->window,
- DefaultRootWindow( p_vout->p_sys->p_display ),
- 0, 0 );
-
- XEvent xev;
-
- /* init X event structure for _NET_WM_FULLSCREEN client msg */
- xev.xclient.type = ClientMessage;
- xev.xclient.serial = 0;
- xev.xclient.send_event = True;
- xev.xclient.message_type = XInternAtom( p_vout->p_sys->p_display,
- "_NET_WM_STATE", False );
- xev.xclient.window = p_vout->p_sys->window;
- xev.xclient.format = 32;
- if( p_vout->b_fullscreen )
- xev.xclient.data.l[0] = 1;
- else
- xev.xclient.data.l[0] = 0;
- xev.xclient.data.l[1] = XInternAtom( p_vout->p_sys->p_display,
- "_NET_WM_STATE_FULLSCREEN", False );
- xev.xclient.data.l[2] = 0;
- xev.xclient.data.l[3] = 0;
- xev.xclient.data.l[4] = 0;
-
- XSendEvent( p_vout->p_sys->p_display,
- DefaultRootWindow( p_vout->p_sys->p_display ), False,
- SubstructureRedirectMask | SubstructureNotifyMask, &xev);
-
- p_vout->p_sys->main_window.i_x = p_vout->p_sys->main_window.i_y = 0;
- p_vout->p_sys->main_window.i_width = p_vout->p_sys->fb_vinfo.xres;
- p_vout->p_sys->main_window.i_height = p_vout->p_sys->fb_vinfo.yres;
- }
- else
- {
- msg_Dbg( p_vout, "Leaving fullscreen mode" );
-
- XDestroyWindow( p_vout->p_sys->p_display, p_vout->p_sys->window );
-
- p_vout->p_sys->main_window = p_vout->p_sys->embedded_window;
- CreateWindow( p_vout->p_sys );
- }
-
- XSync( p_vout->p_sys->p_display, False);
-
- /* signal that the size needs to be updated */
- p_vout->i_changes |= VOUT_SIZE_CHANGE;
-}