@@ -197,7 +197,7 @@ public class CustomTwilioVideoView extends View implements LifecycleEventListene
197
197
private IntentFilter intentFilter ;
198
198
private BecomingNoisyReceiver myNoisyAudioStreamReceiver ;
199
199
200
- // Dedicated thread and handler for messages received from a RemoteDataTrack
200
+ // Dedicated thread and handler for messages received from a RemoteDataTrack
201
201
private final HandlerThread dataTrackMessageThread =
202
202
new HandlerThread (DATA_TRACK_MESSAGE_THREAD_NAME );
203
203
private Handler dataTrackMessageThreadHandler ;
@@ -230,10 +230,10 @@ public CustomTwilioVideoView(ThemedReactContext context) {
230
230
intentFilter = new IntentFilter (Intent .ACTION_HEADSET_PLUG );
231
231
232
232
// Create the local data track
233
- // localDataTrack = LocalDataTrack.create(this);
234
- localDataTrack = LocalDataTrack .create (getContext ());
233
+ // localDataTrack = LocalDataTrack.create(this);
234
+ localDataTrack = LocalDataTrack .create (getContext ());
235
235
236
- // Start the thread where data messages are received
236
+ // Start the thread where data messages are received
237
237
dataTrackMessageThread .start ();
238
238
dataTrackMessageThreadHandler = new Handler (dataTrackMessageThread .getLooper ());
239
239
@@ -433,7 +433,7 @@ public void connectToRoomWrapper(
433
433
boolean dominantSpeakerEnabled ,
434
434
boolean maintainVideoTrackInBackground ,
435
435
String cameraType
436
- ) {
436
+ ) {
437
437
this .roomName = roomName ;
438
438
this .accessToken = accessToken ;
439
439
this .enableRemoteAudio = enableRemoteAudio ;
@@ -451,7 +451,7 @@ public void connectToRoomWrapper(
451
451
Log .d ("RNTwilioVideo" , "Failed to create local video" );
452
452
// No need to connect to room if video creation failed
453
453
return ;
454
- }
454
+ }
455
455
} else {
456
456
isVideoEnabled = false ;
457
457
}
@@ -480,18 +480,18 @@ public void connectToRoom() {
480
480
481
481
//LocalDataTrack localDataTrack = LocalDataTrack.create(getContext());
482
482
483
- if (localDataTrack != null ) {
483
+ if (localDataTrack != null ) {
484
484
connectOptionsBuilder .dataTracks (Collections .singletonList (localDataTrack ));
485
485
}
486
486
487
487
connectOptionsBuilder .enableDominantSpeaker (this .dominantSpeakerEnabled );
488
488
489
- if (enableNetworkQualityReporting ) {
490
- connectOptionsBuilder .enableNetworkQuality (true );
491
- connectOptionsBuilder .networkQualityConfiguration (new NetworkQualityConfiguration (
492
- NetworkQualityVerbosity .NETWORK_QUALITY_VERBOSITY_MINIMAL ,
493
- NetworkQualityVerbosity .NETWORK_QUALITY_VERBOSITY_MINIMAL ));
494
- }
489
+ if (enableNetworkQualityReporting ) {
490
+ connectOptionsBuilder .enableNetworkQuality (true );
491
+ connectOptionsBuilder .networkQualityConfiguration (new NetworkQualityConfiguration (
492
+ NetworkQualityVerbosity .NETWORK_QUALITY_VERBOSITY_MINIMAL ,
493
+ NetworkQualityVerbosity .NETWORK_QUALITY_VERBOSITY_MINIMAL ));
494
+ }
495
495
496
496
room = Video .connect (getContext (), connectOptionsBuilder .build (), roomListener ());
497
497
}
@@ -586,10 +586,10 @@ public void disconnect() {
586
586
587
587
// ===== SEND STRING ON DATA TRACK ======================================================================
588
588
public void sendString (String message ) {
589
- if (localDataTrack != null ) {
590
- localDataTrack .send (message );
591
- }
589
+ if (localDataTrack != null ) {
590
+ localDataTrack .send (message );
592
591
}
592
+ }
593
593
594
594
private static boolean isCurrentCameraSourceBackFacing () {
595
595
return cameraCapturer != null && cameraCapturer .getCameraId () == backFacingDevice ;
@@ -619,7 +619,7 @@ public void switchCamera() {
619
619
}
620
620
621
621
public void toggleVideo (boolean enabled ) {
622
- isVideoEnabled = enabled ;
622
+ isVideoEnabled = enabled ;
623
623
624
624
if (cameraCapturer == null && enabled ) {
625
625
String fallbackCameraType = cameraType == null ? CustomTwilioVideoView .FRONT_CAMERA_TYPE : cameraType ;
@@ -640,13 +640,13 @@ public void toggleVideo(boolean enabled) {
640
640
}
641
641
}
642
642
643
- public void toggleSoundSetup (boolean speaker ){
644
- AudioManager audioManager = (AudioManager ) getContext ().getSystemService (Context .AUDIO_SERVICE );
645
- if (speaker ){
646
- audioManager .setSpeakerphoneOn (true );
647
- } else {
648
- audioManager .setSpeakerphoneOn (false );
649
- }
643
+ public void toggleSoundSetup (boolean speaker ) {
644
+ AudioManager audioManager = (AudioManager ) getContext ().getSystemService (Context .AUDIO_SERVICE );
645
+ if (speaker ) {
646
+ audioManager .setSpeakerphoneOn (true );
647
+ } else {
648
+ audioManager .setSpeakerphoneOn (false );
649
+ }
650
650
}
651
651
652
652
public void toggleAudio (boolean enabled ) {
@@ -661,7 +661,7 @@ public void toggleAudio(boolean enabled) {
661
661
662
662
public void toggleBluetoothHeadset (boolean enabled ) {
663
663
AudioManager audioManager = (AudioManager ) getContext ().getSystemService (Context .AUDIO_SERVICE );
664
- if (enabled ){
664
+ if (enabled ) {
665
665
audioManager .startBluetoothSco ();
666
666
} else {
667
667
audioManager .stopBluetoothSco ();
@@ -671,9 +671,9 @@ public void toggleBluetoothHeadset(boolean enabled) {
671
671
public void toggleRemoteAudio (boolean enabled ) {
672
672
if (room != null ) {
673
673
for (RemoteParticipant rp : room .getRemoteParticipants ()) {
674
- for (AudioTrackPublication at : rp .getAudioTracks ()) {
675
- if (at .getAudioTrack () != null ) {
676
- ((RemoteAudioTrack )at .getAudioTrack ()).enablePlayback (enabled );
674
+ for (AudioTrackPublication at : rp .getAudioTracks ()) {
675
+ if (at .getAudioTrack () != null ) {
676
+ ((RemoteAudioTrack ) at .getAudioTrack ()).enablePlayback (enabled );
677
677
}
678
678
}
679
679
}
@@ -865,12 +865,12 @@ public void onDisconnected(Room room, TwilioException e) {
865
865
WritableMap event = new WritableNativeMap ();
866
866
867
867
if (localParticipant != null ) {
868
- event .putString ("participant" , localParticipant .getIdentity ());
868
+ event .putString ("participant" , localParticipant .getIdentity ());
869
869
}
870
870
event .putString ("roomName" , room .getName ());
871
871
event .putString ("roomSid" , room .getSid ());
872
872
if (e != null ) {
873
- event .putString ("error" , e .getMessage ());
873
+ event .putString ("error" , e .getMessage ());
874
874
}
875
875
pushEvent (CustomTwilioVideoView .this , ON_DISCONNECTED , event );
876
876
@@ -941,16 +941,16 @@ private void addParticipant(Room room, RemoteParticipant remoteParticipant) {
941
941
remoteParticipant .setListener (mediaListener ());
942
942
943
943
for (final RemoteDataTrackPublication remoteDataTrackPublication :
944
- remoteParticipant .getRemoteDataTracks ()) {
945
- /*
946
- * Data track messages are received on the thread that calls setListener. Post the
947
- * invocation of setting the listener onto our dedicated data track message thread.
948
- */
949
- if (remoteDataTrackPublication .isTrackSubscribed ()) {
950
- dataTrackMessageThreadHandler .post (() -> addRemoteDataTrack (remoteParticipant ,
951
- remoteDataTrackPublication .getRemoteDataTrack ()));
952
- }
953
- }
944
+ remoteParticipant .getRemoteDataTracks ()) {
945
+ /*
946
+ * Data track messages are received on the thread that calls setListener. Post the
947
+ * invocation of setting the listener onto our dedicated data track message thread.
948
+ */
949
+ if (remoteDataTrackPublication .isTrackSubscribed ()) {
950
+ dataTrackMessageThreadHandler .post (() -> addRemoteDataTrack (remoteParticipant ,
951
+ remoteDataTrackPublication .getRemoteDataTrack ()));
952
+ }
953
+ }
954
954
}
955
955
956
956
/*
@@ -977,15 +977,15 @@ private RemoteParticipant.Listener mediaListener() {
977
977
return new RemoteParticipant .Listener () {
978
978
@ Override
979
979
public void onAudioTrackSubscribed (RemoteParticipant participant , RemoteAudioTrackPublication publication , RemoteAudioTrack audioTrack ) {
980
- audioTrack .enablePlayback (enableRemoteAudio );
981
- WritableMap event = buildParticipantVideoEvent (participant , publication );
982
- pushEvent (CustomTwilioVideoView .this , ON_PARTICIPANT_ADDED_AUDIO_TRACK , event );
980
+ audioTrack .enablePlayback (enableRemoteAudio );
981
+ WritableMap event = buildParticipantVideoEvent (participant , publication );
982
+ pushEvent (CustomTwilioVideoView .this , ON_PARTICIPANT_ADDED_AUDIO_TRACK , event );
983
983
}
984
984
985
985
@ Override
986
986
public void onAudioTrackUnsubscribed (RemoteParticipant participant , RemoteAudioTrackPublication publication , RemoteAudioTrack audioTrack ) {
987
- WritableMap event = buildParticipantVideoEvent (participant , publication );
988
- pushEvent (CustomTwilioVideoView .this , ON_PARTICIPANT_REMOVED_AUDIO_TRACK , event );
987
+ WritableMap event = buildParticipantVideoEvent (participant , publication );
988
+ pushEvent (CustomTwilioVideoView .this , ON_PARTICIPANT_REMOVED_AUDIO_TRACK , event );
989
989
}
990
990
991
991
@ Override
@@ -1004,15 +1004,15 @@ public void onAudioTrackUnpublished(RemoteParticipant participant, RemoteAudioTr
1004
1004
1005
1005
@ Override
1006
1006
public void onDataTrackSubscribed (RemoteParticipant remoteParticipant , RemoteDataTrackPublication remoteDataTrackPublication , RemoteDataTrack remoteDataTrack ) {
1007
- WritableMap event = buildParticipantDataEvent (remoteParticipant , remoteDataTrackPublication );
1008
- pushEvent (CustomTwilioVideoView .this , ON_PARTICIPANT_ADDED_DATA_TRACK , event );
1009
- dataTrackMessageThreadHandler .post (() -> addRemoteDataTrack (remoteParticipant , remoteDataTrack ));
1007
+ WritableMap event = buildParticipantDataEvent (remoteParticipant , remoteDataTrackPublication );
1008
+ pushEvent (CustomTwilioVideoView .this , ON_PARTICIPANT_ADDED_DATA_TRACK , event );
1009
+ dataTrackMessageThreadHandler .post (() -> addRemoteDataTrack (remoteParticipant , remoteDataTrack ));
1010
1010
}
1011
1011
1012
1012
@ Override
1013
1013
public void onDataTrackUnsubscribed (RemoteParticipant remoteParticipant , RemoteDataTrackPublication remoteDataTrackPublication , RemoteDataTrack remoteDataTrack ) {
1014
- WritableMap event = buildParticipantDataEvent (remoteParticipant , remoteDataTrackPublication );
1015
- pushEvent (CustomTwilioVideoView .this , ON_PARTICIPANT_REMOVED_DATA_TRACK , event );
1014
+ WritableMap event = buildParticipantDataEvent (remoteParticipant , remoteDataTrackPublication );
1015
+ pushEvent (CustomTwilioVideoView .this , ON_PARTICIPANT_REMOVED_DATA_TRACK , event );
1016
1016
}
1017
1017
1018
1018
@ Override
0 commit comments