/*
* MPlayer video driver for DirectFramebuffer device
*
* copyright (C) 2002 Jiri Svoboda <Jiri.Svoboda@seznam.cz>
*
* based on vo_directfb2.c
*
* This file is part of MPlayer.
*
* MPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* MPlayer 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MPlayer; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <directfb.h>
#include <directfb_version.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libavutil/common.h>
#include "config.h"
#include "video_out.h"
#include "fastmemcpy.h"
#include "sub/sub.h"
#include "mp_msg.h"
#include "aspect.h"
#include "subopt-helper.h"
#include "mp_fifo.h"
#include "input/keycodes.h"
#include "libmpcodecs/mp_image.h"
#include "libmpcodecs/vfcap.h"
#include "osd.h"
// triple buffering
#define TRIPLE 1
/******************************
* vo_directfb globals *
******************************/
#define DFBCHECK(x ...) \
do { \
DFBResult err = x; \
\
if (err != DFB_OK) \
{ \
fprintf(stderr, "%s <%d>:\n\t", __FILE__, __LINE__); \
DirectFBErrorFatal(# x, err); \
} \
} while (0)
/*
* filled by preinit
*/
// main DirectFB handle
static IDirectFB *dfb = NULL;
// keyboard handle
static IDirectFBInputDevice *keyboard = NULL;
// A buffer for input events.
static IDirectFBEventBuffer *buffer = NULL;
/*
* filled during config
*/
// handle of used layer
static IDirectFBDisplayLayer *layer = NULL;
// surface of used layer
static IDirectFBSurface *primary = NULL;
static int primarylocked = 0;
// handle of temporary surface (if used)
static IDirectFBSurface *frame = NULL;
static int framelocked = 0;
// flipping mode flag (layer/surface)
static int flipping = 0;
// scaling flag
static int stretch = 0;
// picture position
static int xoffset = 0, yoffset = 0;
// picture size
static int out_width = 0, out_height = 0;
// frame/primary size
static int width = 0, height = 0;
// frame primary format
DFBSurfacePixelFormat pixel_format;
/*
static void (*draw_alpha_p)(int w, int h, unsigned char *src,
unsigned char *srca, int stride, unsigned char *dst,
int dstride);
*/
/******************************
* cmd line parameteres *
******************************/
/* command line/config file options */
static int layer_id = -1;
static int buffer_mode = 1;
static int use_input = 1;
static int field_parity = -1;
/******************************
* implementation *
******************************/
static void unlock(void)
{
if (frame && framelocked)
frame->Unlock(frame);
if (primary && primarylocked)
primary->Unlock(primary);
}
static int get_parity(strarg_t *arg)
{
if (strargcmp(arg, "top") == 0)
return 0;
if (strargcmp(arg, "bottom") == 0)
return 1;
return -1;
}
static int check_parity(void *arg)
{
return get_parity(arg) != -1;
}
static int get_mode(strarg_t *arg)
{
if (strargcmp(arg, "single") == 0)
return 1;
if (strargcmp(arg, "double") == 0)
return 2;
if (strargcmp(arg, "triple") == 0)
return 3;
return 0;
}
static int check_mode(void *arg)
{
return get_mode(arg) != 0;
}
static int preinit(struct vo *vo, const char *arg)
{
DFBResult ret;
strarg_t mode_str = {
0, NULL
};
strarg_t par_str = {
0, NULL
};
strarg_t dfb_params = {
0, NULL
};
const opt_t subopts[] = {
{"input", OPT_ARG_BOOL, &use_input, NULL},
{"buffermode", OPT_ARG_STR, &mode_str, check_mode},
{"fieldparity", OPT_ARG_STR, &par_str, check_parity},
{"layer", OPT_ARG_INT, &layer_id, NULL},
{"dfbopts", OPT_ARG_STR, &dfb_params, NULL},
{NULL}
};
//mp_msg(MSGT_VO, MSGL_INFO,"DirectFB: Preinit entered\n");
if (dfb)
return 0; // we are already initialized!
// set defaults
buffer_mode = 1 + vo_doublebuffering; // honor -double switch
layer_id = -1;
use_input = 1;
field_parity = -1;
if (subopt_parse(arg, subopts) != 0) {
mp_msg(MSGT_VO, MSGL_ERR,
"\n-vo directfb command line help:\n"
"Example: mplayer -vo directfb:layer=1:buffermode=single\n"
"\nOptions (use 'no' prefix to disable):\n"
" input Use DirectFB for keyboard input\n"
"\nOther options:\n"
" layer=n\n"
" n=0..xx Use layer with id n for output (0=primary)\n"
" buffermode=(single|double|triple)\n"
" single Use single buffering\n"
" double Use double buffering\n"
" triple Use triple buffering\n"
" fieldparity=(top|bottom)\n"
" top Top field first\n"
" bottom Bottom field first\n"
" dfbopts=<str>\n"
" Specify a parameter list for DirectFB\n"
"\n");
return -1;
}
if (mode_str.len)
buffer_mode = get_mode(&mode_str);
if (par_str.len)
field_parity = get_parity(&par_str);
if (dfb_params.len > 0) {
int argc = 2;
char arg0[10] = "mplayer";
char *arg1 = malloc(dfb_params.len + 7);
char *argv[3];
char **a;
a = &argv[0];
strcpy(arg1, "--dfb:");
strncat(arg1, dfb_params.str, dfb_params.len);
argv[0] = arg0;
|