@@ -84,7 +84,12 @@ namespace python_webrtc {
84
84
.def_property_readonly (" sctp" , &RTCPeerConnection::GetSctp)
85
85
.def (" restartIce" , &RTCPeerConnection::RestartIce)
86
86
.def (" removeTrack" , &RTCPeerConnection::RemoveTrack)
87
- .def (" close" , &RTCPeerConnection::Close);
87
+ .def (" close" , &RTCPeerConnection::Close)
88
+ .def_property_readonly (" connectionState" , &RTCPeerConnection::GetConnectionState);
89
+ // TODO bind enums
90
+ // .def_property_readonly("signalingState", &RTCPeerConnection::GetSignalingState)
91
+ // .def_property_readonly("iceConnectionState", &RTCPeerConnection::GetIceConnectionState)
92
+ // .def_property_readonly("iceGatheringState", &RTCPeerConnection::GetIceGatheringState);
88
93
}
89
94
90
95
void RTCPeerConnection::SaveLastSdp (const RTCSessionDescriptionInit &lastSdp) {
@@ -339,6 +344,38 @@ namespace python_webrtc {
339
344
}
340
345
}
341
346
347
+ webrtc::PeerConnectionInterface::PeerConnectionState RTCPeerConnection::GetConnectionState () {
348
+ if (_jinglePeerConnection) {
349
+ return _jinglePeerConnection->peer_connection_state ();
350
+ } else {
351
+ return webrtc::PeerConnectionInterface::PeerConnectionState::kClosed ;
352
+ }
353
+ }
354
+
355
+ webrtc::PeerConnectionInterface::SignalingState RTCPeerConnection::GetSignalingState () {
356
+ if (_jinglePeerConnection) {
357
+ return _jinglePeerConnection->signaling_state ();
358
+ } else {
359
+ return webrtc::PeerConnectionInterface::SignalingState::kClosed ;
360
+ }
361
+ }
362
+
363
+ webrtc::PeerConnectionInterface::IceConnectionState RTCPeerConnection::GetIceConnectionState () {
364
+ if (_jinglePeerConnection) {
365
+ return _jinglePeerConnection->standardized_ice_connection_state ();
366
+ } else {
367
+ return webrtc::PeerConnectionInterface::IceConnectionState::kIceConnectionClosed ;
368
+ }
369
+ }
370
+
371
+ webrtc::PeerConnectionInterface::IceGatheringState RTCPeerConnection::GetIceGatheringState () {
372
+ if (_jinglePeerConnection) {
373
+ return _jinglePeerConnection->ice_gathering_state ();
374
+ } else {
375
+ return webrtc::PeerConnectionInterface::IceGatheringState::kIceGatheringComplete ;
376
+ }
377
+ }
378
+
342
379
void RTCPeerConnection::OnSignalingChange (webrtc::PeerConnectionInterface::SignalingState new_state) {
343
380
// TODO call python callback
344
381
if (new_state == webrtc::PeerConnectionInterface::kClosed ) {
0 commit comments