MT#55283 redirect additional call pointers

Update media player, send timer, jitter buffer objects.

Set final memory arena pointer as the releasing the last reference might
reset it to null.

Exclude media_player stuff from no-transcoding builds and adjust ifdef
guards accordingly.

Closes #2186

Change-Id: I42dc5a449816d765bc4d1da2b35315e0b6f7c29b
(cherry picked from commit 2366392202)
(cherry picked from commit 2ee9247bb7)
mr26.0.1
Richard Fuchs 1 month ago
parent 617d11d5bb
commit 1067b4d7c9

@ -5046,8 +5046,10 @@ static void __call_cleanup(call_t *c) {
for (__auto_type l = c->monologues.head; l; l = l->next) {
struct call_monologue *ml = l->data;
__monologue_stop(ml);
#ifdef WITH_TRANSCODING
media_player_put(&ml->player);
media_player_put(&ml->rec_player);
#endif
if (ml->tone_freqs)
g_array_free(ml->tone_freqs, true);
obj_release_o(ml->janus_session);
@ -5598,6 +5600,16 @@ bool call_merge(call_t *call, call_t *call2) {
t_hash_table_insert(call->viabranches, &ml->viabranch, ml);
if (ml->label.len)
t_hash_table_insert(call->labels, &ml->label, ml);
#ifdef WITH_TRANSCODING
if (ml->player && ml->player->call) {
obj_put(ml->player->call);
ml->player->call = obj_get(call);
}
if (ml->rec_player && ml->rec_player->call) {
obj_put(ml->rec_player->call);
ml->rec_player->call = obj_get(call);
}
#endif
}
last_id = call->medias.head->data->unique_id;
@ -5606,6 +5618,11 @@ bool call_merge(call_t *call, call_t *call2) {
media->unique_id = ++last_id;
media->call = call;
t_queue_push_tail(&call->medias, media);
if (media->ice_agent && media->ice_agent->call) {
obj_put(media->ice_agent->call);
media->ice_agent->call = obj_get(call);
}
}
t_hash_table_foreach_remove(call2->sdp_fragments, fragment_move, call);
@ -5616,6 +5633,16 @@ bool call_merge(call_t *call, call_t *call2) {
stream->unique_id = ++last_id;
stream->call = call;
t_queue_push_tail(&call->streams, stream);
if (stream->send_timer && stream->send_timer->call) {
obj_put(stream->send_timer->call);
stream->send_timer->call = obj_get(call);
}
if (stream->jb && stream->jb->call) {
obj_put(stream->jb->call);
stream->jb->call = obj_get(call);
}
}
last_id = call->stream_fds.head->data->unique_id;
@ -5670,6 +5697,8 @@ bool call_merge(call_t *call, call_t *call2) {
rwlock_unlock_w(&call2->master_lock);
obj_release(call2);
call_memory_arena_set(call);
return true;
}
@ -6247,8 +6276,10 @@ static void media_stop(struct call_media *m) {
* Stops media player of given monologue.
*/
static void __monologue_stop(struct call_monologue *ml) {
#ifdef WITH_TRANSCODING
media_player_stop(ml->player);
media_player_stop(ml->rec_player);
#endif
}
/**
* Stops media player and all medias of given monolgue.

@ -1530,13 +1530,12 @@ static bool media_player_add_file(struct media_player *mp, media_player_opts_t o
int ret = __media_player_add_file(mp, opts, NULL);
return ret == 0;
}
#endif
/**
* When to_ml is given, check MoH capabilities of it,
* because then an offerer wants to use them instead of its own (from_ml).
*/
bool call_ml_wants_moh(struct call_monologue *from_ml, struct call_monologue *to_ml,
static bool call_ml_wants_moh(struct call_monologue *from_ml, struct call_monologue *to_ml,
enum ng_opmode opmode)
{
struct call_monologue *ml = to_ml ? : from_ml;
@ -1549,18 +1548,17 @@ bool call_ml_wants_moh(struct call_monologue *from_ml, struct call_monologue *to
return false;
}
bool call_ml_stops_moh(struct call_monologue *from_ml, struct call_monologue *to_ml,
static bool call_ml_stops_moh(struct call_monologue *from_ml, struct call_monologue *to_ml,
enum ng_opmode opmode)
{
#ifdef WITH_TRANSCODING
if (opmode == OP_OFFER && !call_ml_sendonly_inactive(from_ml) && (to_ml->player && to_ml->player->opts.moh))
{
return true;
}
#endif
return false;
}
/**
* MOH_ZEROCONN: check if originator wants to advertise zero address during moh.
* Sets zero-connection for the first found subscription media with a sendonly state
@ -1570,8 +1568,7 @@ bool call_ml_stops_moh(struct call_monologue *from_ml, struct call_monologue *to
* Sets the sendrecv state for the first found subscription media with a sendonly state
* and audio type.
*/
void call_ml_moh_handle_flags(struct call_monologue *from_ml, struct call_monologue *to_ml) {
#ifdef WITH_TRANSCODING
static void call_ml_moh_handle_flags(struct call_monologue *from_ml, struct call_monologue *to_ml) {
/* if from_ml not given, then it's a reflected MoH, use capabilities of to_ml */
struct call_monologue *moh_ml = from_ml ? : to_ml;
@ -1616,8 +1613,9 @@ check_next:
}
}
}
#endif
}
#endif
const char * call_check_moh(struct call_monologue *from_ml, struct call_monologue *to_ml,
sdp_ng_flags *flags)
@ -1668,13 +1666,11 @@ const char * call_check_moh(struct call_monologue *from_ml, struct call_monologu
call_stop_media_for_ml(to_ml);
ilog(LOG_DEBUG, "Music on hold stopped with coming SDP offer.");
}
return NULL;
#else
return NULL;
#endif
return NULL;
}
const char * call_play_media_for_ml(struct call_monologue *ml,
const char *call_play_media_for_ml(struct call_monologue *ml,
media_player_opts_t opts, sdp_ng_flags *flags)
{
#ifdef WITH_TRANSCODING

@ -345,11 +345,13 @@ static void recording_update_flags(call_t *call, bool streams) {
static void rec_setup_monologue(struct call_monologue *ml) {
recording_setup_monologue(ml);
#ifdef WITH_TRANSCODING
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");
}
#endif
}
// lock must be held

@ -622,8 +622,10 @@ struct call_monologue {
GHashTable *subscribers_ht; /* for quick lookup */
medias_arr *medias;
media_id_ht media_ids;
#ifdef WITH_TRANSCODING
struct media_player *player;
struct media_player *rec_player;
#endif
struct session_bandwidth sdp_session_bandwidth;
GString *last_out_sdp;

@ -136,14 +136,10 @@ bool media_player_pt_match(const struct media_player *mp, const rtp_payload_type
void media_player_add_packet(struct media_player *mp, char *buf, size_t len,
int64_t us_dur, unsigned long long pts);
const char * call_play_media_for_ml(struct call_monologue *ml,
const char *call_play_media_for_ml(struct call_monologue *ml,
media_player_opts_t opts, sdp_ng_flags *flags);
long long call_stop_media_for_ml(struct call_monologue *ml);
bool call_ml_wants_moh(struct call_monologue *from_ml, struct call_monologue *to_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,
const char *call_check_moh(struct call_monologue *from_ml, struct call_monologue *to_ml,
sdp_ng_flags *flags);
void media_player_init(void);

Loading…
Cancel
Save