diff options
author | Mark Thompson <sw@jkqxz.net> | 2019-05-06 15:31:18 +0100 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2019-06-02 22:58:22 +0100 |
commit | d2141a9b652c52350b5a4519ec34c59f5531fad1 (patch) | |
tree | 58dbb026e2b16c0515f848b18ed07fd61b85affc /libavutil/hwcontext_vaapi.c | |
parent | a4448637380d9397a7ea5d644e9853af90a66a89 (diff) | |
download | ffmpeg-d2141a9b652c52350b5a4519ec34c59f5531fad1.tar.gz |
hwcontext_vaapi: Add option to specify connection type
Can be set to "drm" or "x11" to force a specific connection type.
Diffstat (limited to 'libavutil/hwcontext_vaapi.c')
-rw-r--r-- | libavutil/hwcontext_vaapi.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 8624369bb9..561b82fcce 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -1469,6 +1469,8 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, { VAAPIDevicePriv *priv; VADisplay display = NULL; + const AVDictionaryEntry *ent; + int try_drm, try_x11, try_all; priv = av_mallocz(sizeof(*priv)); if (!priv) @@ -1479,8 +1481,26 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, ctx->user_opaque = priv; ctx->free = vaapi_device_free; + ent = av_dict_get(opts, "connection_type", NULL, 0); + if (ent) { + try_all = try_drm = try_x11 = 0; + if (!strcmp(ent->value, "drm")) { + try_drm = 1; + } else if (!strcmp(ent->value, "x11")) { + try_x11 = 1; + } else { + av_log(ctx, AV_LOG_ERROR, "Invalid connection type %s.\n", + ent->value); + return AVERROR(EINVAL); + } + } else { + try_all = 1; + try_drm = HAVE_VAAPI_DRM; + try_x11 = HAVE_VAAPI_X11; + } + #if HAVE_VAAPI_X11 - if (!display && !(device && device[0] == '/')) { + if (!display && try_x11) { // Try to open the device as an X11 display. priv->x11_display = XOpenDisplay(device); if (!priv->x11_display) { @@ -1501,7 +1521,7 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, #endif #if HAVE_VAAPI_DRM - if (!display) { + if (!display && try_drm) { // Try to open the device as a DRM path. // Default to using the first render node if the user did not // supply a path. @@ -1525,8 +1545,12 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, #endif if (!display) { - av_log(ctx, AV_LOG_ERROR, "No VA display found for " - "device: %s.\n", device ? device : ""); + if (device) + av_log(ctx, AV_LOG_ERROR, "No VA display found for " + "device %s.\n", device); + else + av_log(ctx, AV_LOG_ERROR, "No VA display found for " + "any default device.\n"); return AVERROR(EINVAL); } |