2009-02-08 04:27:30 +01:00
|
|
|
/*
|
|
|
|
* libvo common functions, variables used by many/all drivers.
|
|
|
|
*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer 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.
|
|
|
|
*
|
|
|
|
* 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU 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.
|
|
|
|
*/
|
2001-02-24 21:28:24 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2009-09-17 16:47:43 +02:00
|
|
|
#include <assert.h>
|
2009-09-18 15:27:55 +02:00
|
|
|
#include <stdbool.h>
|
2001-02-24 21:28:24 +01:00
|
|
|
|
|
|
|
#include <unistd.h>
|
2002-03-24 01:44:54 +01:00
|
|
|
//#include <sys/mman.h>
|
2001-02-24 21:28:24 +01:00
|
|
|
|
|
|
|
#include "config.h"
|
2008-04-19 06:04:55 +02:00
|
|
|
#include "options.h"
|
2008-04-20 05:04:10 +02:00
|
|
|
#include "talloc.h"
|
2012-09-29 18:10:33 +02:00
|
|
|
#include "bstr.h"
|
2001-02-24 21:28:24 +01:00
|
|
|
#include "video_out.h"
|
2007-02-17 21:58:55 +01:00
|
|
|
#include "aspect.h"
|
|
|
|
#include "geometry.h"
|
2010-04-26 18:22:56 +02:00
|
|
|
#include "input/input.h"
|
2010-12-14 20:58:47 +01:00
|
|
|
#include "mp_fifo.h"
|
2012-06-25 22:12:03 +02:00
|
|
|
#include "m_config.h"
|
2002-09-29 23:53:05 +02:00
|
|
|
#include "mp_msg.h"
|
|
|
|
|
2004-10-28 03:15:53 +02:00
|
|
|
#include "osdep/shmem.h"
|
2008-08-08 01:04:43 +02:00
|
|
|
#ifdef CONFIG_X11
|
2008-04-20 06:36:34 +02:00
|
|
|
#include "x11_common.h"
|
|
|
|
#endif
|
2001-02-24 21:28:24 +01:00
|
|
|
|
2006-04-16 15:38:28 +02:00
|
|
|
int xinerama_screen = -1;
|
|
|
|
int xinerama_x;
|
|
|
|
int xinerama_y;
|
|
|
|
|
2003-09-01 20:24:27 +02:00
|
|
|
int vo_nomouse_input = 0;
|
2002-09-28 22:09:14 +02:00
|
|
|
int vo_grabpointer = 1;
|
2012-07-29 19:04:27 +02:00
|
|
|
int vo_vsync = 1;
|
2002-03-07 18:50:25 +01:00
|
|
|
int vo_fs = 0;
|
2001-07-04 01:46:24 +02:00
|
|
|
int vo_fsmode = 0;
|
2002-06-04 22:17:07 +02:00
|
|
|
float vo_panscan = 0.0f;
|
2004-03-13 17:48:52 +01:00
|
|
|
int vo_adapter_num=0;
|
|
|
|
int vo_refresh_rate=0;
|
2004-05-01 16:52:15 +02:00
|
|
|
int vo_keepaspect=1;
|
2004-07-29 16:59:48 +02:00
|
|
|
int vo_rootwin=0;
|
2005-11-10 23:25:54 +01:00
|
|
|
int vo_border=1;
|
2009-03-02 12:24:20 +01:00
|
|
|
int64_t WinID = -1;
|
2001-04-13 15:47:36 +02:00
|
|
|
|
2001-11-05 03:58:47 +01:00
|
|
|
int vo_pts=0; // for hw decoding
|
2006-07-12 15:03:40 +02:00
|
|
|
float vo_fps=0;
|
2001-11-05 03:58:47 +01:00
|
|
|
|
2003-10-03 20:13:45 +02:00
|
|
|
int vo_colorkey = 0x0000ff00; // default colorkey is green
|
2008-12-20 12:49:00 +01:00
|
|
|
// (0xff000000 means that colorkey has been disabled)
|
2003-10-03 20:13:45 +02:00
|
|
|
|
2001-02-24 21:28:24 +01:00
|
|
|
//
|
|
|
|
// Externally visible list of all vo drivers
|
|
|
|
//
|
2008-04-03 05:25:41 +02:00
|
|
|
extern struct vo_driver video_out_x11;
|
2009-02-18 00:07:37 +01:00
|
|
|
extern struct vo_driver video_out_vdpau;
|
2008-04-03 05:25:41 +02:00
|
|
|
extern struct vo_driver video_out_xv;
|
2012-09-23 16:10:00 +02:00
|
|
|
extern struct vo_driver video_out_opengl;
|
2012-09-29 18:36:05 +02:00
|
|
|
extern struct vo_driver video_out_opengl_hq;
|
2012-09-23 16:10:00 +02:00
|
|
|
extern struct vo_driver video_out_opengl_old;
|
2008-04-03 05:25:41 +02:00
|
|
|
extern struct vo_driver video_out_null;
|
2012-08-06 17:52:17 +02:00
|
|
|
extern struct vo_driver video_out_image;
|
2012-09-14 17:51:26 +02:00
|
|
|
extern struct vo_driver video_out_lavc;
|
2008-04-03 05:25:41 +02:00
|
|
|
extern struct vo_driver video_out_caca;
|
2008-11-22 18:16:43 +01:00
|
|
|
extern struct vo_driver video_out_direct3d;
|
2011-11-04 08:39:20 +01:00
|
|
|
extern struct vo_driver video_out_direct3d_shaders;
|
2009-05-08 22:50:26 +02:00
|
|
|
extern struct vo_driver video_out_corevideo;
|
2008-04-03 05:25:41 +02:00
|
|
|
|
|
|
|
const struct vo_driver *video_out_drivers[] =
|
2001-02-24 21:28:24 +01:00
|
|
|
{
|
2008-11-18 14:18:55 +01:00
|
|
|
#ifdef CONFIG_DIRECT3D
|
2011-11-04 08:39:20 +01:00
|
|
|
&video_out_direct3d_shaders,
|
2012-02-28 00:25:17 +01:00
|
|
|
&video_out_direct3d,
|
2008-11-18 14:18:55 +01:00
|
|
|
#endif
|
2012-03-16 22:00:32 +01:00
|
|
|
#ifdef CONFIG_GL_COCOA
|
2012-09-23 16:10:00 +02:00
|
|
|
&video_out_opengl,
|
|
|
|
&video_out_opengl_old,
|
2012-03-16 22:00:32 +01:00
|
|
|
#endif
|
2008-08-06 09:42:26 +02:00
|
|
|
#ifdef CONFIG_COREVIDEO
|
2009-05-04 18:55:05 +02:00
|
|
|
&video_out_corevideo,
|
2005-05-05 02:17:27 +02:00
|
|
|
#endif
|
2009-04-02 22:48:10 +02:00
|
|
|
#if CONFIG_VDPAU
|
|
|
|
&video_out_vdpau,
|
|
|
|
#endif
|
2009-09-18 23:25:36 +02:00
|
|
|
#ifdef CONFIG_XV
|
|
|
|
&video_out_xv,
|
|
|
|
#endif
|
2012-03-31 01:13:38 +02:00
|
|
|
#ifdef CONFIG_GL
|
2012-04-24 00:48:14 +02:00
|
|
|
#if !defined CONFIG_GL_COCOA
|
2012-09-23 16:10:00 +02:00
|
|
|
&video_out_opengl,
|
|
|
|
&video_out_opengl_old,
|
2012-03-31 01:13:38 +02:00
|
|
|
#endif
|
2010-02-25 23:53:04 +01:00
|
|
|
#endif
|
2012-04-24 00:48:14 +02:00
|
|
|
#ifdef CONFIG_X11
|
2001-02-24 21:28:24 +01:00
|
|
|
&video_out_x11,
|
2001-08-14 14:30:56 +02:00
|
|
|
#endif
|
2008-08-02 19:38:11 +02:00
|
|
|
#ifdef CONFIG_CACA
|
2008-12-20 12:49:00 +01:00
|
|
|
&video_out_caca,
|
2004-10-04 21:36:12 +02:00
|
|
|
#endif
|
|
|
|
&video_out_null,
|
2008-12-20 12:49:00 +01:00
|
|
|
// should not be auto-selected
|
2012-08-06 17:52:17 +02:00
|
|
|
&video_out_image,
|
2012-09-14 17:51:26 +02:00
|
|
|
#ifdef CONFIG_ENCODING
|
|
|
|
&video_out_lavc,
|
|
|
|
#endif
|
2012-04-24 00:48:14 +02:00
|
|
|
#ifdef CONFIG_GL
|
2012-09-29 18:36:05 +02:00
|
|
|
&video_out_opengl_hq,
|
2004-10-24 00:43:19 +02:00
|
|
|
#endif
|
2001-02-24 21:28:24 +01:00
|
|
|
NULL
|
|
|
|
};
|
2002-05-13 15:15:40 +02:00
|
|
|
|
2008-04-03 05:25:41 +02:00
|
|
|
|
2012-06-25 22:12:03 +02:00
|
|
|
static int vo_preinit(struct vo *vo, char *arg)
|
2008-04-03 05:25:41 +02:00
|
|
|
{
|
2012-08-06 17:52:17 +02:00
|
|
|
if (vo->driver->priv_size) {
|
2012-08-06 17:51:53 +02:00
|
|
|
vo->priv = talloc_zero_size(vo, vo->driver->priv_size);
|
2012-08-06 17:52:17 +02:00
|
|
|
if (vo->driver->priv_defaults)
|
|
|
|
memcpy(vo->priv, vo->driver->priv_defaults, vo->driver->priv_size);
|
|
|
|
}
|
2012-06-25 22:12:03 +02:00
|
|
|
if (vo->driver->options) {
|
2012-08-04 11:33:24 +02:00
|
|
|
struct m_config *cfg = m_config_simple(vo->priv);
|
2012-08-04 11:14:38 +02:00
|
|
|
talloc_steal(vo->priv, cfg);
|
2012-08-04 11:33:24 +02:00
|
|
|
m_config_register_options(cfg, vo->driver->options);
|
2012-06-25 22:12:03 +02:00
|
|
|
char n[50];
|
|
|
|
int l = snprintf(n, sizeof(n), "vo/%s", vo->driver->info->short_name);
|
|
|
|
assert(l < sizeof(n));
|
mplayer: turn playtree into a list, and change per-file option handling
Summary:
- There is no playtree anymore. It's reduced to a simple list.
- Options are now always global. You can still have per-file options,
but these are optional and require special syntax.
- The slave command pt_step has been removed, and playlist_next
and playlist_prev added. (See etc/input.conf changes.)
This is a user visible incompatible change, and will break slave-mode
applications.
- The pt_clear slave command is renamed to playlist_clear.
- Playtree entries could have multiple files. This is not the case
anymore, and playlist entries have always exactly one entry. Whenever
something adds more than one file (like ASX playlists or dvd:// or
dvdnav:// on the command line), all files are added as separate
playlist entries.
Note that some of the changes are quite deep and violent. Expect
regressions.
The playlist parsing code in particular is of low quality. I didn't try
to improve it, and merely spent to least effort necessary to keep it
somehow working. (Especially ASX playlist handling.)
The playtree code was complicated and bloated. It was also barely used.
Most users don't even know that mplayer manages the playlist as tree,
or how to use it. The most obscure features was probably specifying a
tree on command line (with '{' and '}' to create/close tree nodes). It
filled the player code with complexity and confused users with weird
slave commands like pt_up.
Replace the playtree with a simple flat playlist. Playlist parsers that
actually return trees are changed to append all files to the playlist
pre-order.
It used to be the responsibility of the playtree code to change per-file
config options. Now this is done by the player core, and the playlist
code is free of such details.
Options are not per-file by default anymore. This was a very obscure and
complicated feature that confused even experienced users. Consider the
following command line:
mplayer file1.mkv file2.mkv --no-audio file3.mkv
This will disable the audio for file2.mkv only, because options are
per-file by default. To make the option affect all files, you're
supposed to put it before the first file.
This is bad, because normally you don't need per-file options. They are
very rarely needed, and the only reasonable use cases I can imagine are
use of the encode backend (mplayer encode branch), or for debugging. The
normal use case is made harder, and the feature is perceived as bug.
Even worse, correct usage is hard to explain for users.
Make all options global by default. The position of an option isn't
significant anymore (except for options that compensate each other,
consider --shuffle --no-shuffle).
One other important change is that no options are reset anymore if a
new file is started. If you change settings with slave mode commands,
they will not be changed by playing a new file. (Exceptions include
settings that are too file specific, like audio/subtitle stream
selection.)
There is still some need for per-file options. Debugging and encoding
are use cases that profit from per-file options. Per-file profiles (as
well as per-protocol and per-VO/AO options) need the implementation
related mechanisms to backup and restore options when the playback file
changes.
Simplify the save-slot stuff, which is possible because there is no
hierarchical play tree anymore. Now there's a simple backup field.
Add a way to specify per-file options on command line. Example:
mplayer f1.mkv -o0 --{ -o1 f2.mkv -o2 f3.mkv --} f4.mkv -o3
will have the following options per file set:
f1.mkv, f4.mkv: -o0 -o3
f2.mkv, f3.mkv: -o0 -o3 -o1 -o2
The options --{ and --} start and end per-file options. All files inside
the { } will be affected by the options equally (similar to how global
options and multiple files are handled). When playback of a file starts,
the per-file options are set according to the command line. When
playback ends, the per-file options are restored to the values when
playback started.
2012-07-31 21:33:26 +02:00
|
|
|
int r = m_config_parse_suboptions(cfg, n, arg);
|
2012-06-25 22:12:03 +02:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
}
|
2008-04-03 05:25:41 +02:00
|
|
|
return vo->driver->preinit(vo, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int vo_control(struct vo *vo, uint32_t request, void *data)
|
|
|
|
{
|
|
|
|
return vo->driver->control(vo, request, data);
|
|
|
|
}
|
|
|
|
|
2009-09-18 15:27:55 +02:00
|
|
|
// Return -1 if driver appears not to support a draw_image interface,
|
|
|
|
// 0 otherwise (whether the driver actually drew something or not).
|
|
|
|
int vo_draw_image(struct vo *vo, struct mp_image *mpi, double pts)
|
|
|
|
{
|
|
|
|
if (!vo->config_ok)
|
|
|
|
return 0;
|
|
|
|
if (vo->driver->buffer_frames) {
|
|
|
|
vo->driver->draw_image(vo, mpi, pts);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
vo->frame_loaded = true;
|
|
|
|
vo->next_pts = pts;
|
2011-12-04 17:10:17 +01:00
|
|
|
// Guaranteed to support at least DRAW_IMAGE later
|
|
|
|
if (vo->driver->is_new) {
|
|
|
|
vo->waiting_mpi = mpi;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-18 15:27:55 +02:00
|
|
|
if (vo_control(vo, VOCTRL_DRAW_IMAGE, mpi) == VO_NOTIMPL)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-12-05 04:24:18 +01:00
|
|
|
int vo_redraw_frame(struct vo *vo)
|
|
|
|
{
|
2012-02-28 02:17:25 +01:00
|
|
|
if (!vo->config_ok || !vo->hasframe)
|
2011-12-05 04:24:18 +01:00
|
|
|
return -1;
|
|
|
|
if (vo_control(vo, VOCTRL_REDRAW_FRAME, NULL) == true) {
|
|
|
|
vo->redrawing = true;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-09-18 15:27:55 +02:00
|
|
|
int vo_get_buffered_frame(struct vo *vo, bool eof)
|
|
|
|
{
|
|
|
|
if (!vo->config_ok)
|
|
|
|
return -1;
|
|
|
|
if (vo->frame_loaded)
|
|
|
|
return 0;
|
|
|
|
if (!vo->driver->buffer_frames)
|
|
|
|
return -1;
|
|
|
|
vo->driver->get_buffered_frame(vo, eof);
|
|
|
|
return vo->frame_loaded ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
2011-03-03 11:54:36 +01:00
|
|
|
void vo_skip_frame(struct vo *vo)
|
|
|
|
{
|
2011-12-04 17:10:17 +01:00
|
|
|
vo_control(vo, VOCTRL_SKIPFRAME, NULL);
|
2011-03-03 11:54:36 +01:00
|
|
|
vo->frame_loaded = false;
|
|
|
|
}
|
|
|
|
|
2008-04-03 05:25:41 +02:00
|
|
|
int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y)
|
|
|
|
{
|
|
|
|
return vo->driver->draw_slice(vo, src, stride, w, h, x, y);
|
|
|
|
}
|
|
|
|
|
2011-12-04 17:10:17 +01:00
|
|
|
void vo_new_frame_imminent(struct vo *vo)
|
|
|
|
{
|
|
|
|
if (!vo->driver->is_new)
|
|
|
|
return;
|
|
|
|
if (vo->driver->buffer_frames)
|
|
|
|
vo_control(vo, VOCTRL_NEWFRAME, NULL);
|
|
|
|
else {
|
|
|
|
vo_control(vo, VOCTRL_DRAW_IMAGE, vo->waiting_mpi);
|
|
|
|
vo->waiting_mpi = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-24 00:53:58 +02:00
|
|
|
void vo_draw_osd(struct vo *vo, struct osd_state *osd)
|
2008-04-03 05:25:41 +02:00
|
|
|
{
|
2008-04-18 05:28:47 +02:00
|
|
|
if (!vo->config_ok)
|
|
|
|
return;
|
2008-06-24 00:53:58 +02:00
|
|
|
vo->driver->draw_osd(vo, osd);
|
2008-04-03 05:25:41 +02:00
|
|
|
}
|
|
|
|
|
2009-11-15 03:39:22 +01:00
|
|
|
void vo_flip_page(struct vo *vo, unsigned int pts_us, int duration)
|
2008-04-03 05:25:41 +02:00
|
|
|
{
|
2008-04-18 05:28:47 +02:00
|
|
|
if (!vo->config_ok)
|
|
|
|
return;
|
2011-12-05 04:24:18 +01:00
|
|
|
if (!vo->redrawing) {
|
|
|
|
vo->frame_loaded = false;
|
|
|
|
vo->next_pts = MP_NOPTS_VALUE;
|
|
|
|
}
|
2011-12-05 05:36:20 +01:00
|
|
|
vo->want_redraw = false;
|
2011-12-05 04:24:18 +01:00
|
|
|
vo->redrawing = false;
|
2009-11-15 03:39:22 +01:00
|
|
|
if (vo->driver->flip_page_timed)
|
|
|
|
vo->driver->flip_page_timed(vo, pts_us, duration);
|
|
|
|
else
|
|
|
|
vo->driver->flip_page(vo);
|
2012-02-28 02:17:25 +01:00
|
|
|
vo->hasframe = true;
|
2008-04-03 05:25:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void vo_check_events(struct vo *vo)
|
|
|
|
{
|
2010-12-14 20:58:47 +01:00
|
|
|
if (!vo->config_ok) {
|
|
|
|
if (vo->registered_fd != -1)
|
|
|
|
mp_input_rm_key_fd(vo->input_ctx, vo->registered_fd);
|
|
|
|
vo->registered_fd = -1;
|
2008-04-18 05:28:47 +02:00
|
|
|
return;
|
2010-12-14 20:58:47 +01:00
|
|
|
}
|
2008-04-03 05:25:41 +02:00
|
|
|
vo->driver->check_events(vo);
|
|
|
|
}
|
|
|
|
|
2009-09-18 15:27:55 +02:00
|
|
|
void vo_seek_reset(struct vo *vo)
|
|
|
|
{
|
|
|
|
vo_control(vo, VOCTRL_RESET, NULL);
|
|
|
|
vo->frame_loaded = false;
|
2012-03-15 00:24:52 +01:00
|
|
|
vo->hasframe = false;
|
2009-09-18 15:27:55 +02:00
|
|
|
}
|
|
|
|
|
2008-04-03 05:25:41 +02:00
|
|
|
void vo_destroy(struct vo *vo)
|
|
|
|
{
|
2010-12-14 20:58:47 +01:00
|
|
|
if (vo->registered_fd != -1)
|
|
|
|
mp_input_rm_key_fd(vo->input_ctx, vo->registered_fd);
|
2008-04-03 05:25:41 +02:00
|
|
|
vo->driver->uninit(vo);
|
2008-04-20 05:04:10 +02:00
|
|
|
talloc_free(vo);
|
2008-04-03 05:25:41 +02:00
|
|
|
}
|
|
|
|
|
2008-04-03 03:58:32 +02:00
|
|
|
void list_video_out(void)
|
|
|
|
{
|
|
|
|
int i = 0;
|
2009-07-07 00:15:02 +02:00
|
|
|
mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Available video output drivers:\n");
|
2008-04-03 03:58:32 +02:00
|
|
|
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_OUTPUTS\n");
|
|
|
|
while (video_out_drivers[i]) {
|
2002-11-11 16:22:10 +01:00
|
|
|
const vo_info_t *info = video_out_drivers[i++]->info;
|
2008-04-03 03:58:32 +02:00
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name);
|
|
|
|
}
|
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
|
2002-09-29 23:53:05 +02:00
|
|
|
}
|
|
|
|
|
2012-09-29 18:10:33 +02:00
|
|
|
static void replace_legacy_vo_name(bstr *name)
|
|
|
|
{
|
|
|
|
bstr new = *name;
|
|
|
|
if (bstr_equals0(*name, "gl"))
|
|
|
|
new = bstr0("opengl");
|
|
|
|
if (bstr_equals0(*name, "gl3"))
|
2012-09-29 18:36:05 +02:00
|
|
|
new = bstr0("opengl-hq");
|
2012-09-29 18:10:33 +02:00
|
|
|
if (!bstr_equals(*name, new)) {
|
|
|
|
mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "VO driver '%.*s' has been replaced "
|
|
|
|
"with '%.*s'!\n", BSTR_P(*name), BSTR_P(new));
|
|
|
|
}
|
|
|
|
*name = new;
|
|
|
|
}
|
|
|
|
|
2012-08-03 05:55:02 +02:00
|
|
|
struct vo *init_best_video_out(struct MPOpts *opts,
|
2008-04-30 10:06:55 +02:00
|
|
|
struct mp_fifo *key_fifo,
|
2012-09-14 17:51:26 +02:00
|
|
|
struct input_ctx *input_ctx,
|
|
|
|
struct encode_lavc_context *encode_lavc_ctx)
|
2008-04-03 03:58:32 +02:00
|
|
|
{
|
2008-04-19 06:04:55 +02:00
|
|
|
char **vo_list = opts->video_driver_list;
|
2002-09-29 23:53:05 +02:00
|
|
|
int i;
|
2008-04-20 05:04:10 +02:00
|
|
|
struct vo *vo = talloc_ptrtype(NULL, vo);
|
2008-04-30 10:06:55 +02:00
|
|
|
struct vo initial_values = {
|
|
|
|
.opts = opts,
|
|
|
|
.key_fifo = key_fifo,
|
2012-09-14 17:51:26 +02:00
|
|
|
.encode_lavc_ctx = encode_lavc_ctx,
|
2008-04-30 10:06:55 +02:00
|
|
|
.input_ctx = input_ctx,
|
2010-12-14 20:58:47 +01:00
|
|
|
.event_fd = -1,
|
|
|
|
.registered_fd = -1,
|
2008-04-30 10:06:55 +02:00
|
|
|
};
|
2002-09-29 23:53:05 +02:00
|
|
|
// first try the preferred drivers, with their optional subdevice param:
|
2008-04-03 03:58:32 +02:00
|
|
|
if (vo_list && vo_list[0])
|
|
|
|
while (vo_list[0][0]) {
|
2012-09-29 18:10:33 +02:00
|
|
|
char *arg = vo_list[0];
|
|
|
|
bstr name = bstr0(arg);
|
|
|
|
char *params = strchr(arg, ':');
|
|
|
|
if (params) {
|
|
|
|
name = bstr_splice(name, 0, params - arg);
|
|
|
|
params++;
|
2008-04-03 03:58:32 +02:00
|
|
|
}
|
2012-09-29 18:10:33 +02:00
|
|
|
replace_legacy_vo_name(&name);
|
2008-04-03 03:58:32 +02:00
|
|
|
for (i = 0; video_out_drivers[i]; i++) {
|
2008-04-03 05:25:41 +02:00
|
|
|
const struct vo_driver *video_driver = video_out_drivers[i];
|
2008-04-03 03:58:32 +02:00
|
|
|
const vo_info_t *info = video_driver->info;
|
2012-09-29 18:10:33 +02:00
|
|
|
if (bstr_equals0(name, info->short_name)) {
|
2008-04-03 03:58:32 +02:00
|
|
|
// name matches, try it
|
2008-04-30 10:06:55 +02:00
|
|
|
*vo = initial_values;
|
2008-04-03 05:25:41 +02:00
|
|
|
vo->driver = video_driver;
|
2012-09-29 18:10:33 +02:00
|
|
|
if (!vo_preinit(vo, params))
|
2008-04-03 05:25:41 +02:00
|
|
|
return vo; // success!
|
2009-05-09 01:37:35 +02:00
|
|
|
talloc_free_children(vo);
|
2003-05-31 19:33:33 +02:00
|
|
|
}
|
2002-09-29 23:53:05 +02:00
|
|
|
}
|
2008-04-03 03:58:32 +02:00
|
|
|
// continue...
|
|
|
|
++vo_list;
|
2012-08-25 12:11:52 +02:00
|
|
|
if (!(vo_list[0])) {
|
|
|
|
talloc_free(vo);
|
2008-04-03 03:58:32 +02:00
|
|
|
return NULL; // do NOT fallback to others
|
2012-08-25 12:11:52 +02:00
|
|
|
}
|
2002-09-29 23:53:05 +02:00
|
|
|
}
|
|
|
|
// now try the rest...
|
2008-04-03 03:58:32 +02:00
|
|
|
for (i = 0; video_out_drivers[i]; i++) {
|
2008-04-03 05:25:41 +02:00
|
|
|
const struct vo_driver *video_driver = video_out_drivers[i];
|
2008-04-30 10:06:55 +02:00
|
|
|
*vo = initial_values;
|
2008-04-03 05:25:41 +02:00
|
|
|
vo->driver = video_driver;
|
2012-09-01 18:36:45 +02:00
|
|
|
if (!vo_preinit(vo, NULL))
|
2008-04-03 05:25:41 +02:00
|
|
|
return vo; // success!
|
2009-05-09 01:37:35 +02:00
|
|
|
talloc_free_children(vo);
|
2002-09-29 23:53:05 +02:00
|
|
|
}
|
2012-08-16 16:18:51 +02:00
|
|
|
talloc_free(vo);
|
2002-09-29 23:53:05 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-14 20:58:47 +01:00
|
|
|
static int event_fd_callback(void *ctx, int fd)
|
|
|
|
{
|
|
|
|
struct vo *vo = ctx;
|
|
|
|
vo_check_events(vo);
|
2011-07-17 03:47:50 +02:00
|
|
|
return MP_INPUT_NOTHING;
|
2010-12-14 20:58:47 +01:00
|
|
|
}
|
|
|
|
|
2008-04-03 05:25:41 +02:00
|
|
|
int vo_config(struct vo *vo, uint32_t width, uint32_t height,
|
2007-02-17 21:58:55 +01:00
|
|
|
uint32_t d_width, uint32_t d_height, uint32_t flags,
|
2011-12-06 20:23:54 +01:00
|
|
|
uint32_t format)
|
2008-04-03 03:58:32 +02:00
|
|
|
{
|
2008-04-21 01:18:28 +02:00
|
|
|
struct MPOpts *opts = vo->opts;
|
2008-05-01 10:02:26 +02:00
|
|
|
panscan_init(vo);
|
|
|
|
aspect_save_orig(vo, width, height);
|
|
|
|
aspect_save_prescale(vo, d_width, d_height);
|
2007-02-17 21:58:55 +01:00
|
|
|
|
2008-04-03 05:25:41 +02:00
|
|
|
if (vo_control(vo, VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) {
|
2008-05-01 10:02:26 +02:00
|
|
|
aspect(vo, &d_width, &d_height, A_NOZOOM);
|
2008-04-21 01:18:28 +02:00
|
|
|
vo->dx = (int)(opts->vo_screenwidth - d_width) / 2;
|
|
|
|
vo->dy = (int)(opts->vo_screenheight - d_height) / 2;
|
2008-04-20 22:29:28 +02:00
|
|
|
geometry(&vo->dx, &vo->dy, &d_width, &d_height,
|
2008-04-21 01:18:28 +02:00
|
|
|
opts->vo_screenwidth, opts->vo_screenheight);
|
2010-06-05 22:23:18 +02:00
|
|
|
geometry_xy_changed |= xinerama_screen >= 0;
|
2008-04-20 22:29:28 +02:00
|
|
|
vo->dx += xinerama_x;
|
|
|
|
vo->dy += xinerama_y;
|
|
|
|
vo->dwidth = d_width;
|
|
|
|
vo->dheight = d_height;
|
2008-04-03 03:58:32 +02:00
|
|
|
}
|
2007-02-17 21:58:55 +01:00
|
|
|
|
2008-04-18 05:28:47 +02:00
|
|
|
int ret = vo->driver->config(vo, width, height, d_width, d_height, flags,
|
2011-12-06 20:23:54 +01:00
|
|
|
format);
|
2008-04-18 05:28:47 +02:00
|
|
|
vo->config_ok = (ret == 0);
|
|
|
|
vo->config_count += vo->config_ok;
|
2010-12-14 20:58:47 +01:00
|
|
|
if (vo->registered_fd == -1 && vo->event_fd != -1 && vo->config_ok) {
|
|
|
|
mp_input_add_key_fd(vo->input_ctx, vo->event_fd, 1, event_fd_callback,
|
|
|
|
NULL, vo);
|
|
|
|
vo->registered_fd = vo->event_fd;
|
|
|
|
}
|
2011-12-04 17:10:17 +01:00
|
|
|
vo->frame_loaded = false;
|
|
|
|
vo->waiting_mpi = NULL;
|
2011-12-05 04:24:18 +01:00
|
|
|
vo->redrawing = false;
|
2012-02-28 02:17:25 +01:00
|
|
|
vo->hasframe = false;
|
2008-04-18 05:28:47 +02:00
|
|
|
return ret;
|
2007-02-17 21:58:55 +01:00
|
|
|
}
|
2002-09-29 23:53:05 +02:00
|
|
|
|
2008-12-20 12:52:11 +01:00
|
|
|
/**
|
|
|
|
* \brief lookup an integer in a table, table must have 0 as the last key
|
|
|
|
* \param key key to search for
|
|
|
|
* \result translation corresponding to key or "to" value of last mapping
|
|
|
|
* if not found.
|
|
|
|
*/
|
2010-04-23 12:22:44 +02:00
|
|
|
int lookup_keymap_table(const struct mp_keymap *map, int key) {
|
2008-12-20 12:52:11 +01:00
|
|
|
while (map->from && map->from != key) map++;
|
|
|
|
return map->to;
|
|
|
|
}
|
|
|
|
|
2009-02-12 18:40:53 +01:00
|
|
|
/**
|
|
|
|
* \brief helper function for the kind of panscan-scaling that needs a source
|
|
|
|
* and destination rectangle like Direct3D and VDPAU
|
|
|
|
*/
|
|
|
|
static void src_dst_split_scaling(int src_size, int dst_size, int scaled_src_size,
|
|
|
|
int *src_start, int *src_end, int *dst_start, int *dst_end) {
|
|
|
|
if (scaled_src_size > dst_size) {
|
|
|
|
int border = src_size * (scaled_src_size - dst_size) / scaled_src_size;
|
|
|
|
// round to a multiple of 2, this is at least needed for vo_direct3d and ATI cards
|
|
|
|
border = (border / 2 + 1) & ~1;
|
|
|
|
*src_start = border;
|
|
|
|
*src_end = src_size - border;
|
|
|
|
*dst_start = 0;
|
|
|
|
*dst_end = dst_size;
|
|
|
|
} else {
|
|
|
|
*src_start = 0;
|
|
|
|
*src_end = src_size;
|
|
|
|
*dst_start = (dst_size - scaled_src_size) / 2;
|
|
|
|
*dst_end = *dst_start + scaled_src_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate the appropriate source and destination rectangle to
|
|
|
|
* get a correctly scaled picture, including pan-scan.
|
|
|
|
* Can be extended to take future cropping support into account.
|
|
|
|
*
|
|
|
|
* \param crop specifies the cropping border size in the left, right, top and bottom members, may be NULL
|
2009-02-17 12:59:49 +01:00
|
|
|
* \param borders the border values as e.g. EOSD (ASS) and properly placed DVD highlight support requires,
|
|
|
|
* may be NULL and only left and top are currently valid.
|
2009-02-12 18:40:53 +01:00
|
|
|
*/
|
2009-02-18 00:07:37 +01:00
|
|
|
void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
|
|
|
|
struct vo_rect *src, struct vo_rect *dst,
|
|
|
|
struct vo_rect *borders, const struct vo_rect *crop)
|
|
|
|
{
|
2009-02-12 18:40:53 +01:00
|
|
|
static const struct vo_rect no_crop = {0, 0, 0, 0, 0, 0};
|
|
|
|
int scaled_width = 0;
|
|
|
|
int scaled_height = 0;
|
|
|
|
if (!crop) crop = &no_crop;
|
|
|
|
src_width -= crop->left + crop->right;
|
|
|
|
src_height -= crop->top + crop->bottom;
|
|
|
|
if (src_width < 2) src_width = 2;
|
|
|
|
if (src_height < 2) src_height = 2;
|
2009-02-13 02:52:51 +01:00
|
|
|
dst->left = 0; dst->right = vo->dwidth;
|
|
|
|
dst->top = 0; dst->bottom = vo->dheight;
|
2009-02-12 18:40:53 +01:00
|
|
|
src->left = 0; src->right = src_width;
|
|
|
|
src->top = 0; src->bottom = src_height;
|
2009-02-17 12:59:49 +01:00
|
|
|
if (borders) {
|
|
|
|
borders->left = 0; borders->top = 0;
|
|
|
|
}
|
2009-08-27 21:13:19 +02:00
|
|
|
if (aspect_scaling()) {
|
2009-09-04 18:49:35 +02:00
|
|
|
aspect(vo, &scaled_width, &scaled_height, A_WINZOOM);
|
|
|
|
panscan_calc_windowed(vo);
|
2009-02-13 02:52:51 +01:00
|
|
|
scaled_width += vo->panscan_x;
|
|
|
|
scaled_height += vo->panscan_y;
|
2009-02-17 12:59:49 +01:00
|
|
|
if (borders) {
|
2009-02-18 00:07:37 +01:00
|
|
|
borders->left = (vo->dwidth - scaled_width ) / 2;
|
|
|
|
borders->top = (vo->dheight - scaled_height) / 2;
|
2009-02-17 12:59:49 +01:00
|
|
|
}
|
2009-02-13 02:52:51 +01:00
|
|
|
src_dst_split_scaling(src_width, vo->dwidth, scaled_width,
|
2009-02-12 18:40:53 +01:00
|
|
|
&src->left, &src->right, &dst->left, &dst->right);
|
2009-02-13 02:52:51 +01:00
|
|
|
src_dst_split_scaling(src_height, vo->dheight, scaled_height,
|
2009-02-12 18:40:53 +01:00
|
|
|
&src->top, &src->bottom, &dst->top, &dst->bottom);
|
|
|
|
}
|
|
|
|
src->left += crop->left; src->right += crop->left;
|
|
|
|
src->top += crop->top; src->bottom += crop->top;
|
|
|
|
src->width = src->right - src->left;
|
|
|
|
src->height = src->bottom - src->top;
|
|
|
|
dst->width = dst->right - dst->left;
|
|
|
|
dst->height = dst->bottom - dst->top;
|
|
|
|
}
|
|
|
|
|
2011-12-06 20:23:54 +01:00
|
|
|
// Return the window title the VO should set. Always returns a null terminated
|
|
|
|
// string. The string is valid until frontend code is invoked again. Copy it if
|
|
|
|
// you need to keep the string for an extended period of time.
|
|
|
|
const char *vo_get_window_title(struct vo *vo)
|
|
|
|
{
|
2012-08-16 16:18:51 +02:00
|
|
|
if (!vo->window_title)
|
|
|
|
vo->window_title = talloc_strdup(vo, "");
|
2012-08-02 02:36:26 +02:00
|
|
|
return vo->window_title;
|
2011-12-06 20:23:54 +01:00
|
|
|
}
|
|
|
|
|
2010-04-25 18:13:57 +02:00
|
|
|
/**
|
|
|
|
* Generates a mouse movement message if those are enable and sends it
|
|
|
|
* to the "main" MPlayer.
|
|
|
|
*
|
|
|
|
* \param posx new x position of mouse
|
|
|
|
* \param posy new y position of mouse
|
|
|
|
*/
|
2010-04-26 18:22:56 +02:00
|
|
|
void vo_mouse_movement(struct vo *vo, int posx, int posy)
|
|
|
|
{
|
2010-04-25 18:13:57 +02:00
|
|
|
char cmd_str[40];
|
|
|
|
if (!enable_mouse_movements)
|
|
|
|
return;
|
|
|
|
snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i", posx, posy);
|
2012-10-13 21:09:42 +02:00
|
|
|
mp_input_queue_cmd(vo->input_ctx, mp_input_parse_cmd(bstr0(cmd_str), ""));
|
2010-04-25 18:13:57 +02:00
|
|
|
}
|