本文整理汇总了C++中Stream_SetPosition函数的典型用法代码示例。如果您正苦于以下问题:C++ Stream_SetPosition函数的具体用法?C++ Stream_SetPosition怎么用?C++ Stream_SetPosition使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Stream_SetPosition函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestStream_Extent
static BOOL TestStream_Extent(UINT32 maxSize)
{
UINT32 i;
wStream *s = NULL;
BOOL result = FALSE;
if (!(s = Stream_New(NULL, 1)))
{
printf("%s: Stream_New failed\n", __FUNCTION__);
return FALSE;
}
for (i = 1; i < maxSize; i++)
{
if (i % 2)
{
if (!Stream_EnsureRemainingCapacity(s, i))
goto fail;
}
else
{
if (!Stream_EnsureCapacity(s, i))
goto fail;
}
Stream_SetPosition(s, i);
Stream_SealLength(s);
if (!TestStream_Verify(s, i, i, i))
{
printf("%s: failed to verify stream in iteration %d\n", __FUNCTION__, i);
goto fail;
}
}
result = TRUE;
fail:
if (s)
{
Stream_Free(s, TRUE);
}
return result;
}
示例2: rail_virtual_channel_event_data_received
static void rail_virtual_channel_event_data_received(railPlugin* rail,
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
{
wStream* data_in;
if ((dataFlags & CHANNEL_FLAG_SUSPEND) || (dataFlags & CHANNEL_FLAG_RESUME))
{
return;
}
if (dataFlags & CHANNEL_FLAG_FIRST)
{
if (rail->data_in)
Stream_Free(rail->data_in, TRUE);
rail->data_in = Stream_New(NULL, totalLength);
if (!rail->data_in)
{
WLog_ERR(TAG, "%s: unable to allocate data_in", __FUNCTION__);
return;
}
}
data_in = rail->data_in;
if (!Stream_EnsureRemainingCapacity(data_in, (int) dataLength))
{
WLog_ERR(TAG, "%s: unable to grow data_in to %d", __FUNCTION__, dataLength);
return;
}
Stream_Write(data_in, pData, dataLength);
if (dataFlags & CHANNEL_FLAG_LAST)
{
if (Stream_Capacity(data_in) != Stream_GetPosition(data_in))
{
WLog_ERR(TAG, "rail_plugin_process_received: read error");
}
rail->data_in = NULL;
Stream_SealLength(data_in);
Stream_SetPosition(data_in, 0);
MessageQueue_Post(rail->queue, NULL, 0, (void*) data_in, NULL);
}
}
示例3: video_control_send_client_notification
static UINT video_control_send_client_notification(VideoClientContext *context, TSMM_CLIENT_NOTIFICATION *notif)
{
BYTE buf[100];
wStream *s;
VIDEO_PLUGIN* video = (VIDEO_PLUGIN *)context->handle;
IWTSVirtualChannel* channel;
UINT ret;
UINT32 cbSize;
s = Stream_New(buf, 30);
if (!s)
return CHANNEL_RC_NO_MEMORY;
cbSize = 16;
Stream_Seek_UINT32(s); /* cbSize */
Stream_Write_UINT32(s, TSMM_PACKET_TYPE_CLIENT_NOTIFICATION); /* PacketType */
Stream_Write_UINT8(s, notif->PresentationId);
Stream_Write_UINT8(s, notif->NotificationType);
Stream_Zero(s, 2);
if (notif->NotificationType == TSMM_CLIENT_NOTIFICATION_TYPE_FRAMERATE_OVERRIDE)
{
Stream_Write_UINT32(s, 16); /* cbData */
/* TSMM_CLIENT_NOTIFICATION_FRAMERATE_OVERRIDE */
Stream_Write_UINT32(s, notif->FramerateOverride.Flags);
Stream_Write_UINT32(s, notif->FramerateOverride.DesiredFrameRate);
Stream_Zero(s, 4 * 2);
cbSize += 4 * 4;
}
else
{
Stream_Write_UINT32(s, 0); /* cbData */
}
Stream_SealLength(s);
Stream_SetPosition(s, 0);
Stream_Write_UINT32(s, cbSize);
Stream_Free(s, FALSE);
channel = video->control_callback->channel_callback->channel;
ret = channel->Write(channel, cbSize, buf, NULL);
return ret;
}
示例4: nla_client_authenticate
int nla_client_authenticate(rdpNla* nla)
{
wStream* s;
int status;
s = Stream_New(NULL, 4096);
if (!s)
{
WLog_ERR(TAG, "Stream_New failed!");
return -1;
}
if (nla_client_begin(nla) < 1)
{
Stream_Free(s, TRUE);
return -1;
}
while (nla->state < NLA_STATE_AUTH_INFO)
{
Stream_SetPosition(s, 0);
status = transport_read_pdu(nla->transport, s);
if (status < 0)
{
WLog_ERR(TAG, "nla_client_authenticate failure");
Stream_Free(s, TRUE);
return -1;
}
status = nla_recv_pdu(nla, s);
if (status < 0)
{
Stream_Free(s, TRUE);
return -1;
}
}
Stream_Free(s, TRUE);
return 1;
}
示例5: wts_read_drdynvc_data_first
static void wts_read_drdynvc_data_first(rdpPeerChannel* channel, wStream* s, int cbLen, UINT32 length)
{
int value;
value = wts_read_variable_uint(s, cbLen, &channel->dvc_total_length);
if (value == 0)
return;
length -= value;
if (length > channel->dvc_total_length)
return;
Stream_SetPosition(channel->receiveData, 0);
Stream_EnsureRemainingCapacity(channel->receiveData, (int) channel->dvc_total_length);
Stream_Write(channel->receiveData, Stream_Pointer(s), length);
}
示例6: dvcman_receive_channel_data
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr,
UINT32 ChannelId, wStream* data)
{
UINT status = CHANNEL_RC_OK;
DVCMAN_CHANNEL* channel;
size_t dataSize = Stream_GetRemainingLength(data);
channel = (DVCMAN_CHANNEL*) dvcman_find_channel_by_id(pChannelMgr, ChannelId);
if (!channel)
{
WLog_ERR(TAG, "ChannelId %d not found!", ChannelId);
return ERROR_INTERNAL_ERROR;
}
if (channel->dvc_data)
{
/* Fragmented data */
if (Stream_GetPosition(channel->dvc_data) + dataSize > (UINT32) Stream_Capacity(channel->dvc_data))
{
WLog_ERR(TAG, "data exceeding declared length!");
Stream_Release(channel->dvc_data);
channel->dvc_data = NULL;
return ERROR_INVALID_DATA;
}
Stream_Write(channel->dvc_data, Stream_Pointer(data), dataSize);
if (((size_t) Stream_GetPosition(channel->dvc_data)) >= channel->dvc_data_length)
{
Stream_SealLength(channel->dvc_data);
Stream_SetPosition(channel->dvc_data, 0);
status = channel->channel_callback->OnDataReceived(channel->channel_callback, channel->dvc_data);
Stream_Release(channel->dvc_data);
channel->dvc_data = NULL;
}
}
else
{
status = channel->channel_callback->OnDataReceived(channel->channel_callback, data);
}
return status;
}
示例7: encomsp_recv_change_participant_control_level_pdu
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT encomsp_recv_change_participant_control_level_pdu(
EncomspServerContext* context, wStream* s, ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
ENCOMSP_CHANGE_PARTICIPANT_CONTROL_LEVEL_PDU pdu;
UINT error = CHANNEL_RC_OK;
beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
if (Stream_GetRemainingLength(s) < 6)
{
WLog_ERR(TAG, "Not enough data!");
return ERROR_INVALID_DATA;
}
Stream_Read_UINT16(s, pdu.Flags); /* Flags (2 bytes) */
Stream_Read_UINT32(s, pdu.ParticipantId); /* ParticipantId (4 bytes) */
end = (int) Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
WLog_ERR(TAG, "Not enough data!");
return ERROR_INVALID_DATA;
}
if ((beg + header->Length) > end)
{
if (Stream_GetRemainingLength(s) < ((beg + header->Length) - end))
{
WLog_ERR(TAG, "Not enough data!");
return ERROR_INVALID_DATA;
}
Stream_SetPosition(s, (beg + header->Length));
}
IFCALLRET(context->ChangeParticipantControlLevel, error, context, &pdu);
if (error)
WLog_ERR(TAG, "context->ChangeParticipantControlLevel failed with error %u",
error);
return error;
}
示例8: update_recv_surfcmd_surface_bits
static int update_recv_surfcmd_surface_bits(rdpUpdate* update, wStream* s, UINT32* length)
{
int pos;
SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
if (Stream_GetRemainingLength(s) < 20)
return -1;
Stream_Read_UINT16(s, cmd->destLeft);
Stream_Read_UINT16(s, cmd->destTop);
Stream_Read_UINT16(s, cmd->destRight);
Stream_Read_UINT16(s, cmd->destBottom);
Stream_Read_UINT8(s, cmd->bpp);
if ((cmd->bpp < 1) || (cmd->bpp > 32))
{
WLog_ERR(TAG, "invalid bpp value %d", cmd->bpp);
return FALSE;
}
Stream_Seek(s, 2); /* reserved1, reserved2 */
Stream_Read_UINT8(s, cmd->codecID);
Stream_Read_UINT16(s, cmd->width);
Stream_Read_UINT16(s, cmd->height);
Stream_Read_UINT32(s, cmd->bitmapDataLength);
if (Stream_GetRemainingLength(s) < cmd->bitmapDataLength)
return -1;
pos = Stream_GetPosition(s) + cmd->bitmapDataLength;
cmd->bitmapData = Stream_Pointer(s);
Stream_SetPosition(s, pos);
*length = 20 + cmd->bitmapDataLength;
WLog_Print(update->log, WLOG_DEBUG,
"SurfaceBits: destLeft: %d destTop: %d destRight: %d destBottom: %d "
"bpp: %d codecId: %d width: %d height: %d bitmapDataLength: %d",
cmd->destLeft, cmd->destTop, cmd->destRight, cmd->destBottom,
cmd->bpp, cmd->codecID, cmd->width, cmd->height, cmd->bitmapDataLength);
IFCALL(update->SurfaceBits, update->context, cmd);
return 0;
}
示例9: wf_update_encode
void wf_update_encode(wfInfo* wfi)
{
RFX_RECT rect;
long height, width;
BYTE* pDataBits = NULL;
int stride;
SURFACE_BITS_COMMAND* cmd;
wf_info_find_invalid_region(wfi);
cmd = &wfi->cmd;
Stream_SetPosition(wfi->s, 0);
wf_info_getScreenData(wfi, &width, &height, &pDataBits, &stride);
rect.x = 0;
rect.y = 0;
rect.width = (UINT16) width;
rect.height = (UINT16) height;
//printf("x:%d y:%d w:%d h:%d\n", wfi->invalid.left, wfi->invalid.top, width, height);
Stream_Clear(wfi->s);
rfx_compose_message(wfi->rfx_context, wfi->s, &rect, 1,
pDataBits, width, height, stride);
wfi->frame_idx = wfi->rfx_context->frameIdx;
cmd->destLeft = wfi->invalid.left;
cmd->destTop = wfi->invalid.top;
cmd->destRight = wfi->invalid.left + width;
cmd->destBottom = wfi->invalid.top + height;
cmd->bpp = 32;
cmd->codecID = 3;
cmd->width = width;
cmd->height = height;
cmd->bitmapDataLength = Stream_GetPosition(wfi->s);
cmd->bitmapData = Stream_Buffer(wfi->s);
}
示例10: rdpgfx_send_reset_graphics_pdu
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT rdpgfx_send_reset_graphics_pdu(RdpgfxServerContext* context,
RDPGFX_RESET_GRAPHICS_PDU* pdu)
{
UINT32 index;
MONITOR_DEF* monitor;
wStream* s;
/* Check monitorCount. This ensures total size within 340 bytes) */
if (pdu->monitorCount >= 16)
{
WLog_ERR(TAG, "Monitor count MUST be less than or equal to 16: %lu",
(unsigned long) pdu->monitorCount);
return ERROR_INVALID_DATA;
}
s = rdpgfx_server_single_packet_new(
RDPGFX_CMDID_RESETGRAPHICS,
RDPGFX_RESET_GRAPHICS_PDU_SIZE - RDPGFX_HEADER_SIZE);
if (!s)
{
WLog_ERR(TAG, "rdpgfx_server_single_packet_new failed!");
return CHANNEL_RC_NO_MEMORY;
}
Stream_Write_UINT32(s, pdu->width); /* width (4 bytes) */
Stream_Write_UINT32(s, pdu->height); /* height (4 bytes) */
Stream_Write_UINT32(s, pdu->monitorCount); /* monitorCount (4 bytes) */
for (index = 0; index < pdu->monitorCount; index++)
{
monitor = &(pdu->monitorDefArray[index]);
Stream_Write_UINT32(s, monitor->left); /* left (4 bytes) */
Stream_Write_UINT32(s, monitor->top); /* top (4 bytes) */
Stream_Write_UINT32(s, monitor->right); /* right (4 bytes) */
Stream_Write_UINT32(s, monitor->bottom); /* bottom (4 bytes) */
Stream_Write_UINT32(s, monitor->flags); /* flags (4 bytes) */
}
/* pad (total size must be 340 bytes) */
Stream_SetPosition(s, RDPGFX_RESET_GRAPHICS_PDU_SIZE);
return rdpgfx_server_single_packet_send(context, s);
}
示例11: dvcman_receive_channel_data
int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelId, wStream* data)
{
int status = 0;
DVCMAN_CHANNEL* channel;
UINT32 dataSize = Stream_GetRemainingLength(data);
channel = (DVCMAN_CHANNEL*) dvcman_find_channel_by_id(pChannelMgr, ChannelId);
if (!channel)
{
DEBUG_WARN("ChannelId %d not found!", ChannelId);
return 1;
}
if (channel->dvc_data)
{
/* Fragmented data */
if (Stream_GetPosition(channel->dvc_data) + dataSize > (UINT32) Stream_Capacity(channel->dvc_data))
{
DEBUG_WARN("data exceeding declared length!");
Stream_Release(channel->dvc_data);
channel->dvc_data = NULL;
return 1;
}
Stream_Write(channel->dvc_data, Stream_Pointer(data), dataSize);
if (((size_t) Stream_GetPosition(channel->dvc_data)) >= Stream_Capacity(channel->dvc_data))
{
Stream_SealLength(channel->dvc_data);
Stream_SetPosition(channel->dvc_data, 0);
status = channel->channel_callback->OnDataReceived(channel->channel_callback, channel->dvc_data);
Stream_Release(channel->dvc_data);
channel->dvc_data = NULL;
}
}
else
{
status = channel->channel_callback->OnDataReceived(channel->channel_callback, data);
}
return status;
}
示例12: svc_plugin_process_received
static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, UINT32 dataLength,
UINT32 totalLength, UINT32 dataFlags)
{
wStream* s;
if ((dataFlags & CHANNEL_FLAG_SUSPEND) || (dataFlags & CHANNEL_FLAG_RESUME))
{
/*
* According to MS-RDPBCGR 2.2.6.1, "All virtual channel traffic MUST be suspended.
* This flag is only valid in server-to-client virtual channel traffic. It MUST be
* ignored in client-to-server data." Thus it would be best practice to cease data
* transmission. However, simply returning here avoids a crash.
*/
return;
}
if (dataFlags & CHANNEL_FLAG_FIRST)
{
if (plugin->data_in != NULL)
Stream_Free(plugin->data_in, TRUE);
plugin->data_in = Stream_New(NULL, totalLength);
}
s = plugin->data_in;
Stream_EnsureRemainingCapacity(s, (int) dataLength);
Stream_Write(s, pData, dataLength);
if (dataFlags & CHANNEL_FLAG_LAST)
{
if (Stream_Capacity(s) != Stream_GetPosition(s))
{
fprintf(stderr, "svc_plugin_process_received: read error\n");
}
plugin->data_in = NULL;
Stream_SealLength(s);
Stream_SetPosition(s, 0);
MessageQueue_Post(plugin->MsgPipe->In, NULL, 0, (void*) s, NULL);
}
}
示例13: freerds_client_outbound_vblank_event
int freerds_client_outbound_vblank_event(rdsModuleConnector* connector)
{
int length;
int status;
wStream* s;
RDS_MSG_VBLANK_EVENT msg;
msg.msgFlags = 0;
msg.type = RDS_CLIENT_VBLANK_EVENT;
s = connector->OutboundStream;
Stream_SetPosition(s, 0);
length = freerds_write_vblank_event(NULL, &msg);
freerds_write_vblank_event(s, &msg);
status = freerds_named_pipe_write(connector->hClientPipe, Stream_Buffer(s), length);
return status;
}
示例14: encomsp_recv_graphics_stream_resumed_pdu
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
static UINT encomsp_recv_graphics_stream_resumed_pdu(encomspPlugin* encomsp, wStream* s, ENCOMSP_ORDER_HEADER* header)
{
int beg, end;
EncomspClientContext* context;
ENCOMSP_GRAPHICS_STREAM_RESUMED_PDU pdu;
UINT error = CHANNEL_RC_OK;
context = encomsp_get_client_interface(encomsp);
if (!context)
return ERROR_INVALID_HANDLE;
beg = ((int) Stream_GetPosition(s)) - ENCOMSP_ORDER_HEADER_SIZE;
CopyMemory(&pdu, header, sizeof(ENCOMSP_ORDER_HEADER));
end = (int) Stream_GetPosition(s);
if ((beg + header->Length) < end)
{
WLog_ERR(TAG, "Not enought data!");
return ERROR_INVALID_DATA;
}
if ((beg + header->Length) > end)
{
if (Stream_GetRemainingLength(s) < (size_t) ((beg + header->Length) - end))
{
WLog_ERR(TAG, "Not enought data!");
return ERROR_INVALID_DATA;
}
Stream_SetPosition(s, (beg + header->Length));
}
IFCALLRET(context->GraphicsStreamResumed, error, context, &pdu);
if (error)
WLog_ERR(TAG, "context->GraphicsStreamResumed failed with error %lu", error);
return error;
}
示例15: rpc_client_receive_pool_take
RPC_PDU* rpc_client_receive_pool_take(rdpRpc* rpc)
{
RPC_PDU* pdu = NULL;
if (WaitForSingleObject(Queue_Event(rpc->client->ReceivePool), 0) == WAIT_OBJECT_0)
pdu = Queue_Dequeue(rpc->client->ReceivePool);
if (!pdu)
{
pdu = (RPC_PDU*) malloc(sizeof(RPC_PDU));
pdu->s = Stream_New(NULL, rpc->max_recv_frag);
}
pdu->CallId = 0;
pdu->Flags = 0;
Stream_Length(pdu->s) = 0;
Stream_SetPosition(pdu->s, 0);
return pdu;
}