[PATCH 1/2] lavd/xv: add window id param
Device is able to use existing window, that can be a part of existing GUI - instead of newly created one. Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com> --- doc/outdevs.texi | 9 ++++++++- libavdevice/xv.c | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/outdevs.texi b/doc/outdevs.texi index bc94b9e..2dadf6c 100644 --- a/doc/outdevs.texi +++ b/doc/outdevs.texi @@ -388,19 +388,26 @@ For example, @code{dual-headed:0.1} would specify screen 1 of display Check the X11 specification for more detailed information about the display name format. +@item window_id +When set to non-zero value then device doesn't create new window, +but uses existing one with provided @var{window_id}. By default +this options is set to zero and device creates its own window. + @item window_size Set the created window size, can be a string of the form @var{width}x@var{height} or a video size abbreviation. If not specified it defaults to the size of the input video. +Ignored when @var{window_id} is set. @item window_x @item window_y Set the X and Y window offsets for the created window. They are both set to 0 by default. The values may be ignored by the window manager. +Ignored when @var{window_id} is set. @item window_title Set the window title, if not specified default to the filename -specified for the output device. +specified for the output device. Ignored when @var{window_id} is set. @end table For more information about XVideo see @url{http://www.x.org/}. diff --git a/libavdevice/xv.c b/libavdevice/xv.c index 7f0e4ef..ee74018 100644 --- a/libavdevice/xv.c +++ b/libavdevice/xv.c @@ -24,7 +24,6 @@ * * TODO: * - add support to more formats - * - add support to window id specification */ #include <X11/Xlib.h> @@ -44,6 +43,7 @@ typedef struct { GC gc; Window window; + int64_t window_id; char *window_title; int window_width, window_height; int window_x, window_y; @@ -144,6 +144,8 @@ static int xv_write_header(AVFormatContext *s) xv->window_height = av_rescale(xv->window_height, sar.den, sar.num); } } + if (!xv->window_id) { + //TODO: reident xv->window = XCreateSimpleWindow(xv->display, DefaultRootWindow(xv->display), xv->window_x, xv->window_y, xv->window_width, xv->window_height, @@ -156,6 +158,8 @@ static int xv_write_header(AVFormatContext *s) } XStoreName(xv->display, xv->window, xv->window_title); XMapWindow(xv->display, xv->window); + } else + xv->window = xv->window_id; if (XvQueryAdaptors(xv->display, DefaultRootWindow(xv->display), &num_adaptors, &ai) != Success) { ret = AVERROR_EXTERNAL; @@ -315,6 +319,7 @@ static int xv_write_frame(AVFormatContext *s, int stream_index, AVFrame **frame, #define OFFSET(x) offsetof(XVContext, x) static const AVOption options[] = { { "display_name", "set display name", OFFSET(display_name), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, + { "window_id", "set existing window id", OFFSET(window_id), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { "window_size", "set window forced size", OFFSET(window_width), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { "window_title", "set window title", OFFSET(window_title), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { "window_x", "set window x offset", OFFSET(window_x), AV_OPT_TYPE_INT, {.i64 = 0 }, -INT_MAX, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, -- 1.9.1
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com> --- libavdevice/xv.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/libavdevice/xv.c b/libavdevice/xv.c index ee74018..7353310 100644 --- a/libavdevice/xv.c +++ b/libavdevice/xv.c @@ -251,21 +251,12 @@ static void compute_display_area(AVFormatContext *s) } } -static int write_picture(AVFormatContext *s, AVPicture *pict) +static int xv_repaint(AVFormatContext *s) { XVContext *xv = s->priv_data; - XvImage *img = xv->yuv_image; XWindowAttributes window_attrs; - uint8_t *data[3] = { - img->data + img->offsets[0], - img->data + img->offsets[1], - img->data + img->offsets[2] - }; - av_image_copy(data, img->pitches, (const uint8_t **)pict->data, pict->linesize, - xv->image_format, img->width, img->height); XGetWindowAttributes(xv->display, xv->window, &window_attrs); - if (window_attrs.width != xv->window_width || window_attrs.height != xv->window_height) { XRectangle rect[2]; xv->dest_w = window_attrs.width; @@ -298,6 +289,20 @@ static int write_picture(AVFormatContext *s, AVPicture *pict) return 0; } +static int write_picture(AVFormatContext *s, AVPicture *pict) +{ + XVContext *xv = s->priv_data; + XvImage *img = xv->yuv_image; + uint8_t *data[3] = { + img->data + img->offsets[0], + img->data + img->offsets[1], + img->data + img->offsets[2] + }; + av_image_copy(data, img->pitches, (const uint8_t **)pict->data, pict->linesize, + xv->image_format, img->width, img->height); + return xv_repaint(s); +} + static int xv_write_packet(AVFormatContext *s, AVPacket *pkt) { AVPicture pict; @@ -316,6 +321,17 @@ static int xv_write_frame(AVFormatContext *s, int stream_index, AVFrame **frame, return write_picture(s, (AVPicture *)*frame); } +static int xv_control_message(AVFormatContext *s, int type, void *data, size_t data_size) +{ + switch(type) { + case AV_APP_TO_DEV_WINDOW_REPAINT: + return xv_repaint(s); + default: + break; + } + return AVERROR(ENOSYS); +} + #define OFFSET(x) offsetof(XVContext, x) static const AVOption options[] = { { "display_name", "set display name", OFFSET(display_name), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, @@ -346,6 +362,7 @@ AVOutputFormat ff_xv_muxer = { .write_packet = xv_write_packet, .write_uncoded_frame = xv_write_frame, .write_trailer = xv_write_trailer, + .control_message = xv_control_message, .flags = AVFMT_NOFILE | AVFMT_VARIABLE_FPS | AVFMT_NOTIMESTAMPS, .priv_class = &xv_class, }; -- 1.9.1
On Sat, Apr 19, 2014 at 02:14:28AM +0200, Lukasz Marek wrote:
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com> --- libavdevice/xv.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
this seems to not apply cleanly [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Opposition brings concord. Out of discord comes the fairest harmony. -- Heraclitus
On 20.04.2014 01:36, Michael Niedermayer wrote:
On Sat, Apr 19, 2014 at 02:14:28AM +0200, Lukasz Marek wrote:
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com> --- libavdevice/xv.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
this seems to not apply cleanly
Did you apply [PATCH] lavd/xv: keep aspect ratio before? It is possible it still doesn't apply, I made one small change aside and not sure the 2 latest are rebased correctly on that one. Anyway, these all 3 are on my repo. You can merge them when no remarks.
On Sun, Apr 20, 2014 at 03:43:43AM +0200, Lukasz Marek wrote:
On 20.04.2014 01:36, Michael Niedermayer wrote:
On Sat, Apr 19, 2014 at 02:14:28AM +0200, Lukasz Marek wrote:
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com> --- libavdevice/xv.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-)
this seems to not apply cleanly
Did you apply [PATCH] lavd/xv: keep aspect ratio before?
no, and i realized that this probably was the cause moments after sending the mail ...
It is possible it still doesn't apply, I made one small change aside and not sure the 2 latest are rebased correctly on that one.
Anyway, these all 3 are on my repo. You can merge them when no remarks.
merged thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you think the mosad wants you dead since a long time then you are either wrong or dead since a long time.
On 19.04.2014 02:14, Lukasz Marek wrote:
Device is able to use existing window, that can be a part of existing GUI - instead of newly created one.
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com> --- doc/outdevs.texi | 9 ++++++++- libavdevice/xv.c | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-)
Whole patchset tested with QT application. Rendering to QWidget subclass.
On Sat, Apr 19, 2014 at 02:14:27AM +0200, Lukasz Marek wrote:
Device is able to use existing window, that can be a part of existing GUI - instead of newly created one.
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com> --- doc/outdevs.texi | 9 ++++++++- libavdevice/xv.c | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-)
probably ok also it seems we dont have anyone listed in MAINTAINERs for xv if you or someone else wants to add themself, that would be welcome [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator
On 20.04.2014 01:36, Michael Niedermayer wrote:
On Sat, Apr 19, 2014 at 02:14:27AM +0200, Lukasz Marek wrote:
Device is able to use existing window, that can be a part of existing GUI - instead of newly created one.
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com> --- doc/outdevs.texi | 9 ++++++++- libavdevice/xv.c | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-)
probably ok
also it seems we dont have anyone listed in MAINTAINERs for xv if you or someone else wants to add themself, that would be welcome
I guess no one else is interested then I can add myself.
On Sat, May 03, 2014 at 12:19:01AM +0200, Lukasz Marek wrote:
On 20.04.2014 01:36, Michael Niedermayer wrote:
On Sat, Apr 19, 2014 at 02:14:27AM +0200, Lukasz Marek wrote:
Device is able to use existing window, that can be a part of existing GUI - instead of newly created one.
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com> --- doc/outdevs.texi | 9 ++++++++- libavdevice/xv.c | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-)
probably ok
also it seems we dont have anyone listed in MAINTAINERs for xv if you or someone else wants to add themself, that would be welcome
I guess no one else is interested then I can add myself.
MAINTAINERS | 1 + 1 file changed, 1 insertion(+) 6761d93f451d7335ac54c0c21a500a6b1680778a 0001-MAINTAINERS-add-myself-as-lavd-xv-maintainer.patch From d383d811328d1d90ecf495199911d5cb786decad Mon Sep 17 00:00:00 2001 From: Lukasz Marek <lukasz.m.luki2@gmail.com> Date: Sat, 3 May 2014 00:16:02 +0200 Subject: [PATCH] MAINTAINERS: add myself as lavd/xv maintainer
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
applied thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I know you won't believe me, but the highest form of Human Excellence is to question oneself and others. -- Socrates
participants (2)
-
Lukasz Marek -
Michael Niedermayer