return TRUE;
}
+void rdp_print_bitmap_codec_guid(GUID* guid)
+{
+ WLog_INFO(TAG, "%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X",
+ guid->Data1, guid->Data2, guid->Data3,
+ guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
+ guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
+}
+
+char* rdp_get_bitmap_codec_guid_name(GUID* guid)
+{
+ RPC_STATUS rpc_status;
+
+ if (UuidEqual(guid, &CODEC_GUID_REMOTEFX, &rpc_status))
+ return "CODEC_GUID_REMOTEFX";
+ else if (UuidEqual(guid, &CODEC_GUID_NSCODEC, &rpc_status))
+ return "CODEC_GUID_NSCODEC";
+ else if (UuidEqual(guid, &CODEC_GUID_IGNORE, &rpc_status))
+ return "CODEC_GUID_IGNORE";
+ else if (UuidEqual(guid, &CODEC_GUID_IMAGE_REMOTEFX, &rpc_status))
+ return "CODEC_GUID_IMAGE_REMOTEFX";
+ else if (UuidEqual(guid, &CODEC_GUID_JPEG, &rpc_status))
+ return "CODEC_GUID_JPEG";
+
+ return "CODEC_GUID_UNKNOWN";
+}
+
+
void rdp_read_bitmap_codec_guid(wStream* s, GUID* guid)
{
BYTE g[16];
Stream_Write(s, g, 16);
}
-void rdp_print_bitmap_codec_guid(GUID* guid)
-{
- WLog_INFO(TAG, "%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X",
- guid->Data1, guid->Data2, guid->Data3,
- guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
- guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
-}
-
-char* rdp_get_bitmap_codec_guid_name(GUID* guid)
-{
- RPC_STATUS rpc_status;
-
- if (UuidEqual(guid, &CODEC_GUID_REMOTEFX, &rpc_status))
- return "CODEC_GUID_REMOTEFX";
- else if (UuidEqual(guid, &CODEC_GUID_NSCODEC, &rpc_status))
- return "CODEC_GUID_NSCODEC";
- else if (UuidEqual(guid, &CODEC_GUID_IGNORE, &rpc_status))
- return "CODEC_GUID_IGNORE";
- else if (UuidEqual(guid, &CODEC_GUID_IMAGE_REMOTEFX, &rpc_status))
- return "CODEC_GUID_IMAGE_REMOTEFX";
- else if (UuidEqual(guid, &CODEC_GUID_JPEG, &rpc_status))
- return "CODEC_GUID_JPEG";
-
- return "CODEC_GUID_UNKNOWN";
-}
-
/**
* Read bitmap codecs capability set.\n
* @msdn{dd891377}
BOOL rdp_read_bitmap_codecs_capability_set(wStream* s, UINT16 length, rdpSettings* settings)
{
+ BYTE codecId;
GUID codecGuid;
RPC_STATUS rpc_status;
BYTE bitmapCodecCount;
UINT16 codecPropertiesLength;
UINT16 remainingLength;
- BOOL receivedRemoteFxCodec = FALSE;
- BOOL receivedNSCodec = FALSE;
+ BOOL guidNSCodec = FALSE;
+ BOOL guidRemoteFx = FALSE;
+ BOOL guidRemoteFxImage = FALSE;
if (length < 5)
return FALSE;
rdp_read_bitmap_codec_guid(s, &codecGuid); /* codecGuid (16 bytes) */
- if (settings->ServerMode)
- {
- if (UuidEqual(&codecGuid, &CODEC_GUID_REMOTEFX, &rpc_status))
- {
- Stream_Read_UINT8(s, settings->RemoteFxCodecId);
- receivedRemoteFxCodec = TRUE;
- }
- else if (UuidEqual(&codecGuid, &CODEC_GUID_NSCODEC, &rpc_status))
- {
- Stream_Read_UINT8(s, settings->NSCodecId);
- receivedNSCodec = TRUE;
- }
- else
- {
- Stream_Seek_UINT8(s); /* codecID (1 byte) */
- }
- }
- else
- {
- Stream_Seek_UINT8(s); /* codecID (1 byte) */
- }
-
+ Stream_Read_UINT8(s, codecId); /* codecId (1 byte) */
Stream_Read_UINT16(s, codecPropertiesLength); /* codecPropertiesLength (2 bytes) */
remainingLength -= 19;
if (settings->ServerMode)
{
+ UINT32 beg;
+ UINT32 end;
+
+ beg = (UINT32) Stream_GetPosition(s);
+ end = beg + codecPropertiesLength;
+
if (UuidEqual(&codecGuid, &CODEC_GUID_REMOTEFX, &rpc_status))
{
- Stream_Seek_UINT32(s); /* length */
- Stream_Read_UINT32(s, settings->RemoteFxCaptureFlags); /* captureFlags */
- Stream_Rewind(s, 8);
+ UINT32 rfxCapsLength;
+ UINT32 rfxPropsLength;
+ UINT32 captureFlags;
+
+ guidRemoteFx = TRUE;
+ settings->RemoteFxCodecId = codecId;
+
+ Stream_Read_UINT32(s, rfxPropsLength); /* length (4 bytes) */
+ Stream_Read_UINT32(s, captureFlags); /* captureFlags (4 bytes) */
+ Stream_Read_UINT32(s, rfxCapsLength); /* capsLength (4 bytes) */
- if (settings->RemoteFxCaptureFlags & CARDP_CAPS_CAPTURE_NON_CAC)
+ settings->RemoteFxCaptureFlags = captureFlags;
+ settings->RemoteFxOnly = (captureFlags & CARDP_CAPS_CAPTURE_NON_CAC) ? TRUE : FALSE;
+
+ if (rfxCapsLength)
{
- settings->RemoteFxOnly = TRUE;
+ UINT16 blockType;
+ UINT32 blockLen;
+ UINT16 numCapsets;
+ BYTE rfxCodecId;
+ UINT16 capsetType;
+ UINT16 numIcaps;
+ UINT16 icapLen;
+
+ /* TS_RFX_CAPS */
+
+ Stream_Read_UINT16(s, blockType); /* blockType (2 bytes) */
+ Stream_Read_UINT32(s, blockLen); /* blockLen (4 bytes) */
+ Stream_Read_UINT16(s, numCapsets); /* numCapsets (2 bytes) */
+
+ if (blockType != 0xCBC0)
+ return FALSE;
+
+ if (blockLen != 8)
+ return FALSE;
+
+ if (numCapsets != 1)
+ return FALSE;
+
+ /* TS_RFX_CAPSET */
+
+ Stream_Read_UINT16(s, blockType); /* blockType (2 bytes) */
+ Stream_Read_UINT32(s, blockLen); /* blockLen (4 bytes) */
+ Stream_Read_UINT8(s, rfxCodecId); /* codecId (1 byte) */
+ Stream_Read_UINT16(s, capsetType); /* capsetType (2 bytes) */
+ Stream_Read_UINT16(s, numIcaps); /* numIcaps (2 bytes) */
+ Stream_Read_UINT16(s, icapLen); /* icapLen (2 bytes) */
+
+ if (blockType != 0xCBC1)
+ return FALSE;
+
+ if (rfxCodecId != 1)
+ return FALSE;
+
+ if (capsetType != 0xCFC0)
+ return FALSE;
+
+ while (numIcaps--)
+ {
+ UINT16 version;
+ UINT16 tileSize;
+ BYTE codecFlags;
+ BYTE colConvBits;
+ BYTE transformBits;
+ BYTE entropyBits;
+
+ /* TS_RFX_ICAP */
+
+ Stream_Read_UINT16(s, version); /* version (2 bytes) */
+ Stream_Read_UINT16(s, tileSize); /* tileSize (2 bytes) */
+ Stream_Read_UINT8(s, codecFlags); /* flags (1 byte) */
+ Stream_Read_UINT8(s, colConvBits); /* colConvBits (1 byte) */
+ Stream_Read_UINT8(s, transformBits); /* transformBits (1 byte) */
+ Stream_Read_UINT8(s, entropyBits); /* entropyBits (1 byte) */
+
+ if (version != 0x0100)
+ return FALSE;
+
+ if (tileSize != 0x0040)
+ return FALSE;
+
+ if (colConvBits != 1)
+ return FALSE;
+
+ if (transformBits != 1)
+ return FALSE;
+ }
}
}
- }
+ else if (UuidEqual(&codecGuid, &CODEC_GUID_IMAGE_REMOTEFX, &rpc_status))
+ {
+ guidRemoteFxImage = TRUE;
+ Stream_Seek(s, codecPropertiesLength); /* codecProperties */
+ }
+ else if (UuidEqual(&codecGuid, &CODEC_GUID_NSCODEC, &rpc_status))
+ {
+ BYTE colorLossLevel;
+ BYTE fAllowSubsampling;
+ BYTE fAllowDynamicFidelity;
- Stream_Seek(s, codecPropertiesLength); /* codecProperties */
- remainingLength -= codecPropertiesLength;
+ guidNSCodec = TRUE;
+ settings->NSCodecId = codecId;
+
+ Stream_Read_UINT8(s, fAllowDynamicFidelity); /* fAllowDynamicFidelity (1 byte) */
+ Stream_Read_UINT8(s, fAllowSubsampling); /* fAllowSubsampling (1 byte) */
+ Stream_Read_UINT8(s, colorLossLevel); /* colorLossLevel (1 byte) */
+
+ if (colorLossLevel < 1)
+ colorLossLevel = 1;
+
+ if (colorLossLevel > 7)
+ colorLossLevel = 7;
+
+ settings->NSCodecAllowDynamicColorFidelity = fAllowDynamicFidelity;
+ settings->NSCodecAllowSubsampling = fAllowSubsampling;
+ settings->NSCodecColorLossLevel = colorLossLevel;
+ }
+ else if (UuidEqual(&codecGuid, &CODEC_GUID_IGNORE, &rpc_status))
+ {
+ Stream_Seek(s, codecPropertiesLength); /* codecProperties */
+ }
+ else
+ {
+ Stream_Seek(s, codecPropertiesLength); /* codecProperties */
+ }
+
+ if (Stream_GetPosition(s) != end)
+ {
+ fprintf(stderr, "error while reading codec properties: actual offset: %d expected offset: %d\n",
+ Stream_GetPosition(s), end);
+ Stream_SetPosition(s, end);
+ }
+
+ remainingLength -= codecPropertiesLength;
+ }
+ else
+ {
+ Stream_Seek(s, codecPropertiesLength); /* codecProperties */
+ remainingLength -= codecPropertiesLength;
+ }
bitmapCodecCount--;
}
if (settings->ServerMode)
{
/* only enable a codec if we've announced/enabled it before */
- settings->RemoteFxCodec = settings->RemoteFxCodec && receivedRemoteFxCodec;
- settings->NSCodec = settings->NSCodec && receivedNSCodec;
+ settings->RemoteFxCodec = settings->RemoteFxCodec && guidRemoteFx;
+ settings->RemoteFxImageCodec = settings->RemoteFxImageCodec && guidRemoteFxImage;
+ settings->NSCodec = settings->NSCodec && guidNSCodec;
settings->JpegCodec = FALSE;
}
Stream_Write_UINT16(s, 3); /* codecPropertiesLength */
/* TS_NSCODEC_CAPABILITYSET */
- Stream_Write_UINT8(s, 1); /* fAllowDynamicFidelity */
- Stream_Write_UINT8(s, 1); /* fAllowSubsampling */
- Stream_Write_UINT8(s, 3); /* colorLossLevel */
+ Stream_Write_UINT8(s, settings->NSCodecAllowDynamicColorFidelity); /* fAllowDynamicFidelity */
+ Stream_Write_UINT8(s, settings->NSCodecAllowSubsampling); /* fAllowSubsampling */
+ Stream_Write_UINT8(s, settings->NSCodecColorLossLevel); /* colorLossLevel */
}
void rdp_write_jpeg_client_capability_container(wStream* s, rdpSettings* settings)
bitmapCodecCount = 0;
if (settings->RemoteFxCodec)
- settings->RemoteFxImageCodec = TRUE;
-
- if (settings->RemoteFxCodec)
bitmapCodecCount++;
if (settings->NSCodec)
bitmapCodecCount++;