mirror of
https://github.com/pion/webrtc.git
synced 2025-10-05 07:06:51 +08:00
Fix deprecation cutover, and bad SDP creation
Methods that were marked as deprecated weren't properly handled. There was a mix of old+new ones supported which caused broken behavior. SDP creation didn't add SCTP to Offer Resolves #156
This commit is contained in:
@@ -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()
|
||||
|
@@ -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)
|
||||
|
@@ -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()
|
||||
|
@@ -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")
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user