]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7500: move function to core
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 6 Feb 2015 17:41:15 +0000 (11:41 -0600)
committerMichael Jerris <mike@jerris.com>
Thu, 28 May 2015 17:46:58 +0000 (12:46 -0500)
src/include/switch_core_video.h
src/mod/applications/mod_fsv/mod_fsv.c
src/switch_core_video.c

index 51f4dd6ffee2eec146f53b45e9d75c4388479a15..880af749e5e9672e3ce7639064fd61627edd0313 100644 (file)
@@ -176,6 +176,7 @@ SWITCH_DECLARE(void) switch_img_flip(switch_image_t *img);
 */
 SWITCH_DECLARE(void) switch_img_free(switch_image_t **img);
 
+SWITCH_DECLARE(void) switch_img_add_text(void *buffer, int w, int x, int y, char *s);
 
 /** @} */
 
index 74ecae7c2137c9ac1e5a4d0b3e5c9298fd1270e7..8f703e8776f7ff8e7a188d4bd2c64a905efdbfa1 100644 (file)
@@ -481,59 +481,6 @@ SWITCH_STANDARD_APP(play_fsv_function)
        switch_core_session_video_reset(session);
 }
 
-uint8_t art[14][16] = {
-       {0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00},
-       {0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00},
-       {0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00},
-       {0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x00},
-       {0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00},
-       {0x00, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x00},
-       {0x00, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00},
-       {0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00},
-       {0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00},
-       {0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x00},
-       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00}, /*.*/
-       {0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*:*/
-       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-*/
-       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* */
-};
-
-void tag(void *buffer, int w, int x, int y, uint8_t n)
-{
-       int i = 0, j=0;
-       uint8_t *p = buffer;
-
-       if (n < 0 || n > 13) return;
-
-       for(i=0; i<8; i++) {
-               for (j=0; j<16; j++) {
-                       *( p + (y + j) * w + (x + i)) = (art[n][j] & 0x80 >> i) ? 0xFF : 0x00;
-               }
-       }
-}
-
-void text(void *buffer, int w, int x, int y, char *s)
-{
-       while (*s) {
-               int index;
-
-               if (x > w - 8) break;
-
-               switch (*s) {
-                       case '.': index = 10; break;
-                       case ':': index = 11; break;
-                       case '-': index = 12; break;
-                       case ' ': index = 13; break;
-                       default:
-                               index = *s - 0x30;
-               }
-
-               tag(buffer, w, x, y, index);
-               x += 8;
-               s++;
-       }
-}
-
 /*
        \brief play YUV file in I420 (YV12) format
 */
@@ -653,7 +600,7 @@ SWITCH_STANDARD_APP(play_yuv_function)
                if (read_frame) switch_core_session_write_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0);
 
                sprintf(ts_str, "%" SWITCH_TIME_T_FMT, switch_micro_time_now() / 1000);
-               text(img->planes[SWITCH_PLANE_PACKED], width, 20, 20, ts_str);
+               switch_img_add_text(img->planes[SWITCH_PLANE_PACKED], width, 20, 20, ts_str);
                vid_frame.img = img;
                switch_core_session_write_video_frame(session, &vid_frame, SWITCH_IO_FLAG_NONE, 0);
        }
index 2e90ae73a3becf9af90c4fa892de442248ce02f3..9d9b1618f91472b8d383e59bbd5f277d9560308e 100644 (file)
@@ -136,6 +136,61 @@ SWITCH_DECLARE(void) switch_img_copy(switch_image_t *img, switch_image_t **new_i
 
 }
 
+
+static uint8_t scv_art[14][16] = {
+       {0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00},
+       {0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00},
+       {0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00},
+       {0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x00},
+       {0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00},
+       {0x00, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x00},
+       {0x00, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00},
+       {0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00},
+       {0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00},
+       {0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x00},
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00}, /*.*/
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*:*/
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-*/
+       {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* */
+};
+
+static void scv_tag(void *buffer, int w, int x, int y, uint8_t n)
+{
+       int i = 0, j=0;
+       uint8_t *p = buffer;
+
+       if (n < 0 || n > 13) return;
+
+       for(i=0; i<8; i++) {
+               for (j=0; j<16; j++) {
+                       *( p + (y + j) * w + (x + i)) = (scv_art[n][j] & 0x80 >> i) ? 0xFF : 0x00;
+               }
+       }
+}
+
+SWITCH_DECLARE(void) switch_img_add_text(void *buffer, int w, int x, int y, char *s)
+{
+       while (*s) {
+               int index;
+
+               if (x > w - 8) break;
+
+               switch (*s) {
+                       case '.': index = 10; break;
+                       case ':': index = 11; break;
+                       case '-': index = 12; break;
+                       case ' ': index = 13; break;
+                       default:
+                               index = *s - 0x30;
+               }
+
+               scv_tag(buffer, w, x, y, index);
+               x += 8;
+               s++;
+       }
+}
+
+
 /* For Emacs:
  * Local Variables:
  * mode:c