diff --git a/src/include/switch_core_video.h b/src/include/switch_core_video.h index 0e9ebdd320..00b9de4175 100644 --- a/src/include/switch_core_video.h +++ b/src/include/switch_core_video.h @@ -330,9 +330,9 @@ SWITCH_DECLARE(void) switch_png_free(switch_png_t **pngP); * \param[in] img The small Image descriptor * \param[in] x Leftmost pos * \param[in] y Topmost pos -* \param[in] alpha Alaha value from 0(completely transparent) to 255(opaque) +* \param[in] percent Alaha value from 0(completely transparent) to 100(opaque) */ -SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img, int x, int y, uint8_t alpha); +SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img, int x, int y, uint8_t percent); SWITCH_DECLARE(switch_status_t) switch_img_scale(switch_image_t *src, switch_image_t **destP, int width, int height); SWITCH_DECLARE(switch_status_t) switch_img_fit(switch_image_t **srcP, int width, int height, switch_img_fit_t fit); diff --git a/src/mod/formats/mod_local_stream/mod_local_stream.c b/src/mod/formats/mod_local_stream/mod_local_stream.c index b704e8b83a..df25128372 100644 --- a/src/mod/formats/mod_local_stream/mod_local_stream.c +++ b/src/mod/formats/mod_local_stream/mod_local_stream.c @@ -123,7 +123,8 @@ struct local_stream_source { switch_timer_t timer; int logo_always; switch_img_position_t logo_pos; - int logo_opacity; + uint8_t logo_opacity; + uint8_t text_opacity; }; typedef struct local_stream_source local_stream_source_t; @@ -1061,9 +1062,7 @@ static switch_status_t local_stream_file_read_video(switch_file_handle_t *handle } if (frame->img && context->banner_img && frame->img->d_w >= context->banner_img->d_w) { - //switch_img_overlay(frame->img, context->banner_img, 0, frame->img->d_h - context->banner_img->d_h, 100); - switch_img_patch(frame->img, context->banner_img, 0, frame->img->d_h - context->banner_img->d_h); - //switch_img_patch(frame->img, context->banner_img, 0, 0); + switch_img_overlay(frame->img, context->banner_img, 0, frame->img->d_h - context->banner_img->d_h, context->source->text_opacity); } if (frame->img && context->source->logo_img && @@ -1079,11 +1078,7 @@ static switch_status_t local_stream_file_read_video(switch_file_handle_t *handle y -= context->banner_img->d_h; } - if (context->source->logo_opacity > 0 && context->source->logo_opacity < 100) { - switch_img_overlay(frame->img, context->source->logo_img, x, y-1, context->source->logo_opacity); - } else { - switch_img_patch(frame->img, context->source->logo_img, x, y-1); - } + switch_img_overlay(frame->img, context->source->logo_img, x, y, context->source->logo_opacity); } return SWITCH_STATUS_SUCCESS; @@ -1156,6 +1151,8 @@ static void launch_thread(const char *name, const char *path, switch_xml_t direc source->stopped = 0; source->hup = 0; source->chime_freq = 30; + source->logo_opacity = source->text_opacity = 100; + for (param = switch_xml_child(directory, "param"); param; param = param->next) { char *var = (char *) switch_xml_attr_soft(param, "name"); char *val = (char *) switch_xml_attr_soft(param, "value"); @@ -1214,6 +1211,11 @@ static void launch_thread(const char *name, const char *path, switch_xml_t direc if (source->logo_opacity < 0 && source->logo_opacity > 100) { source->logo_opacity = 0; } + } else if (!strcasecmp(var, "text-opacity") && !zstr(val)) { + source->text_opacity = atoi(val); + if (source->text_opacity < 0 && source->text_opacity > 100) { + source->text_opacity = 0; + } } } diff --git a/src/switch_core_video.c b/src/switch_core_video.c index 67c2f7ae69..69bd310fd1 100644 --- a/src/switch_core_video.c +++ b/src/switch_core_video.c @@ -580,11 +580,13 @@ static inline void switch_img_get_rgb_pixel(switch_image_t *img, switch_rgb_colo #endif } -SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img, int x, int y, uint8_t alpha) +SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img, int x, int y, uint8_t percent) { int i, j, len, max_h; switch_rgb_color_t RGB = {0}, rgb = {0}, c = {0}; int xoff = 0, yoff = 0; + uint8_t alpha = (int8_t)((255 * percent) / 100); + switch_assert(IMG->fmt == SWITCH_IMG_FMT_I420);