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:
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);
}
}
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);
}
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 {
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);
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);
}
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;
}
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);
}
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);
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;
}
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;
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;
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;
}
/* 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) {
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)
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;
}
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);
}
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);
}
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);
}
}
}
+ 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;
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;