freeswitch: update 480-fix-libyuv-dependency.patch
[feed/telephony.git] / net / freeswitch / patches / 480-fix-libyuv-dependency.patch
1 commit a2ce46c6fde38d6ac54a8a2ee1a5b391e2ed2071
2 Author: Sebastian Kemper <sebastian_ml@gmx.net>
3 Date: Mon Nov 1 09:59:09 2021 +0100
4
5 [core] fix "--disable-libyuv"
6
7 Recent changes made it impossible to compile freeswitch without libyuv
8 support.
9
10 src/switch_core_video.c: In function 'switch_img_read_from_file':
11 src/switch_core_video.c:3139:4: error: implicit declaration of function 'RAWToI420' [-Werror=implicit-function-declaration]
12 RAWToI420(data, width * 3,
13 ^
14 src/switch_core_video.c:3148:4: error: implicit declaration of function 'ABGRToARGB' [-Werror=implicit-function-declaration]
15 ABGRToARGB(data, width * 4, img->planes[SWITCH_PLANE_PACKED], img->stride[SWITCH_PLANE_PACKED], width, height);
16 ^
17
18 Fix this my adding/moving the checks for "SWITCH_HAVE_YUV".
19
20 Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
21
22 --- a/src/switch_core_video.c
23 +++ b/src/switch_core_video.c
24 @@ -3116,6 +3116,7 @@ SWITCH_DECLARE(switch_status_t) switch_i
25
26 SWITCH_DECLARE(switch_image_t *) switch_img_read_from_file(const char* file_name, switch_img_fmt_t img_fmt)
27 {
28 +#ifdef SWITCH_HAVE_YUV
29 int width = 0, height = 0, channels = 0;
30 int comp = STBI_rgb;
31 unsigned char *data = NULL;
32 @@ -3155,12 +3156,16 @@ SWITCH_DECLARE(switch_image_t *) switch_
33 } else if (data) {
34 stbi_image_free(data);
35 }
36 +#endif
37
38 return NULL;
39 }
40
41 SWITCH_DECLARE(switch_status_t) switch_img_write_to_file(switch_image_t *img, const char* file_name, int quality)
42 {
43 +#ifndef SWITCH_HAVE_YUV
44 + return SWITCH_STATUS_FALSE;
45 +#else
46 int comp = STBI_rgb;
47 unsigned char *data = NULL;
48 const char *ext = strrchr(file_name, '.');
49 @@ -3217,6 +3222,7 @@ SWITCH_DECLARE(switch_status_t) switch_i
50 free(data);
51
52 return ret ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
53 +#endif
54 }
55
56 typedef struct data_url_context_s {
57 @@ -3224,14 +3230,19 @@ typedef struct data_url_context_s {
58 char **urlP;
59 } data_url_context_t;
60
61 +#ifdef SWITCH_HAVE_YUV
62 static void data_url_write_func(void *context, void *data, int size)
63 {
64 switch_buffer_t *buffer = (switch_buffer_t *)context;
65 switch_buffer_write(buffer, data, size);
66 }
67 +#endif
68
69 SWITCH_DECLARE(switch_status_t) switch_img_data_url(switch_image_t *img, char **urlP, const char *type, int quality)
70 {
71 +#ifndef SWITCH_HAVE_YUV
72 + return SWITCH_STATUS_FALSE;
73 +#else
74 int comp = STBI_rgb;
75 unsigned char *data = NULL;
76 int stride_in_bytes = 0;
77 @@ -3300,6 +3311,7 @@ SWITCH_DECLARE(switch_status_t) switch_i
78 switch_buffer_destroy(&buffer);
79
80 return ret ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
81 +#endif /* SWITCH_HAVE_YUV */
82 }
83
84
85 --- a/tests/unit/switch_core_video.c
86 +++ b/tests/unit/switch_core_video.c
87 @@ -48,6 +48,7 @@ FST_CORE_BEGIN("./conf")
88 }
89 FST_TEARDOWN_END()
90
91 +#ifdef SWITCH_HAVE_YUV
92 FST_TEST_BEGIN(data_url_test)
93 {
94 char *data_url = NULL;
95 @@ -88,6 +89,7 @@ FST_CORE_BEGIN("./conf")
96 unlink(argb_filename);
97 }
98 FST_TEST_END()
99 +#endif /* SWITCH_HAVE_YUV */
100
101 FST_TEST_BEGIN(img_patch)
102 {
103 @@ -239,6 +241,7 @@ FST_CORE_BEGIN("./conf")
104 }
105 FST_TEST_END()
106
107 +#ifdef SWITCH_HAVE_YUV
108 FST_TEST_BEGIN(stb_data_url)
109 {
110 switch_image_t *img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, 120, 60, 1);
111 @@ -321,6 +324,7 @@ FST_CORE_BEGIN("./conf")
112 unlink(jpg_write_filename);
113 }
114 FST_TEST_END()
115 +#endif /* SWITCH_HAVE_YUV */
116 }
117 FST_SUITE_END()
118 }