From b0a52eb1feaade9f0c0a89813fe4faf9dc5fab5c Mon Sep 17 00:00:00 2001 From: Jakub Karolczyk Date: Fri, 9 Jun 2023 18:25:25 +0000 Subject: [PATCH] [core] Add switch_core_media_get_engine() and switch_core_media_get_codec() functions --- src/include/switch_core_media.h | 4 ++++ src/switch_core_media.c | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/include/switch_core_media.h b/src/include/switch_core_media.h index 8694a0bc88..1c1c321cb3 100644 --- a/src/include/switch_core_media.h +++ b/src/include/switch_core_media.h @@ -399,6 +399,10 @@ SWITCH_DECLARE(void) switch_core_media_set_smode(switch_core_session_t *session, SWITCH_DECLARE(void) switch_core_media_set_resolveice(switch_bool_t resolve_ice); SWITCH_DECLARE(switch_bool_t) switch_core_media_has_resolveice(void); +typedef struct switch_rtp_engine_s switch_rtp_engine_t; +SWITCH_DECLARE(switch_rtp_engine_t *) switch_core_media_get_engine(switch_core_session_t *session, int media_type); +SWITCH_DECLARE(switch_codec_t*) switch_core_media_get_codec(switch_core_session_t *session, switch_media_type_t type); + SWITCH_END_EXTERN_C #endif /* For Emacs: diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 912d5a5012..ae5dbf6d45 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -110,7 +110,7 @@ struct switch_rtp_text_factory_s { }; -typedef struct switch_rtp_engine_s { +struct switch_rtp_engine_s { switch_secure_settings_t ssec[CRYPTO_INVALID+1]; switch_rtp_crypto_key_type_t crypto_type; @@ -204,7 +204,7 @@ typedef struct switch_rtp_engine_s { void *engine_user_data; int8_t engine_function_running; switch_frame_buffer_t *write_fb; -} switch_rtp_engine_t; +}; #define MAX_REJ_STREAMS 10 @@ -16421,7 +16421,21 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess return status; } +SWITCH_DECLARE(switch_rtp_engine_t *) switch_core_media_get_engine(switch_core_session_t *session, int media_type) +{ + if (!session) return NULL; + return &session->media_handle->engines[media_type]; +} + +SWITCH_DECLARE(switch_codec_t*) switch_core_media_get_codec(switch_core_session_t *session, switch_media_type_t type) +{ + switch_rtp_engine_t *engine = switch_core_media_get_engine(session, type); + + if (!engine) return NULL; + + return &engine->read_codec; +} /* For Emacs: * Local Variables: