MT#61630 moh: move `call_check_moh()` to media_player

This function belongs to a specific scope, which
is rather in media_player than call_interfaces.

Change-Id: I74bda66491f002e6e90767d7d2750cfc270eea96
pull/1897/head
Donat Zenichev 11 months ago
parent d4146e80f0
commit 7862ccf0b6

@ -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)
{

@ -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)

@ -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);

Loading…
Cancel
Save