]> 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:55:06 +0000 (16:55 -0500)
src/include/switch_core_video.h
src/mod/applications/mod_conference/conference_video.c
src/switch_core_video.c

index 64c08ddb0dec9749659905a116db8627147fa235..17cf44f27e03f0ed5541829702308e2f08bc5eb7 100644 (file)
@@ -71,6 +71,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 74a938be69ed7368a23126826705c8538fc189cd..8d8e4935030fdedf122af6d3bf7478c9955ba4cc 100644 (file)
@@ -851,7 +851,7 @@ void conference_video_scale_and_patch(mcu_layer_t *layer, switch_image_t *ximg,
 
                switch_img_scale(img, &layer->img, img_w, img_h);
                
-               
+
                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;
@@ -1143,7 +1143,7 @@ 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 e5e60abe355c4ecdccca449a7c9d9c20870ea166..a395825dcea23ea602f3151e3477363f08e45559 100644 (file)
@@ -148,6 +148,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}
 };
 
@@ -1605,6 +1606,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
@@ -1691,6 +1694,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;
        }
 }
 
@@ -2038,10 +2042,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,
@@ -2054,18 +2054,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;
@@ -2812,6 +2815,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);