diff --git a/examples/data-channels/main.go b/examples/data-channels/main.go index f361418a..e64dbc5c 100644 --- a/examples/data-channels/main.go +++ b/examples/data-channels/main.go @@ -61,7 +61,7 @@ func main() { datachannels := make([]*webrtc.RTCDataChannel, 0) var dataChannelsLock sync.RWMutex - peerConnection.Ondatachannel = func(d *webrtc.RTCDataChannel) { + peerConnection.OnDataChannel = func(d *webrtc.RTCDataChannel) { dataChannelsLock.Lock() datachannels = append(datachannels, d) dataChannelsLock.Unlock() diff --git a/examples/gstreamer-receive/main.go b/examples/gstreamer-receive/main.go index 05174dbb..74fda41d 100644 --- a/examples/gstreamer-receive/main.go +++ b/examples/gstreamer-receive/main.go @@ -46,7 +46,7 @@ func main() { // Set a handler for when a new remote track starts, this handler creates a gstreamer pipeline // for the given codec - peerConnection.Ontrack = func(track *webrtc.RTCTrack) { + peerConnection.OnTrack = func(track *webrtc.RTCTrack) { codec := track.Codec fmt.Printf("Track has started, of type %d: %s \n", track.PayloadType, codec.Name) pipeline := gst.CreatePipeline(codec.Name) diff --git a/examples/pion-to-pion/offer/main.go b/examples/pion-to-pion/offer/main.go index 38e9b6fa..23a7c7f4 100644 --- a/examples/pion-to-pion/offer/main.go +++ b/examples/pion-to-pion/offer/main.go @@ -26,7 +26,7 @@ func buildPeerConnection() *webrtc.RTCPeerConnection { fmt.Printf("Connection State has changed %s \n", connectionState.String()) } - peerConnection.Ondatachannel = func(d *webrtc.RTCDataChannel) { + peerConnection.OnDataChannel = func(d *webrtc.RTCDataChannel) { fmt.Printf("New DataChannel %s %d\n", d.Label, d.ID) d.Lock() diff --git a/examples/save-to-disk/main.go b/examples/save-to-disk/main.go index 4b27b52e..dd7d31d8 100644 --- a/examples/save-to-disk/main.go +++ b/examples/save-to-disk/main.go @@ -47,7 +47,7 @@ func main() { // Set a handler for when a new remote track starts, this handler saves buffers to disk as // an ivf file, since we could have multiple video tracks we provide a counter. // In your application this is where you would handle/process video - peerConnection.Ontrack = func(track *webrtc.RTCTrack) { + peerConnection.OnTrack = func(track *webrtc.RTCTrack) { if track.Codec.Name == webrtc.VP8 { fmt.Println("Got VP8 track, saving to disk as output.ivf") i, err := ivfwriter.New("output.ivf") diff --git a/rtcpeerconnection.go b/rtcpeerconnection.go index 969c2a72..cda2a916 100644 --- a/rtcpeerconnection.go +++ b/rtcpeerconnection.go @@ -99,35 +99,17 @@ type RTCPeerConnection struct { // OnIceCandidateError func() // FIXME NOT-USED // OnSignalingStateChange func() // FIXME NOT-USED - // OnICEConnectionStateChange designates an event handler which is called - // when an ice connection state is changed. - // - // Deprecated: use OnIceConnectionStateChange instead. - OnICEConnectionStateChange func(ice.ConnectionState) - // OnIceConnectionStateChange designates an event handler which is called // when an ice connection state is changed. - OnIceConnectionStateChange func(ice.ConnectionState) + OnICEConnectionStateChange func(ice.ConnectionState) // OnIceGatheringStateChange func() // FIXME NOT-USED // OnConnectionStateChange func() // FIXME NOT-USED - // Ontrack designates an event handler which is called when remote track - // arrives from a remote peer. - // - // Deprecated: use OnTrack instead. - Ontrack func(*RTCTrack) - // OnTrack designates an event handler which is called when remote track // arrives from a remote peer. OnTrack func(*RTCTrack) - // Ondatachannel designates an event handler which is invoked when a data - // channel message arrives from a remote peer. - // - // Deprecated: use OnDataChannel instead. - Ondatachannel func(*RTCDataChannel) - // OnDataChannel designates an event handler which is invoked when a data // channel message arrives from a remote peer. OnDataChannel func(*RTCDataChannel) @@ -419,6 +401,7 @@ func (pc *RTCPeerConnection) CreateAnswer(options *RTCAnswerOptions) (RTCSession } } else if strings.HasPrefix(*remoteMedia.MediaName.String(), "application") { pc.addDataMediaSection(d, midValue, candidates, sdp.ConnectionRoleActive) + appendBundle() } } @@ -763,7 +746,7 @@ func (pc *RTCPeerConnection) Close() error { /* Everything below is private */ func (pc *RTCPeerConnection) generateChannel(ssrc uint32, payloadType uint8) (buffers chan<- *rtp.Packet) { - if pc.Ontrack == nil { + if pc.OnTrack == nil { return nil } @@ -792,7 +775,7 @@ func (pc *RTCPeerConnection) generateChannel(ssrc uint32, payloadType uint8) (bu // TODO: Register the receiving Track - go pc.Ontrack(track) + go pc.OnTrack(track) return bufferTransport } @@ -815,10 +798,10 @@ func (pc *RTCPeerConnection) dataChannelEventHandler(e network.DataChannelEvent) id := event.StreamIdentifier() newDataChannel := &RTCDataChannel{ID: &id, Label: event.Label, rtcPeerConnection: pc} pc.dataChannels[e.StreamIdentifier()] = newDataChannel - if pc.Ondatachannel != nil { - go pc.Ondatachannel(newDataChannel) + if pc.OnDataChannel != nil { + go pc.OnDataChannel(newDataChannel) } else { - fmt.Println("Ondatachannel is unset, discarding message") + fmt.Println("OnDataChannel is unset, discarding message") } case *network.DataChannelMessage: if datachannel, ok := pc.dataChannels[e.StreamIdentifier()]; ok {