MT#61630 moh: support inactive hold

Support inactive hold, because some
client implementations (such as Zoiper5)
are using `a=inactive` for their holds.

For us this means, either of this
puts the other side on hold:
- `sendonly: !MEDIA_ISSET(media, SEND) && MEDIA_ISSET(media, RECV)`
- `inactive: !MEDIA_ISSET(media, SEND) && !MEDIA_ISSET(media, RECV)`

Change-Id: I75562eee60220885e233fa965bf22da92850a8f4
pull/1897/head
Donat Zenichev 4 months ago
parent 2ce79f9bb4
commit 51a0175ae7

@ -3464,17 +3464,20 @@ struct media_subscription *call_ml_get_top_ms(struct call_monologue *ml) {
}
/**
* Checks if any present audio medias put this monologue into sendonly state.
* Checks if any present audio medias are sendonly/inactive.
* Should only be used when medias are already initialized with flags.
*/
bool call_ml_sendonly(struct call_monologue *ml) {
bool call_ml_sendonly_inactive(struct call_monologue *ml) {
for (int i = 0; i < ml->medias->len; i++)
{
struct call_media * media = ml->medias->pdata[i];
if (!media || media->type_id != MT_AUDIO)
continue;
/* sendonly media means it can receive packets, but doesn't send */
if (!MEDIA_ISSET(media, SEND) && MEDIA_ISSET(media, RECV))
/* sendonly media for rtpengine means: receive from this media, but don't send to it
* sendonly: !MEDIA_ISSET(media, SEND) && MEDIA_ISSET(media, RECV)
* inactive: !MEDIA_ISSET(media, SEND) && !MEDIA_ISSET(media, RECV)
*/
if (!MEDIA_ISSET(media, SEND))
return true;
}
return false;

@ -1218,7 +1218,7 @@ static bool media_player_add_file(struct media_player *mp, media_player_opts_t o
bool call_ml_wants_moh(struct call_monologue *ml, enum ng_opmode opmode)
{
if (opmode == OP_OFFER && call_ml_sendonly(ml) &&
if (opmode == OP_OFFER && call_ml_sendonly_inactive(ml) &&
(ml->moh_db_id > 0 || ml->moh_file.len || ml->moh_blob.len))
{
return true;
@ -1230,7 +1230,7 @@ bool call_ml_stops_moh(struct call_monologue *from_ml, struct call_monologue *to
enum ng_opmode opmode)
{
#ifdef WITH_TRANSCODING
if (opmode == OP_OFFER && !call_ml_sendonly(from_ml) && (to_ml->player && to_ml->player->moh))
if (opmode == OP_OFFER && !call_ml_sendonly_inactive(from_ml) && (to_ml->player && to_ml->player->moh))
{
return true;
}

@ -816,7 +816,7 @@ struct packet_stream *__packet_stream_new(call_t *call);
void __add_media_subscription(struct call_media * which, struct call_media * to,
const struct sink_attrs *attrs);
struct media_subscription *call_ml_get_top_ms(struct call_monologue *ml);
bool call_ml_sendonly(struct call_monologue *ml);
bool call_ml_sendonly_inactive(struct call_monologue *ml);
struct media_subscription *call_media_get_top_ms(struct call_media * cm);
struct media_subscription *call_get_media_subscription(subscription_ht ht, struct call_media * cm);
struct call_monologue * ml_medias_subscribed_to_single_ml(struct call_monologue *ml);

Loading…
Cancel
Save