diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index c1760c548..3f4212a9d 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -1214,16 +1214,7 @@ static const char *call_offer_answer_ng(bencode_item_t *input, * call in memory and recreates an OWN call in redis */ // SDP fragments for trickle ICE must always operate on an existing call if (opmode == OP_OFFER && !flags.fragment) { - if (call) { - if (IS_FOREIGN_CALL(call)) { - /* destroy call and create new one */ - rwlock_unlock_w(&call->master_lock); - call_destroy(call); - obj_put(call); - call = call_get_or_create(&flags.call_id, 0); - } - } - else { + if (!call) { /* call == NULL, should create call */ call = call_get_or_create(&flags.call_id, 0); } @@ -1233,6 +1224,9 @@ static const char *call_offer_answer_ng(bencode_item_t *input, if (!call) goto out; + if (IS_FOREIGN_CALL(call)) + call_make_own_foreign(call, 0); + if (!call->created_from && addr) { call->created_from = call_strdup(call, addr); call->created_from_addr = sin->address; diff --git a/daemon/media_socket.c b/daemon/media_socket.c index a2367da35..d1730c198 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -1876,6 +1876,8 @@ static int stream_packet(struct packet_handler_ctx *phc) { } #endif + if (IS_FOREIGN_CALL(phc->mp.call)) + call_make_own_foreign(phc->mp.call, 0); // this sets rtcp, in_srtp, out_srtp, and sink media_packet_rtcp_demux(phc);