diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 5e392e159..33e62eaf6 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -168,45 +168,6 @@ static void updated_created_from(call_t *c, const char *addr, const endpoint_t * } } -/** - * TODO: probably makes sense to move to the call.c - */ -static const char* call_check_moh(struct call_monologue *from_ml, struct call_monologue *to_ml, - sdp_ng_flags *flags) -{ -#ifdef WITH_TRANSCODING - if (call_ml_wants_moh(from_ml, flags->opmode)) - { - const char *errstr = NULL; - media_player_opts_t opts = MPO( - .repeat = 999, - .duration_spent = rtpe_config.moh_max_duration, - .start_pos = 0, - .block_egress = 1, - .codec_set = flags->codec_set, - .file = from_ml->moh_file, - .blob = from_ml->moh_blob, - .db_id = from_ml->moh_db_id, - ); - /* whom to play the moh audio */ - errstr = call_play_media_for_ml(to_ml, opts, NULL); - if (errstr) - return errstr; - /* mark player as used for MoH */ - to_ml->player->moh = true; - /* handle MoH related flags */ - call_ml_moh_handle_flags(from_ml, to_ml); - } else if (call_ml_stops_moh(from_ml, to_ml, flags->opmode)) - { - /* whom to stop the moh audio */ - call_stop_media_for_ml(to_ml); - } - return NULL; -#else - return NULL; -#endif -} - static str *call_update_lookup_udp(char **out, enum ng_opmode opmode, const char* addr, const endpoint_t *sin) { diff --git a/daemon/media_player.c b/daemon/media_player.c index 0f7186cd7..0d3f6d255 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -10,6 +10,7 @@ #include "log.h" #include "timerthread.h" #include "call.h" +#include "call_interfaces.h" #include "str.h" #include "rtplib.h" #include "codec.h" @@ -1272,7 +1273,41 @@ check_next: #endif } - +const char * call_check_moh(struct call_monologue *from_ml, struct call_monologue *to_ml, + sdp_ng_flags *flags) +{ +#ifdef WITH_TRANSCODING + if (call_ml_wants_moh(from_ml, flags->opmode)) + { + const char *errstr = NULL; + media_player_opts_t opts = MPO( + .repeat = 999, + .duration_spent = rtpe_config.moh_max_duration, + .start_pos = 0, + .block_egress = 1, + .codec_set = flags->codec_set, + .file = from_ml->moh_file, + .blob = from_ml->moh_blob, + .db_id = from_ml->moh_db_id, + ); + /* whom to play the moh audio */ + errstr = call_play_media_for_ml(to_ml, opts, NULL); + if (errstr) + return errstr; + /* mark player as used for MoH */ + to_ml->player->moh = true; + /* handle MoH related flags */ + call_ml_moh_handle_flags(from_ml, to_ml); + } else if (call_ml_stops_moh(from_ml, to_ml, flags->opmode)) + { + /* whom to stop the moh audio */ + call_stop_media_for_ml(to_ml); + } + return NULL; +#else + return NULL; +#endif +} const char * call_play_media_for_ml(struct call_monologue *ml, media_player_opts_t opts, sdp_ng_flags *flags) diff --git a/include/media_player.h b/include/media_player.h index eeb81feb1..1b91cd889 100644 --- a/include/media_player.h +++ b/include/media_player.h @@ -142,6 +142,8 @@ bool call_ml_wants_moh(struct call_monologue *ml, enum ng_opmode opmode); bool call_ml_stops_moh(struct call_monologue *from_ml, struct call_monologue *to_ml, enum ng_opmode opmode); void call_ml_moh_handle_flags(struct call_monologue *from_ml, struct call_monologue *to_ml); +const char * call_check_moh(struct call_monologue *from_ml, struct call_monologue *to_ml, + sdp_ng_flags *flags); void media_player_init(void); void media_player_free(void);