Added optional PreFrameAck callback to RdpgfxClientContext (#5303)
authorMati Shabtay <35010736+m4ntis@users.noreply.github.com>
Fri, 5 Apr 2019 11:37:51 +0000 (14:37 +0300)
committerakallabeth <akallabeth@users.noreply.github.com>
Fri, 5 Apr 2019 11:37:51 +0000 (13:37 +0200)
* RdpgfxClientContext: Add PreFrameAck callback

* client/rdpgfx_main.c: Call PreFrameAck callback before acking frame

* client/rdpgfx_main.c: Fix windows_msbuild_vs2010 CI build

* client/rdpgfx_main.c: Fix error logs log level

channels/rdpgfx/client/rdpgfx_main.c
include/freerdp/client/rdpgfx.h

index bd3b993..987c787 100644 (file)
@@ -148,7 +148,6 @@ static UINT rdpgfx_send_caps_advertise_pdu(RDPGFX_CHANNEL_CALLBACK* callback)
                capsSet->version = RDPGFX_CAPVERSION_105;
                capsSet->length = 0x4;
                capsSet->flags = caps10Flags;
-
                /* TODO: Until  RDPGFX_MAP_SURFACE_TO_SCALED_OUTPUT_PDU and
                 * RDPGFX_MAP_SURFACE_TO_SCALED_WINDOW_PDU are not implemented do not
                 * announce the following version */
@@ -600,6 +599,7 @@ static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
        RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
        RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
        UINT error = CHANNEL_RC_OK;
+       BOOL sendAck = TRUE;
 
        if (Stream_GetRemainingLength(s) < RDPGFX_END_FRAME_PDU_SIZE)
        {
@@ -625,23 +625,27 @@ static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
        gfx->TotalDecodedFrames++;
        ack.frameId = pdu.frameId;
        ack.totalFramesDecoded = gfx->TotalDecodedFrames;
+       IFCALLRET(context->PreFrameAck, sendAck, context, &ack);
 
-       if (gfx->suspendFrameAcks)
+       if (sendAck)
        {
-               ack.queueDepth = SUSPEND_FRAME_ACKNOWLEDGEMENT;
+               if (gfx->suspendFrameAcks)
+               {
+                       ack.queueDepth = SUSPEND_FRAME_ACKNOWLEDGEMENT;
+
+                       if (gfx->TotalDecodedFrames == 1)
+                               if ((error = rdpgfx_send_frame_acknowledge_pdu(callback, &ack)))
+                                       WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_send_frame_acknowledge_pdu failed with error %"PRIu32"",
+                                                  error);
+               }
+               else
+               {
+                       ack.queueDepth = QUEUE_DEPTH_UNAVAILABLE;
 
-               if (gfx->TotalDecodedFrames == 1)
                        if ((error = rdpgfx_send_frame_acknowledge_pdu(callback, &ack)))
                                WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_send_frame_acknowledge_pdu failed with error %"PRIu32"",
                                           error);
-       }
-       else
-       {
-               ack.queueDepth = QUEUE_DEPTH_UNAVAILABLE;
-
-               if ((error = rdpgfx_send_frame_acknowledge_pdu(callback, &ack)))
-                       WLog_Print(gfx->log, WLOG_DEBUG, "rdpgfx_send_frame_acknowledge_pdu failed with error %"PRIu32"",
-                                  error);
+               }
        }
 
        switch (gfx->ConnectionCaps.version)
@@ -663,7 +667,7 @@ static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
                                qoe.timeDiffEDR = 1;
 
                                if ((error = rdpgfx_send_qoe_frame_acknowledge_pdu(callback, &qoe)))
-                                       WLog_Print(gfx->log, WLOG_DEBUG, "rdpgfx_send_frame_acknowledge_pdu failed with error %"PRIu32"",
+                                       WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_send_frame_acknowledge_pdu failed with error %"PRIu32"",
                                                   error);
                        }
 
index 84f5219..7de72ed 100644 (file)
@@ -83,6 +83,9 @@ typedef UINT(*pcRdpgfxUpdateSurfaces)(RdpgfxClientContext* context);
 typedef UINT(*pcRdpgfxUpdateSurfaceArea)(RdpgfxClientContext* context, UINT16 surfaceId,
         UINT32 nrRects, const RECTANGLE_16* rects);
 
+typedef BOOL(*pcRdpgfxPreFrameAck)(RdpgfxClientContext* context,
+                                   RDPGFX_FRAME_ACKNOWLEDGE_PDU* frameAcknowledge);
+
 struct _rdpgfx_client_context
 {
        void* handle;
@@ -118,6 +121,8 @@ struct _rdpgfx_client_context
        pcRdpgfxUpdateSurfaces UpdateSurfaces;
        pcRdpgfxUpdateSurfaceArea UpdateSurfaceArea;
 
+       pcRdpgfxPreFrameAck PreFrameAck;
+
        CRITICAL_SECTION mux;
        PROFILER_DEFINE(SurfaceProfiler)
 };