@@ -28,6 +28,7 @@ const {
28
28
const {
29
29
ForwardStream,
30
30
MixedStream,
31
+ SelectedStream,
31
32
StreamConfigure,
32
33
} = require ( './stream' ) ;
33
34
@@ -356,15 +357,24 @@ var Conference = function (rpcClient, selfRpcId) {
356
357
room_id = roomId ;
357
358
is_initializing = false ;
358
359
359
- room_config . views . forEach ( ( viewSettings ) => {
360
- var mixed_stream_id = room_id + '-' + viewSettings . label ;
361
- var mixed_stream_info = new MixedStream ( mixed_stream_id , viewSettings . label ) ;
360
+ roomController . getMixedStreams ( ) . forEach ( ( { streamId, view} ) => {
361
+ const mixedStreamInfo = new MixedStream ( streamId , view ) ;
362
+ streams [ streamId ] = mixedStreamInfo ;
363
+ streams [ streamId ] . info . origin = origin ;
364
+ log . debug ( 'Mixed stream info:' , mixedStreamInfo ) ;
365
+ room_config . notifying . streamChange &&
366
+ sendMsg ( 'room' , 'all' , 'stream' ,
367
+ { id : streamId , status : 'add' , data : mixedStreamInfo . toPortalFormat ( ) } ) ;
368
+ } ) ;
362
369
363
- streams [ mixed_stream_id ] = mixed_stream_info ;
364
- streams [ mixed_stream_id ] . info . origin = origin ;
365
- log . debug ( 'Mixed stream info:' , mixed_stream_info ) ;
370
+ roomController . getActiveAudioStreams ( ) . forEach ( ( streamId ) => {
371
+ const selectedStreamInfo = new SelectedStream ( streamId ) ;
372
+ streams [ streamId ] = selectedStreamInfo ;
373
+ streams [ streamId ] . info . origin = origin ;
374
+ log . debug ( 'Selected stream info:' , selectedStreamInfo ) ;
366
375
room_config . notifying . streamChange &&
367
- sendMsg ( 'room' , 'all' , 'stream' , { id : mixed_stream_id , status : 'add' , data : mixed_stream_info . toPortalFormat ( ) } ) ;
376
+ sendMsg ( 'room' , 'all' , 'stream' ,
377
+ { id : streamId , status : 'add' , data : selectedStreamInfo . toPortalFormat ( ) } ) ;
368
378
} ) ;
369
379
370
380
participants [ 'admin' ] = Participant ( {
@@ -639,6 +649,15 @@ var Conference = function (rpcClient, selfRpcId) {
639
649
streams [ id ] = fwdStream ;
640
650
pubArgs . forEach ( pubArg => {
641
651
trackOwners [ pubArg . id ] = id ;
652
+ if ( room_config . selectActiveAudio ) {
653
+ if ( pubArg . media . audio ) {
654
+ roomController . selectAudio ( pubArg . id , ( ) => {
655
+ log . debug ( 'Select active audio ok:' , pubArg . id ) ;
656
+ } , ( err ) => {
657
+ log . info ( 'Select active audio error:' , pubArg . id , err ) ;
658
+ } ) ;
659
+ }
660
+ }
642
661
} ) ;
643
662
if ( ! isReadded ) {
644
663
setTimeout ( ( ) => {
@@ -1845,28 +1864,44 @@ var Conference = function (rpcClient, selfRpcId) {
1845
1864
}
1846
1865
} ;
1847
1866
1848
- that . onAudioActiveness = function ( roomId , activeInputStream , view , callback ) {
1849
- log . debug ( 'onAudioActiveness, roomId:' , roomId , 'activeInputStream:' , activeInputStream , 'view :' , view ) ;
1867
+ that . onAudioActiveness = function ( roomId , activeInputStream , target , callback ) {
1868
+ log . debug ( 'onAudioActiveness, roomId:' , roomId , 'activeInputStream:' , activeInputStream , 'target :' , target ) ;
1850
1869
if ( ( room_id === roomId ) && roomController ) {
1851
- room_config . views . forEach ( ( viewSettings ) => {
1852
- if ( viewSettings . label === view && viewSettings . video . keepActiveInputPrimary ) {
1853
- roomController . setPrimary ( activeInputStream , view ) ;
1854
- }
1855
- } ) ;
1870
+ if ( typeof target . view === 'string' ) {
1871
+ const view = target . view ;
1872
+ room_config . views . forEach ( ( viewSettings ) => {
1873
+ if ( viewSettings . label === view && viewSettings . video . keepActiveInputPrimary ) {
1874
+ roomController . setPrimary ( activeInputStream , view ) ;
1875
+ }
1876
+ } ) ;
1856
1877
1857
- var input = streams [ activeInputStream ] ? activeInputStream : trackOwners [ activeInputStream ] ;
1858
- if ( input && streams [ input ] ) {
1859
- for ( var id in streams ) {
1860
- if ( streams [ id ] . type === 'mixed' && streams [ id ] . info . label === view ) {
1861
- if ( streams [ id ] . info . activeInput !== input ) {
1862
- streams [ id ] . info . activeInput = input ;
1863
- room_config . notifying . streamChange && sendMsg ( 'room' , 'all' , 'stream' , { id : id , status : 'update' , data : { field : 'activeInput' , value : input } } ) ;
1864
- }
1865
- break ;
1878
+ const input = streams [ activeInputStream ] ?
1879
+ activeInputStream : trackOwners [ activeInputStream ] ;
1880
+ const mixedId = roomController . getMixedStream ( view ) ;
1881
+ if ( streams [ mixedId ] instanceof MixedStream ) {
1882
+ if ( streams [ mixedId ] . info . activeInput !== input ) {
1883
+ streams [ mixedId ] . info . activeInput = input ;
1884
+ room_config . notifying . streamChange &&
1885
+ sendMsg ( 'room' , 'all' , 'stream' ,
1886
+ { id : mixedId , status : 'update' , data : { field : 'activeInput' , value : input } } ) ;
1887
+ }
1888
+ }
1889
+ callback ( 'callback' , 'ok' ) ;
1890
+ } else {
1891
+ const input = streams [ activeInputStream ] ?
1892
+ activeInputStream : trackOwners [ activeInputStream ] ;
1893
+ const activeAudioId = target . id ;
1894
+ if ( streams [ activeAudioId ] instanceof SelectedStream ) {
1895
+ if ( streams [ activeAudioId ] . info . activeInput !== input ) {
1896
+ streams [ activeAudioId ] . info . activeInput = input ;
1897
+ streams [ activeAudioId ] . info . owner = target . owner ;
1898
+ room_config . notifying . streamChange &&
1899
+ sendMsg ( 'room' , 'all' , 'stream' ,
1900
+ { id : activeAudioId , status : 'update' , data : { field : 'activeInput' , value : input } } ) ;
1866
1901
}
1867
1902
}
1903
+ callback ( 'callback' , 'ok' ) ;
1868
1904
}
1869
- callback ( 'callback' , 'ok' ) ;
1870
1905
} else {
1871
1906
log . info ( 'onAudioActiveness, room does not exist' ) ;
1872
1907
callback ( 'callback' , 'error' , 'room is not in service' ) ;
0 commit comments