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:
Anthony Minessale
2014-11-12 21:30:39 -06:00
parent 5f1f628e28
commit a6012594fb
11 changed files with 258 additions and 65 deletions
+17
View File
@@ -1634,6 +1634,23 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_encode_video(switch_codec_t *c
switch_image_t *img,
void *encoded_data, uint32_t *encoded_data_len, unsigned int *flag);
/*!
\brief send control data using a codec handle
\param codec the codec handle to use
\param cmd the command to send
\param ctype the type of the arguement
\param cmd_data a void pointer to the data matching the passed type
\param rtype the type of the response if any
\param ret_data a void pointer to a pointer of return data
\return SWITCH_STATUS_SUCCESS if the command was received
*/
SWITCH_DECLARE(switch_status_t) switch_core_codec_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);
/*!
\brief Decode video data using a codec handle
\param codec the codec handle to use
+11
View File
@@ -294,6 +294,17 @@ SWITCH_DECLARE(const char *) switch_core_media_crypto_type2str(switch_rtp_crypto
SWITCH_DECLARE(int) switch_core_media_crypto_keylen(switch_rtp_crypto_key_type_t type);
SWITCH_DECLARE(char *) switch_core_media_filter_sdp(const char *sdp, const char *cmd, const char *arg);
SWITCH_DECLARE(char *) switch_core_media_process_sdp_filter(const char *sdp, const char *cmd_buf, switch_core_session_t *session);
SWITCH_DECLARE(switch_status_t) switch_core_media_codec_control(switch_core_session_t *session,
switch_media_type_t mtype,
switch_io_type_t iotype,
switch_codec_control_command_t cmd,
switch_codec_control_type_t ctype,
void *cmd_data,
switch_codec_control_type_t *rtype,
void **ret_data);
SWITCH_END_EXTERN_C
#endif
/* For Emacs:
+16 -13
View File
@@ -533,19 +533,21 @@ static inline void switch_core_codec_add_implementation(switch_memory_pool_t *po
///\}
static inline void switch_core_codec_add_video_implementation(switch_memory_pool_t *pool, switch_codec_interface_t *codec_interface,
/*! the IANA code number */
switch_payload_t ianacode,
/*! the IANA code name */
const char *iananame,
/*! default fmtp to send (can be overridden by the init function) */
char *fmtp,
switch_core_codec_init_func_t init,
/*! function to encode raw data into encoded data */
switch_core_codec_video_encode_func_t encode,
/*! function to decode encoded data into raw data */
switch_core_codec_video_decode_func_t decode,
/*! deinitalize a codec handle using this implementation */
switch_core_codec_destroy_func_t destroy)
/*! the IANA code number */
switch_payload_t ianacode,
/*! the IANA code name */
const char *iananame,
/*! default fmtp to send (can be overridden by the init function) */
char *fmtp,
switch_core_codec_init_func_t init,
/*! function to encode raw data into encoded data */
switch_core_codec_video_encode_func_t encode,
/*! function to decode encoded data into raw data */
switch_core_codec_video_decode_func_t decode,
/*! function to send control messages to the codec */
switch_core_codec_control_func_t control,
/*! deinitalize a codec handle using this implementation */
switch_core_codec_destroy_func_t destroy)
{
switch_codec_implementation_t *impl = (switch_codec_implementation_t *) switch_core_alloc(pool, sizeof(*impl));
@@ -564,6 +566,7 @@ static inline void switch_core_codec_add_video_implementation(switch_memory_pool
impl->init = init;
impl->encode_video = encode;
impl->decode_video = decode;
impl->codec_control = control;
impl->destroy = destroy;
impl->codec_id = codec_interface->codec_id;
impl->next = codec_interface->implementations;
+2
View File
@@ -679,6 +679,8 @@ struct switch_codec_implementation {
switch_core_codec_video_encode_func_t encode_video;
/*! function to decode video encoded data into raw data */
switch_core_codec_video_decode_func_t decode_video;
/*! function to send control messages to the codec */
switch_core_codec_control_func_t codec_control;
/*! deinitalize a codec handle using this implementation */
switch_core_codec_destroy_func_t destroy;
uint32_t codec_id;
+25 -4
View File
@@ -2168,12 +2168,33 @@ typedef switch_status_t (*switch_core_codec_decode_func_t) (switch_codec_t *code
void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag);
typedef switch_status_t (*switch_core_codec_video_encode_func_t) (switch_codec_t *codec,
switch_image_t *img,
void *encoded_data, uint32_t *encoded_data_len, unsigned int *flag);
switch_image_t *img,
void *encoded_data, uint32_t *encoded_data_len, unsigned int *flag);
typedef switch_status_t (*switch_core_codec_video_decode_func_t) (switch_codec_t *codec,
switch_frame_t *frame,
switch_image_t **img, unsigned int *flag);
switch_frame_t *frame,
switch_image_t **img, unsigned int *flag);
typedef enum {
SCC_VIDEO_REFRESH = 0
} switch_codec_control_command_t;
typedef enum {
SCCT_NONE = 0
} switch_codec_control_type_t;
typedef enum {
SWITCH_IO_READ,
SWITCH_IO_WRITE
} switch_io_type_t;
typedef switch_status_t (*switch_core_codec_control_func_t) (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);
typedef switch_status_t (*switch_core_codec_init_func_t) (switch_codec_t *, switch_codec_flag_t, const switch_codec_settings_t *codec_settings);
typedef switch_status_t (*switch_core_codec_fmtp_parse_func_t) (const char *fmtp, switch_codec_fmtp_t *codec_fmtp);