Skip to content

Commit

Permalink
remove OnIceComplete from cgo since it's deprecating in native land, …
Browse files Browse the repository at this point in the history
…but maintain for the Go interface (issue #5)
  • Loading branch information
keroserene committed Dec 28, 2015
1 parent d827de7 commit 065ca21
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
6 changes: 0 additions & 6 deletions cpeerconnection.cc
Expand Up @@ -121,12 +121,6 @@ class Peer
cgoOnIceCandidate(goPeerConnection, cgoIC);
}

// TODO: OnIceComplete is actually being deprecated in native code.
// Should switch to OnIceGatheringState.
void OnIceComplete() {
cgoOnIceComplete(goPeerConnection);
}

void OnIceConnectionChange(
PeerConnectionInterface::IceConnectionState new_state) {
// TODO: This may need to be slightly more complicated...
Expand Down
8 changes: 8 additions & 0 deletions demo/chat/chat.go
Expand Up @@ -218,6 +218,14 @@ func start(instigator bool) {
sdp := pc.LocalDescription().Serialize()
signalSend(sdp)
}
/*
pc.OnIceGatheringStateChange = func(state webrtc.IceGatheringState) {
fmt.Println("Ice Gathering State:", webrtc.IceGatheringStateString[state])
if webrtc.IceGatheringStateComplete == state {
// send local description.
}
}
*/
// A DataChannel is generated through this callback only when the remote peer
// has initiated the creation of the data channel.
pc.OnDataChannel = func(channel *data.Channel) {
Expand Down
15 changes: 5 additions & 10 deletions webrtc.go
Expand Up @@ -49,7 +49,6 @@ import (
func init() {
SetLoggingVerbosity(3) // Default verbosity.
}

type (
PeerConnectionState int
IceGatheringState int
Expand Down Expand Up @@ -336,15 +335,6 @@ func cgoOnIceCandidate(p unsafe.Pointer, cIC C.CGO_IceCandidate) {
}
}

//export cgoOnIceComplete
func cgoOnIceComplete(p unsafe.Pointer) {
INFO.Println("fired OnIceComplete: ", p)
pc := (*PeerConnection)(p)
if nil != pc.OnIceComplete {
pc.OnIceComplete()
}
}

//export cgoOnConnectionStateChange
func cgoOnConnectionStateChange(p unsafe.Pointer, state PeerConnectionState) {
INFO.Println("fired OnConnectionStateChange: ", p)
Expand All @@ -361,6 +351,11 @@ func cgoOnIceGatheringStateChange(p unsafe.Pointer, state IceGatheringState) {
if nil != pc.OnIceGatheringStateChange {
pc.OnIceGatheringStateChange(state)
}
// Although OnIceComplete is to be deprecated in the native API, and no longer
// part of the w3 spec, keeping it for go seems easier for the users.
if IceGatheringStateComplete == state && nil != pc.OnIceComplete {
pc.OnIceComplete()
}
}

//export cgoOnDataChannel
Expand Down

0 comments on commit 065ca21

Please sign in to comment.