mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 08:05:37 +00:00
FS-7500: move function to core
This commit is contained in:
parent
8f00bd1173
commit
e14ad07a26
@ -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);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user