diff --git a/daemon/call.c b/daemon/call.c index a2203a5a2c..5d24846b90 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2611,6 +2611,26 @@ static void __call_monologue_init_from_flags(struct call_monologue *ml, sdp_ng_f SET_VSC(start_pause_resume, START_PAUSE_RESUME) #undef SET_VSC } + +#ifdef WITH_TRANSCODING + if (flags->recording_announcement) { + media_player_new(&ml->rec_player, ml); + bool ret = true; + media_player_opts_t opts = MPO( + .repeat = flags->repeat_times, + .start_pos = flags->start_pos, + .block_egress = !!flags->block_egress, + ); + if (flags->file.len) + ret = media_player_init_file(ml->rec_player, &flags->file, opts); + else if (flags->blob.len) + ret = media_player_init_blob(ml->rec_player, &flags->blob, opts); + else if (flags->db_id > 0) + ret = media_player_init_db(ml->rec_player, flags->db_id, opts); + if (!ret) + ilog(LOG_WARN, "Failed to initialise media player for recording announcement"); + } +#endif } __attribute__((nonnull(2, 3))) @@ -3563,6 +3583,7 @@ static void __call_cleanup(call_t *c) { struct call_monologue *ml = l->data; __monologue_stop(ml); media_player_put(&ml->player); + media_player_put(&ml->rec_player); if (ml->tone_freqs) g_array_free(ml->tone_freqs, true); if (ml->janus_session) @@ -4645,6 +4666,7 @@ static void media_stop(struct call_media *m) { */ static void __monologue_stop(struct call_monologue *ml) { media_player_stop(ml->player); + media_player_stop(ml->rec_player); } /** * Stops media player and all medias of given monolgue. diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 5aef55baf2..a42097bf5f 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -1137,6 +1137,9 @@ static void call_ng_flags_flags(sdp_ng_flags *out, str *s, helper_arg dummy) { case CSH_LOOKUP("recording-VSC"): out->recording_vsc = 1; break; + case CSH_LOOKUP("recording-announcement"): + out->recording_announcement = 1; + break; case CSH_LOOKUP("reorder-codecs"): ilog(LOG_INFO, "Ignoring obsolete flag `reorder-codecs`"); break; diff --git a/daemon/recording.c b/daemon/recording.c index 5120087fcb..9b76d991fa 100644 --- a/daemon/recording.c +++ b/daemon/recording.c @@ -22,6 +22,7 @@ #include "cdr.h" #include "log.h" #include "call_interfaces.h" +#include "media_player.h" #include "xt_RTPENGINE.h" @@ -340,6 +341,11 @@ static void recording_update_flags(call_t *call, bool streams) { static void rec_setup_monologue(struct call_monologue *ml) { recording_setup_monologue(ml); + if (ml->rec_player) { + bool ret = media_player_start(ml->rec_player); + if (!ret) + ilog(LOG_WARN, "Failed to start media player for recording announcement"); + } } // lock must be held diff --git a/docs/ng_control_protocol.md b/docs/ng_control_protocol.md index 5b395607d2..9d691f3dce 100644 --- a/docs/ng_control_protocol.md +++ b/docs/ng_control_protocol.md @@ -844,7 +844,8 @@ Spaces in each string may be replaced by hyphens. Instructs *rtpengine* to suppress and block other egress media to a remote client while media playback towards that client is ongoing. Useful for - `play media` messages. + `play media` messages, as well as `offer` and `answer` in combination with + `recording announcement`. * `block short` or `block short packets` @@ -978,6 +979,19 @@ Spaces in each string may be replaced by hyphens. Identical to setting `record call` to `on` (see below). +* `recording announcement` + + Enable playback of an announcement message when call recording is started. + One of the flags identifying a media file (such as `file=`, same as for the + `play media` message) must also be given, and generally usage of `block + egress` is recommended. + + Announcement messages are enabled directionally, meaning this flag enables + it for the call party relevant to the current message (e.g the call + originator for an initial `invite`) but not for other. In other words this + flag must be set for all call parties which are meant to hear the + announcement. + * `reject ICE` Useful for `offer` messages that advertise support for ICE. diff --git a/include/call.h b/include/call.h index 63ae58ced0..b3bfae9131 100644 --- a/include/call.h +++ b/include/call.h @@ -550,6 +550,7 @@ struct call_monologue { medias_arr *medias; GHashTable *media_ids; struct media_player *player; + struct media_player *rec_player; unsigned long long sdp_session_id; unsigned long long sdp_version; str last_in_sdp; diff --git a/include/call_interfaces.h b/include/call_interfaces.h index 3d3d082f93..7042ef8e61 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -170,6 +170,7 @@ struct sdp_ng_flags { exclude_recording:1, skip_recording_db:1, recording_vsc:1, + recording_announcement:1, debug:1, inactive:1, loop_protect:1,