From b15ffd9e7be4bccd1d6f4773f93570c4bbba5e32 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 8 Nov 2021 20:11:12 +0530 Subject: [PATCH] Loop option implementation in conference member play --- .../mod_conference/conference_member.c | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_conference/conference_member.c b/src/mod/applications/mod_conference/conference_member.c index 6df96fca97..5318352b52 100644 --- a/src/mod/applications/mod_conference/conference_member.c +++ b/src/mod/applications/mod_conference/conference_member.c @@ -604,7 +604,20 @@ void conference_member_add_file_data(conference_member_t *member, int16_t *data, } if (file_sample_len <= 0) { - member->fnode->done++; + if (member->fnode->loops) { + if (--member->fnode->loops < 0) { + member->fnode->loops = -1; + } + + if (member->fnode->loops) { + uint32_t pos = 0; + switch_core_file_seek(&member->fnode->fh, &pos, 0, SEEK_SET); + } + } + + if (!member->fnode->loops) { + member->fnode->done++; + } } else { /* there is file node data to mix into the frame */ uint32_t i; int32_t sample; @@ -1500,6 +1513,7 @@ switch_status_t conference_member_play_file(conference_member_t *member, char *f if (fnode->fh.params) { const char *vol = switch_event_get_header(fnode->fh.params, "vol"); + const char *loopsstr = switch_event_get_header(fnode->fh.params, "loops"); const char *position = switch_event_get_header(fnode->fh.params, "position"); if (!zstr(vol)) { @@ -1507,6 +1521,14 @@ switch_status_t conference_member_play_file(conference_member_t *member, char *f switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG, "Set playback volume for file: %d\n",fnode->fh.vol); } + if (loopsstr) { + fnode->loops = atoi(loopsstr); + + if (!strcasecmp(loopsstr, "inf") || !strcasecmp(loopsstr, "infinite")) { + fnode->loops = -1; + } + } + if (!bad_params && !zstr(position) && member->conference->channels == 2) { fnode->al = conference_al_create(pool); if (conference_al_parse_position(fnode->al, position) != SWITCH_STATUS_SUCCESS) {