summaryrefslogtreecommitdiff
path: root/libavdevice/xcbgrab.c
Commit message (Collapse)AuthorAgeFilesLines
* av(codec|device): Don't cast pointers to intAndreas Rheinhardt2021-11-211-1/+1
| | | | | | | | | | C99/C11 6.3.2.3 5: "Any pointer type may be converted to an integer type. [...] If the result cannot be represented in the integer type, the behavior is undefined." So stop casting pointers to int; use uintptr_t instead. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avdevice: Constify all devicesAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | This is possible now that the next-API is gone. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/buffer: Switch AVBuffer API to size_tAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | Announced in 14040a1d913794d9a3fd6406a6d8c2f0e37e0062. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avdevice/xcbgrab: stop using av_init_packet()James Almer2021-03-171-4/+0
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avdevice/xcbgrab: Add option for grabbing a windowsgerwk2021-03-141-18/+52
| | | | | | | | The option allows to select a specific window instead of the whole screen. Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com> Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avdevice: use the buffer_size_t typedef where requiredJames Almer2021-03-101-1/+1
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avdevice: use av_gettime_relative() for elapsed time calculationsMarton Balint2021-02-271-3/+4
| | | | | | | | | | av_gettime_relative() is using the monotonic clock therefore more suitable for elapsed time calculations. Packet timestamps are still kept absolute, although that should be configurable in the future. Related to ticket #9089. Signed-off-by: Marton Balint <cus@passwd.hu>
* avdevice/xcbgrab: don't assume xserver endiannessAndriy Gelman2021-02-061-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | xserver defines the endianness of the grabbed images. Use this information to set the correct pixel format. This also fixes format selection in configuration depth=32/bpp=32 with xserver on a little endian machine. Before the patch, the big endian layout 0RGB was always selected which is incorrect because BGR0 should be used. RGB24 was also incorrectly assumed (but this format was removed in xserver 1.20). The big-endian settings can be tested using docker+qemu from a little-endian machine: $ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes $ docker run --rm -it -v /tmp:/tmp powerpc64/debian /bin/bash In docker container $ apt-get update $ apt-get install xvfb $ apt-get install x11-apps To test AV_PIX_FMT_0RGB32 $ Xvfb :2 -screen 0 720x480x24 & $ export DISPLAY=:2 $ xclock -geometry 720x480 -bg green #test different colors On your host machine grab the frames using the following command. View output to check that colors are rendered correctly $ ./ffmpeg -y -f x11grab -i :2.0 -codec:v mpeg2video out.mp4 Other pixel formats can be tested by modifying how Xvfb is started in the docker container: AV_PIX_FMT_RGB565 $ Xvfb :2 -screen 0 720x480x16 AV_PIX_FMT_RGB555 $ Xvfb :2 -screen 0 720x480x15 AV_PIX_FMT_BGR24 / AV_PIX_FMT_RGB24 This is difficult to test because bpp=24 support was removed in xserver 1.20 https://lists.x.org/archives/xorg-devel/2018-February/056175.html?hmsr=joyk.com&utm_source=joyk.com&utm_medium=referral However, I was able to run previous version of Xvfb (with some modifications to force 24bpp) to check that images are rendered correctly. Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com> Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
* avdevice/xcbgrab: Add select_region optionOmar Emara2020-11-061-0/+122
| | | | | | | | | | | | | | | | | | | | This patch adds a select_region option to the xcbgrab input device. If set to 1, the user will be prompted to select the grabbing area graphically by clicking and dragging. A rectangle will be drawn to mark the grabbing area. A single click with no dragging will select the whole screen. The option overwrites the video_size, grab_x, and grab_y options if set by the user. For testing, just set the select_region option as follows: ffmpeg -f x11grab -select_region 1 -i :0.0 output.mp4 The drawing happens directly on the root window using standard rubber banding techniques, so it is very efficient and doesn't depend on any X extensions or compositors. Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com> Signed-off-by: Omar Emara <mail@OmarEmara.dev>
* avdevice/xcbgrab: check return values of xcb query functionsMoritz Barsnick2020-08-151-0/+9
| | | | | | | | | | | | Fixes #7312, segmentation fault on close of X11 server xcb_query_pointer_reply() and xcb_get_geometry_reply() can return NULL if e.g. the X server closes or the connection is lost. This needs to be checked in order to cleanly exit, because the returned pointers are dereferenced later. Signed-off-by: Moritz Barsnick <barsnick@gmx.net> Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
* avdevice/xcbgrab: check if frame size fits in INT_MAXMarton Balint2020-01-241-6/+14
| | | | | | Also fixes a possible overflow and sets stream bitrate. Signed-off-by: Marton Balint <cus@passwd.hu>
* avdevice/xcbgrab: move some initialization code from ↵Marton Balint2020-01-241-11/+13
| | | | | | pixfmt_from_pixmap_format to create_stream Signed-off-by: Marton Balint <cus@passwd.hu>
* avdevice/xcbgrab: capture the full desktop if video_size is not specifiedMarton Balint2019-12-301-6/+6
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avdevice/xcbgrab: fix packet timestampsMarton Balint2019-12-301-5/+9
| | | | | | | Since 648b8cca6c56a4fa1760efc72dfe1363a5c6e31e and c991e9cd91845044e93a9c89dd25b48ae707461b timestamps were not set properly. Signed-off-by: Marton Balint <cus@passwd.hu>
* avdevice/xcbgrab: use a buffer pool for shared memory segmentsMarton Balint2019-12-261-32/+47
| | | | | | | Also by wrapping the SHM buffer in an AVBufferRef we eliminate yet another possible memcpy improving performance. Signed-off-by: Marton Balint <cus@passwd.hu>
* avdevice/xcbgrab: wrap non-shm image replies in a buffer refMarton Balint2019-12-061-6/+15
| | | | | | This avoids a memcpy improving performance if SHM is not used. Signed-off-by: Marton Balint <cus@passwd.hu>
* avdevice/xcbgrab: Handle reply and error properlyKusanagi Kouichi2019-12-031-0/+5
| | | | | | | Fix a NULL dereference and leaks. Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp> Signed-off-by: Marton Balint <cus@passwd.hu>
* lavd/x11grab: fix vertical repositioningOctavio Alvarez2019-04-061-1/+1
| | | | | | | | | | | | | | | | There is a calculation error in xcbgrab_reposition() that breaks vertical repositioning on follow_mouse. It made the bottom reposition occur when moving the mouse lower than N pixels after the capture bottom edge, instead of before. This commit fixes the calculation to match the documentation. follow_mouse: centered or number of pixels. The documentation says: When it is specified with "centered", the grabbing region follows the mouse pointer and keeps the pointer at the center of region; otherwise, the region follows only when the mouse pointer reaches within PIXELS (greater than zero) to the edge of region.
* avdevice: migrate to AVFormatContext->urlMarton Balint2018-01-281-4/+4
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* Merge commit '67deba8a416d818f3d95aef0aa916589090396e2'Clément Bœsch2017-03-311-1/+1
|\ | | | | | | | | | | | | * commit '67deba8a416d818f3d95aef0aa916589090396e2': Use avpriv_report_missing_feature() where appropriate Merged-by: Clément Bœsch <cboesch@gopro.com>
| * Use avpriv_report_missing_feature() where appropriateDiego Biurrun2016-11-081-1/+1
| |
* | Merge commit '5ed4644d6de7f6112431dc2d9a5cfe9a0a75a688'Clément Bœsch2017-03-151-1/+1
|\ \ | |/ | | | | | | | | | | * commit '5ed4644d6de7f6112431dc2d9a5cfe9a0a75a688': x11grab: Rename internal component to "xcbgrab" Merged-by: Clément Bœsch <u@pkh.me>
| * x11grab: Rename internal component to "xcbgrab"Diego Biurrun2016-07-291-1/+1
| |
* | lavd/xcbgrab: do not try to create refcounted packets.Nicolas George2016-11-031-30/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The framework will allocate a buffer and copy the data to it, that takes time. But it avoids constently creating and destroyng the shared memory segment, and that saves more time. On my setup, from ~200 to ~300 FPS at full screen (1920×1200), from ~1400 to ~3300 at smaller size (640×480), similar to legacy x11grab and confirmed by others. Plus, shared memory segments are a scarce resource, allocating potentially many is a bad idea. Note: if the application were to drop all references to the buffer before the next call to av_read_frame(), then passing the shared memory segment as a refcounted buffer would be even more efficient, but it is hard to guarantee, and it does not happen with the ffmpeg command-line tool. Using a small number of preallocated buffers and resorting to a copy when the pool is exhausted would be a solution to get the better of both worlds.
* | Merge commit '9200514ad8717c63f82101dc394f4378854325bf'Derek Buitenhuis2016-04-101-6/+5
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '9200514ad8717c63f82101dc394f4378854325bf': lavf: replace AVStream.codec with AVStream.codecpar This has been a HUGE effort from: - Derek Buitenhuis <derek.buitenhuis@gmail.com> - Hendrik Leppkes <h.leppkes@gmail.com> - wm4 <nfxjfg@googlemail.com> - Clément Bœsch <clement@stupeflix.com> - James Almer <jamrial@gmail.com> - Michael Niedermayer <michael@niedermayer.cc> - Rostislav Pehlivanov <atomnuker@gmail.com> Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * lavf: replace AVStream.codec with AVStream.codecparAnton Khirnov2016-02-231-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, AVStream contains an embedded AVCodecContext instance, which is used by demuxers to export stream parameters to the caller and by muxers to receive stream parameters from the caller. It is also used internally as the codec context that is passed to parsers. In addition, it is also widely used by the callers as the decoding (when demuxer) or encoding (when muxing) context, though this has been officially discouraged since Libav 11. There are multiple important problems with this approach: - the fields in AVCodecContext are in general one of * stream parameters * codec options * codec state However, it's not clear which ones are which. It is consequently unclear which fields are a demuxer allowed to set or a muxer allowed to read. This leads to erratic behaviour depending on whether decoding or encoding is being performed or not (and whether it uses the AVStream embedded codec context). - various synchronization issues arising from the fact that the same context is used by several different APIs (muxers/demuxers, parsers, bitstream filters and encoders/decoders) simultaneously, with there being no clear rules for who can modify what and the different processes being typically delayed with respect to each other. - avformat_find_stream_info() making it necessary to support opening and closing a single codec context multiple times, thus complicating the semantics of freeing various allocated objects in the codec context. Those problems are resolved by replacing the AVStream embedded codec context with a newly added AVCodecParameters instance, which stores only the stream parameters exported by the demuxers or read by the muxers.
* | avdevice/xcbgrab: fix -Wunused-variableGanesh Ajjanagadde2015-09-191-1/+1
| | | | | | | | | | | | | | | | | | This patch fixes a -Wunused-variable reported in e.g http://fate.ffmpeg.org/log.cgi?time=20150918194649&log=compile&slot=x86_64-debian-asan-144800. av_unused is used as opposed to a header guard for readability. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Merge commit '059a934806d61f7af9ab3fd9f74994b838ea5eba'Michael Niedermayer2015-07-271-1/+1
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '059a934806d61f7af9ab3fd9f74994b838ea5eba': lavc: Consistently prefix input buffer defines Conflicts: doc/examples/decoding_encoding.c libavcodec/4xm.c libavcodec/aac_adtstoasc_bsf.c libavcodec/aacdec.c libavcodec/aacenc.c libavcodec/ac3dec.h libavcodec/asvenc.c libavcodec/avcodec.h libavcodec/avpacket.c libavcodec/dvdec.c libavcodec/ffv1enc.c libavcodec/g2meet.c libavcodec/gif.c libavcodec/h264.c libavcodec/h264_mp4toannexb_bsf.c libavcodec/huffyuvdec.c libavcodec/huffyuvenc.c libavcodec/jpeglsenc.c libavcodec/libxvid.c libavcodec/mdec.c libavcodec/motionpixels.c libavcodec/mpeg4videodec.c libavcodec/mpegvideo.c libavcodec/noise_bsf.c libavcodec/nuv.c libavcodec/nvenc.c libavcodec/options.c libavcodec/parser.c libavcodec/pngenc.c libavcodec/proresenc_kostya.c libavcodec/qsvdec.c libavcodec/svq1enc.c libavcodec/tiffenc.c libavcodec/truemotion2.c libavcodec/utils.c libavcodec/utvideoenc.c libavcodec/vc1dec.c libavcodec/wmalosslessdec.c libavformat/adxdec.c libavformat/aiffdec.c libavformat/apc.c libavformat/apetag.c libavformat/avidec.c libavformat/bink.c libavformat/cafdec.c libavformat/flvdec.c libavformat/id3v2.c libavformat/isom.c libavformat/matroskadec.c libavformat/mov.c libavformat/mpc.c libavformat/mpc8.c libavformat/mpegts.c libavformat/mvi.c libavformat/mxfdec.c libavformat/mxg.c libavformat/nutdec.c libavformat/oggdec.c libavformat/oggparsecelt.c libavformat/oggparseflac.c libavformat/oggparseopus.c libavformat/oggparsespeex.c libavformat/omadec.c libavformat/rawdec.c libavformat/riffdec.c libavformat/rl2.c libavformat/rmdec.c libavformat/rtpdec_latm.c libavformat/rtpdec_mpeg4.c libavformat/rtpdec_qdm2.c libavformat/rtpdec_svq3.c libavformat/sierravmd.c libavformat/smacker.c libavformat/smush.c libavformat/spdifenc.c libavformat/takdec.c libavformat/tta.c libavformat/utils.c libavformat/vqf.c libavformat/westwood_vqa.c libavformat/xmv.c libavformat/xwma.c libavformat/yop.c Merged-by: Michael Niedermayer <michael@niedermayer.cc>
| * lavc: Consistently prefix input buffer definesVittorio Giovara2015-07-271-1/+1
| | | | | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
| * xcbgrab: Explicitly include xcb/shape.hLuca Barbato2015-07-061-0/+1
| | | | | | | | Found-By: Cheristheus
| * xcbgrab: Accept geometries matching the screen sizeNicolas George2015-05-061-2/+2
| | | | | | | | Introduced in e8c4db0d4d077.
* | lavd/xcbgrab: fix comparison with screen size.Nicolas George2015-05-061-2/+2
| | | | | | | | | | Signed-off-by: Nicolas George <george@nsup.org> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'e8c4db0d4d07738fed716b1d2f20c85aac944641'Michael Niedermayer2015-04-301-2/+11
|\ \ | |/ | | | | | | | | | | * commit 'e8c4db0d4d07738fed716b1d2f20c85aac944641': xcbgrab: Validate the capture area Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * xcbgrab: Validate the capture areaLuca Barbato2015-04-301-2/+11
| | | | | | | | | | | | And notify why the capture is impossible. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | Merge commit '82a10225f817b2612fdd2b23af9d4f0a3408df3b'Michael Niedermayer2015-04-301-2/+14
|\ \ | |/ | | | | | | | | | | * commit '82a10225f817b2612fdd2b23af9d4f0a3408df3b': xcbgrab: Do not assume the non shm image data is always available Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * xcbgrab: Do not assume the non shm image data is always availableLuca Barbato2015-04-301-2/+14
| | | | | | | | Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | Merge commit 'c201069fac9a76e6604f9d84d76a172434d62200'Michael Niedermayer2015-04-091-3/+4
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'c201069fac9a76e6604f9d84d76a172434d62200': avdevice: Add missing header for NULL_IF_CONFIG_SMALL Conflicts: libavdevice/alsa-audio-dec.c libavdevice/alsa-audio-enc.c libavdevice/pulse_audio_dec.c libavdevice/sndio_enc.c libavdevice/vfwcap.c libavdevice/x11grab.c libavdevice/xcbgrab.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * avdevice: Add missing header for NULL_IF_CONFIG_SMALLDiego Biurrun2015-04-091-3/+4
| | | | | | | | Also reshuffle headers into canonical order where appropriate.
| * xcbgrab: Check av_strdup() allocationVittorio Giovara2015-03-121-0/+2
| | | | | | | | Bug-Id: CID 1274038
* | Merge commit '5f5b78aca35d07c771f5c4c73a984be9fe04a0b8'Michael Niedermayer2015-03-081-0/+1
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | * commit '5f5b78aca35d07c771f5c4c73a984be9fe04a0b8': xcbgrab: Free the host string after checking the connection Conflicts: libavdevice/xcbgrab.c No change as the bug was not in FFmpeg Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * xcbgrab: Free the host string after checking the connectionLuca Barbato2015-03-081-3/+6
| | | | | | | | | | | | | | Prevent an use after free in the error message. Bug-Id: CID 1274040 CC: libav-stable@libav.org
* | Merge commit '85b3b1c4ba7af9c2658442b0aafd27d613e1854b'Michael Niedermayer2015-02-251-0/+1
|\ \ | |/ | | | | | | | | | | | | | | | | | | * commit '85b3b1c4ba7af9c2658442b0aafd27d613e1854b': xcbgrab: Unbreak parsing filename options Conflicts: libavdevice/xcbgrab.c See: db442c873631065e8719df6da91c016d25501084 Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * xcbgrab: Unbreak parsing filename optionsLuca Barbato2015-02-241-6/+14
| | | | | | | | | | | | CC: libav-stable@libav.org Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | Merge commit 'b31328d008985f87f0a7c83c700847cef1a4f08c'Michael Niedermayer2015-02-251-0/+2
|\ \ | |/ | | | | | | | | | | | | | | | | | | * commit 'b31328d008985f87f0a7c83c700847cef1a4f08c': xcbgrab: Provide better names for the y and x option Conflicts: doc/indevs.texi libavdevice/x11grab.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * xcbgrab: Provide better names for the y and x optionLuca Barbato2015-02-241-0/+2
| | | | | | | | | | | | | | | | | | | | Incidentally `-y` also collides with avconv global options. Update x11grab to match and document the option. CC: libav-stable@libav.org Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
| * xcbgrab: Use the correct geometry for the region highlightDaniel Moran2015-02-151-1/+1
| | | | | | | | | | | | | | The feature is implemented using a transparent window and drawing inside it a rectangle filling the whole window to highlight it. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | Merge commit 'd40815a982c36ff9da09ae3edb5e3bd7d97b5d42'Michael Niedermayer2015-02-151-6/+2
|\ \ | |/ | | | | | | | | | | | | | | | | | | * commit 'd40815a982c36ff9da09ae3edb5e3bd7d97b5d42': xcbgrab: Correctly make shm optional Conflicts: libavdevice/xcbgrab.c See: 8c0ae9015a2bd8b3f4f92c35570e592e7fdeaef0 Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * xcbgrab: Correctly make shm optionalLuca Barbato2015-02-151-4/+4
| | | | | | | | | | The segment field in the struct has to be conditionally build as well.
* | Merge commit '9e06327ecb8f73c7904d10af7ad339c57cdaa788'Michael Niedermayer2014-12-191-3/+2
|\ \ | |/ | | | | | | | | | | | | | | | | | | * commit '9e06327ecb8f73c7904d10af7ad339c57cdaa788': xcbgrab: Move NULL check before pointer dereference Conflicts: libavdevice/xcbgrab.c See: e86df0206f06b8d1e97e2b60db8f74a398d53127 Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * xcbgrab: Move NULL check before pointer dereferenceVittorio Giovara2014-12-181-1/+5
| | | | | | | | Bug-Id: CID 1254668