mirror of https://git.ffmpeg.org/ffmpeg.git
libavdevice/gdigrab: fix capture of windows with non-ASCII titles
Properly convert the UTF-8 input string to Windows wchar, and utilize the wchar version of FindWindow. Signed-off-by: He Yang <1160386205@qq.com>
This commit is contained in:
parent
33db0cbfd0
commit
707f9c9f47
|
@ -32,6 +32,7 @@
|
||||||
#include "libavformat/internal.h"
|
#include "libavformat/internal.h"
|
||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
#include "libavutil/time.h"
|
#include "libavutil/time.h"
|
||||||
|
#include "libavutil/wchar_filename.h"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -245,8 +246,20 @@ gdigrab_read_header(AVFormatContext *s1)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!strncmp(filename, "title=", 6)) {
|
if (!strncmp(filename, "title=", 6)) {
|
||||||
|
wchar_t *name_w = NULL;
|
||||||
name = filename + 6;
|
name = filename + 6;
|
||||||
hwnd = FindWindow(NULL, name);
|
|
||||||
|
if(utf8towchar(name, &name_w)) {
|
||||||
|
ret = AVERROR(errno);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
if(!name_w) {
|
||||||
|
ret = AVERROR(EINVAL);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
hwnd = FindWindowW(NULL, name_w);
|
||||||
|
av_freep(&name_w);
|
||||||
if (!hwnd) {
|
if (!hwnd) {
|
||||||
av_log(s1, AV_LOG_ERROR,
|
av_log(s1, AV_LOG_ERROR,
|
||||||
"Can't find window '%s', aborting.\n", name);
|
"Can't find window '%s', aborting.\n", name);
|
||||||
|
|
Loading…
Reference in New Issue