diff --git a/daemon/call.c b/daemon/call.c index 06d0b6053..e3ff42ae4 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -3603,6 +3603,9 @@ static void __call_cleanup(struct call *c) { media_player_put(&ml->player); if (ml->tone_freqs) g_array_free(ml->tone_freqs, true); + if (ml->janus_session) + obj_put_o((void *) ml->janus_session); + ml->janus_session = NULL; } while (c->stream_fds.head) { @@ -3612,10 +3615,6 @@ static void __call_cleanup(struct call *c) { } recording_finish(c); - - if (c->janus_session) - obj_put_o((void *) c->janus_session); - c->janus_session = NULL; } /* called lock-free, but must hold a reference to the call */ diff --git a/daemon/janus.c b/daemon/janus.c index f0b4f1d37..60e33dfa5 100644 --- a/daemon/janus.c +++ b/daemon/janus.c @@ -194,7 +194,6 @@ static const char *janus_videoroom_create(struct janus_session *session, struct if (!call->created_from) call->created_from = "janus"; g_hash_table_insert(janus_rooms, &room->id, room); - call->janus_session = obj_get(session); rwlock_unlock_w(&call->master_lock); obj_put(call); break; @@ -524,6 +523,9 @@ static const char *janus_videoroom_join(struct websocket_message *wm, struct jan else ret = sdp_create(jsep_sdp_out, dest_ml, &flags); + if (!dest_ml->janus_session) + dest_ml->janus_session = obj_get(session); + if (ret) return "Error generating SDP"; *jsep_type_out = "offer"; @@ -723,6 +725,9 @@ static const char *janus_videoroom_configure(struct websocket_message *wm, struc if (ret) return "Publish error"; + if (!ml->janus_session) + ml->janus_session = obj_get(session); + save_last_sdp(ml, &sdp_in, &parsed, &streams); *jsep_sdp_out = sdp_out; sdp_out = STR_NULL; // ownership passed to output @@ -1044,8 +1049,7 @@ void janus_detach_websocket(struct janus_session *session, struct websocket_conn // call is locked in some way void janus_media_up(struct call_monologue *ml) { - struct call *call = ml->call; - struct janus_session *session = call->janus_session; + struct janus_session *session = ml->janus_session; if (!session) return; diff --git a/include/call.h b/include/call.h index 197ac0d10..94ebcc1ca 100644 --- a/include/call.h +++ b/include/call.h @@ -506,6 +506,7 @@ struct call_monologue { char *sdp_session_name; struct ssrc_hash *ssrc_hash; str metadata; + struct janus_session *janus_session; // DTMF blocking/replacement stuff: enum block_dtmf_mode block_dtmf; @@ -633,7 +634,6 @@ struct call { GQueue endpoint_maps; struct dtls_cert *dtls_cert; /* for outgoing */ struct mqtt_timer *mqtt_timer; - struct janus_session *janus_session; str callid; struct timeval created;