H264 and others require the surface resolution to work properly.
This initializes the codecs and the resolution on reset.
if (!surface || !surface->outputMapped)
continue;
- freerdp_client_codecs_reset(surface->codecs, FREERDP_CODEC_ALL);
+ if (!freerdp_client_codecs_reset(surface->codecs, FREERDP_CODEC_ALL,
+ surface->width, surface->height))
+ {
+ free(pSurfaceIds);
+ return ERROR_INTERNAL_ERROR;
+ }
region16_clear(&surface->invalidRegion);
}
free(pSurfaceIds);
- freerdp_client_codecs_reset(xfc->codecs, FREERDP_CODEC_ALL);
+ if (!freerdp_client_codecs_reset(xfc->codecs, FREERDP_CODEC_ALL,
+ xfc->settings->DesktopWidth,
+ xfc->settings->DesktopHeight))
+ return ERROR_INTERNAL_ERROR;
xfc->graphicsReset = TRUE;
return CHANNEL_RC_NO_MEMORY;
}
+ if (!freerdp_client_codecs_reset(surface->codecs, FREERDP_CODEC_ALL,
+ createSurface->width, createSurface->height))
+ {
+ free (surface);
+ return ERROR_INTERNAL_ERROR;
+ }
+
surface->surfaceId = createSurface->surfaceId;
surface->width = (UINT32) createSurface->width;
surface->height = (UINT32) createSurface->height;
FREERDP_API int clear_decompress(CLEAR_CONTEXT* clear, BYTE* pSrcData, UINT32 SrcSize,
BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight);
-FREERDP_API int clear_context_reset(CLEAR_CONTEXT* clear);
+FREERDP_API BOOL clear_context_reset(CLEAR_CONTEXT* clear);
FREERDP_API CLEAR_CONTEXT* clear_context_new(BOOL Compressor);
FREERDP_API void clear_context_free(CLEAR_CONTEXT* clear);
#endif
#endif /* FREERDP_CODEC_CLEAR_H */
-
+
FLOAT FrameRate;
UINT32 QP;
UINT32 NumberOfThreads;
-
+
int iStride[3];
BYTE* pYUVData[3];
BYTE** ppDstData, DWORD DstFormat, int nDstStep, int nDstWidth, int nDstHeight,
RDPGFX_RECT16* regionRects, int numRegionRect);
-FREERDP_API int h264_context_reset(H264_CONTEXT* h264);
+FREERDP_API BOOL h264_context_reset(H264_CONTEXT* h264, UINT32 width, UINT32 height);
FREERDP_API H264_CONTEXT* h264_context_new(BOOL Compressor);
FREERDP_API void h264_context_free(H264_CONTEXT* h264);
FREERDP_API int interleaved_compress(BITMAP_INTERLEAVED_CONTEXT* interleaved, BYTE* pDstData, UINT32* pDstSize,
int nWidth, int nHeight, BYTE* pSrcData, DWORD SrcFormat, int nSrcStep, int nXSrc, int nYSrc, BYTE* palette, int bpp);
-FREERDP_API int bitmap_interleaved_context_reset(BITMAP_INTERLEAVED_CONTEXT* interleaved);
+FREERDP_API BOOL bitmap_interleaved_context_reset(BITMAP_INTERLEAVED_CONTEXT* interleaved);
FREERDP_API BITMAP_INTERLEAVED_CONTEXT* bitmap_interleaved_context_new(BOOL Compressor);
FREERDP_API void bitmap_interleaved_context_free(BITMAP_INTERLEAVED_CONTEXT* interleaved);
FREERDP_API int nsc_write_message(NSC_CONTEXT* context, wStream* s, NSC_MESSAGE* message);
FREERDP_API int nsc_message_free(NSC_CONTEXT* context, NSC_MESSAGE* message);
-FREERDP_API int nsc_context_reset(NSC_CONTEXT* context);
+FREERDP_API BOOL nsc_context_reset(NSC_CONTEXT* context, UINT32 width, UINT32 height);
FREERDP_API NSC_CONTEXT* nsc_context_new(void);
FREERDP_API void nsc_context_free(NSC_CONTEXT* context);
FREERDP_API BYTE* freerdp_bitmap_compress_planar(BITMAP_PLANAR_CONTEXT* context, BYTE* data, UINT32 format,
int width, int height, int scanline, BYTE* dstData, int* pDstSize);
-FREERDP_API int freerdp_bitmap_planar_context_reset(BITMAP_PLANAR_CONTEXT* context);
+FREERDP_API BOOL freerdp_bitmap_planar_context_reset(BITMAP_PLANAR_CONTEXT* context);
FREERDP_API BITMAP_PLANAR_CONTEXT* freerdp_bitmap_planar_context_new(DWORD flags, int maxWidth, int maxHeight);
FREERDP_API void freerdp_bitmap_planar_context_free(BITMAP_PLANAR_CONTEXT* context);
FREERDP_API int progressive_create_surface_context(PROGRESSIVE_CONTEXT* progressive, UINT16 surfaceId, UINT32 width, UINT32 height);
FREERDP_API int progressive_delete_surface_context(PROGRESSIVE_CONTEXT* progressive, UINT16 surfaceId);
-FREERDP_API int progressive_context_reset(PROGRESSIVE_CONTEXT* progressive);
+FREERDP_API BOOL progressive_context_reset(PROGRESSIVE_CONTEXT* progressive);
FREERDP_API PROGRESSIVE_CONTEXT* progressive_context_new(BOOL Compressor);
FREERDP_API void progressive_context_free(PROGRESSIVE_CONTEXT* progressive);
#endif
#endif /* FREERDP_CODEC_PROGRESSIVE_H */
-
+
BYTE* data, int width, int height, int scanline, int* numMessages, int maxDataSize);
FREERDP_API BOOL rfx_write_message(RFX_CONTEXT* context, wStream* s, RFX_MESSAGE* message);
-FREERDP_API void rfx_context_reset(RFX_CONTEXT* context);
+FREERDP_API BOOL rfx_context_reset(RFX_CONTEXT* context, UINT32 width, UINT32 height);
FREERDP_API RFX_CONTEXT* rfx_context_new(BOOL encoder);
FREERDP_API void rfx_context_free(RFX_CONTEXT* context);
#endif
FREERDP_API BOOL freerdp_client_codecs_prepare(rdpCodecs* codecs, UINT32 flags);
-FREERDP_API BOOL freerdp_client_codecs_reset(rdpCodecs* codecs, UINT32 flags);
+FREERDP_API BOOL freerdp_client_codecs_reset(rdpCodecs* codecs, UINT32 flags,
+ UINT32 width, UINT32 height);
FREERDP_API rdpCodecs* codecs_new(rdpContext* context);
FREERDP_API void codecs_free(rdpCodecs* codecs);
return 1;
}
-int clear_context_reset(CLEAR_CONTEXT* clear)
+BOOL clear_context_reset(CLEAR_CONTEXT* clear)
{
+ if (!clear)
+ return FALSE;
+
clear->seqNumber = 0;
clear->VBarStorageCursor = 0;
clear->ShortVBarStorageCursor = 0;
- return 1;
+
+ return TRUE;
}
CLEAR_CONTEXT* clear_context_new(BOOL Compressor)
#define __IMFDXGIDeviceManager_INTERFACE_DEFINED__
typedef struct IMFDXGIDeviceManagerVtbl
-{
+{
HRESULT (STDMETHODCALLTYPE * QueryInterface)(IMFDXGIDeviceManager* This, REFIID riid, void** ppvObject);
ULONG (STDMETHODCALLTYPE * AddRef)(IMFDXGIDeviceManager* This);
- ULONG (STDMETHODCALLTYPE * Release)(IMFDXGIDeviceManager* This);
- HRESULT (STDMETHODCALLTYPE * CloseDeviceHandle)(IMFDXGIDeviceManager* This, HANDLE hDevice);
- HRESULT (STDMETHODCALLTYPE * GetVideoService)(IMFDXGIDeviceManager* This, HANDLE hDevice, REFIID riid, void** ppService);
- HRESULT (STDMETHODCALLTYPE * LockDevice)(IMFDXGIDeviceManager* This, HANDLE hDevice, REFIID riid, void** ppUnkDevice, BOOL fBlock);
- HRESULT (STDMETHODCALLTYPE * OpenDeviceHandle)(IMFDXGIDeviceManager* This, HANDLE* phDevice);
- HRESULT (STDMETHODCALLTYPE * ResetDevice)(IMFDXGIDeviceManager* This, IUnknown* pUnkDevice, UINT resetToken);
- HRESULT (STDMETHODCALLTYPE * TestDevice)(IMFDXGIDeviceManager* This, HANDLE hDevice);
- HRESULT (STDMETHODCALLTYPE * UnlockDevice)(IMFDXGIDeviceManager* This, HANDLE hDevice, BOOL fSaveState);
+ ULONG (STDMETHODCALLTYPE * Release)(IMFDXGIDeviceManager* This);
+ HRESULT (STDMETHODCALLTYPE * CloseDeviceHandle)(IMFDXGIDeviceManager* This, HANDLE hDevice);
+ HRESULT (STDMETHODCALLTYPE * GetVideoService)(IMFDXGIDeviceManager* This, HANDLE hDevice, REFIID riid, void** ppService);
+ HRESULT (STDMETHODCALLTYPE * LockDevice)(IMFDXGIDeviceManager* This, HANDLE hDevice, REFIID riid, void** ppUnkDevice, BOOL fBlock);
+ HRESULT (STDMETHODCALLTYPE * OpenDeviceHandle)(IMFDXGIDeviceManager* This, HANDLE* phDevice);
+ HRESULT (STDMETHODCALLTYPE * ResetDevice)(IMFDXGIDeviceManager* This, IUnknown* pUnkDevice, UINT resetToken);
+ HRESULT (STDMETHODCALLTYPE * TestDevice)(IMFDXGIDeviceManager* This, HANDLE hDevice);
+ HRESULT (STDMETHODCALLTYPE * UnlockDevice)(IMFDXGIDeviceManager* This, HANDLE hDevice, BOOL fSaveState);
}
IMFDXGIDeviceManagerVtbl;
}
else if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT)
{
-
+
}
else if (FAILED(hr))
{
h264->iStride[0] = h264->iStride[1] = h264->iStride[2] = 0;
sys->MFShutdown();
-
+
CoUninitialize();
free(sys);
var.vt = VT_UI4;
var.ulVal = 1;
-
+
hr = sys->codecApi->lpVtbl->SetValue(sys->codecApi, &CODECAPI_AVLowLatencyMode, &var);
if (FAILED(hr))
}
hr = sys->inputType->lpVtbl->SetGUID(sys->inputType, &MF_MT_SUBTYPE, &MFVideoFormat_H264);
-
+
if (FAILED(hr))
{
WLog_ERR(TAG, "SetGUID(MF_MT_SUBTYPE) failure: 0x%04X", hr);
width = rect->right - rect->left;
height = rect->bottom - rect->top;
-
+
pDstPoint = pDstData + rect->top * nDstStep + rect->left * 4;
pYUVPoint[0] = pYUVData[0] + rect->top * iStride[0] + rect->left;
return FALSE;
}
-int h264_context_reset(H264_CONTEXT* h264)
+BOOL h264_context_reset(H264_CONTEXT* h264, UINT32 width, UINT32 height)
{
- return 1;
+ if (!h264)
+ return FALSE;
+
+ h264->width = width;
+ h264->height = height;
+
+ return TRUE;
}
H264_CONTEXT* h264_context_new(BOOL Compressor)
return status;
}
-int bitmap_interleaved_context_reset(BITMAP_INTERLEAVED_CONTEXT* interleaved)
+BOOL bitmap_interleaved_context_reset(BITMAP_INTERLEAVED_CONTEXT* interleaved)
{
- return 1;
+ if (!interleaved)
+ return FALSE;
+
+ return TRUE;
}
BITMAP_INTERLEAVED_CONTEXT* bitmap_interleaved_context_new(BOOL Compressor)
PROFILER_PRINT_FOOTER;
}
-int nsc_context_reset(NSC_CONTEXT* context)
+BOOL nsc_context_reset(NSC_CONTEXT* context, UINT32 width, UINT32 height)
{
- return 1;
+ if (!context)
+ return FALSE;
+
+ context->width = width;
+ context->height = height;
+
+ return TRUE;
}
NSC_CONTEXT* nsc_context_new(void)
return dstData;
}
-int freerdp_bitmap_planar_context_reset(BITMAP_PLANAR_CONTEXT* context)
+BOOL freerdp_bitmap_planar_context_reset(BITMAP_PLANAR_CONTEXT* context)
{
- return 1;
+ if (!context)
+ return FALSE;
+
+ return TRUE;
}
BITMAP_PLANAR_CONTEXT* freerdp_bitmap_planar_context_new(DWORD flags, int maxWidth, int maxHeight)
return 1;
}
-int progressive_context_reset(PROGRESSIVE_CONTEXT* progressive)
+BOOL progressive_context_reset(PROGRESSIVE_CONTEXT* progressive)
{
- return 1;
+ if (!progressive)
+ return FALSE;
+
+ return TRUE;
}
PROGRESSIVE_CONTEXT* progressive_context_new(BOOL Compressor)
{
RFX_CONTEXT_PRIV *priv;
+ if (!context)
+ return;
+
assert(NULL != context);
assert(NULL != context->priv);
assert(NULL != context->priv->TilePool);
}
}
-void rfx_context_reset(RFX_CONTEXT* context)
+BOOL rfx_context_reset(RFX_CONTEXT* context, UINT32 width, UINT32 height)
{
+ if (!context)
+ return FALSE;
+
+ context->width = width;
+ context->height = height;
context->state = RFX_STATE_SEND_HEADERS;
context->frameIdx = 0;
+
+ return TRUE;
}
static BOOL rfx_process_message_sync(RFX_CONTEXT* context, wStream* s)
return TRUE;
}
-BOOL freerdp_client_codecs_reset(rdpCodecs* codecs, UINT32 flags)
+BOOL freerdp_client_codecs_reset(rdpCodecs* codecs, UINT32 flags,
+ UINT32 width, UINT32 height)
{
+ BOOL rc = TRUE;
+
+ if (!freerdp_client_codecs_prepare(codecs, flags))
+ return FALSE;
+
if (flags & FREERDP_CODEC_INTERLEAVED)
{
if (codecs->interleaved)
{
- bitmap_interleaved_context_reset(codecs->interleaved);
+ rc &= bitmap_interleaved_context_reset(codecs->interleaved);
}
}
{
if (codecs->planar)
{
- freerdp_bitmap_planar_context_reset(codecs->planar);
+ rc &= freerdp_bitmap_planar_context_reset(codecs->planar);
}
}
{
if (codecs->nsc)
{
- nsc_context_reset(codecs->nsc);
+ rc &= nsc_context_reset(codecs->nsc, width, height);
}
}
{
if (codecs->rfx)
{
- rfx_context_reset(codecs->rfx);
+ rc &= rfx_context_reset(codecs->rfx, width, height);
}
}
{
if (codecs->clear)
{
- clear_context_reset(codecs->clear);
+ rc &= clear_context_reset(codecs->clear);
}
}
{
if (codecs->progressive)
{
- progressive_context_reset(codecs->progressive);
+ rc &= progressive_context_reset(codecs->progressive);
}
}
{
if (codecs->h264)
{
- h264_context_reset(codecs->h264);
+ rc &= h264_context_reset(codecs->h264, width, height);
}
}
- return TRUE;
+ return rc;
}
rdpCodecs* codecs_new(rdpContext* context)
if (!surface || !surface->outputMapped)
continue;
- freerdp_client_codecs_reset(surface->codecs, FREERDP_CODEC_ALL);
+ if (!freerdp_client_codecs_reset(surface->codecs, FREERDP_CODEC_ALL,
+ surface->width, surface->height))
+ {
+ free (surface);
+ return ERROR_INTERNAL_ERROR;
+ }
region16_clear(&surface->invalidRegion);
}
free(pSurfaceIds);
- freerdp_client_codecs_reset(gdi->codecs, FREERDP_CODEC_ALL);
+ if (!freerdp_client_codecs_reset(gdi->codecs, FREERDP_CODEC_ALL,
+ gdi->width, gdi->height))
+ return ERROR_INTERNAL_ERROR;
gdi->graphicsReset = TRUE;
return CHANNEL_RC_NO_MEMORY;
}
+ if (!freerdp_client_codecs_reset(surface->codecs, FREERDP_CODEC_ALL,
+ createSurface->width, createSurface->height))
+ {
+ free (surface);
+ return ERROR_INTERNAL_ERROR;
+ }
+
surface->surfaceId = createSurface->surfaceId;
surface->width = (UINT32) createSurface->width;
surface->height = (UINT32) createSurface->height;
if (!(context->rfx_context = rfx_context_new(TRUE)))
goto fail_rfx_context;
+ if (!rfx_context_reset(context->rfx_context, SAMPLE_SERVER_DEFAULT_WIDTH,
+ SAMPLE_SERVER_DEFAULT_HEIGHT))
+ goto fail_rfx_context;
+
context->rfx_context->mode = RLGR3;
- context->rfx_context->width = SAMPLE_SERVER_DEFAULT_WIDTH;
- context->rfx_context->height = SAMPLE_SERVER_DEFAULT_HEIGHT;
+
rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_R8G8B8);
if (!(context->nsc_context = nsc_context_new()))
{
testPeerContext* context = (testPeerContext*) client->context;
- rfx_context_reset(context->rfx_context);
context->activated = TRUE;
//client->settings->CompressionLevel = PACKET_COMPR_TYPE_8K;
UINT32 shadow_encoder_inflight_frames(rdpShadowEncoder* encoder)
{
- /* Return inflight frame count =
+ /* Return inflight frame count =
* <last sent frame id> - <last client-acknowledged frame id>
- * Note: This function is exported so that subsystem could
+ * Note: This function is exported so that subsystem could
* implement its own strategy to tune fps.
*/
return encoder->frameId - encoder->lastAckframeId;
if (!encoder->rfx)
encoder->rfx = rfx_context_new(TRUE);
+ if (!rfx_context_reset(encoder->rfx, encoder->width, encoder->height))
+ goto fail;
+
if (!encoder->rfx)
- return -1;
+ goto fail;
+
encoder->rfx->mode = RLGR3;
encoder->rfx->width = encoder->width;
encoder->codecs |= FREERDP_CODEC_REMOTEFX;
return 1;
+
+fail:
+ rfx_context_free(encoder->rfx);
+ return -1;
}
int shadow_encoder_init_nsc(rdpShadowEncoder* encoder)