FS-7500: another round of trying to make things work

This commit is contained in:
Anthony Minessale 2014-11-24 18:39:10 -05:00 committed by Michael Jerris
parent 81bec5ebd0
commit 01fda5748c
6 changed files with 68 additions and 44 deletions

View File

@ -313,6 +313,8 @@ SWITCH_DECLARE(void) switch_core_media_start_video_function(switch_core_session_
SWITCH_DECLARE(void) switch_core_media_end_video_function(switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_core_session_start_video_thread(switch_core_session_t *session);
SWITCH_DECLARE(int) switch_core_media_check_video_function(switch_core_session_t *session);
SWITCH_DECLARE(void) switch_core_session_video_reinit(switch_core_session_t *session);
SWITCH_END_EXTERN_C
#endif
/* For Emacs:

View File

@ -3940,15 +3940,11 @@ SWITCH_STANDARD_API(uuid_video_refresh_function)
if (argc < 1) {
stream->write_function(stream, "-USAGE: %s\n", VIDEO_REFRESH_SYNTAX);
} else {
switch_core_session_message_t msg = { 0 };
switch_core_session_t *lsession = NULL;
msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ;
msg.string_array_arg[2] = argv[1];
msg.from = __FILE__;
if ((lsession = switch_core_session_locate(argv[0]))) {
status = switch_core_session_receive_message(lsession, &msg);
switch_core_session_video_reinit(lsession);
status = SWITCH_STATUS_SUCCESS;
switch_core_session_rwunlock(lsession);
}
}

View File

@ -2260,12 +2260,12 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe
switch_channel_clear_flag(channel, CF_VIDEO_PASSIVE);
}
/* Tell the channel to request a fresh vid frame */
switch_core_session_refresh_video_both_ways(member->session);
switch_core_session_video_reinit(member->session);
if (conference->video_floor_holder) {
switch_mutex_lock(conference->mutex);
if (conference->video_floor_holder) {
switch_core_session_refresh_video_both_ways(conference->video_floor_holder->session);
switch_core_session_video_reinit(conference->video_floor_holder->session);
// there's already someone hold the floor, tell the core thread start to read video
switch_channel_clear_flag(member->channel, CF_VIDEO_PASSIVE);
}
@ -2488,7 +2488,7 @@ static void conference_set_video_floor_holder(conference_obj_t *conference, conf
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Adding video floor %s\n",
switch_channel_get_name(member->channel));
//switch_channel_set_flag(member->channel, CF_VIDEO_PASSIVE);
switch_core_session_refresh_video_both_ways(member->session);
switch_core_session_video_reinit(member->session);
conference->video_floor_holder = member;
member_update_status_field(member);
} else {
@ -2514,7 +2514,7 @@ static void conference_set_video_floor_holder(conference_obj_t *conference, conf
switch_channel_set_flag(imember->channel, CF_VIDEO_BREAK);
switch_core_session_kill_channel(imember->session, SWITCH_SIG_BREAK);
switch_core_session_refresh_video_both_ways(imember->session);
switch_core_session_video_reinit(imember->session);
}
switch_set_flag(conference, CFLAG_FLOOR_CHANGE);
@ -2880,7 +2880,7 @@ static void *SWITCH_THREAD_FUNC conference_video_bridge_thread_run(switch_thread
switch_channel_ready(channel_a) && switch_channel_ready(channel_b)) {
if (switch_channel_test_flag(channel_a, CF_VIDEO_REFRESH_REQ)) {
switch_core_session_refresh_video_both_ways(session_b);
switch_core_session_video_reinit(session_b);
switch_channel_clear_flag(channel_a, CF_VIDEO_REFRESH_REQ);
}
@ -3027,7 +3027,7 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr
switch_mutex_unlock(conference->mutex);
if (want_refresh && session) {
switch_core_session_refresh_video_both_ways(session);
switch_core_session_video_reinit(session);
want_refresh = 0;
}
@ -4335,7 +4335,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v
if (switch_channel_test_flag(channel, CF_VIDEO) && !switch_test_flag(member, MFLAG_ACK_VIDEO)) {
switch_set_flag_locked(member, MFLAG_ACK_VIDEO);
switch_core_session_refresh_video_both_ways(member->session);
switch_core_session_video_reinit(member->session);
conference_set_video_floor_holder(member->conference, member, SWITCH_FALSE);
}
@ -5203,7 +5203,7 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th
switch_mutex_lock(conference->mutex);
if (!conference->record_fh) conference->record_fh = &fh;
if (conference->video_floor_holder) {
switch_core_session_refresh_video_both_ways(conference->video_floor_holder->session);
switch_core_session_video_reinit(conference->video_floor_holder->session);
}
switch_mutex_unlock(conference->mutex);

View File

@ -99,7 +99,7 @@ static switch_status_t init_codec(switch_codec_t *codec)
if (context->codec_settings.video.bandwidth) {
context->bandwidth = context->codec_settings.video.bandwidth;
} else {
int x = (context->codec_settings.video.width / 1000) + 1;
int x = (context->codec_settings.video.width / 100) + 1;
context->bandwidth = context->codec_settings.video.width * context->codec_settings.video.height * x;
}

View File

@ -6453,7 +6453,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
switch_rtp_engine_t *a_engine, *v_engine;
switch_media_handle_t *smh;
ice_t *ice_out;
int vp8 = 0;
//int vp8 = 0;
//int red = 0;
payload_map_t *pmap;
int is_outbound = switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND;
@ -7065,9 +7065,9 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
const char *of;
payload_map_t *pmap;
if (!strcasecmp(v_engine->cur_payload_map->rm_encoding, "VP8")) {
vp8 = v_engine->cur_payload_map->pt;
}
//if (!strcasecmp(v_engine->cur_payload_map->rm_encoding, "VP8")) {
// vp8 = v_engine->cur_payload_map->pt;
//}
//if (!strcasecmp(v_engine->cur_payload_map->rm_encoding, "red")) {
// red = v_engine->cur_payload_map->pt;
@ -7153,9 +7153,9 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
channels = get_channels(imp->iananame, imp->number_of_channels);
if (!strcasecmp(imp->iananame, "VP8")) {
vp8 = ianacode;
}
//if (!strcasecmp(imp->iananame, "VP8")) {
// vp8 = ianacode;
//}
//if (!strcasecmp(imp->iananame, "red")) {
// red = ianacode;
@ -7232,27 +7232,31 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
}
/* DFF nack pli etc */
nack = v_engine->nack = 0;//pli = v_engine->pli = 0;
nack = v_engine->nack = 0; //pli = v_engine->pli = 0;
if (vp8) {
if (v_engine->fir || fir) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf),
"a=rtcp-fb:%d ccm fir\n", vp8);
}
if (v_engine->nack || nack) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf),
"a=rtcp-fb:%d nack\n", vp8);
}
if (v_engine->pli || pli) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf),
"a=rtcp-fb:%d nack pli\n", vp8);
for (pmap = v_engine->cur_payload_map; pmap && pmap->allocated; pmap = pmap->next) {
if (!v_engine->codec_negotiated ||
(pmap->negotiated && (pmap->pt == v_engine->cur_payload_map->agreed_pt ||
switch_media_handle_test_media_flag(smh, SCMF_MULTI_ANSWER_VIDEO)))) {
if (v_engine->fir || fir) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf),
"a=rtcp-fb:%d ccm fir\n", pmap->pt);
}
if (v_engine->nack || nack) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf),
"a=rtcp-fb:%d nack\n", pmap->pt);
}
if (v_engine->pli || pli) {
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf),
"a=rtcp-fb:%d nack pli\n", pmap->pt);
}
}
}
//switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u\n", v_engine->ssrc);
if (v_engine->ice_out.cands[0][0].ready) {
@ -9558,6 +9562,24 @@ static switch_status_t raw_write_video(switch_core_session_t *session, switch_fr
return status;
}
SWITCH_DECLARE(void) switch_core_session_video_reinit(switch_core_session_t *session)
{
switch_media_handle_t *smh;
switch_assert(session);
if (!(smh = session->media_handle)) {
return;
}
if (switch_channel_down(session->channel)) {
return;
}
smh->video_init = 0;
smh->video_last_key_time = 0;
switch_core_session_refresh_video_both_ways(session);
}
SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags,
int stream_id)
@ -9638,8 +9660,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_video_frame(switch_cor
switch_assert((encode_status == SWITCH_STATUS_SUCCESS && frame->m) || !frame->m);
if (frame->flags & SFF_PICTURE_RESET) {
smh->video_init = 0;
smh->video_last_key_time = 0;
switch_core_session_video_reinit(session);
frame->flags &= ~SFF_PICTURE_RESET;
}

View File

@ -710,6 +710,7 @@ static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_
return RESULT_CONTINUE;
}
static int rtp_write_ready(switch_rtp_t *rtp_session, uint32_t bytes, int line);
static int global_init = 0;
static int rtp_common_write(switch_rtp_t *rtp_session,
rtp_msg_t *send_msg, void *data, uint32_t datalen, switch_payload_t payload, uint32_t timestamp, switch_frame_flag_t *flags);
@ -953,7 +954,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
}
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
switch_core_media_gen_key_frame(rtp_session->session);
switch_core_session_video_reinit(rtp_session->session);
}
switch_rtp_set_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH);
}
@ -1104,7 +1105,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
if (!ice->ready) {
ice->ready = 1;
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
switch_core_media_gen_key_frame(rtp_session->session);
switch_core_session_video_reinit(rtp_session->session);
}
switch_rtp_set_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH);
}
@ -4877,6 +4878,10 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
}
}
if (*bytes && !rtp_write_ready(rtp_session, *bytes, __LINE__)) {
*bytes = 0;
goto more;
}
if (*bytes && rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]) {
const char *tx_host;
@ -6403,7 +6408,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read(switch_rtp_t *rtp_sessi
static int rtp_write_ready(switch_rtp_t *rtp_session, uint32_t bytes, int line)
{
if (rtp_session->ice.ice_user && !(rtp_session->ice.rready)) {
if (rtp_session->ice.ice_user && !(rtp_session->ice.rready && rtp_session->ice.ready)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Skip sending %s packet %ld bytes (ice not ready @ line %d!)\n",
rtp_type(rtp_session), (long)bytes, line);
return 0;