FS-7513: add auto-3d-position attr to <layout> and the auto as a valid value in existingaudio-position in <image> to auto-arrage the 3d openal positioning to either set it for the whole layout or an individual image
This commit is contained in:
parent
42e7b81b1e
commit
5d9e4752a5
|
@ -4,21 +4,21 @@
|
|||
<layout name="1x1">
|
||||
<image x="0" y="0" scale="360" floor="true"/>
|
||||
</layout>
|
||||
<layout name="1x2">
|
||||
<layout name="1x2" auto-3d-position="true">
|
||||
<image x="90" y="0" scale="180"/>
|
||||
<image x="90" y="180" scale="180"/>
|
||||
</layout>
|
||||
<layout name="2x1">
|
||||
<layout name="2x1" auto-3d-position="true">
|
||||
<image x="0" y="90" scale="180"/>
|
||||
<image x="180" y="90" scale="180"/>
|
||||
</layout>
|
||||
<layout name="2x2">
|
||||
<layout name="2x2" auto-3d-position="true">
|
||||
<image x="0" y="0" scale="180"/>
|
||||
<image x="180" y="0" scale="180"/>
|
||||
<image x="0" y="180" scale="180"/>
|
||||
<image x="180" y="180" scale="180"/>
|
||||
</layout>
|
||||
<layout name="3x3">
|
||||
<layout name="3x3" auto-3d-position="true">
|
||||
<image x="0" y="0" scale="120"/>
|
||||
<image x="120" y="0" scale="120"/>
|
||||
<image x="240" y="0" scale="120"/>
|
||||
|
@ -29,7 +29,7 @@
|
|||
<image x="120" y="240" scale="120"/>
|
||||
<image x="240" y="240" scale="120"/>
|
||||
</layout>
|
||||
<layout name="4x4">
|
||||
<layout name="4x4" auto-3d-position="true">
|
||||
<image x="0" y="0" scale="90"/>
|
||||
<image x="90" y="0" scale="90"/>
|
||||
<image x="180" y="0" scale="90"/>
|
||||
|
@ -47,7 +47,7 @@
|
|||
<image x="180" y="270" scale="90"/>
|
||||
<image x="270" y="270" scale="90"/>
|
||||
</layout>
|
||||
<layout name="5x5">
|
||||
<layout name="5x5" auto-3d-position="true">
|
||||
<image x="0" y="0" scale="72"/>
|
||||
<image x="72" y="0" scale="72"/>
|
||||
<image x="144" y="0" scale="72"/>
|
||||
|
@ -74,7 +74,7 @@
|
|||
<image x="216" y="288" scale="72"/>
|
||||
<image x="288" y="288" scale="72"/>
|
||||
</layout>
|
||||
<layout name="6x6">
|
||||
<layout name="6x6" auto-3d-position="true">
|
||||
<image x="0" y="0" scale="60"/>
|
||||
<image x="60" y="0" scale="60"/>
|
||||
<image x="120" y="0" scale="60"/>
|
||||
|
@ -112,7 +112,7 @@
|
|||
<image x="240" y="300" scale="60"/>
|
||||
<image x="300" y="300" scale="60"/>
|
||||
</layout>
|
||||
<layout name="8x8">
|
||||
<layout name="8x8" auto-3d-position="true">
|
||||
<image x="0" y="0" scale="45"/>
|
||||
<image x="45" y="0" scale="45"/>
|
||||
<image x="90" y="0" scale="45"/>
|
||||
|
@ -178,15 +178,15 @@
|
|||
<image x="270" y="315" scale="45"/>
|
||||
<image x="315" y="315" scale="45"/>
|
||||
</layout>
|
||||
<layout name="1up_top_left+5">
|
||||
<image x="0" y="0" scale="240" floor="true" audio-position="-.5:0:0"/>
|
||||
<image x="240" y="0" scale="120" audio-position=".25:0:0"/>
|
||||
<image x="240" y="120" scale="120" audio-position=".25:0:-.25"/>
|
||||
<image x="0" y="240" scale="120" audio-position="-.5:0:-1"/>
|
||||
<image x="120" y="240" scale="120" audio-position="0:0:-1"/>
|
||||
<image x="240" y="240" scale="120" audio-position=".25:0:-1"/>
|
||||
<layout name="1up_top_left+5" auto-3d-position="true">
|
||||
<image x="0" y="0" scale="240" floor="true"/>
|
||||
<image x="240" y="0" scale="120"/>
|
||||
<image x="240" y="120" scale="120"/>
|
||||
<image x="0" y="240" scale="120"/>
|
||||
<image x="120" y="240" scale="120"/>
|
||||
<image x="240" y="240" scale="120"/>
|
||||
</layout>
|
||||
<layout name="1up_top_left+7">
|
||||
<layout name="1up_top_left+7" auto-3d-position="true">
|
||||
<image x="0" y="0" scale="270" floor="true"/>
|
||||
<image x="270" y="0" scale="90"/>
|
||||
<image x="270" y="90" scale="90"/>
|
||||
|
@ -196,7 +196,7 @@
|
|||
<image x="180" y="270" scale="90"/>
|
||||
<image x="270" y="270" scale="90"/>
|
||||
</layout>
|
||||
<layout name="1up_top_left+9">
|
||||
<layout name="1up_top_left+9" auto-3d-position="true">
|
||||
<image x="0" y="0" scale="288" floor="true"/>
|
||||
<image x="288" y="0" scale="72"/>
|
||||
<image x="288" y="72" scale="72"/>
|
||||
|
@ -208,7 +208,7 @@
|
|||
<image x="216" y="288" scale="72"/>
|
||||
<image x="288" y="288" scale="72"/>
|
||||
</layout>
|
||||
<layout name="2up_top+8">
|
||||
<layout name="2up_top+8" auto-3d-position="true">
|
||||
<image x="0" y="0" scale="180" floor="true"/>
|
||||
<image x="180" y="0" scale="180" reservation_id="secondary"/>
|
||||
<image x="0" y="180" scale="90"/>
|
||||
|
@ -220,7 +220,7 @@
|
|||
<image x="180" y="270" scale="90"/>
|
||||
<image x="270" y="270" scale="90"/>
|
||||
</layout>
|
||||
<layout name="2up_middle+8">
|
||||
<layout name="2up_middle+8" auto-3d-position="true">
|
||||
<image x="0" y="90" scale="180" floor="true"/>
|
||||
<image x="180" y="90" scale="180" reservation_id="secondary"/>
|
||||
<image x="0" y="0" scale="90"/>
|
||||
|
@ -232,7 +232,7 @@
|
|||
<image x="180" y="270" scale="90"/>
|
||||
<image x="270" y="270" scale="90"/>
|
||||
</layout>
|
||||
<layout name="2up_bottom+8">
|
||||
<layout name="2up_bottom+8" auto-3d-position="true">
|
||||
<image x="0" y="180" scale="180" floor="true"/>
|
||||
<image x="180" y="180" scale="180" reservation_id="secondary"/>
|
||||
<image x="0" y="0" scale="90"/>
|
||||
|
@ -244,7 +244,7 @@
|
|||
<image x="180" y="90" scale="90"/>
|
||||
<image x="270" y="90" scale="90"/>
|
||||
</layout>
|
||||
<layout name="3up+4">
|
||||
<layout name="3up+4" auto-3d-position="true">
|
||||
<image x="0" y="0" scale="180" floor="true"/>
|
||||
<image x="180" y="0" scale="180" reservation_id="secondary"/>
|
||||
<image x="0" y="180" scale="180" reservation_id="third"/>
|
||||
|
@ -253,7 +253,7 @@
|
|||
<image x="180" y="270" scale="90"/>
|
||||
<image x="270" y="270" scale="90"/>
|
||||
</layout>
|
||||
<layout name="3up+9">
|
||||
<layout name="3up+9" auto-3d-position="true">
|
||||
<image x="0" y="0" scale="180" floor="true"/>
|
||||
<image x="180" y="0" scale="180" reservation_id="secondary"/>
|
||||
<image x="0" y="180" scale="180" reservation_id="third"/>
|
||||
|
@ -291,7 +291,7 @@
|
|||
<image x="0" y="0" scale="360" floor-only="true"/>
|
||||
<image x="180" y="180" scale="180" overlap="true" reservation_id="presenter"/>
|
||||
</layout>
|
||||
<layout name="overlaps">
|
||||
<layout name="overlaps" auto-3d-position="true">
|
||||
<image x="0" y="0" scale="360"/>
|
||||
<image x="300" y="300" scale="60"/>
|
||||
<image x="240" y="300" scale="60"/>
|
||||
|
|
|
@ -114,6 +114,9 @@ static int EC = 0;
|
|||
/* max supported layers in one mcu */
|
||||
#define MCU_MAX_LAYERS 64
|
||||
|
||||
/* video layout scale factor */
|
||||
#define VIDEO_LAYOUT_SCALE 360.0f
|
||||
|
||||
#define CONFERENCE_MUX_DEFAULT_LAYOUT "group:grid"
|
||||
#define CONFERENCE_CANVAS_DEFAULT_WIDTH 1280
|
||||
#define CONFERENCE_CANVAS_DEFAULT_HIGHT 720
|
||||
|
@ -790,7 +793,7 @@ static switch_status_t conf_api_sub_position(conference_member_t *member, switch
|
|||
//#define lock_member(_member) switch_mutex_lock(_member->write_mutex)
|
||||
//#define unlock_member(_member) switch_mutex_unlock(_member->write_mutex)
|
||||
|
||||
static void conference_parse_layouts(conference_obj_t *conference)
|
||||
static void conference_parse_layouts(conference_obj_t *conference, int WIDTH, int HEIGHT)
|
||||
{
|
||||
switch_event_t *params;
|
||||
switch_xml_t cxml = NULL, cfg = NULL, x_layouts, x_layout, x_layout_settings, x_group, x_groups, x_image;
|
||||
|
@ -818,6 +821,7 @@ static void conference_parse_layouts(conference_obj_t *conference)
|
|||
for (x_layout = switch_xml_child(x_layouts, "layout"); x_layout; x_layout = x_layout->next) {
|
||||
video_layout_t *vlayout;
|
||||
const char *val = NULL, *name = NULL;
|
||||
switch_bool_t auto_3d = SWITCH_FALSE;
|
||||
|
||||
if ((val = switch_xml_attr(x_layout, "name"))) {
|
||||
name = val;
|
||||
|
@ -828,6 +832,8 @@ static void conference_parse_layouts(conference_obj_t *conference)
|
|||
continue;
|
||||
}
|
||||
|
||||
auto_3d = switch_true(switch_xml_attr(x_layout, "auto-3d-position"));
|
||||
|
||||
vlayout = switch_core_alloc(conference->pool, sizeof(*vlayout));
|
||||
vlayout->name = switch_core_strdup(conference->pool, name);
|
||||
|
||||
|
@ -890,8 +896,35 @@ static void conference_parse_layouts(conference_obj_t *conference)
|
|||
vlayout->images[vlayout->layers].res_id = switch_core_strdup(conference->pool, res_id);
|
||||
}
|
||||
|
||||
if (audio_position) {
|
||||
vlayout->images[vlayout->layers].audio_position = switch_core_strdup(conference->pool, audio_position);
|
||||
if (auto_3d || audio_position) {
|
||||
if (auto_3d || !strcasecmp(audio_position, "auto")) {
|
||||
int x_pos = WIDTH * x / VIDEO_LAYOUT_SCALE;
|
||||
int y_pos = HEIGHT * y / VIDEO_LAYOUT_SCALE;
|
||||
int width = WIDTH * scale / VIDEO_LAYOUT_SCALE;
|
||||
int height = HEIGHT * scale / VIDEO_LAYOUT_SCALE;
|
||||
int center_x = x_pos + width / 2;
|
||||
int center_y = y_pos + height / 2;
|
||||
int half_x = WIDTH / 2;
|
||||
int half_y = HEIGHT / 2;
|
||||
float xv = 0, yv = 0;
|
||||
|
||||
if (center_x > half_x) {
|
||||
xv = (float)(center_x - half_x) / half_x;
|
||||
} else {
|
||||
xv = (float) -1 - (center_x / half_x) * -1;
|
||||
}
|
||||
|
||||
if (center_y > half_y) {
|
||||
yv = -1 - ((center_y - half_y) / half_y) * -1;
|
||||
} else {
|
||||
yv = center_y / half_y;
|
||||
}
|
||||
|
||||
vlayout->images[vlayout->layers].audio_position = switch_core_sprintf(conference->pool, "%02f:0.0:%02f", xv, yv);
|
||||
|
||||
} else {
|
||||
vlayout->images[vlayout->layers].audio_position = switch_core_strdup(conference->pool, audio_position);
|
||||
}
|
||||
}
|
||||
|
||||
vlayout->layers++;
|
||||
|
@ -968,8 +1001,6 @@ static void reset_image(switch_image_t *img, switch_rgb_color_t *color)
|
|||
switch_img_fill(img, 0, 0, img->d_w, img->d_h, color);
|
||||
}
|
||||
|
||||
#define SCALE_FACTOR 360.0f
|
||||
|
||||
/* clear layer and reset_layer called inside lock always */
|
||||
|
||||
static void clear_layer(mcu_canvas_t *canvas, mcu_layer_t *layer)
|
||||
|
@ -1021,8 +1052,8 @@ static void scale_and_patch(conference_obj_t *conference, mcu_layer_t *layer, sw
|
|||
int x_pos = layer->x_pos;
|
||||
int y_pos = layer->y_pos;
|
||||
|
||||
img_w = layer->screen_w = IMG->d_w * layer->geometry.scale / SCALE_FACTOR;
|
||||
img_h = layer->screen_h = IMG->d_h * layer->geometry.scale / SCALE_FACTOR;
|
||||
img_w = layer->screen_w = IMG->d_w * layer->geometry.scale / VIDEO_LAYOUT_SCALE;
|
||||
img_h = layer->screen_h = IMG->d_h * layer->geometry.scale / VIDEO_LAYOUT_SCALE;
|
||||
|
||||
screen_aspect = (double) layer->screen_w / layer->screen_h;
|
||||
img_aspect = (double) img->d_w / img->d_h;
|
||||
|
@ -1433,14 +1464,14 @@ static void init_canvas_layers(conference_obj_t *conference, video_layout_t *vla
|
|||
layer->idx = i;
|
||||
|
||||
|
||||
layer->screen_w = conference->canvas->img->d_w * layer->geometry.scale / SCALE_FACTOR;
|
||||
layer->screen_h = conference->canvas->img->d_h * layer->geometry.scale / SCALE_FACTOR;
|
||||
layer->screen_w = conference->canvas->img->d_w * layer->geometry.scale / VIDEO_LAYOUT_SCALE;
|
||||
layer->screen_h = conference->canvas->img->d_h * layer->geometry.scale / VIDEO_LAYOUT_SCALE;
|
||||
|
||||
// if (layer->screen_w % 2) layer->screen_w++; // round to even
|
||||
// if (layer->screen_h % 2) layer->screen_h++; // round to even
|
||||
|
||||
layer->x_pos = conference->canvas->img->d_w * layer->geometry.x / SCALE_FACTOR;
|
||||
layer->y_pos = conference->canvas->img->d_h * layer->geometry.y / SCALE_FACTOR;
|
||||
layer->x_pos = conference->canvas->img->d_w * layer->geometry.x / VIDEO_LAYOUT_SCALE;
|
||||
layer->y_pos = conference->canvas->img->d_h * layer->geometry.y / VIDEO_LAYOUT_SCALE;
|
||||
|
||||
|
||||
if (layer->geometry.floor) {
|
||||
|
@ -12581,7 +12612,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c
|
|||
conference->caller_controls = switch_core_strdup(conference->pool, caller_controls);
|
||||
conference->moderator_controls = switch_core_strdup(conference->pool, moderator_controls);
|
||||
conference->broadcast_chat_messages = broadcast_chat_messages;
|
||||
conference_parse_layouts(conference);
|
||||
|
||||
|
||||
if (video_codec_bandwidth) {
|
||||
conference->video_codec_settings.video.bandwidth = switch_parse_bandwidth_string(video_codec_bandwidth);
|
||||
|
@ -12590,6 +12621,30 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c
|
|||
conference->conf_video_mode = conf_video_mode;
|
||||
|
||||
if (conference->conf_video_mode == CONF_VIDEO_MODE_MUX) {
|
||||
int canvas_w = 0, canvas_h = 0;
|
||||
if (video_canvas_size) {
|
||||
char *p;
|
||||
|
||||
if ((canvas_w = atoi(video_canvas_size))) {
|
||||
if ((p = strchr(video_canvas_size, 'x'))) {
|
||||
p++;
|
||||
if (*p) {
|
||||
canvas_h = atoi(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (canvas_w < 320 || canvas_h < 180) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s video-canvas-size, falling back to %ux%u\n",
|
||||
video_canvas_size ? "Invalid" : "Unspecified", CONFERENCE_CANVAS_DEFAULT_WIDTH, CONFERENCE_CANVAS_DEFAULT_HIGHT);
|
||||
canvas_w = CONFERENCE_CANVAS_DEFAULT_WIDTH;
|
||||
canvas_h = CONFERENCE_CANVAS_DEFAULT_HIGHT;
|
||||
}
|
||||
|
||||
|
||||
conference_parse_layouts(conference, canvas_w, canvas_h);
|
||||
|
||||
if (!video_canvas_bgcolor) {
|
||||
video_canvas_bgcolor = "#333333";
|
||||
}
|
||||
|
@ -12641,29 +12696,8 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c
|
|||
conference->conf_video_mode = CONF_VIDEO_MODE_TRANSCODE;
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid conference layout settings, falling back to transcode mode\n");
|
||||
} else {
|
||||
int w = 0, h = 0;
|
||||
if (video_canvas_size) {
|
||||
char *p;
|
||||
|
||||
if ((w = atoi(video_canvas_size))) {
|
||||
if ((p = strchr(video_canvas_size, 'x'))) {
|
||||
p++;
|
||||
if (*p) {
|
||||
h = atoi(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (w > 0 && h > 0) {
|
||||
conference->canvas_width = w;
|
||||
conference->canvas_height = h;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s video-canvas-size, falling back to %ux%u\n",
|
||||
video_canvas_size ? "Invalid" : "Unspecified", CONFERENCE_CANVAS_DEFAULT_WIDTH, CONFERENCE_CANVAS_DEFAULT_HIGHT);
|
||||
conference->canvas_width = CONFERENCE_CANVAS_DEFAULT_WIDTH;
|
||||
conference->canvas_height = CONFERENCE_CANVAS_DEFAULT_HIGHT;
|
||||
}
|
||||
conference->canvas_width = canvas_w;
|
||||
conference->canvas_height = canvas_h;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue