diff options
author | Lena <lena@nihil.gay> | 2023-12-17 18:29:33 +0100 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2023-12-17 19:14:08 +0100 |
commit | d7ac7101ee8c70a253f7caf400d9ae3870880d7f (patch) | |
tree | 87f572c4fc9b723b4a3db973cea46b02670b7e9e /libavdevice | |
parent | 419145c11bb3310539eb975751291bcf023e9170 (diff) |
gdigrab: allow capturing a window by its handle
x11grab can capture windows by their ID, but gdigrab can only capture
windows by their names, internally calling FindWindowW to lookup its
handle.
This patch simply allows the user to specify a window handle directly.
Signed-off-by: Lena <lena@nihil.gay>
Diffstat (limited to 'libavdevice')
-rw-r--r-- | libavdevice/gdigrab.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c index c069232472..41ef370f2b 100644 --- a/libavdevice/gdigrab.c +++ b/libavdevice/gdigrab.c @@ -273,9 +273,22 @@ gdigrab_read_header(AVFormatContext *s1) } } else if (!strcmp(filename, "desktop")) { hwnd = NULL; + } else if (!strncmp(filename, "hwnd=", 5)) { + name = filename + 5; + char *p; + + hwnd = strtol(name, &p, 0); + + if (p == NULL || p == name || p[0] == '\0') + { + av_log(s1, AV_LOG_ERROR, + "Invalid window handle '%s', must be a valid integer.\n", name); + ret = AVERROR(EINVAL); + goto error; + } } else { av_log(s1, AV_LOG_ERROR, - "Please use \"desktop\" or \"title=<windowname>\" to specify your target.\n"); + "Please use \"desktop\", \"title=<windowname>\" or \"hwnd=<hwnd>\" to specify your target.\n"); ret = AVERROR(EIO); goto error; } |