[warnings] fix some compiler warnings

* fix compiler warnings found in a lot of places
* add missing enum type for clipboard channel
* mark deallocator for winpr image function
This commit is contained in:
akallabeth
2024-10-30 12:37:36 +01:00
parent d11be9025d
commit dc76879e0b
23 changed files with 215 additions and 179 deletions

View File

@@ -141,10 +141,6 @@ static BOOL tsmf_alsa_set_format(ITSMFAudioDevice* audio, UINT32 sample_rate, UI
static BOOL tsmf_alsa_play(ITSMFAudioDevice* audio, const BYTE* src, UINT32 data_size)
{
int len = 0;
int error = 0;
int frames = 0;
const BYTE* end = NULL;
const BYTE* pindex = NULL;
TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*)audio;
DEBUG_TSMF("data_size %" PRIu32 "", data_size);
@@ -153,22 +149,22 @@ static BOOL tsmf_alsa_play(ITSMFAudioDevice* audio, const BYTE* src, UINT32 data
{
const size_t rbytes_per_frame = 1ULL * alsa->actual_channels * alsa->bytes_per_sample;
pindex = src;
end = pindex + data_size;
const BYTE* end = pindex + data_size;
while (pindex < end)
{
len = end - pindex;
frames = len / rbytes_per_frame;
error = snd_pcm_writei(alsa->out_handle, pindex, frames);
const size_t len = (size_t)(end - pindex);
const size_t frames = len / rbytes_per_frame;
snd_pcm_sframes_t error = snd_pcm_writei(alsa->out_handle, pindex, frames);
if (error == -EPIPE)
{
snd_pcm_recover(alsa->out_handle, error, 0);
snd_pcm_recover(alsa->out_handle, -EPIPE, 0);
error = 0;
}
else if (error < 0)
{
DEBUG_TSMF("error len %d", error);
DEBUG_TSMF("error len %ld", error);
snd_pcm_close(alsa->out_handle);
alsa->out_handle = 0;
tsmf_alsa_open_device(alsa);
@@ -180,7 +176,7 @@ static BOOL tsmf_alsa_play(ITSMFAudioDevice* audio, const BYTE* src, UINT32 data
if (error == 0)
break;
pindex += error * rbytes_per_frame;
pindex += (size_t)error * rbytes_per_frame;
}
}

View File

@@ -82,7 +82,7 @@ typedef struct
enum AVCodecID codec_id;
#endif
AVCodecContext* codec_context;
AVCodec* codec;
const AVCodec* codec;
AVFrame* frame;
int prepared;
@@ -458,10 +458,7 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI
TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder;
int len = 0;
int frame_size = 0;
UINT32 src_size = 0;
const BYTE* src = NULL;
BYTE* dst = NULL;
int dst_offset = 0;
#if 0
WLog_DBG(TAG, ("tsmf_ffmpeg_decode_audio: data_size %"PRIu32"", data_size));
@@ -484,10 +481,10 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI
return FALSE;
/* align the memory for SSE2 needs */
dst = (BYTE*)(((uintptr_t)mdecoder->decoded_data + 15) & ~0x0F);
dst_offset = dst - mdecoder->decoded_data;
src = data;
src_size = data_size;
BYTE* dst = (BYTE*)(((uintptr_t)mdecoder->decoded_data + 15) & ~0x0F);
size_t dst_offset = (size_t)(dst - mdecoder->decoded_data);
const BYTE* src = data;
UINT32 src_size = data_size;
while (src_size > 0)
{
@@ -504,11 +501,12 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI
mdecoder->decoded_data = tmp_data;
dst = (BYTE*)(((uintptr_t)mdecoder->decoded_data + 15) & ~0x0F);
if (dst - mdecoder->decoded_data != dst_offset)
const size_t diff = (size_t)(dst - mdecoder->decoded_data);
if (diff != dst_offset)
{
/* re-align the memory if the alignment has changed after realloc */
memmove(dst, mdecoder->decoded_data + dst_offset, mdecoder->decoded_size);
dst_offset = dst - mdecoder->decoded_data;
dst_offset = diff;
}
dst += mdecoder->decoded_size;

View File

@@ -167,7 +167,6 @@ static BOOL tsmf_oss_set_format(ITSMFAudioDevice* audio, UINT32 sample_rate, UIN
static BOOL tsmf_oss_play(ITSMFAudioDevice* audio, const BYTE* data, UINT32 data_size)
{
int status = 0;
UINT32 offset = 0;
TSMFOssAudioDevice* oss = (TSMFOssAudioDevice*)audio;
DEBUG_TSMF("tsmf_oss_play: data_size %" PRIu32 "", data_size);
@@ -183,7 +182,7 @@ static BOOL tsmf_oss_play(ITSMFAudioDevice* audio, const BYTE* data, UINT32 data
while (offset < data_size)
{
status = write(oss->pcm_handle, &data[offset], (data_size - offset));
const ssize_t status = write(oss->pcm_handle, &data[offset], (data_size - offset));
if (status < 0)
{

View File

@@ -251,6 +251,8 @@ static const TSMFMediaTypeMap tsmf_format_type_map[] = {
static void tsmf_print_guid(const BYTE* guid)
{
WINPR_UNUSED(guid);
#ifdef WITH_DEBUG_TSMF
char guidString[37];
@@ -321,7 +323,7 @@ static UINT32 tsmf_codec_parse_VIDEOINFOHEADER2(TS_AM_MEDIA_TYPE* mediatype, wSt
/* VIDEOINFOHEADER2.AvgTimePerFrame */
Stream_Read_UINT64(s, AvgTimePerFrame);
mediatype->SamplesPerSecond.Numerator = 1000000;
mediatype->SamplesPerSecond.Denominator = (int)(AvgTimePerFrame / 10LL);
mediatype->SamplesPerSecond.Denominator = (UINT32)(AvgTimePerFrame / 10ULL);
/* Remaining fields before bmiHeader */
Stream_Seek(s, 24);
return 72;
@@ -359,7 +361,7 @@ static UINT32 tsmf_codec_parse_VIDEOINFOHEADER(TS_AM_MEDIA_TYPE* mediatype, wStr
/* VIDEOINFOHEADER.AvgTimePerFrame */
Stream_Read_UINT64(s, AvgTimePerFrame);
mediatype->SamplesPerSecond.Numerator = 1000000;
mediatype->SamplesPerSecond.Denominator = (int)(AvgTimePerFrame / 10LL);
mediatype->SamplesPerSecond.Denominator = (UINT32)(AvgTimePerFrame / 10ULL);
return 48;
}
@@ -393,7 +395,7 @@ static BOOL tsmf_read_format_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s, UINT3
return FALSE;
if (!Stream_CheckAndLogRequiredLength(TAG, s, nsize))
return FALSE;
mediatype->ExtraDataSize = nsize;
mediatype->ExtraDataSize = (UINT32)nsize;
mediatype->ExtraData = Stream_Pointer(s);
}
break;

View File

@@ -57,8 +57,8 @@ struct s_ITSMFDecoder
UINT64 (*GetRunningTime)(ITSMFDecoder* decoder);
/* Update Gstreamer Rendering Area */
BOOL(*UpdateRenderingArea)
(ITSMFDecoder* decoder, int newX, int newY, int newWidth, int newHeight, int numRectangles,
RDP_RECT* rectangles);
(ITSMFDecoder* decoder, UINT32 newX, UINT32 newY, UINT32 newWidth, UINT32 newHeight,
UINT32 numRectangles, const RECTANGLE_32* rectangles);
/* Change Gstreamer Audio Volume */
BOOL (*ChangeVolume)(ITSMFDecoder* decoder, UINT32 newVolume, UINT32 muted);
/* Check buffer level */

View File

@@ -68,8 +68,6 @@ UINT tsmf_ifman_rim_exchange_capability_request(TSMF_IFMAN* ifman)
*/
UINT tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman)
{
UINT32 v = 0;
UINT32 pos = 0;
UINT32 CapabilityType = 0;
UINT32 cbCapabilityLength = 0;
UINT32 numHostCapabilities = 0;
@@ -81,9 +79,9 @@ UINT tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman)
if (!Stream_CheckAndLogRequiredLength(TAG, ifman->input, ifman->input_size))
return ERROR_INVALID_DATA;
pos = Stream_GetPosition(ifman->output);
const size_t xpos = Stream_GetPosition(ifman->output);
Stream_Copy(ifman->input, ifman->output, ifman->input_size);
Stream_SetPosition(ifman->output, pos);
Stream_SetPosition(ifman->output, xpos);
if (!Stream_CheckAndLogRequiredLength(TAG, ifman->output, 4))
return ERROR_INVALID_DATA;
@@ -101,28 +99,34 @@ UINT tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman)
if (!Stream_CheckAndLogRequiredLength(TAG, ifman->output, cbCapabilityLength))
return ERROR_INVALID_DATA;
pos = Stream_GetPosition(ifman->output);
const size_t pos = Stream_GetPosition(ifman->output);
switch (CapabilityType)
{
case 1: /* Protocol version request */
{
if (!Stream_CheckAndLogRequiredLength(TAG, ifman->output, 4))
return ERROR_INVALID_DATA;
Stream_Read_UINT32(ifman->output, v);
const UINT32 v = Stream_Get_UINT32(ifman->output);
WINPR_UNUSED(v);
DEBUG_TSMF("server protocol version %" PRIu32 "", v);
break;
}
break;
case 2: /* Supported platform */
{
if (!Stream_CheckAndLogRequiredLength(TAG, ifman->output, 4))
return ERROR_INVALID_DATA;
Stream_Peek_UINT32(ifman->output, v);
const UINT32 v = Stream_Get_UINT32(ifman->output);
WINPR_UNUSED(v);
DEBUG_TSMF("server supported platform %" PRIu32 "", v);
/* Claim that we support both MF and DShow platforms. */
Stream_Write_UINT32(ifman->output, MMREDIR_CAPABILITY_PLATFORM_MF |
MMREDIR_CAPABILITY_PLATFORM_DSHOW);
break;
}
break;
default:
WLog_ERR(TAG, "skipping unknown capability type %" PRIu32 "", CapabilityType);
@@ -482,8 +486,7 @@ UINT tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman)
UINT32 Width = 0;
UINT32 Height = 0;
UINT32 cbVisibleRect = 0;
RDP_RECT* rects = NULL;
int num_rects = 0;
RECTANGLE_32* rects = NULL;
UINT error = CHANNEL_RC_OK;
size_t pos = 0;
@@ -505,34 +508,32 @@ UINT tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman)
Stream_Read_UINT32(ifman->input, Top);
Stream_SetPosition(ifman->input, pos + numGeometryInfo);
Stream_Read_UINT32(ifman->input, cbVisibleRect);
num_rects = cbVisibleRect / 16;
const UINT32 num_rects = cbVisibleRect / 16;
DEBUG_TSMF("numGeometryInfo %" PRIu32 " Width %" PRIu32 " Height %" PRIu32 " Left %" PRIu32
" Top %" PRIu32 " cbVisibleRect %" PRIu32 " num_rects %d",
numGeometryInfo, Width, Height, Left, Top, cbVisibleRect, num_rects);
if (num_rects > 0)
{
rects = (RDP_RECT*)calloc(num_rects, sizeof(RDP_RECT));
rects = (RECTANGLE_32*)calloc(num_rects, sizeof(RECTANGLE_32));
for (UINT32 i = 0; i < num_rects; i++)
for (size_t i = 0; i < num_rects; i++)
{
Stream_Read_UINT16(ifman->input, rects[i].y); /* Top */
Stream_Seek_UINT16(ifman->input);
Stream_Read_UINT16(ifman->input, rects[i].x); /* Left */
Stream_Seek_UINT16(ifman->input);
Stream_Read_UINT16(ifman->input, rects[i].height); /* Bottom */
Stream_Seek_UINT16(ifman->input);
Stream_Read_UINT16(ifman->input, rects[i].width); /* Right */
Stream_Seek_UINT16(ifman->input);
rects[i].width -= rects[i].x;
rects[i].height -= rects[i].y;
Stream_Read_UINT32(ifman->input, rects[i].top); /* Top */
Stream_Read_UINT32(ifman->input, rects[i].left); /* Left */
Stream_Read_UINT32(ifman->input, rects[i].height); /* Bottom */
Stream_Read_UINT32(ifman->input, rects[i].width); /* Right */
rects[i].width -= rects[i].left;
rects[i].height -= rects[i].top;
DEBUG_TSMF("rect %d: %" PRId16 " %" PRId16 " %" PRId16 " %" PRId16 "", i, rects[i].x,
rects[i].y, rects[i].width, rects[i].height);
}
}
if (!tsmf_presentation_set_geometry_info(presentation, Left, Top, Width, Height, num_rects,
rects))
const BOOL rc = tsmf_presentation_set_geometry_info(presentation, Left, Top, Width, Height,
num_rects, rects);
free(rects);
if (!rc)
return ERROR_INVALID_OPERATION;
ifman->output_pending = TRUE;

View File

@@ -36,8 +36,7 @@
BOOL tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32 message_id)
{
wStream* s = NULL;
int status = -1;
ssize_t status = -1;
TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)pChannelCallback;
if (!callback)
@@ -48,7 +47,7 @@ BOOL tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32
if (callback && callback->stream_id && callback->channel && callback->channel->Write)
{
s = Stream_New(NULL, 24);
wStream* s = Stream_New(NULL, 24);
if (!s)
return FALSE;
@@ -59,9 +58,10 @@ BOOL tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32
Stream_Write_UINT32(s, callback->stream_id); /* StreamId */
Stream_Write_UINT32(s, TSMM_CLIENT_EVENT_ENDOFSTREAM); /* EventId */
Stream_Write_UINT32(s, 0); /* cbData */
DEBUG_TSMF("EOS response size %" PRIuz "", Stream_GetPosition(s));
status = callback->channel->Write(callback->channel, Stream_GetPosition(s),
Stream_Buffer(s), NULL);
const size_t pos = Stream_GetPosition(s);
DEBUG_TSMF("EOS response size %" PRIuz "", pos);
WINPR_ASSERT(pos <= UINT32_MAX);
status = callback->channel->Write(callback->channel, (UINT32)pos, Stream_Buffer(s), NULL);
if (status)
{
@@ -77,14 +77,13 @@ BOOL tsmf_send_eos_response(IWTSVirtualChannelCallback* pChannelCallback, UINT32
BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, UINT32 message_id,
UINT64 duration, UINT32 data_size)
{
wStream* s = NULL;
int status = -1;
ssize_t status = -1;
TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)pChannelCallback;
if (!callback)
return FALSE;
s = Stream_New(NULL, 32);
wStream* s = Stream_New(NULL, 32);
if (!s)
return FALSE;
@@ -95,7 +94,9 @@ BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, UINT32 mess
Stream_Write_UINT32(s, callback->stream_id); /* StreamId */
Stream_Write_UINT64(s, duration); /* DataDuration */
Stream_Write_UINT64(s, data_size); /* cbData */
DEBUG_TSMF("ACK response size %" PRIuz "", Stream_GetPosition(s));
const size_t pos = Stream_GetPosition(s);
DEBUG_TSMF("ACK response size %" PRIuz "", pos);
if (!callback->channel || !callback->channel->Write)
{
@@ -105,8 +106,8 @@ BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, UINT32 mess
}
else
{
status = callback->channel->Write(callback->channel, Stream_GetPosition(s),
Stream_Buffer(s), NULL);
WINPR_ASSERT(pos <= UINT32_MAX);
status = callback->channel->Write(callback->channel, (UINT32)pos, Stream_Buffer(s), NULL);
}
if (status)
@@ -125,7 +126,6 @@ BOOL tsmf_playback_ack(IWTSVirtualChannelCallback* pChannelCallback, UINT32 mess
*/
static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data)
{
size_t length = 0;
wStream* input = NULL;
wStream* output = NULL;
UINT error = CHANNEL_RC_OK;
@@ -135,10 +135,10 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
UINT32 FunctionId = 0;
UINT32 InterfaceId = 0;
TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)pChannelCallback;
UINT32 cbSize = Stream_GetRemainingLength(data);
const size_t cbSize = Stream_GetRemainingLength(data);
/* 2.2.1 Shared Message Header (SHARED_MSG_HEADER) */
if (!Stream_CheckAndLogRequiredLength(TAG, data, 12))
if (!Stream_CheckAndLogRequiredLength(TAG, data, 12) || (cbSize > UINT32_MAX))
return ERROR_INVALID_DATA;
input = data;
@@ -162,7 +162,7 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
ifman.stream_id = callback->stream_id;
ifman.message_id = MessageId;
ifman.input = input;
ifman.input_size = cbSize - 12;
ifman.input_size = (UINT32)(cbSize - 12U);
ifman.output = output;
ifman.output_pending = FALSE;
ifman.output_interface_id = InterfaceId;
@@ -374,12 +374,15 @@ static UINT tsmf_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
if (processed && !ifman.output_pending)
{
/* Response packet does not have FunctionId */
length = Stream_GetPosition(output);
const size_t length = Stream_GetPosition(output);
if (length > UINT32_MAX)
goto out;
Stream_SetPosition(output, 0);
Stream_Write_UINT32(output, ifman.output_interface_id);
Stream_Write_UINT32(output, MessageId);
DEBUG_TSMF("response size %d", length);
error = callback->channel->Write(callback->channel, length, Stream_Buffer(output), NULL);
error = callback->channel->Write(callback->channel, (UINT32)length, Stream_Buffer(output),
NULL);
if (error)
{

View File

@@ -79,13 +79,10 @@ struct S_TSMF_PRESENTATION
wArrayList* stream_list;
int x;
int y;
int width;
int height;
RECTANGLE_32 rect;
int nr_rects;
void* rects;
UINT32 nr_rects;
RECTANGLE_32* rects;
};
struct S_TSMF_STREAM
@@ -166,16 +163,13 @@ static UINT64 get_current_time(void)
static TSMF_SAMPLE* tsmf_stream_pop_sample(TSMF_STREAM* stream, int sync)
{
UINT32 count = 0;
TSMF_STREAM* s = NULL;
TSMF_SAMPLE* sample = NULL;
BOOL pending = FALSE;
TSMF_PRESENTATION* presentation = NULL;
if (!stream)
return NULL;
presentation = stream->presentation;
TSMF_PRESENTATION* presentation = stream->presentation;
if (Queue_Count(stream->sample_list) < 1)
return NULL;
@@ -196,11 +190,12 @@ static TSMF_SAMPLE* tsmf_stream_pop_sample(TSMF_STREAM* stream, int sync)
if (stream->last_start_time > AUDIO_TOLERANCE)
{
ArrayList_Lock(presentation->stream_list);
count = ArrayList_Count(presentation->stream_list);
const size_t count = ArrayList_Count(presentation->stream_list);
for (UINT32 index = 0; index < count; index++)
for (size_t index = 0; index < count; index++)
{
s = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
TSMF_STREAM* s =
(TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index);
/* Start time is more reliable than end time as some stream types seem
* to have incorrect end times from the server
@@ -391,12 +386,11 @@ static char* guid_to_string(const BYTE* guid, char* str, size_t len)
TSMF_PRESENTATION* tsmf_presentation_find_by_id(const BYTE* guid)
{
UINT32 count = 0;
BOOL found = FALSE;
char guid_str[GUID_SIZE * 2 + 1] = { 0 };
TSMF_PRESENTATION* presentation = NULL;
ArrayList_Lock(presentation_list);
count = ArrayList_Count(presentation_list);
const size_t count = ArrayList_Count(presentation_list);
for (size_t index = 0; index < count; index++)
{
@@ -420,8 +414,8 @@ TSMF_PRESENTATION* tsmf_presentation_find_by_id(const BYTE* guid)
static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
{
UINT64 t = 0;
TSMF_VIDEO_FRAME_EVENT event;
WINPR_ASSERT(sample);
TSMF_STREAM* stream = sample->stream;
TSMF_PRESENTATION* presentation = stream->presentation;
TSMF_CHANNEL_CALLBACK* callback = (TSMF_CHANNEL_CALLBACK*)sample->channel_callback;
@@ -431,7 +425,7 @@ static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
if (sample->data)
{
t = get_current_time();
const UINT64 t = get_current_time();
/* Start time is more reliable than end time as some stream types seem to have incorrect
* end times from the server
@@ -440,24 +434,46 @@ static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
((sample->start_time >= presentation->audio_start_time) ||
((sample->start_time < stream->last_start_time) && (!sample->invalidTimestamps))))
{
USleep((stream->next_start_time - t) / 10);
size_t delay = (stream->next_start_time - t) / 10;
while (delay > 0)
{
const UINT32 d = (delay > UINT32_MAX) ? UINT32_MAX : (UINT32)delay;
USleep(d);
delay -= d;
}
}
if (sample->stream->width > INT16_MAX)
return FALSE;
if (sample->stream->height > INT16_MAX)
return FALSE;
if (presentation->rect.left > INT16_MAX)
return FALSE;
if (presentation->rect.top > INT16_MAX)
return FALSE;
if (presentation->rect.width > INT16_MAX)
return FALSE;
if (presentation->rect.height > INT16_MAX)
return FALSE;
if (presentation->nr_rects > UINT16_MAX)
return FALSE;
stream->next_start_time = t + sample->duration - 50000;
ZeroMemory(&event, sizeof(TSMF_VIDEO_FRAME_EVENT));
TSMF_VIDEO_FRAME_EVENT event = { 0 };
event.frameData = sample->data;
event.frameSize = sample->decoded_size;
event.framePixFmt = sample->pixfmt;
event.frameWidth = sample->stream->width;
event.frameHeight = sample->stream->height;
event.x = presentation->x;
event.y = presentation->y;
event.width = presentation->width;
event.height = presentation->height;
event.frameWidth = (INT16)sample->stream->width;
event.frameHeight = (INT16)sample->stream->height;
event.x = (INT16)presentation->rect.left;
event.y = (INT16)presentation->rect.top;
event.width = (INT16)presentation->rect.width;
event.height = (INT16)presentation->rect.height;
if (presentation->nr_rects > 0)
{
event.numVisibleRects = presentation->nr_rects;
event.numVisibleRects = (UINT16)presentation->nr_rects;
event.visibleRects = (RECTANGLE_16*)calloc(event.numVisibleRects, sizeof(RECTANGLE_16));
if (!event.visibleRects)
@@ -466,36 +482,26 @@ static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
return FALSE;
}
for (size_t x = 0; x < presentation->nr_rects; x++)
{
const RECTANGLE_32* cur = &presentation->rects[x];
RECTANGLE_16* dst = &event.visibleRects[x];
if ((cur->left > UINT16_MAX) || (cur->top > UINT16_MAX) ||
(cur->width > UINT16_MAX) || (cur->height > UINT16_MAX))
{
free(event.visibleRects);
return FALSE;
}
dst->right = dst->left = (UINT16)cur->left;
dst->bottom = dst->top = (UINT16)cur->top;
dst->right += (UINT16)cur->width;
dst->bottom += (UINT16)cur->height;
}
memcpy(event.visibleRects, presentation->rects,
presentation->nr_rects * sizeof(RDP_RECT));
presentation->nr_rects * sizeof(RECTANGLE_16));
presentation->nr_rects = 0;
}
#if 0
/* Dump a .ppm image for every 30 frames. Assuming the frame is in YUV format, we
extract the Y values to create a grayscale image. */
static int frame_id = 0;
char buf[100];
if ((frame_id % 30) == 0)
{
sprintf_s(buf, sizeof(buf), "/tmp/FreeRDP_Frame_%d.ppm", frame_id);
FILE* fp = fopen(buf, "wb");
if (fp)
{
fwrite("P5\n", 1, 3, fp);
sprintf_s(buf, sizeof(buf), "%"PRIu32" %"PRIu32"\n", sample->stream->width,
sample->stream->height);
fwrite(buf, 1, strnlen(buf, sizeof(buf)), fp);
fwrite("255\n", 1, 4, fp);
fwrite(sample->data, 1, sample->stream->width * sample->stream->height, fp);
fflush(fp);
fclose(fp);
}
}
frame_id++;
#endif
/* The frame data ownership is passed to the event object, and is freed after the event is
* processed. */
sample->data = NULL;
@@ -505,9 +511,7 @@ static BOOL tsmf_sample_playback_video(TSMF_SAMPLE* sample)
tsmf->FrameEvent(tsmf, &event);
free(event.frameData);
if (event.visibleRects != NULL)
free(event.visibleRects);
free(event.visibleRects);
}
return TRUE;
@@ -574,7 +578,7 @@ static BOOL tsmf_sample_playback(TSMF_SAMPLE* sample)
TSMF_STREAM* temp_stream = NULL;
TSMF_PRESENTATION* presentation = stream->presentation;
ArrayList_Lock(presentation->stream_list);
int count = ArrayList_Count(presentation->stream_list);
const size_t count = ArrayList_Count(presentation->stream_list);
for (size_t index = 0; index < count; index++)
{
@@ -1080,11 +1084,10 @@ BOOL tsmf_presentation_stop(TSMF_PRESENTATION* presentation)
}
BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, int num_rects,
RDP_RECT* rects)
UINT32 width, UINT32 height, UINT32 num_rects,
const RECTANGLE_32* rects)
{
TSMF_STREAM* stream = NULL;
void* tmp_rects = NULL;
BOOL ret = TRUE;
/* The server may send messages with invalid width / height.
@@ -1097,19 +1100,19 @@ BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation, UINT32
* or not the window is visible. So, always process a valid message with unchanged position/size
* and/or no visibility rects.
*/
presentation->x = x;
presentation->y = y;
presentation->width = width;
presentation->height = height;
tmp_rects = realloc(presentation->rects, sizeof(RDP_RECT) * num_rects);
presentation->rect.left = x;
presentation->rect.top = y;
presentation->rect.width = width;
presentation->rect.height = height;
void* tmp_rects = realloc(presentation->rects, sizeof(RECTANGLE_32) * num_rects);
if (!tmp_rects && num_rects)
return FALSE;
presentation->nr_rects = num_rects;
presentation->rects = tmp_rects;
presentation->rects = (RECTANGLE_32*)tmp_rects;
if (presentation->rects)
CopyMemory(presentation->rects, rects, sizeof(RDP_RECT) * num_rects);
CopyMemory(presentation->rects, rects, sizeof(RECTANGLE_32) * num_rects);
ArrayList_Lock(presentation->stream_list);
size_t count = ArrayList_Count(presentation->stream_list);

View File

@@ -47,8 +47,8 @@ BOOL tsmf_presentation_restarted(TSMF_PRESENTATION* presentation);
BOOL tsmf_presentation_volume_changed(TSMF_PRESENTATION* presentation, UINT32 newVolume,
UINT32 muted);
BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation, UINT32 x, UINT32 y,
UINT32 width, UINT32 height, int num_rects,
RDP_RECT* rects);
UINT32 width, UINT32 height, UINT32 num_rects,
const RECTANGLE_32* rects);
void tsmf_presentation_set_audio_device(TSMF_PRESENTATION* presentation, const char* name,
const char* device);
void tsmf_presentation_free(TSMF_PRESENTATION* presentation);