@@ -223,6 +223,7 @@ class Voice {
223
223
( ! this . users . has ( json . d . audio_ssrc ) && json . d . audio_ssrc !== 0 ) ||
224
224
( ! this . vidusers . has ( json . d . video_ssrc ) && json . d . video_ssrc !== 0 )
225
225
) {
226
+ this . sendtosend12 = false ;
226
227
console . log ( "redo 12!" ) ;
227
228
this . makeOp12 ( ) ;
228
229
}
@@ -435,6 +436,7 @@ a=rtcp-mux\r`;
435
436
async makeOp12 (
436
437
sender : RTCRtpSender | undefined | [ RTCRtpSender , number ] = this . ssrcMap . entries ( ) . next ( ) . value ,
437
438
) {
439
+ if ( ! this . ws ) return ;
438
440
if ( ! sender ) throw new Error ( "sender doesn't exist" ) ;
439
441
if ( sender instanceof Array ) {
440
442
sender = sender [ 0 ] ;
@@ -460,33 +462,32 @@ a=rtcp-mux\r`;
460
462
//width = settings.width || 0;
461
463
//height = settings.height || 0;
462
464
}
463
- if ( this . ws ) {
464
- console . log ( this . ssrcMap ) ;
465
- this . ws . send (
466
- JSON . stringify ( {
467
- op : 12 ,
468
- d : {
469
- audio_ssrc : this . ssrcMap . get ( sender ) ,
470
- video_ssrc,
471
- rtx_ssrc,
472
- streams : [
473
- {
474
- type : "video" ,
475
- rid : "100" ,
476
- ssrc : video_ssrc ,
477
- active : ! ! video_ssrc ,
478
- quality : 100 ,
479
- rtx_ssrc : rtx_ssrc ,
480
- max_bitrate : 2500000 , //TODO
481
- max_framerate, //TODO
482
- max_resolution : { type : "fixed" , width, height} ,
483
- } ,
484
- ] ,
485
- } ,
486
- } ) ,
487
- ) ;
488
- this . status = "Sending audio streams" ;
489
- }
465
+
466
+ console . log ( this . ssrcMap ) ;
467
+ this . ws . send (
468
+ JSON . stringify ( {
469
+ op : 12 ,
470
+ d : {
471
+ audio_ssrc : this . ssrcMap . get ( sender ) ,
472
+ video_ssrc,
473
+ rtx_ssrc,
474
+ streams : [
475
+ {
476
+ type : "video" ,
477
+ rid : "100" ,
478
+ ssrc : video_ssrc ,
479
+ active : ! ! video_ssrc ,
480
+ quality : 100 ,
481
+ rtx_ssrc : rtx_ssrc ,
482
+ max_bitrate : 2500000 , //TODO
483
+ max_framerate, //TODO
484
+ max_resolution : { type : "fixed" , width, height} ,
485
+ } ,
486
+ ] ,
487
+ } ,
488
+ } ) ,
489
+ ) ;
490
+ this . status = "Sending audio streams" ;
490
491
}
491
492
senders : Set < RTCRtpSender > = new Set ( ) ;
492
493
recivers = new Set < RTCRtpReceiver > ( ) ;
@@ -586,21 +587,25 @@ a=rtcp-mux\r`;
586
587
this . owner . video = false ;
587
588
if ( ! this . cammera ) return ;
588
589
this . cammera . stop ( ) ;
590
+ this . cammera = undefined ;
591
+
589
592
this . cam . sender . replaceTrack ( null ) ;
593
+ this . cam . direction = "inactive" ;
594
+
595
+ this . pc ?. setLocalDescription ( ) ;
590
596
591
597
this . owner . updateSelf ( ) ;
592
- this . cammera = undefined ;
593
598
594
599
this . videos . delete ( this . userid ) ;
595
600
this . onUserChange ( this . userid , {
596
601
deaf : false ,
597
602
muted : this . owner . mute ,
598
603
video : false ,
599
604
} ) ;
600
-
601
- this . makeOp12 ( ) ;
602
605
}
606
+ videoStarted = false ;
603
607
async startVideo ( caml : MediaStream ) {
608
+ console . warn ( "test test test test video sent!" ) ;
604
609
if ( ! this . cam ) return ;
605
610
const tracks = caml . getVideoTracks ( ) ;
606
611
const [ cam ] = tracks ;
@@ -614,10 +619,10 @@ a=rtcp-mux\r`;
614
619
this . videos . set ( this . userid , video ) ;
615
620
video . srcObject = caml ;
616
621
video . autoplay = true ;
617
- await this . cam . sender . replaceTrack ( cam ) ;
618
-
619
- // await this.pc?.setLocalDescription( );
620
- await this . makeOp12 ( ) ;
622
+ this . cam . direction = "sendonly" ;
623
+ const sender = this . cam . sender ;
624
+ await sender . replaceTrack ( cam ) ;
625
+ this . pc ?. setLocalDescription ( ) ;
621
626
622
627
this . owner . updateSelf ( ) ;
623
628
}
@@ -819,6 +824,7 @@ a=rtcp-mux\r`;
819
824
} ) ,
820
825
) ;
821
826
}
827
+ console . warn ( "done with this!" ) ;
822
828
}
823
829
static parsesdp ( sdp : string ) {
824
830
let currentA = new Map < string , Set < string > > ( ) ;
@@ -877,8 +883,11 @@ a=rtcp-mux\r`;
877
883
const vals = { deaf : update . deaf , muted : update . mute , video : update . self_video } ;
878
884
this . onUserChange ( update . user_id , vals ) ;
879
885
this . userids . set ( update . user_id , vals ) ;
880
-
881
- if ( update . user_id === this . userid && this . open && ! ( this . status === "Done" ) ) {
886
+ if ( update . user_id === this . userid && this . videoStarted !== update . self_video ) {
887
+ this . makeOp12 ( ) ;
888
+ this . videoStarted = update . self_video ;
889
+ }
890
+ if ( update . user_id === this . userid && this . open && ! this . ws ) {
882
891
if ( ! update ) {
883
892
this . status = "bad responce from WS" ;
884
893
return ;
0 commit comments