]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10107 can of worms contd
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 15 Mar 2017 21:55:00 +0000 (16:55 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 15 Mar 2017 21:58:39 +0000 (16:58 -0500)
src/include/switch_core_video.h
src/mod/applications/mod_conference/conference_video.c
src/switch_core_video.c

index c8b226509dbe4c4a33261d18e1162312142540c7..416251fca665376314001e32cbeb5ff6a8f02206 100644 (file)
@@ -69,6 +69,7 @@ typedef enum {
        SWITCH_FIT_SIZE,
        SWITCH_FIT_SCALE,
        SWITCH_FIT_SIZE_AND_SCALE,
+       SWITCH_FIT_NECESSARY,
        SWITCH_FIT_NONE
 } switch_img_fit_t;
 
index 40fa473075569b7e86b515e7629ab84e43977544..0161261cfa8fca737ef77e1acd365b69a34d47f6 100644 (file)
@@ -500,7 +500,6 @@ void conference_video_scale_and_patch(mcu_layer_t *layer, switch_image_t *ximg,
                        switch_img_patch(IMG, layer->img, x_pos + layer->geometry.border, y_pos + layer->geometry.border);
                }
 
-
                if (layer->logo_img) {
                        int ew = layer->screen_w - (layer->geometry.border * 2), eh = layer->screen_h - (layer->banner_img ? layer->banner_img->d_h : 0) - (layer->geometry.border * 2);
                        int ex = 0, ey = 0;
@@ -782,7 +781,9 @@ void conference_member_set_logo(conference_member_t *member, const char *path)
                                }
 
                                img = switch_img_write_text_img(member->video_logo->d_w, member->video_logo->d_h, SWITCH_FALSE, var);
-                               switch_img_fit(&img, member->video_logo->d_w, member->video_logo->d_h, SWITCH_FIT_SIZE);
+                               switch_img_fit(&img, member->video_logo->d_w, member->video_logo->d_h, SWITCH_FIT_NECESSARY);
+                               switch_img_attenuate(member->video_logo);
+
                                switch_img_patch(member->video_logo, img, x, y);
                                switch_img_free(&img);
                        }
index 886eba812bf3b594f59cd0fbf6bea891510c0117..7edb1baf6727c7173b4487ed2a6e253afaefcdc0 100644 (file)
@@ -132,6 +132,7 @@ static struct fit_el IMG_FIT_TABLE[] = {
        {SWITCH_FIT_SIZE, "fit-size"},
        {SWITCH_FIT_SCALE, "fit-scale"},
        {SWITCH_FIT_SIZE_AND_SCALE, "fit-size-and-scale"},
+       {SWITCH_FIT_NECESSARY, "fit-necessary"},
        {SWITCH_FIT_NONE, NULL}
 };
 
@@ -1105,6 +1106,8 @@ SWITCH_DECLARE(void) switch_color_set_rgb(switch_rgb_color_t *color, const char
                        color->b = 255;
                }
        }
+
+       color->a = 255;
 }
 
 #ifdef SWITCH_HAVE_YUV
@@ -1191,6 +1194,7 @@ static void init_gradient_table(switch_img_txt_handle_t *handle)
                color->r = c1->r + (c2->r - c1->r) * i / MAX_GRADIENT;
                color->g = c1->g + (c2->g - c1->g) * i / MAX_GRADIENT;
                color->b = c1->b + (c2->b - c1->b) * i / MAX_GRADIENT;
+               color->a = 255;
        }
 }
 
@@ -1538,10 +1542,6 @@ SWITCH_DECLARE(switch_image_t *) switch_img_write_text_img(int w, int h, switch_
 
        switch_img_txt_handle_create(&txthandle, font_face, fg, bg, font_size, 0, NULL);
 
-       if (bg) {
-               switch_color_set_rgb(&bgcolor, bg);
-       }
-
        pre_width = switch_img_txt_handle_render(txthandle,
                                                                                         NULL,
                                                                                         font_size / 2, font_size / 2,
@@ -1554,18 +1554,21 @@ SWITCH_DECLARE(switch_image_t *) switch_img_write_text_img(int w, int h, switch_
        } else {
                width = pre_width;
        }
-
+       
        //if (bg) {
        //      txtimg = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, width, height, 1);
        //      switch_assert(txtimg);
        //      switch_img_fill(txtimg, 0, 0, txtimg->d_w, txtimg->d_h, &bgcolor);
        //} else {
-               txtimg = switch_img_alloc(NULL, SWITCH_IMG_FMT_ARGB, width, height, 1);
-               switch_assert(txtimg);
+       txtimg = switch_img_alloc(NULL, SWITCH_IMG_FMT_ARGB, width, height, 1);
+       switch_assert(txtimg);
+       //memset(txtimg->planes[SWITCH_PLANE_PACKED], 0, width * height * 4);
+       if (bg) {
+               switch_color_set_rgb(&bgcolor, bg);
+               switch_img_fill(txtimg, 0, 0, txtimg->d_w, txtimg->d_h, &bgcolor);
+       } else {
                memset(txtimg->planes[SWITCH_PLANE_PACKED], 0, width * height * 4);
-               if (bg) {
-                       switch_img_fill(txtimg, 0, 0, txtimg->d_w, txtimg->d_h, &bgcolor);
-               }
+       }
                //}
 
        x = font_size / 2;
@@ -2312,6 +2315,10 @@ SWITCH_DECLARE(switch_status_t) switch_img_fit(switch_image_t **srcP, int width,
                return SWITCH_STATUS_SUCCESS;
        }
 
+       if (fit == SWITCH_FIT_NECESSARY && src->d_w <= width && src->d_h < height) {
+               return SWITCH_STATUS_SUCCESS;
+       }
+
        if (fit == SWITCH_FIT_SCALE) {
                switch_img_scale(src, &tmp, width, height);
                switch_img_free(&src);