* \param[in] width The raw data width
* \param[in] height The raw data height
*/
-SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t *dest, void *src, switch_img_fmt_t fmt, int width, int height);
+SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t** destP, void *src, switch_img_fmt_t fmt, int width, int height);
SWITCH_DECLARE(switch_image_t *) switch_img_write_text_img(int w, int h, switch_bool_t full, const char *text);
SWITCH_DECLARE(switch_image_t *) switch_img_read_file(const char* file_name);
}
if (context->rawImage && (context->debug || !context->overlay_count)) {
- switch_img_from_raw(frame->img, (uint8_t *)context->rawImage->imageData, SWITCH_IMG_FMT_RGB24, context->rawImage->width, context->rawImage->height);
+ switch_img_from_raw(&frame->img, (uint8_t *)context->rawImage->imageData, SWITCH_IMG_FMT_RGB24, context->rawImage->width, context->rawImage->height);
}
int abs = 0;
}
- switch_img_from_raw(frame->img, patch_data, SWITCH_IMG_FMT_ARGB, frame->img->d_w, frame->img->d_h);
+ switch_img_from_raw(&frame->img, patch_data, SWITCH_IMG_FMT_ARGB, frame->img->d_w, frame->img->d_h);
switch_img_free(&img);
return SWITCH_STATUS_FALSE;
}
- switch_img_from_raw(context->img, storage, SWITCH_IMG_FMT_BGR24, w, h);
+ switch_img_from_raw(&context->img, storage, SWITCH_IMG_FMT_BGR24, w, h);
free(storage);
} else {
switch_image_t *img = switch_img_alloc(NULL, SWITCH_IMG_FMT_ARGB, image->columns, image->rows, 0);
if (!(ep = switch_loadable_module_get_endpoint_interface(argv[0]))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "EP ERROR\n");
+ switch_xml_free(xml);
+
return 0;
}
#endif
}
-SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t *dest, void *src, switch_img_fmt_t fmt, int width, int height)
+SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t **destP, void *src, switch_img_fmt_t fmt, int width, int height)
{
#ifdef SWITCH_HAVE_YUV
uint32_t fourcc;
int ret = -1;
+ switch_image_t *dest = NULL;
+
+ if (!destP) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ dest = *destP;
fourcc = switch_img_fmt2fourcc(fmt);
0, fourcc);
}
+ *destP = dest;
+
return ret == 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
#else
return SWITCH_STATUS_FALSE;
switch_image_t *dest = NULL;
int ret = 0;
- if (destP) {
- dest = *destP;
+ if (!destP) {
+ return SWITCH_STATUS_FALSE;
}
+ dest = *destP;
+
switch_assert(width > 0);
switch_assert(height > 0);
kFilterBox);
}
+ *destP = dest;
+
if (ret != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Scaling Error: ret: %d\n", ret);
return SWITCH_STATUS_FALSE;
}
- if (destP) {
- *destP = dest;
- }
-
return SWITCH_STATUS_SUCCESS;
#else
return SWITCH_STATUS_FALSE;
switch_image_t *dest = NULL;
int ret = 0;
- if (destP) {
- dest = *destP;
+ if (!destP) {
+ return SWITCH_STATUS_FALSE;
}
+ dest = *destP;
+
if (dest && src->fmt != dest->fmt) switch_img_free(&dest);
if (!dest) dest = switch_img_alloc(NULL, src->fmt, src->d_w, src->d_h, 1);
}
+ *destP = dest;
+
if (ret != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Mirror Error: ret: %d\n", ret);
return SWITCH_STATUS_FALSE;
}
- if (destP) {
- *destP = dest;
- }
-
return SWITCH_STATUS_SUCCESS;
#else
return SWITCH_STATUS_FALSE;
data = (char *) malloc(2048);
if (!data) {
va_end(ap);
+ switch_xml_free(xml);
+
return NULL;
}
ret = vsnprintf(data, 2048, fmt, ap);
#ifndef HAVE_VASPRINTF
free(data);
#endif
+ switch_xml_free(xml);
+
return NULL;
}
}
if ((fd = open(file, O_RDONLY, 0)) > -1) {
fstat(fd, &st);
- if (!st.st_size) goto error;
+ if (!st.st_size) {
+ close(fd);
+ goto error;
+ }
+
m = switch_must_malloc(st.st_size);
- if (!(0<(l = read(fd, m, st.st_size)))) goto error;
- if (!(root = (switch_xml_root_t) switch_xml_parse_str((char *) m, l))) goto error;
+ if (!(0 < (l = read(fd, m, st.st_size)))) {
+ free(m);
+ close(fd);
+ goto error;
+ }
+
+ if (!(root = (switch_xml_root_t)switch_xml_parse_str((char*)m, l))) {
+ free(m);
+ close(fd);
+ goto error;
+ }
+
root->dynamic = 1;
close(fd);
return &root->xml;