rdpgfx/client: Expose QoeFrameAck
authorkubistika <kmizrachi18@gmail.com>
Wed, 5 Jun 2019 13:18:00 +0000 (16:18 +0300)
committerkubistika <kmizrachi18@gmail.com>
Thu, 6 Jun 2019 04:53:34 +0000 (07:53 +0300)
channels/rdpgfx/client/rdpgfx_main.c
include/freerdp/client/rdpgfx.h

index 48996ba..8bd9559 100644 (file)
@@ -368,16 +368,31 @@ fail:
        return error;
 }
 
-static UINT rdpgfx_send_qoe_frame_acknowledge_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
+static UINT rdpgfx_send_qoe_frame_acknowledge_pdu(RdpgfxClientContext* context,
         const RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU* pdu)
 {
        UINT error;
        wStream* s;
        RDPGFX_HEADER header;
-       RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
+       RDPGFX_CHANNEL_CALLBACK* callback;
+       RDPGFX_PLUGIN* gfx;
        header.flags = 0;
        header.cmdId = RDPGFX_CMDID_QOEFRAMEACKNOWLEDGE;
        header.pduLength = RDPGFX_HEADER_SIZE + 12;
+
+       if (!context || !pdu)
+               return ERROR_BAD_ARGUMENTS;
+
+       gfx = (RDPGFX_PLUGIN*) context->handle;
+
+       if (!gfx)
+               return ERROR_BAD_CONFIGURATION;
+
+       callback = gfx->listener_callback->channel_callback;
+
+       if (!callback)
+               return ERROR_BAD_CONFIGURATION;
+
        DEBUG_RDPGFX(gfx->log, "SendQoeFrameAcknowledgePdu: %"PRIu32"", pdu->frameId);
        s = Stream_New(NULL, header.pduLength);
 
@@ -791,28 +806,29 @@ static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
 
        gfx->UnacknowledgedFrames--;
        gfx->TotalDecodedFrames++;
+
+       if (!gfx->sendFrameAcks)
+               return error;
+
        ack.frameId = pdu.frameId;
        ack.totalFramesDecoded = gfx->TotalDecodedFrames;
 
-       if (gfx->sendFrameAcks)
+       if (gfx->suspendFrameAcks)
        {
-               if (gfx->suspendFrameAcks)
-               {
-                       ack.queueDepth = SUSPEND_FRAME_ACKNOWLEDGEMENT;
-
-                       if (gfx->TotalDecodedFrames == 1)
-                               if ((error = rdpgfx_send_frame_acknowledge_pdu(context, &ack)))
-                                       WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_send_frame_acknowledge_pdu failed with error %"PRIu32"",
-                                                  error);
-               }
-               else
-               {
-                       ack.queueDepth = QUEUE_DEPTH_UNAVAILABLE;
+               ack.queueDepth = SUSPEND_FRAME_ACKNOWLEDGEMENT;
 
+               if (gfx->TotalDecodedFrames == 1)
                        if ((error = rdpgfx_send_frame_acknowledge_pdu(context, &ack)))
                                WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_send_frame_acknowledge_pdu failed with error %"PRIu32"",
-                                          error);
-               }
+                                                       error);
+       }
+       else
+       {
+               ack.queueDepth = QUEUE_DEPTH_UNAVAILABLE;
+
+               if ((error = rdpgfx_send_frame_acknowledge_pdu(context, &ack)))
+                       WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_send_frame_acknowledge_pdu failed with error %"PRIu32"",
+                                               error);
        }
 
        switch (gfx->ConnectionCaps.version)
@@ -836,7 +852,7 @@ static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback,
                                qoe.timeDiffSE = diff;
                                qoe.timeDiffEDR = 1;
 
-                               if ((error = rdpgfx_send_qoe_frame_acknowledge_pdu(callback, &qoe)))
+                               if ((error = rdpgfx_send_qoe_frame_acknowledge_pdu(context, &qoe)))
                                        WLog_Print(gfx->log, WLOG_ERROR,
                                                   "rdpgfx_send_qoe_frame_acknowledge_pdu failed with error %"PRIu32"",
                                                   error);
@@ -2105,6 +2121,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
                context->CapsAdvertise = rdpgfx_send_caps_advertise_pdu;
                context->FrameAcknowledge = rdpgfx_send_frame_acknowledge_pdu;
                context->CacheImportOffer = rdpgfx_send_cache_import_offer_pdu;
+               context->QoeFrameAcknowledge = rdpgfx_send_qoe_frame_acknowledge_pdu;
 
                gfx->iface.pInterface = (void*) context;
                gfx->zgfx = zgfx_context_new(FALSE);
index 793f0e0..b33786a 100644 (file)
@@ -92,6 +92,8 @@ typedef UINT(*pcRdpgfxCapsConfirm)(RdpgfxClientContext* context,
                                    const RDPGFX_CAPS_CONFIRM_PDU* capsConfirm);
 typedef UINT(*pcRdpgfxFrameAcknowledge)(RdpgfxClientContext* context,
                                         const RDPGFX_FRAME_ACKNOWLEDGE_PDU* frameAcknowledge);
+typedef UINT(*pcRdpgfxQoeFrameAcknowledge)(RdpgfxClientContext* context,
+                                        const RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU* qoeFrameAcknowledge);
 
 typedef UINT(*pcRdpgfxMapWindowForSurface)(RdpgfxClientContext* context, UINT16 surfaceID,
         UINT64 windowID);
@@ -134,6 +136,7 @@ struct _rdpgfx_client_context
        pcRdpgfxCapsAdvertise CapsAdvertise;
        pcRdpgfxCapsConfirm CapsConfirm;
        pcRdpgfxFrameAcknowledge FrameAcknowledge;
+       pcRdpgfxQoeFrameAcknowledge QoeFrameAcknowledge;
 
        /* No locking required */
        pcRdpgfxUpdateSurfaces UpdateSurfaces;