Allow freerdp clients to function with WITH_OPENH264_LOADING
authorArmin Novak <armin.novak@thincast.com>
Mon, 7 Oct 2019 07:31:20 +0000 (09:31 +0200)
committerArmin Novak <armin.novak@thincast.com>
Mon, 7 Oct 2019 07:31:20 +0000 (09:31 +0200)
If no library can be loaded at runtime ignore H264 capabilities.
This allows a build with only OpenH264 support and dynamic loading
enabled to function when no openh264 library was detected.

CMakeLists.txt
libfreerdp/core/codecs.c
libfreerdp/core/connection.c
libfreerdp/gdi/gfx.c

index a387f30..e9498d0 100644 (file)
@@ -875,7 +875,7 @@ find_feature(soxr ${SOXR_FEATURE_TYPE} ${SOXR_FEATURE_PURPOSE} ${SOXR_FEATURE_DE
 find_feature(GSSAPI ${GSSAPI_FEATURE_TYPE} ${GSSAPI_FEATURE_PURPOSE} ${GSSAPI_FEATURE_DESCRIPTION})
 
 if (WITH_OPENH264 AND NOT WITH_OPENH264_LOADING)
-       set(WITH_OPENH264_LOADING OFF)
+       option(WITH_OPENH264_LOADING "Use LoadLibrary to load openh264 at runtime" OFF)
 endif (WITH_OPENH264 AND NOT WITH_OPENH264_LOADING)
 
 if ((WITH_FFMPEG OR WITH_DSP_FFMPEG) AND NOT FFMPEG_FOUND)
index 3812eb4..fbfb630 100644 (file)
@@ -94,7 +94,9 @@ BOOL freerdp_client_codecs_prepare(rdpCodecs* codecs, UINT32 flags,
                if (!(codecs->h264 = h264_context_new(FALSE)))
                {
                        WLog_ERR(TAG, "Failed to create h264 codec context");
+#ifndef WITH_OPENH264_LOADING
                        return FALSE;
+#endif
                }
        }
 #endif
index d6822f7..0f15af3 100644 (file)
@@ -184,8 +184,23 @@ static BOOL rdp_client_reset_codecs(rdpContext* context)
        if (!context->codecs)
                return FALSE;
 
-       return freerdp_client_codecs_prepare(context->codecs, FREERDP_CODEC_ALL,
-                                            settings->DesktopWidth, settings->DesktopHeight);
+       if (!freerdp_client_codecs_prepare(context->codecs, FREERDP_CODEC_ALL,
+                                                                          settings->DesktopWidth, settings->DesktopHeight))
+               return FALSE;
+
+/* Runtime H264 detection. (only available if dynamic backend loading is defined)
+ * If no backend is available disable it before the channel is loaded.
+ */
+#if defined(WITH_GFX_H264) && defined(WITH_OPENH264_LOADING)
+       if (!context->codecs->h264)
+       {
+               settings->GfxH264 = FALSE;
+               settings->GfxAVC444 = FALSE;
+               settings->GfxAVC444v2 = FALSE;
+       }
+#endif
+       return TRUE;
+
 }
 
 /**
index 89d83fc..4bb2c3e 100644 (file)
@@ -459,6 +459,7 @@ static UINT gdi_SurfaceCommand_AVC420(rdpGdi* gdi,
        gdiGfxSurface* surface;
        RDPGFX_H264_METABLOCK* meta;
        RDPGFX_AVC420_BITMAP_STREAM* bs;
+
        surface = (gdiGfxSurface*) context->GetSurfaceData(context, cmd->surfaceId);
 
        if (!surface)
@@ -482,6 +483,9 @@ static UINT gdi_SurfaceCommand_AVC420(rdpGdi* gdi,
                        return ERROR_INTERNAL_ERROR;
        }
 
+       if (!surface->h264)
+               return ERROR_NOT_SUPPORTED;
+
        bs = (RDPGFX_AVC420_BITMAP_STREAM*) cmd->extra;
 
        if (!bs)
@@ -566,6 +570,9 @@ static UINT gdi_SurfaceCommand_AVC444(rdpGdi* gdi, RdpgfxClientContext* context,
                        return ERROR_INTERNAL_ERROR;
        }
 
+       if (!surface->h264)
+               return ERROR_NOT_SUPPORTED;
+
        bs = (RDPGFX_AVC444_BITMAP_STREAM*) cmd->extra;
 
        if (!bs)