]> git.sesse.net Git - ffmpeg/blobdiff - libavdevice/gdigrab.c
avdevice: Constify all devices
[ffmpeg] / libavdevice / gdigrab.c
index 9b2c55fe902a28a7090e902a236d75c86e1a95ac..c0692324725e2daa94f6dcd6a500a51d844941c3 100644 (file)
@@ -32,6 +32,7 @@
 #include "libavformat/internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/time.h"
+#include "libavutil/wchar_filename.h"
 #include <windows.h>
 
 /**
@@ -245,8 +246,20 @@ gdigrab_read_header(AVFormatContext *s1)
     int ret;
 
     if (!strncmp(filename, "title=", 6)) {
+        wchar_t *name_w = NULL;
         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) {
             av_log(s1, AV_LOG_ERROR,
                    "Can't find window '%s', aborting.\n", name);
@@ -651,7 +664,7 @@ static const AVClass gdigrab_class = {
 };
 
 /** gdi grabber device demuxer declaration */
-AVInputFormat ff_gdigrab_demuxer = {
+const AVInputFormat ff_gdigrab_demuxer = {
     .name           = "gdigrab",
     .long_name      = NULL_IF_CONFIG_SMALL("GDI API Windows frame grabber"),
     .priv_data_size = sizeof(struct gdigrab),