Skip to content

Commit

Permalink
MT#59038 add rec announcement options
Browse files Browse the repository at this point in the history
Change-Id: I11641208e68cef53568e4e91145fca4493eb6f24
  • Loading branch information
rfuchs committed Mar 9, 2024
1 parent cb39c9a commit 6305912
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
22 changes: 22 additions & 0 deletions daemon/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions daemon/call_interfaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions daemon/recording.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "cdr.h"
#include "log.h"
#include "call_interfaces.h"
#include "media_player.h"

#include "xt_RTPENGINE.h"

Expand Down Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion docs/ng_control_protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions include/call.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions include/call_interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6305912

Please sign in to comment.