@@ -1377,6 +1377,19 @@ static void janus_ice_handle_free(const janus_refcount *handle_ref) {
1377
1377
g_free (handle );
1378
1378
}
1379
1379
1380
+ #ifdef HAVE_CLOSE_ASYNC
1381
+ static void janus_ice_cb_agent_closed (GObject * src , GAsyncResult * result , gpointer data ) {
1382
+ janus_ice_outgoing_traffic * t = (janus_ice_outgoing_traffic * )data ;
1383
+ janus_ice_handle * handle = t -> handle ;
1384
+
1385
+ JANUS_LOG (LOG_VERB , "[%" SCNu64 "] Disposing nice agent %p\n" , handle -> handle_id , handle -> agent );
1386
+ g_object_unref (handle -> agent );
1387
+ handle -> agent = NULL ;
1388
+ g_source_unref ((GSource * )t );
1389
+ janus_refcount_decrease (& handle -> ref );
1390
+ }
1391
+ #endif
1392
+
1380
1393
static void janus_ice_plugin_session_free (const janus_refcount * app_handle_ref ) {
1381
1394
janus_plugin_session * app_handle = janus_refcount_containerof (app_handle_ref , janus_plugin_session , ref );
1382
1395
/* This app handle can be destroyed, free all the resources */
@@ -1436,9 +1449,22 @@ static void janus_ice_webrtc_free(janus_ice_handle *handle) {
1436
1449
handle -> stream = NULL ;
1437
1450
}
1438
1451
if (handle -> agent != NULL ) {
1452
+ #ifdef HAVE_CLOSE_ASYNC
1453
+ if (G_IS_OBJECT (handle -> agent )) {
1454
+ JANUS_LOG (LOG_VERB , "[%" SCNu64 "] Removing stream %d from agent %p\n" ,
1455
+ handle -> handle_id , handle -> stream_id , handle -> agent );
1456
+ nice_agent_remove_stream (handle -> agent , handle -> stream_id );
1457
+ handle -> stream_id = 0 ;
1458
+ JANUS_LOG (LOG_VERB , "[%" SCNu64 "] Closing nice agent %p\n" , handle -> handle_id , handle -> agent );
1459
+ janus_refcount_increase (& handle -> ref );
1460
+ g_source_ref (handle -> rtp_source );
1461
+ nice_agent_close_async (handle -> agent , janus_ice_cb_agent_closed , handle -> rtp_source );
1462
+ }
1463
+ #else
1439
1464
if (G_IS_OBJECT (handle -> agent ))
1440
1465
g_object_unref (handle -> agent );
1441
1466
handle -> agent = NULL ;
1467
+ #endif
1442
1468
}
1443
1469
if (handle -> pending_trickles ) {
1444
1470
while (handle -> pending_trickles ) {
0 commit comments