Rework to remove static temp_img_buffer. Is now a class member. Must be allocated as needed.

This commit is contained in:
Isaac Connor 2022-02-16 14:18:37 -05:00 committed by Ben Dailey
parent 26d89292d7
commit 968acc2d43
1 changed files with 7 additions and 2 deletions

View File

@ -422,12 +422,17 @@ bool MonitorStream::sendFrame(Image *image, SystemTimePoint timestamp) {
/* double pts = */ vid_stream->EncodeFrame(send_image->Buffer(), send_image->Size(), config.mpeg_timed_frames, delta_time.count());
} else {
static unsigned char temp_img_buffer[ZM_MAX_IMAGE_SIZE];
if (temp_img_buffer_size < send_image->Size()) {
Debug(1, "Resizing image buffer from %zu to %u",
temp_img_buffer_size, send_image->Size());
delete[] temp_img_buffer;
temp_img_buffer = new uint8_t[send_image->Size()];
temp_img_buffer_size = send_image->Size();
}
int img_buffer_size = 0;
unsigned char *img_buffer = temp_img_buffer;
switch ( type ) {
case STREAM_JPEG :
send_image->EncodeJpeg(img_buffer, &img_buffer_size);