File tree 3 files changed +32
-10
lines changed
android/src/main/java/com/cloudwebrtc/webrtc
3 files changed +32
-10
lines changed Original file line number Diff line number Diff line change @@ -498,16 +498,16 @@ public void onSignalingChange(PeerConnection.SignalingState signalingState) {
498
498
sendEvent (params );
499
499
}
500
500
501
- @ Override
502
- public void onConnectionChange (PeerConnection .PeerConnectionState connectionState ) {
503
- Log .d (TAG , "onConnectionChange" + connectionState .name ());
504
- ConstraintsMap params = new ConstraintsMap ();
505
- params .putString ("event" , "peerConnectionState" );
506
- params .putString ("state" , connectionStateString (connectionState ));
507
- sendEvent (params );
508
- }
501
+ @ Override
502
+ public void onConnectionChange (PeerConnection .PeerConnectionState connectionState ) {
503
+ Log .d (TAG , "onConnectionChange" + connectionState .name ());
504
+ ConstraintsMap params = new ConstraintsMap ();
505
+ params .putString ("event" , "peerConnectionState" );
506
+ params .putString ("state" , connectionStateString (connectionState ));
507
+ sendEvent (params );
508
+ }
509
509
510
- @ Nullable
510
+ @ Nullable
511
511
private String iceConnectionStateString (PeerConnection .IceConnectionState iceConnectionState ) {
512
512
switch (iceConnectionState ) {
513
513
case NEW :
Original file line number Diff line number Diff line change @@ -253,6 +253,17 @@ - (NSString *)stringForSignalingState:(RTCSignalingState)state {
253
253
return nil ;
254
254
}
255
255
256
+ - (NSString *)stringForPeerConnectionState : (RTCPeerConnectionState)state {
257
+ switch (state) {
258
+ case RTCPeerConnectionStateNew: return @" new" ;
259
+ case RTCPeerConnectionStateConnecting: return @" connecting" ;
260
+ case RTCPeerConnectionStateConnected: return @" connected" ;
261
+ case RTCPeerConnectionStateDisconnected: return @" disconnected" ;
262
+ case RTCPeerConnectionStateFailed: return @" failed" ;
263
+ case RTCPeerConnectionStateClosed: return @" closed" ;
264
+ }
265
+ return nil ;
266
+ }
256
267
257
268
/* *
258
269
* Parses the constraint keys and values of a specific JavaScript object into
@@ -493,7 +504,13 @@ - (void)peerConnection:(RTCPeerConnection*)peerConnection didOpenDataChannel:(RT
493
504
/* * Called any time the PeerConnectionState changes. */
494
505
- (void )peerConnection : (RTCPeerConnection *)peerConnection
495
506
didChangeConnectionState : (RTCPeerConnectionState)newState {
496
-
507
+ FlutterEventSink eventSink = peerConnection.eventSink ;
508
+ if (eventSink){
509
+ eventSink (@{
510
+ @" event" : @" peerConnectionState" ,
511
+ @" state" : [self stringForPeerConnectionState: newState]
512
+ });
513
+ }
497
514
}
498
515
499
516
- (void )peerConnection : (RTCPeerConnection *)peerConnection
Original file line number Diff line number Diff line change @@ -70,6 +70,10 @@ class _MyAppState extends State<LoopBackSample> {
70
70
print (state);
71
71
}
72
72
73
+ void _onPeerConnectionState (RTCPeerConnectionState state) {
74
+ print (state);
75
+ }
76
+
73
77
void _onAddStream (MediaStream stream) {
74
78
print ('New stream: ' + stream.id);
75
79
//_remoteRenderer.srcObject = stream;
@@ -143,6 +147,7 @@ class _MyAppState extends State<LoopBackSample> {
143
147
_peerConnection.onSignalingState = _onSignalingState;
144
148
_peerConnection.onIceGatheringState = _onIceGatheringState;
145
149
_peerConnection.onIceConnectionState = _onIceConnectionState;
150
+ _peerConnection.onConnectionState = _onPeerConnectionState;
146
151
_peerConnection.onAddStream = _onAddStream;
147
152
_peerConnection.onRemoveStream = _onRemoveStream;
148
153
_peerConnection.onIceCandidate = _onCandidate;
You can’t perform that action at this time.
0 commit comments