summaryrefslogtreecommitdiff
path: root/libavdevice/xv.c
diff options
context:
space:
mode:
authorLukasz Marek <lukasz.m.luki2@gmail.com>2014-04-19 01:54:21 +0200
committerLukasz Marek <lukasz.m.luki2@gmail.com>2014-04-19 02:18:45 +0200
commitde705e52d47f469f0920c3a90e927cbc129061e0 (patch)
tree14a8ccd848afae92d8f0f4319a724400dd323e07 /libavdevice/xv.c
parent9fcdfac894b2f5f05aee431f4ded46a866d3b6c1 (diff)
downloadffmpeg-de705e52d47f469f0920c3a90e927cbc129061e0.tar.gz
lavd/xv: implement repaint message
Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
Diffstat (limited to 'libavdevice/xv.c')
-rw-r--r--libavdevice/xv.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/libavdevice/xv.c b/libavdevice/xv.c
index ee74018b76..7353310892 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,
};