@@ -11,6 +11,7 @@ var AccessController = require('./accessController');
11
11
var RoomController = require ( './roomController' ) ;
12
12
var dataAccess = require ( './data_access' ) ;
13
13
var Participant = require ( './participant' ) ;
14
+ const { QuicController } = require ( './quicController' ) ;
14
15
15
16
// Logger
16
17
var log = logger . getLogger ( 'Conference' ) ;
@@ -101,6 +102,7 @@ var Conference = function (rpcClient, selfRpcId) {
101
102
accessController ;
102
103
103
104
var rtcController ;
105
+ let quicController ;
104
106
105
107
/*
106
108
* {
@@ -412,6 +414,25 @@ var Conference = function (rpcClient, selfRpcId) {
412
414
onSessionAborted ( data . owner , sessionId , data . direction , data . reason ) ;
413
415
} ) ;
414
416
417
+ quicController = new QuicController ( room_id , rpcReq , selfRpcId , global . config . clusterName || 'owt-cluster' ) ;
418
+ quicController . on ( 'session-established' , ( sessionInfo ) => {
419
+ const sessionId = sessionInfo . id ;
420
+ const media = { tracks : sessionInfo . tracks } ;
421
+ let direction = sessionInfo . direction ;
422
+ const transport = sessionInfo . transport ;
423
+ const conferenceSessionInfo = {
424
+ locality : transport . locality ,
425
+ media : media ,
426
+ data : sessionInfo . data ,
427
+ info : { type : 'quic' , owner : transport . owner }
428
+ } ;
429
+ onSessionEstablished ( transport . owner , sessionId , direction , conferenceSessionInfo ) ;
430
+ } ) ;
431
+
432
+ quicController . on ( 'session-aborted' , ( sessionId , data ) => {
433
+ onSessionAborted ( data . owner , sessionId , data . direction , data . reason ) ;
434
+ } ) ;
435
+
415
436
accessController = AccessController . create ( { clusterName : global . config . cluster . name || 'owt-cluster' ,
416
437
selfRpcId : selfRpcId ,
417
438
inRoom : room_id ,
@@ -421,7 +442,8 @@ var Conference = function (rpcClient, selfRpcId) {
421
442
onSessionEstablished ,
422
443
onSessionAborted ,
423
444
onLocalSessionSignaling ,
424
- rtcController ) ;
445
+ rtcController ,
446
+ quicController ) ;
425
447
resolve ( 'ok' ) ;
426
448
} ,
427
449
function onError ( reason ) {
@@ -463,9 +485,13 @@ var Conference = function (rpcClient, selfRpcId) {
463
485
if ( pid !== 'admin' && rtcController ) {
464
486
pl . push ( rtcController . terminateByOwner ( pid ) ) ;
465
487
}
488
+ if ( pid != 'admin' && quicController ) {
489
+ pl . push ( quicController . terminateByOwner ( pid ) ) ;
490
+ }
466
491
}
467
492
accessController && pl . push ( accessController . participantLeave ( 'admin' ) ) ;
468
493
rtcController && pl . push ( rtcController . terminateByOwner ( 'admin' ) ) ;
494
+ quicController && pl . push ( quicController . terminateByOwner ( 'admin' ) ) ;
469
495
470
496
return Promise . all ( pl )
471
497
. then ( ( ) => {
@@ -918,14 +944,14 @@ var Conference = function (rpcClient, selfRpcId) {
918
944
}
919
945
920
946
return accessController . participantLeave ( participantId )
921
- . then ( ( ) => rtcController . terminateByOwner ( participantId ) )
922
- . then ( ( ) => removeParticipant ( participantId ) )
923
- . then ( ( result ) => {
947
+ . then ( ( ) => {
948
+ rtcController . terminateByOwner ( participantId ) ;
949
+ quicController . terminateByOwner ( participantId ) ;
950
+ } )
951
+ . then ( ( ) => removeParticipant ( participantId ) )
952
+ . then ( ( result ) => {
924
953
callback ( 'callback' , 'ok' ) ;
925
- selfClean ( ) ;
926
- } , ( e ) => {
927
- callback ( 'callback' , 'error' , e . message ? e . message : e ) ;
928
- } ) ;
954
+ selfClean ( ) ; } , ( e ) => { callback ( 'callback' , 'error' , e . message ? e . message : e ) ; } ) ;
929
955
} ;
930
956
931
957
that . onSessionSignaling = function ( sessionId , signaling , callback ) {
@@ -964,7 +990,7 @@ var Conference = function (rpcClient, selfRpcId) {
964
990
type : subDesc . type ,
965
991
transport : subDesc . transport ,
966
992
transportId : subDesc . transport . id ,
967
- tracks : subDesc . media . tracks ,
993
+ tracks : subDesc . media ? subDesc . media . tracks : undefined ,
968
994
data : subDesc . data ,
969
995
legacy : subDesc . legacy ,
970
996
} ;
@@ -1038,22 +1064,23 @@ var Conference = function (rpcClient, selfRpcId) {
1038
1064
var origin = participants [ participantId ] . getOrigin ( ) ;
1039
1065
var format_preference ;
1040
1066
if ( pubInfo . type === 'webrtc' || pubInfo . type === 'quic' ) {
1041
- const rtcPubInfo = translateRtcPubIfNeeded ( pubInfo ) ;
1042
- if ( rtcPubInfo . tracks ) {
1043
- // Set formatPreference
1044
- rtcPubInfo . tracks . forEach ( track => {
1045
- track . formatPreference = { optional : room_config . mediaIn [ track . type ] } ;
1046
- } ) ;
1047
- }
1048
- initiateStream ( streamId , { owner : participantId , type : pubInfo . type , origin} ) ;
1049
- return rtcController . initiate ( participantId , streamId , 'in' , participants [ participantId ] . getOrigin ( ) , rtcPubInfo )
1050
- . then ( ( result ) => {
1051
- callback ( 'callback' , result ) ;
1052
- } )
1053
- . catch ( ( e ) => {
1054
- removeStream ( streamId ) ;
1055
- callback ( 'callback' , 'error' , e . message ? e . message : e ) ;
1056
- } ) ;
1067
+ const controller = pubInfo . type === 'webrtc' ? rtcController : quicController ;
1068
+ const rtcPubInfo = translateRtcPubIfNeeded ( pubInfo ) ;
1069
+ if ( rtcPubInfo . tracks ) {
1070
+ // Set formatPreference
1071
+ rtcPubInfo . tracks . forEach ( track => {
1072
+ track . formatPreference = { optional : room_config . mediaIn [ track . type ] } ;
1073
+ } ) ;
1074
+ }
1075
+ initiateStream ( streamId , { owner : participantId , type : pubInfo . type , origin } ) ;
1076
+ return controller . initiate ( participantId , streamId , 'in' , participants [ participantId ] . getOrigin ( ) , rtcPubInfo )
1077
+ . then ( ( result ) => {
1078
+ callback ( 'callback' , result ) ;
1079
+ } )
1080
+ . catch ( ( e ) => {
1081
+ removeStream ( streamId ) ;
1082
+ callback ( 'callback' , 'error' , e . message ? e . message : e ) ;
1083
+ } ) ;
1057
1084
}
1058
1085
1059
1086
initiateStream ( streamId , { owner : participantId , type : pubInfo . type , origin} ) ;
@@ -1241,7 +1268,7 @@ var Conference = function (rpcClient, selfRpcId) {
1241
1268
if ( subDesc . type === 'webrtc' ) {
1242
1269
audioTrack = subDesc . media . tracks . find ( t => t . type === 'audio' ) ;
1243
1270
videoTrack = subDesc . media . tracks . find ( t => t . type === 'video' ) ;
1244
- } else {
1271
+ } else if ( subDesc . media ) {
1245
1272
audioTrack = subDesc . media . audio ;
1246
1273
videoTrack = subDesc . media . video ;
1247
1274
}
@@ -1275,6 +1302,7 @@ var Conference = function (rpcClient, selfRpcId) {
1275
1302
} else {
1276
1303
var format_preference ;
1277
1304
if ( subDesc . type === 'webrtc' || subDesc . type === 'quic' ) {
1305
+ const controller = subDesc . type === 'webrtc' ? rtcController : quicController ;
1278
1306
const rtcSubInfo = translateRtcSubIfNeeded ( subDesc ) ;
1279
1307
if ( rtcSubInfo . tracks ) {
1280
1308
// Set formatPreference
@@ -1294,14 +1322,14 @@ var Conference = function (rpcClient, selfRpcId) {
1294
1322
}
1295
1323
1296
1324
initiateSubscription ( subscriptionId , subDesc , { owner : participantId , type : subDesc . type } ) ;
1297
- return rtcController . initiate ( participantId , subscriptionId , 'out' , participants [ participantId ] . getOrigin ( ) , rtcSubInfo )
1325
+ return controller . initiate ( participantId , subscriptionId , 'out' , participants [ participantId ] . getOrigin ( ) , rtcSubInfo )
1298
1326
. then ( ( result ) => {
1299
1327
const releasedSource = rtcSubInfo . tracks ? rtcSubInfo . tracks . find ( track => {
1300
1328
const sourceStreamId = trackOwners [ track . from ] || track . from ;
1301
1329
return ! streams [ sourceStreamId ] ;
1302
1330
} ) : undefined ;
1303
1331
if ( releasedSource ) {
1304
- rtcController . terminate ( participantId , subscriptionId , 'Participant terminate' ) ;
1332
+ controller . terminate ( participantId , subscriptionId , 'Participant terminate' ) ;
1305
1333
return Promise . reject ( 'Target audio/video stream early released' ) ;
1306
1334
}
1307
1335
callback ( 'callback' , result ) ;
@@ -1766,7 +1794,7 @@ var Conference = function (rpcClient, selfRpcId) {
1766
1794
that . onSessionProgress = function ( sessionId , direction , sessionStatus ) {
1767
1795
log . debug ( 'onSessionProgress, sessionId:' , sessionId , 'direction:' , direction , 'sessionStatus:' , sessionStatus ) ;
1768
1796
if ( sessionStatus . data ) {
1769
- rtcController . onSessionProgress ( sessionId , sessionStatus ) ;
1797
+ quicController && quicController . onSessionProgress ( sessionId , sessionStatus ) ;
1770
1798
} else {
1771
1799
accessController && accessController . onSessionStatus ( sessionId , sessionStatus ) ;
1772
1800
}
@@ -2627,6 +2655,8 @@ var Conference = function (rpcClient, selfRpcId) {
2627
2655
dropParticipants ( message . id ) ;
2628
2656
} else if ( message . purpose === 'webrtc' ) {
2629
2657
rtcController && rtcController . terminateByLocality ( message . type , message . id ) ;
2658
+ } else if ( message . purpose === 'quic' ) {
2659
+ quicController && quicController . terminateByLocality ( message . type , message . id ) ;
2630
2660
} else if ( message . purpose === 'recording' ||
2631
2661
message . purpose === 'streaming' ||
2632
2662
message . purpose === 'analytics' ) {
0 commit comments