FS-10447: [freeswitch-core] Manual video refresh mode #resolve
This commit is contained in:
parent
d3dbc74059
commit
db47792558
|
@ -2758,8 +2758,9 @@ SWITCH_DECLARE(int) switch_core_gen_certs(const char *prefix);
|
||||||
SWITCH_DECLARE(int) switch_core_cert_gen_fingerprint(const char *prefix, dtls_fingerprint_t *fp);
|
SWITCH_DECLARE(int) switch_core_cert_gen_fingerprint(const char *prefix, dtls_fingerprint_t *fp);
|
||||||
SWITCH_DECLARE(int) switch_core_cert_expand_fingerprint(dtls_fingerprint_t *fp, const char *str);
|
SWITCH_DECLARE(int) switch_core_cert_expand_fingerprint(dtls_fingerprint_t *fp, const char *str);
|
||||||
SWITCH_DECLARE(int) switch_core_cert_verify(dtls_fingerprint_t *fp);
|
SWITCH_DECLARE(int) switch_core_cert_verify(dtls_fingerprint_t *fp);
|
||||||
SWITCH_DECLARE(switch_status_t) _switch_core_session_request_video_refresh(switch_core_session_t *session, const char *file, const char *func, int line);
|
SWITCH_DECLARE(switch_status_t) _switch_core_session_request_video_refresh(switch_core_session_t *session, int force, const char *file, const char *func, int line);
|
||||||
#define switch_core_session_request_video_refresh(_s) _switch_core_session_request_video_refresh(_s, __FILE__, __SWITCH_FUNC__, __LINE__)
|
#define switch_core_session_request_video_refresh(_s) _switch_core_session_request_video_refresh(_s, 0, __FILE__, __SWITCH_FUNC__, __LINE__)
|
||||||
|
#define switch_core_session_force_request_video_refresh(_s) _switch_core_session_request_video_refresh(_s, 1, __FILE__, __SWITCH_FUNC__, __LINE__)
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_send_and_request_video_refresh(switch_core_session_t *session);
|
SWITCH_DECLARE(switch_status_t) switch_core_session_send_and_request_video_refresh(switch_core_session_t *session);
|
||||||
SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait);
|
SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait);
|
||||||
SWITCH_DECLARE(int) switch_stream_system_fork(const char *cmd, switch_stream_handle_t *stream);
|
SWITCH_DECLARE(int) switch_stream_system_fork(const char *cmd, switch_stream_handle_t *stream);
|
||||||
|
|
|
@ -1457,6 +1457,7 @@ typedef enum {
|
||||||
CF_INTERCEPT,
|
CF_INTERCEPT,
|
||||||
CF_INTERCEPTED,
|
CF_INTERCEPTED,
|
||||||
CF_VIDEO_REFRESH_REQ,
|
CF_VIDEO_REFRESH_REQ,
|
||||||
|
CF_MANUAL_VID_REFRESH,
|
||||||
CF_SERVICE_AUDIO,
|
CF_SERVICE_AUDIO,
|
||||||
CF_SERVICE_VIDEO,
|
CF_SERVICE_VIDEO,
|
||||||
CF_ZRTP_PASSTHRU_REQ,
|
CF_ZRTP_PASSTHRU_REQ,
|
||||||
|
|
|
@ -4203,7 +4203,7 @@ SWITCH_STANDARD_API(uuid_xfer_zombie)
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define VIDEO_REFRESH_SYNTAX "<uuid>"
|
#define VIDEO_REFRESH_SYNTAX "<uuid> [auto|manual]"
|
||||||
SWITCH_STANDARD_API(uuid_video_refresh_function)
|
SWITCH_STANDARD_API(uuid_video_refresh_function)
|
||||||
{
|
{
|
||||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||||
|
@ -4220,11 +4220,28 @@ SWITCH_STANDARD_API(uuid_video_refresh_function)
|
||||||
switch_core_session_t *lsession = NULL;
|
switch_core_session_t *lsession = NULL;
|
||||||
|
|
||||||
if ((lsession = switch_core_session_locate(argv[0]))) {
|
if ((lsession = switch_core_session_locate(argv[0]))) {
|
||||||
switch_channel_set_flag(switch_core_session_get_channel(lsession), CF_XFER_ZOMBIE);
|
char *cmd = (char *)argv[1];
|
||||||
switch_core_session_request_video_refresh(lsession);
|
|
||||||
switch_core_media_gen_key_frame(lsession);
|
if (!zstr(cmd)) {
|
||||||
|
switch_channel_t *channel = switch_core_session_get_channel(lsession);
|
||||||
|
|
||||||
|
if (!strcasecmp(cmd, "manual")) {
|
||||||
|
switch_channel_set_flag(channel, CF_MANUAL_VID_REFRESH);
|
||||||
|
} else if (!strcasecmp(cmd, "auto")) {
|
||||||
|
switch_channel_clear_flag(channel, CF_MANUAL_VID_REFRESH);
|
||||||
|
}
|
||||||
|
|
||||||
|
stream->write_function(stream, "%s video refresh now in %s mode.\n", switch_channel_get_name(channel),
|
||||||
|
switch_channel_test_flag(channel, CF_MANUAL_VID_REFRESH) ? "manual" : "auto");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
switch_core_session_force_request_video_refresh(lsession);
|
||||||
|
switch_core_media_gen_key_frame(lsession);
|
||||||
|
}
|
||||||
|
|
||||||
status = SWITCH_STATUS_SUCCESS;
|
status = SWITCH_STATUS_SUCCESS;
|
||||||
switch_core_session_rwunlock(lsession);
|
switch_core_session_rwunlock(lsession);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1431,9 +1431,27 @@ SWITCH_STANDARD_APP(video_set_decode_function)
|
||||||
SWITCH_STANDARD_APP(video_refresh_function)
|
SWITCH_STANDARD_APP(video_refresh_function)
|
||||||
{
|
{
|
||||||
switch_core_session_message_t msg = { 0 };
|
switch_core_session_message_t msg = { 0 };
|
||||||
|
char *cmd = (char *)data;
|
||||||
|
|
||||||
|
if (!zstr(cmd)) {
|
||||||
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
|
|
||||||
|
if (!strcasecmp(cmd, "manual")) {
|
||||||
|
switch_channel_set_flag(channel, CF_MANUAL_VID_REFRESH);
|
||||||
|
} else if (!strcasecmp(cmd, "auto")) {
|
||||||
|
switch_channel_clear_flag(channel, CF_MANUAL_VID_REFRESH);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
|
||||||
|
"%s video refresh now in %s mode.\n", switch_channel_get_name(channel),
|
||||||
|
switch_channel_test_flag(channel, CF_MANUAL_VID_REFRESH) ? "manual" : "auto");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Tell the channel to refresh video */
|
/* Tell the channel to refresh video */
|
||||||
msg.from = __FILE__;
|
msg.from = __FILE__;
|
||||||
|
msg.numeric_arg = 1;
|
||||||
msg.string_arg = data;
|
msg.string_arg = data;
|
||||||
msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ;
|
msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ;
|
||||||
switch_core_session_receive_message(session, &msg);
|
switch_core_session_receive_message(session, &msg);
|
||||||
|
@ -6321,7 +6339,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
||||||
SWITCH_ADD_APP(app_interface, "ivr", "Run an ivr menu", "Run an ivr menu.", ivr_application_function, "<menu_name>", SAF_NONE);
|
SWITCH_ADD_APP(app_interface, "ivr", "Run an ivr menu", "Run an ivr menu.", ivr_application_function, "<menu_name>", SAF_NONE);
|
||||||
SWITCH_ADD_APP(app_interface, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "<redirect_data>",
|
SWITCH_ADD_APP(app_interface, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "<redirect_data>",
|
||||||
SAF_SUPPORT_NOMEDIA);
|
SAF_SUPPORT_NOMEDIA);
|
||||||
SWITCH_ADD_APP(app_interface, "video_refresh", "Send video refresh.", "Send video refresh.", video_refresh_function, "",
|
SWITCH_ADD_APP(app_interface, "video_refresh", "Send video refresh.", "Send video refresh.", video_refresh_function, "[manual|auto]",
|
||||||
SAF_SUPPORT_NOMEDIA);
|
SAF_SUPPORT_NOMEDIA);
|
||||||
SWITCH_ADD_APP(app_interface, "video_decode", "Set video decode.", "Set video decode.", video_set_decode_function, "[[on|wait]|off]",
|
SWITCH_ADD_APP(app_interface, "video_decode", "Set video decode.", "Set video decode.", video_set_decode_function, "[[on|wait]|off]",
|
||||||
SAF_NONE);
|
SAF_NONE);
|
||||||
|
|
|
@ -1528,7 +1528,7 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ:
|
case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ:
|
||||||
if (switch_channel_media_up(channel) && !switch_channel_test_flag(channel, CF_AVPF) &&
|
if (switch_channel_media_up(channel) && !switch_channel_test_flag(channel, CF_AVPF) && !switch_channel_test_flag(channel, CF_MANUAL_VID_REFRESH) &&
|
||||||
switch_channel_var_true(channel, "sofia_send_info_vid_refresh")) {
|
switch_channel_var_true(channel, "sofia_send_info_vid_refresh")) {
|
||||||
const char *pl = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<media_control><vc_primitive><to_encoder><picture_fast_update /></to_encoder></vc_primitive></media_control>\n";
|
const char *pl = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<media_control><vc_primitive><to_encoder><picture_fast_update /></to_encoder></vc_primitive></media_control>\n";
|
||||||
switch_time_t now = switch_micro_time_now();
|
switch_time_t now = switch_micro_time_now();
|
||||||
|
|
|
@ -11997,13 +11997,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_se
|
||||||
case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ:
|
case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ:
|
||||||
{
|
{
|
||||||
if (v_engine->rtp_session) {
|
if (v_engine->rtp_session) {
|
||||||
if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_FIR)) {
|
if (msg->numeric_arg || !switch_channel_test_flag(session->channel, CF_MANUAL_VID_REFRESH)) {
|
||||||
switch_rtp_video_refresh(v_engine->rtp_session);
|
if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_FIR)) {
|
||||||
}// else {
|
switch_rtp_video_refresh(v_engine->rtp_session);
|
||||||
|
}// else {
|
||||||
if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PLI)) {
|
if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PLI)) {
|
||||||
switch_rtp_video_loss(v_engine->rtp_session);
|
switch_rtp_video_loss(v_engine->rtp_session);
|
||||||
}
|
}
|
||||||
// }
|
//}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13720,7 +13722,7 @@ SWITCH_DECLARE(switch_timer_t *) switch_core_media_get_timer(switch_core_session
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) _switch_core_session_request_video_refresh(switch_core_session_t *session, const char *file, const char *func, int line)
|
SWITCH_DECLARE(switch_status_t) _switch_core_session_request_video_refresh(switch_core_session_t *session, int force, const char *file, const char *func, int line)
|
||||||
{
|
{
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
switch_media_handle_t *smh = NULL;
|
switch_media_handle_t *smh = NULL;
|
||||||
|
@ -13735,11 +13737,16 @@ SWITCH_DECLARE(switch_status_t) _switch_core_session_request_video_refresh(switc
|
||||||
switch_core_session_message_t msg = { 0 };
|
switch_core_session_message_t msg = { 0 };
|
||||||
switch_time_t now = switch_micro_time_now();
|
switch_time_t now = switch_micro_time_now();
|
||||||
|
|
||||||
if (smh->last_video_refresh_req && (now - smh->last_video_refresh_req) < VIDEO_REFRESH_FREQ) {
|
if (!force && (smh->last_video_refresh_req && (now - smh->last_video_refresh_req) < VIDEO_REFRESH_FREQ)) {
|
||||||
return SWITCH_STATUS_BREAK;
|
return SWITCH_STATUS_BREAK;
|
||||||
}
|
}
|
||||||
|
|
||||||
smh->last_video_refresh_req = now;
|
smh->last_video_refresh_req = now;
|
||||||
|
|
||||||
|
if (force) {
|
||||||
|
msg.numeric_arg = 1;
|
||||||
|
}
|
||||||
|
|
||||||
msg._file = file;
|
msg._file = file;
|
||||||
msg._func = func;
|
msg._func = func;
|
||||||
msg._line = line;
|
msg._line = line;
|
||||||
|
|
Loading…
Reference in New Issue