diff --git a/src/mod/applications/mod_conference/conference_api.c b/src/mod/applications/mod_conference/conference_api.c index 119e65c50b..6740844c7c 100644 --- a/src/mod/applications/mod_conference/conference_api.c +++ b/src/mod/applications/mod_conference/conference_api.c @@ -1722,6 +1722,7 @@ switch_status_t conference_api_sub_vid_res_id(conference_member_t *member, switc } stream->write_function(stream, "+OK reservation_id %s\n", text); conference_video_detach_video_layer(member); + conference_video_find_floor(member, SWITCH_FALSE); } diff --git a/src/mod/applications/mod_conference/conference_video.c b/src/mod/applications/mod_conference/conference_video.c index f08e48ab91..b566e3f071 100644 --- a/src/mod/applications/mod_conference/conference_video.c +++ b/src/mod/applications/mod_conference/conference_video.c @@ -1948,6 +1948,7 @@ switch_status_t conference_video_find_layer(conference_obj_t *conference, mcu_ca { uint32_t avatar_layers = 0; mcu_layer_t *layer = NULL; + mcu_layer_t *xlayer; int i; if (conference_utils_test_flag(conference, CFLAG_VIDEO_MUTE_EXIT_CANVAS) && @@ -1958,7 +1959,7 @@ switch_status_t conference_video_find_layer(conference_obj_t *conference, mcu_ca switch_mutex_lock(canvas->mutex); for (i = 0; i < canvas->total_layers; i++) { - mcu_layer_t *xlayer = &canvas->layers[i]; + xlayer = &canvas->layers[i]; if (xlayer->is_avatar && xlayer->member_id != (int)conference->video_floor_holder) { avatar_layers++; @@ -1970,9 +1971,10 @@ switch_status_t conference_video_find_layer(conference_obj_t *conference, mcu_ca (avatar_layers && !member->avatar_png_img) || conference_utils_member_test_flag(member, MFLAG_MOD)) && (member->avatar_png_img || (switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_SENDONLY && switch_core_session_media_flow(member->session, SWITCH_MEDIA_TYPE_VIDEO) != SWITCH_MEDIA_FLOW_INACTIVE))) { + /* find an empty layer */ for (i = 0; i < canvas->total_layers; i++) { - mcu_layer_t *xlayer = &canvas->layers[i]; + xlayer = &canvas->layers[i]; if (xlayer->geometry.res_id) { if (member->video_reservation_id && !strcmp(xlayer->geometry.res_id, member->video_reservation_id)) { @@ -1980,22 +1982,38 @@ switch_status_t conference_video_find_layer(conference_obj_t *conference, mcu_ca conference_video_attach_video_layer(member, canvas, i); break; } - } else if (xlayer->geometry.flooronly && !xlayer->fnode && !xlayer->geometry.fileonly) { - if (member->id == conference->video_floor_holder) { - layer = xlayer; - conference_video_attach_video_layer(member, canvas, i); - break; - } - } else if ((!xlayer->member_id || (!member->avatar_png_img && - xlayer->is_avatar && - (conference->canvas_count > 1 || xlayer->member_id != (int)conference->video_floor_holder))) && - !xlayer->fnode && !xlayer->geometry.fileonly) { - switch_status_t lstatus; - lstatus = conference_video_attach_video_layer(member, canvas, i); + } + } - if (lstatus == SWITCH_STATUS_SUCCESS || lstatus == SWITCH_STATUS_BREAK) { - layer = xlayer; - break; + if (!layer) { + for (i = 0; i < canvas->total_layers; i++) { + xlayer = &canvas->layers[i]; + + if (xlayer->geometry.flooronly && !xlayer->fnode && !xlayer->geometry.fileonly && !xlayer->geometry.res_id) { + if (member->id == conference->video_floor_holder) { + layer = xlayer; + conference_video_attach_video_layer(member, canvas, i); + break; + } + } + } + } + + if (!layer) { + for (i = 0; i < canvas->total_layers; i++) { + xlayer = &canvas->layers[i]; + + + if ((!xlayer->member_id || (!member->avatar_png_img && + xlayer->is_avatar && + (conference->canvas_count > 1 || xlayer->member_id != (int)conference->video_floor_holder))) && + !xlayer->fnode && !xlayer->geometry.fileonly && !xlayer->geometry.res_id && !xlayer->geometry.flooronly) { + switch_status_t lstatus = conference_video_attach_video_layer(member, canvas, i); + + if (lstatus == SWITCH_STATUS_SUCCESS || lstatus == SWITCH_STATUS_BREAK) { + layer = xlayer; + break; + } } } } @@ -2278,7 +2296,7 @@ static void wait_for_canvas(mcu_canvas_t *canvas) mcu_layer_t *layer = &canvas->layers[i]; if (layer->need_patch) { - if (layer->member) { + if (layer->member_id && layer->member && conference_utils_member_test_flag(layer->member, MFLAG_RUNNING) && layer->member->fb) { switch_frame_buffer_trypush(layer->member->fb, (void *) 1); x++; } else {