Commit 3e30c539 authored by Laurent Aimar's avatar Laurent Aimar

Introduce "vout display" module API to replaced "vout" one.

parent 98c46028
This diff is collapsed.
/*****************************************************************************
* vlc_vout_wrapper.h: definitions for vout wrappers (temporary)
*****************************************************************************
* Copyright (C) 2009 Laurent Aimar
* $Id$
*
* Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef VLC_VOUT_WRAPPER_H
#define VLC_VOUT_WRAPPER_H 1
#include <vlc_vout_display.h>
/* XXX DO NOT use it ouside the vout module wrapper XXX */
/**
* It retreive a picture from the display
*/
static inline picture_t *vout_display_Get(vout_display_t *vd)
{
return vd->get(vd);
}
/**
* It preparse a picture for display.
*/
static inline void vout_display_Prepare(vout_display_t *vd, picture_t *picture)
{
if (vd->prepare )
vd->prepare(vd, picture);
}
/**
* It display a picture.
*/
static inline void vout_display_Display(vout_display_t *vd, picture_t *picture)
{
vd->display(vd, picture);
}
/**
* It holds a state for a vout display.
*/
typedef struct {
vout_display_cfg_t cfg;
bool is_on_top;
struct {
int num;
int den;
} sar;
} vout_display_state_t;
/**
* It creates a vout managed display.
*/
VLC_EXPORT(vout_display_t *, vout_NewDisplay, ( vout_thread_t *, const video_format_t *, const vout_display_state_t *, const char *psz_module, mtime_t i_double_click_timeout, mtime_t i_hide_timeout ));
/**
* It destroy a vout managed display.
*/
VLC_EXPORT(void, vout_DeleteDisplay, (vout_display_t *, vout_display_state_t *));
VLC_EXPORT(bool, vout_IsDisplayFiltered, (vout_display_t *));
VLC_EXPORT(picture_t *, vout_FilterDisplay, (vout_display_t *, picture_t *));
VLC_EXPORT(bool, vout_AreDisplayPicturesInvalid, (vout_display_t *));
VLC_EXPORT(void, vout_ManageDisplay, (vout_display_t *));
VLC_EXPORT(void, vout_SetDisplayFullscreen, (vout_display_t *, bool is_fullscreen));
VLC_EXPORT(void, vout_SetDisplayFilled, (vout_display_t *, bool is_filled));
VLC_EXPORT(void, vout_SetDisplayZoom, (vout_display_t *, int num, int den));
VLC_EXPORT(void, vout_SetDisplayOnTop, (vout_display_t *, bool is_on_top));
VLC_EXPORT(void, vout_SetDisplayAspect, (vout_display_t *, unsigned sar_num, unsigned sar_den));
VLC_EXPORT(void, vout_SetDisplayCrop, (vout_display_t *, unsigned crop_num, unsigned crop_den, unsigned x, unsigned y, unsigned width, unsigned height));
#endif /* VLC_VOUT_WRAPPER_H */
......@@ -95,6 +95,7 @@ pluginsinclude_HEADERS = \
../include/vlc_vlm.h \
../include/vlc_video_splitter.h \
../include/vlc_vout.h \
../include/vlc_vout_display.h \
../include/vlc_vout_window.h \
../include/vlc_xml.h \
$(NULL)
......@@ -344,6 +345,8 @@ SOURCES_libvlc_common = \
input/stream_memory.c \
input/subtitles.c \
input/var.c \
video_output/display.c \
video_output/display.h \
video_output/snapshot.c \
video_output/snapshot.h \
video_output/statistic.h \
......
......@@ -575,6 +575,20 @@ vout_UnlinkPicture
vout_window_New
vout_window_Control
vout_window_Delete
vout_NewDisplay
vout_DeleteDisplay
vout_AreDisplayPicturesInvalid
vout_IsDisplayFiltered
vout_FilterDisplay
vout_ManageDisplay
vout_SetDisplayFullscreen
vout_SetDisplayFilled
vout_SetDisplayZoom
vout_SetDisplayOnTop
vout_SetDisplayAspect
vout_SetDisplayCrop
vout_display_GetDefaultDisplaySize
vout_display_PlacePicture
__xml_Create
text_style_Copy
text_style_Delete
......
This diff is collapsed.
/*****************************************************************************
* display.h: "vout display" managment
*****************************************************************************
* Copyright (C) 2009 Laurent Aimar
* $Id$
*
* Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#if defined(__PLUGIN__) || defined(__BUILTIN__) || !defined(__LIBVLC__)
# error This header file can only be included from LibVLC.
#endif
#include <vlc_vout_wrapper.h>
#if 0
#include <vlc_vout_display.h>
#include <vlc_filter.h>
/**
* It retreive a picture from the display
*/
static inline picture_t *vout_display_Get(vout_display_t *vd)
{
return vd->get(vd);
}
/**
* It preparse a picture for display.
*/
static inline void vout_display_Prepare(vout_display_t *vd, picture_t *picture)
{
if (vd->prepare )
vd->prepare(vd, picture);
}
/**
* It display a picture.
*/
static inline void vout_display_Display(vout_display_t *vd, picture_t *picture)
{
vd->display(vd, picture);
}
/**
* It holds a state for a vout display.
*/
typedef struct {
vout_display_cfg_t cfg;
bool is_on_top;
struct {
int num;
int den;
} sar;
} vout_display_state_t;
/**
* It creates a vout managed display.
*/
vout_display_t *vout_NewDisplay( vout_thread_t *,
const video_format_t *,
const vout_display_state_t *,
const char *psz_module,
mtime_t i_double_click_timeout,
mtime_t i_hide_timeout );
/**
* It creates a vout managed display wrapping a video splitter.
*/
vout_display_t *vout_NewSplitter(vout_thread_t *,
const video_format_t *source,
const vout_display_state_t *state,
const char *module,
const char *splitter,
mtime_t double_click_timeout,
mtime_t hide_timeout );
/**
* It destroy a vout managed display.
*/
void vout_DeleteDisplay(vout_display_t *, vout_display_state_t *);
picture_t *vout_FilterDisplay(vout_display_t *, picture_t *);
void vout_ManageDisplay(vout_display_t *);
void vout_SetDisplayFullscreen(vout_display_t *, bool is_fullscreen);
void vout_SetDisplayFilled(vout_display_t *, bool is_filled);
void vout_SetDisplayZoom(vout_display_t *, int num, int den);
void vout_SetDisplayOnTop(vout_display_t *, bool is_on_top);
void vout_SetDisplayAspect(vout_display_t *, unsigned sar_num, unsigned sar_den);
void vout_SetDisplayCrop(vout_display_t *,
unsigned crop_num, unsigned crop_den,
unsigned x, unsigned y, unsigned width, unsigned height);
#endif
/* FIXME should not be there */
void vout_SendDisplayEventMouse(vout_thread_t *, const vlc_mouse_t *);
vout_window_t *vout_NewDisplayWindow(vout_thread_t *, vout_display_t *, const vout_window_cfg_t *);
void vout_DeleteDisplayWindow(vout_thread_t *, vout_display_t *, vout_window_t *);
/*****************************************************************************
* event.h: vout event
*****************************************************************************
* Copyright (C) 2009 Laurent Aimar
* $Id$
*
* Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#if defined(__PLUGIN__) || defined(__BUILTIN__) || !defined(__LIBVLC__)
# error This header file can only be included from LibVLC.
#endif
#include <vlc_common.h>
#include <vlc_playlist.h>
#include <math.h>
#include "vout_control.h"
/* TODO/FIXME
*
* It should be converted to something like input_thread_t:
* one intf-event can be grabbed by a callback, all others
* variable only var_Change
*
* Maybe a intf-mouse can be used too (don't like it).
*
* (Some case may infinite loop otherwise here)
*/
static inline void vout_SendEventClose(vout_thread_t *vout)
{
/* Ask to stop
* FIXME works only for input handled by the playlist
*/
playlist_t *playlist = pl_Hold(vout);
if (playlist) {
playlist_Stop(playlist);
pl_Release(vout);
}
}
static inline void vout_SendEventKey(vout_thread_t *vout, int key)
{
var_SetInteger(vout->p_libvlc, "key-pressed", key);
}
static inline void vout_SendEventMouseMoved(vout_thread_t *vout, int x, int y)
{
var_SetInteger(vout, "mouse-x", x);
var_SetInteger(vout, "mouse-y", y);
var_SetBool(vout, "mouse-moved", true);
}
static inline void vout_SendEventMousePressed(vout_thread_t *vout, int button)
{
int current = var_GetInteger(vout, "mouse-button-down");
current |= 1 << button;
var_SetInteger(vout, "mouse-button-down", current);
switch (button)
{
case MOUSE_BUTTON_LEFT:
var_SetBool(vout, "mouse-clicked", true);
var_SetBool(vout->p_libvlc, "intf-popupmenu", false);
break;
case MOUSE_BUTTON_CENTER:
var_SetBool(vout->p_libvlc, "intf-show",
!var_GetBool(vout->p_libvlc, "intf-show"));
break;
case MOUSE_BUTTON_RIGHT:
var_SetBool(vout->p_libvlc, "intf-popupmenu", true);
break;
}
}
static inline void vout_SendEventMouseReleased(vout_thread_t *vout, int button)
{
int current = var_GetInteger(vout, "mouse-button-down");
current &= ~(1 << button);
var_SetInteger(vout, "mouse-button-down", current);
}
static inline void vout_SendEventMouseDoubleClick(vout_thread_t *vout)
{
//vout_ControlSetFullscreen(vout, !var_GetBool(vout, "fullscreen"));
var_ToggleBool(vout, "fullscreen");
}
static inline void vout_SendEventMouseVisible(vout_thread_t *vout)
{
/* TODO */
VLC_UNUSED(vout);
}
static inline void vout_SendEventMouseHidden(vout_thread_t *vout)
{
/* TODO */
VLC_UNUSED(vout);
}
static inline void vout_SendEventFullscreen(vout_thread_t *vout, bool is_fullscreen)
{
if (!var_GetBool(vout, "fullscreen") != !is_fullscreen)
var_SetBool(vout, "fullscreen", is_fullscreen);
}
static inline void vout_SendEventDisplayFilled(vout_thread_t *vout, bool is_display_filled)
{
if (!var_GetBool(vout, "autoscale") != !is_display_filled)
var_SetBool(vout, "autoscale", is_display_filled);
}
static inline void vout_SendEventZoom(vout_thread_t *vout, int num, int den)
{
/* FIXME deadlock problems with current vout */
#if 0
const float zoom = (float)num / (float)den;
/* XXX 0.1% is arbitrary */
if (fabs(zoom - var_GetFloat(vout, "scale")) > 0.001)
var_SetFloat(vout, "scale", zoom);
#endif
}
static inline void vout_SendEventOnTop(vout_thread_t *vout, bool is_on_top)
{
/* FIXME deadlock problems with current vout */
#if 0
if (!var_GetBool(vout, "video-on-top") != !is_on_top)
var_SetBool(vout, "video-on-top", is_on_top);
#endif
}
/**
* It must be called on source aspect ratio changes, with the new DAR (Display
* Aspect Ratio) value.
*/
static inline void vout_SendEventSourceAspect(vout_thread_t *vout,
unsigned num, unsigned den)
{
/* FIXME the value stored in "aspect-ratio" are not reduced
* creating a lot of problems here */
#if 0
char *ar;
if (num > 0 && den > 0) {
if (asprintf(&ar, "%u:%u", num, den) < 0)
return;
} else {
ar = strdup("");
}
char *current = var_GetString(vout, "aspect-ratio");
msg_Err(vout, "vout_SendEventSourceAspect %s -> %s", current, ar);
if (ar && current && strcmp(ar, current))
var_SetString(vout, "aspect-ratio", ar);
free(current);
free(ar);
#endif
}
static inline void vout_SendEventSourceCrop(vout_thread_t *vout,
unsigned num, unsigned den,
unsigned left, unsigned top,
unsigned right, unsigned bottom)
{
vlc_value_t val;
/* I cannot use var_Set here, infinite loop otherwise */
/* */
val.i_int = left;
var_Change(vout, "crop-left", VLC_VAR_SETVALUE, &val, NULL);
val.i_int = top;
var_Change(vout, "crop-top", VLC_VAR_SETVALUE, &val, NULL);
val.i_int = right;
var_Change(vout, "crop-right", VLC_VAR_SETVALUE, &val, NULL);
val.i_int = bottom;
var_Change(vout, "crop-bottom", VLC_VAR_SETVALUE, &val, NULL);
/* FIXME the value stored in "crop" are not reduced
* creating a lot of problems here */
#if 0
char *crop;
if (num > 0 && den > 0) {
if (asprintf(&crop, "%u:%u", num, den) < 0)
crop = NULL;
} else if (left > 0 || top > 0 || right > 0 || bottom > 0) {
if (asprintf(&crop, "%u+%u+%u+%u", left, top, right, bottom) < 0)
crop = NULL;
} else {
crop = strdup("");
}
if (crop) {
val.psz_string = crop;
var_Change(vout, "crop", VLC_VAR_SETVALUE, &val, NULL);
free(crop);
}
#endif
}
#if 0
static inline void vout_SendEventSnapshot(vout_thread_t *vout, const char *filename)
{
/* Generate a media player event - Right now just trigger a global libvlc var
CHECK: Could not find a more local object. The goal is to communicate
vout_thread with libvlc_media_player or its input_thread */
var_SetString(vout->p_libvlc, "vout-snapshottaken", filename);
}
#warning "FIXME clean up postproc event"
extern void vout_InstallDeprecatedPostProcessing(vout_thread_t *);
extern void vout_UninstallDeprecatedPostProcessing(vout_thread_t *);
static inline void vout_SendEventPostProcessing(vout_thread_t *vout, bool is_available)
{
if (is_available)
vout_InstallDeprecatedPostProcessing(vout);
else
vout_UninstallDeprecatedPostProcessing(vout);
}
static inline void vout_SendEventFilters(vout_thread_t *vout)
{
vout_filter_t **filter;
int filter_count;
vout_ControlGetFilters(vout, &filter, &filter_count);
char *list = strdup("");
for (int i = 0; i < filter_count; i++) {
char *psz;
if (asprintf(&psz, "%s%s%s",
list, i > 0 ? ":" : "", filter[i]->name) < 0) {
free(list);
list = NULL;
break;
}
free(list);
list = psz;
}
if (list) {
vlc_value_t val;
val.psz_string = list;
var_Change(vout, "video-filter", VLC_VAR_SETVALUE, &val, NULL);
free(list);
}
for (int i = 0; i < filter_count; i++)
vout_filter_Delete(filter[i]);
free(filter);
}
#endif
......@@ -397,6 +397,8 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
p_vout->p->b_picture_empty = false;
p_vout->p->i_picture_qtype = QTYPE_NONE;
vlc_mouse_Init( &p_vout->p->mouse );
vout_snapshot_Init( &p_vout->p->snapshot );
/* Initialize locks */
......
......@@ -97,6 +97,9 @@ struct vout_thread_sys_t
int i_title_position;
char *psz_title;
/* */
vlc_mouse_t mouse;
};
/* DO NOT use vout_RenderPicture unless you are in src/video_ouput */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment