summaryrefslogtreecommitdiff
path: root/libavdevice/xcbgrab.c
Commit message (Collapse)AuthorAge
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-31
| | | | | | | | | | | There are lots of files that don't need it: The number of object files that actually need it went down from 2011 to 884 here. Keep it for external users in order to not cause breakages. Also improve the other headers a bit while just at it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avformat: Add FFInputFormat, hide internals of AVInputFormatAndreas Rheinhardt2024-03-07
| | | | | | | | | | | | | | | | | | | | | This commit does for AVInputFormat what commit 59c9dc82f450638a3068deeb1db5c56f6d155752 did for AVOutputFormat: It adds a new type FFInputFormat, moves all the internals of AVInputFormat to it and adds a now reduced AVInputFormat as first member. This does not affect/improve extensibility of both public or private fields for demuxers (it is still a mess due to lavd). This is possible since 50f34172e0cca2cabc5836308ec66dbf93f5f2a3 (which removed the last usage of an internal field of AVInputFormat in fftools). (Hint: tools/probetest.c accesses the internals of FFInputFormat as well, but given that it is a testing tool this is not considered a problem.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* all: use designated initializers for AVOption.unitAnton Khirnov2024-02-14
| | | | | | | | | | | | | | | | | | | | | | | | Makes it robust against adding fields before it, which will be useful in following commits. Majority of the patch generated by the following Coccinelle script: @@ typedef AVOption; identifier arr_name; initializer list il; initializer list[8] il1; expression tail; @@ AVOption arr_name[] = { il, { il1, - tail + .unit = tail }, ... }; with some manual changes, as the script: * has trouble with options defined inside macros * sometimes does not handle options under an #else branch * sometimes swallows whitespace
* Revert "all: Don't set AVClass.item_name to its default value"Anton Khirnov2024-01-20
| | | | | | | Some callers assume that item_name is always set, so this may be considered an API break. This reverts commit 0c6203c97a99f69dbaa6e4011d48c331e1111f5e.
* all: Don't set AVClass.item_name to its default valueAndreas Rheinhardt2023-12-22
| | | | | | | | Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9; also avoids relocations. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* av(codec|device): Don't cast pointers to intAndreas Rheinhardt2021-11-21
| | | | | | | | | | 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-27
| | | | | | | 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-27
| | | | | | | 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-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avdevice/xcbgrab: Add option for grabbing a windowsgerwk2021-03-14
| | | | | | | | 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-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avdevice: use av_gettime_relative() for elapsed time calculationsMarton Balint2021-02-27
| | | | | | | | | | 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-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-06
| | | | | | | | | | | | | | | | | | | | 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-15
| | | | | | | | | | | | 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-24
| | | | | | 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-24
| | | | | | 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-30
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avdevice/xcbgrab: fix packet timestampsMarton Balint2019-12-30
| | | | | | | 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-26
| | | | | | | 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-06
| | | | | | 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-03
| | | | | | | 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-06
| | | | | | | | | | | | | | | | 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-28
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* Merge commit '67deba8a416d818f3d95aef0aa916589090396e2'Clément Bœsch2017-03-31
|\ | | | | | | | | | | | | * 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-08
| |
* | Merge commit '5ed4644d6de7f6112431dc2d9a5cfe9a0a75a688'Clément Bœsch2017-03-15
|\| | | | | | | | | | | | | * 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-29
| |
* | lavd/xcbgrab: do not try to create refcounted packets.Nicolas George2016-11-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-10
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-19
| | | | | | | | | | | | | | | | | | 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-27
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-27
| | | | | | | | Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
| * xcbgrab: Explicitly include xcb/shape.hLuca Barbato2015-07-06
| | | | | | | | Found-By: Cheristheus
| * xcbgrab: Accept geometries matching the screen sizeNicolas George2015-05-06
| | | | | | | | Introduced in e8c4db0d4d077.
* | lavd/xcbgrab: fix comparison with screen size.Nicolas George2015-05-06
| | | | | | | | | | Signed-off-by: Nicolas George <george@nsup.org> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'e8c4db0d4d07738fed716b1d2f20c85aac944641'Michael Niedermayer2015-04-30
|\| | | | | | | | | | | | | * commit 'e8c4db0d4d07738fed716b1d2f20c85aac944641': xcbgrab: Validate the capture area Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * xcbgrab: Validate the capture areaLuca Barbato2015-04-30
| | | | | | | | | | | | And notify why the capture is impossible. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | Merge commit '82a10225f817b2612fdd2b23af9d4f0a3408df3b'Michael Niedermayer2015-04-30
|\| | | | | | | | | | | | | * 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-30
| | | | | | | | Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | Merge commit 'c201069fac9a76e6604f9d84d76a172434d62200'Michael Niedermayer2015-04-09
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-09
| | | | | | | | Also reshuffle headers into canonical order where appropriate.
| * xcbgrab: Check av_strdup() allocationVittorio Giovara2015-03-12
| | | | | | | | Bug-Id: CID 1274038
* | Merge commit '5f5b78aca35d07c771f5c4c73a984be9fe04a0b8'Michael Niedermayer2015-03-08
|\| | | | | | | | | | | | | | | | | | | | | | | * 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-08
| | | | | | | | | | | | | | Prevent an use after free in the error message. Bug-Id: CID 1274040 CC: libav-stable@libav.org
* | Merge commit '85b3b1c4ba7af9c2658442b0aafd27d613e1854b'Michael Niedermayer2015-02-25
|\| | | | | | | | | | | | | | | | | | | | | * 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-24
| | | | | | | | | | | | CC: libav-stable@libav.org Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | Merge commit 'b31328d008985f87f0a7c83c700847cef1a4f08c'Michael Niedermayer2015-02-25
|\| | | | | | | | | | | | | | | | | | | | | * 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-24
| | | | | | | | | | | | | | | | | | | | 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>