mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 12:42:02 +00:00
FS-7500: add support for codec control and use it to pass messages down to the codec and use it to implement keyframe reset for fir, pli and nack. Later we will expand to handle nack correctly.
This commit is contained in:
@@ -533,6 +533,16 @@ end:
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t switch_h264_control(switch_codec_t *codec,
|
||||
switch_codec_control_command_t cmd,
|
||||
switch_codec_control_type_t ctype,
|
||||
void *cmd_data,
|
||||
switch_codec_control_type_t *rtype,
|
||||
void **ret_data) {
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t switch_h264_destroy(switch_codec_t *codec)
|
||||
{
|
||||
h264_codec_context_t *context = (h264_codec_context_t *)codec->private_info;
|
||||
@@ -565,7 +575,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_openh264_load)
|
||||
|
||||
SWITCH_ADD_CODEC(codec_interface, "H264 Video (with Cisco OpenH264)");
|
||||
switch_core_codec_add_video_implementation(pool, codec_interface, 99, "H264", NULL,
|
||||
switch_h264_init, switch_h264_encode, switch_h264_decode, switch_h264_destroy);
|
||||
switch_h264_init, switch_h264_encode, switch_h264_decode, switch_h264_control, switch_h264_destroy);
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
@@ -358,6 +358,7 @@ static switch_status_t switch_vpx_encode(switch_codec_t *codec, switch_image_t *
|
||||
|
||||
if (context->need_key_frame > 0) {
|
||||
// force generate a key frame
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "VPX KEYFRAME REQ\n");
|
||||
vpx_flags |= VPX_EFLAG_FORCE_KF;
|
||||
context->last_ts = switch_micro_time_now();
|
||||
context->need_key_frame--;
|
||||
@@ -508,6 +509,30 @@ error:
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t switch_vpx_control(switch_codec_t *codec,
|
||||
switch_codec_control_command_t cmd,
|
||||
switch_codec_control_type_t ctype,
|
||||
void *cmd_data,
|
||||
switch_codec_control_type_t *rtype,
|
||||
void **ret_data)
|
||||
{
|
||||
|
||||
vpx_context_t *context = (vpx_context_t *)codec->private_info;
|
||||
|
||||
switch(cmd) {
|
||||
case SCC_VIDEO_REFRESH:
|
||||
context->need_key_frame = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t switch_vpx_destroy(switch_codec_t *codec)
|
||||
{
|
||||
vpx_context_t *context = (vpx_context_t *)codec->private_info;
|
||||
@@ -541,7 +566,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_vpx_load)
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
SWITCH_ADD_CODEC(codec_interface, "VP8 Video");
|
||||
switch_core_codec_add_video_implementation(pool, codec_interface, 99, "VP8", NULL,
|
||||
switch_vpx_init, switch_vpx_encode, switch_vpx_decode, switch_vpx_destroy);
|
||||
switch_vpx_init, switch_vpx_encode, switch_vpx_decode, switch_vpx_control, switch_vpx_destroy);
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
@@ -85,7 +85,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_yuv_load)
|
||||
SWITCH_ADD_CODEC(codec_interface, "YUV I420 Video (raw)");
|
||||
|
||||
switch_core_codec_add_video_implementation(pool, codec_interface, 99, "I420", NULL,
|
||||
switch_yuv_init, switch_yuv_encode, switch_yuv_decode, switch_yuv_destroy);
|
||||
switch_yuv_init, switch_yuv_encode, switch_yuv_decode, NULL, switch_yuv_destroy);
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user