Skip to content

Commit

Permalink
Remove RTC prefix from all names
Browse files Browse the repository at this point in the history
Let's pull off the bandaid!

* Reduces studdering: webrtc.RTCTrack -> webrtc.Track
* Makes it easier to find types by editor autocomplete
* Makes code read more fluently (less repetition)

Since we're breaking the API in 2.0, our only chance to
do this is now.

Relates to #408
  • Loading branch information
maxhawkins committed Feb 18, 2019
1 parent b711ec2 commit 0e7086d
Show file tree
Hide file tree
Showing 112 changed files with 2,093 additions and 2,093 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Check out the **[contributing wiki](https://github.com/pions/webrtc/wiki/Contrib
* [Tobias Fridén](https://github.com/tobiasfriden) *SRTP authentication verification*
* [Yutaka Takeda](https://github.com/enobufs) *Fix ICE connection timeout*
* [Hugo Arregui](https://github.com/hugoArregui) *Fix connection timeout*
* [Rob Deutsch](https://github.com/rob-deutsch) *RTCRtpReceiver graceful shutdown*
* [Rob Deutsch](https://github.com/rob-deutsch) *RTPReceiver graceful shutdown*
* [Jin Lei](https://github.com/jinleileiking) - *SFU example use http*

### License
Expand Down
8 changes: 4 additions & 4 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func SetConnectionTimeout(connectionTimeout, keepAlive time.Duration) {

// RegisterCodec on the default API.
// See MediaEngine for details.
func RegisterCodec(codec *RTCRtpCodec) {
func RegisterCodec(codec *RTPCodec) {
defaultAPI.mediaEngine.RegisterCodec(codec)
}

Expand All @@ -89,8 +89,8 @@ func RegisterDefaultCodecs() {

// PeerConnection API

// NewRTCPeerConnection using the default API.
// NewPeerConnection using the default API.
// See API.NewRTCPeerConnection for details.
func NewRTCPeerConnection(configuration RTCConfiguration) (*RTCPeerConnection, error) {
return defaultAPI.NewRTCPeerConnection(configuration)
func NewPeerConnection(configuration Configuration) (*PeerConnection, error) {
return defaultAPI.NewPeerConnection(configuration)
}
18 changes: 9 additions & 9 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ var (
ErrPrivateKeyType = errors.New("private key type not supported")

// ErrModifyingPeerIdentity indicates that an attempt to modify
// PeerIdentity was made after RTCPeerConnection has been initialized.
// PeerIdentity was made after PeerConnection has been initialized.
ErrModifyingPeerIdentity = errors.New("peerIdentity cannot be modified")

// ErrModifyingCertificates indicates that an attempt to modify
// Certificates was made after RTCPeerConnection has been initialized.
// Certificates was made after PeerConnection has been initialized.
ErrModifyingCertificates = errors.New("certificates cannot be modified")

// ErrModifyingBundlePolicy indicates that an attempt to modify
// BundlePolicy was made after RTCPeerConnection has been initialized.
// BundlePolicy was made after PeerConnection has been initialized.
ErrModifyingBundlePolicy = errors.New("bundle policy cannot be modified")

// ErrModifyingRtcpMuxPolicy indicates that an attempt to modify
// RtcpMuxPolicy was made after RTCPeerConnection has been initialized.
ErrModifyingRtcpMuxPolicy = errors.New("rtcp mux policy cannot be modified")
// ErrModifyingRTCPMuxPolicy indicates that an attempt to modify
// RTCPMuxPolicy was made after PeerConnection has been initialized.
ErrModifyingRTCPMuxPolicy = errors.New("rtcp mux policy cannot be modified")

// ErrModifyingIceCandidatePoolSize indicates that an attempt to modify
// IceCandidatePoolSize was made after RTCPeerConnection has been initialized.
ErrModifyingIceCandidatePoolSize = errors.New("ice candidate pool size cannot be modified")
// ErrModifyingICECandidatePoolSize indicates that an attempt to modify
// ICECandidatePoolSize was made after PeerConnection has been initialized.
ErrModifyingICECandidatePoolSize = errors.New("ice candidate pool size cannot be modified")

// ErrStringSizeLimit indicates that the character size limit of string is
// exceeded. The limit is hardcoded to 65535 according to specifications.
Expand Down
10 changes: 5 additions & 5 deletions examples/data-channels-close/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ func main() {
// Everything below is the pion-WebRTC API! Thanks for using it ❤️.

// Prepare the configuration
config := webrtc.RTCConfiguration{
IceServers: []webrtc.RTCIceServer{
config := webrtc.Configuration{
ICEServers: []webrtc.ICEServer{
{
URLs: []string{"stun:stun.l.google.com:19302"},
},
},
}

// Create a new RTCPeerConnection
peerConnection, err := webrtc.NewRTCPeerConnection(config)
peerConnection, err := webrtc.NewPeerConnection(config)
util.Check(err)

// Set the handler for ICE connection state
Expand All @@ -37,7 +37,7 @@ func main() {
})

// Register data channel creation handling
peerConnection.OnDataChannel(func(d *webrtc.RTCDataChannel) {
peerConnection.OnDataChannel(func(d *webrtc.DataChannel) {
fmt.Printf("New DataChannel %s %d\n", d.Label, d.ID)

// Register channel opening handling
Expand Down Expand Up @@ -83,7 +83,7 @@ func main() {
})

// Wait for the offer to be pasted
offer := webrtc.RTCSessionDescription{}
offer := webrtc.SessionDescription{}
util.Decode(util.MustReadStdin(), &offer)

// Set the remote SessionDescription
Expand Down
8 changes: 4 additions & 4 deletions examples/data-channels-create/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ func main() {
// Everything below is the pion-WebRTC API! Thanks for using it ❤️.

// Prepare the configuration
config := webrtc.RTCConfiguration{
IceServers: []webrtc.RTCIceServer{
config := webrtc.Configuration{
ICEServers: []webrtc.ICEServer{
{
URLs: []string{"stun:stun.l.google.com:19302"},
},
},
}

// Create a new RTCPeerConnection
peerConnection, err := webrtc.NewRTCPeerConnection(config)
peerConnection, err := webrtc.NewPeerConnection(config)
util.Check(err)

// Create a datachannel with label 'data'
Expand Down Expand Up @@ -73,7 +73,7 @@ func main() {
fmt.Println(util.Encode(offer))

// Wait for the answer to be pasted
answer := webrtc.RTCSessionDescription{}
answer := webrtc.SessionDescription{}
util.Decode(util.MustReadStdin(), &answer)

// Apply the answer as the remote description
Expand Down
8 changes: 4 additions & 4 deletions examples/data-channels-detach-create/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ func main() {
// Everything below is the pion-WebRTC API! Thanks for using it ❤️.

// Prepare the configuration
config := webrtc.RTCConfiguration{
IceServers: []webrtc.RTCIceServer{
config := webrtc.Configuration{
ICEServers: []webrtc.ICEServer{
{
URLs: []string{"stun:stun.l.google.com:19302"},
},
},
}

// Create a new RTCPeerConnection
peerConnection, err := webrtc.NewRTCPeerConnection(config)
peerConnection, err := webrtc.NewPeerConnection(config)
util.Check(err)

// Create a datachannel with label 'data'
Expand Down Expand Up @@ -70,7 +70,7 @@ func main() {
fmt.Println(util.Encode(offer))

// Wait for the answer to be pasted
answer := webrtc.RTCSessionDescription{}
answer := webrtc.SessionDescription{}
util.Decode(util.MustReadStdin(), answer)

// Apply the answer as the remote description
Expand Down
10 changes: 5 additions & 5 deletions examples/data-channels-detach/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ func main() {
// Everything below is the pion-WebRTC API! Thanks for using it ❤️.

// Prepare the configuration
config := webrtc.RTCConfiguration{
IceServers: []webrtc.RTCIceServer{
config := webrtc.Configuration{
ICEServers: []webrtc.ICEServer{
{
URLs: []string{"stun:stun.l.google.com:19302"},
},
},
}

// Create a new RTCPeerConnection
peerConnection, err := webrtc.NewRTCPeerConnection(config)
peerConnection, err := webrtc.NewPeerConnection(config)
util.Check(err)

// Set the handler for ICE connection state
Expand All @@ -40,7 +40,7 @@ func main() {
})

// Register data channel creation handling
peerConnection.OnDataChannel(func(d *webrtc.RTCDataChannel) {
peerConnection.OnDataChannel(func(d *webrtc.DataChannel) {
fmt.Printf("New DataChannel %s %d\n", d.Label, d.ID)

// Register channel opening handling
Expand All @@ -60,7 +60,7 @@ func main() {
})

// Wait for the offer to be pasted
offer := webrtc.RTCSessionDescription{}
offer := webrtc.SessionDescription{}
util.Decode(util.MustReadStdin(), offer)

// Set the remote SessionDescription
Expand Down
10 changes: 5 additions & 5 deletions examples/data-channels/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ func main() {
// Everything below is the pion-WebRTC API! Thanks for using it ❤️.

// Prepare the configuration
config := webrtc.RTCConfiguration{
IceServers: []webrtc.RTCIceServer{
config := webrtc.Configuration{
ICEServers: []webrtc.ICEServer{
{
URLs: []string{"stun:stun.l.google.com:19302"},
},
},
}

// Create a new RTCPeerConnection
peerConnection, err := webrtc.NewRTCPeerConnection(config)
peerConnection, err := webrtc.NewPeerConnection(config)
util.Check(err)

// Set the handler for ICE connection state
Expand All @@ -33,7 +33,7 @@ func main() {
})

// Register data channel creation handling
peerConnection.OnDataChannel(func(d *webrtc.RTCDataChannel) {
peerConnection.OnDataChannel(func(d *webrtc.DataChannel) {
fmt.Printf("New DataChannel %s %d\n", d.Label, d.ID)

// Register channel opening handling
Expand Down Expand Up @@ -63,7 +63,7 @@ func main() {
})

// Wait for the offer to be pasted
offer := webrtc.RTCSessionDescription{}
offer := webrtc.SessionDescription{}
util.Decode(util.MustReadStdin(), &offer)

// Set the remote SessionDescription
Expand Down
10 changes: 5 additions & 5 deletions examples/gstreamer-receive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ func gstreamerReceiveMain() {
webrtc.RegisterDefaultCodecs()

// Prepare the configuration
config := webrtc.RTCConfiguration{
IceServers: []webrtc.RTCIceServer{
config := webrtc.Configuration{
ICEServers: []webrtc.ICEServer{
{
URLs: []string{"stun:stun.l.google.com:19302"},
},
},
}

// Create a new RTCPeerConnection
peerConnection, err := webrtc.NewRTCPeerConnection(config)
peerConnection, err := webrtc.NewPeerConnection(config)
util.Check(err)

// 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.Track) {
// Send a PLI on an interval so that the publisher is pushing a keyframe every rtcpPLIInterval
// This is a temporary fix until we implement incoming RTCP events, then we would push a PLI only when a viewer requests it
go func() {
Expand Down Expand Up @@ -66,7 +66,7 @@ func gstreamerReceiveMain() {
})

// Wait for the offer to be pasted
offer := webrtc.RTCSessionDescription{}
offer := webrtc.SessionDescription{}
util.Decode(util.MustReadStdin(), &offer)

// Set the remote SessionDescription
Expand Down
12 changes: 6 additions & 6 deletions examples/gstreamer-send-offer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ func main() {
webrtc.RegisterDefaultCodecs()

// Prepare the configuration
config := webrtc.RTCConfiguration{
IceServers: []webrtc.RTCIceServer{
config := webrtc.Configuration{
ICEServers: []webrtc.ICEServer{
{
URLs: []string{"stun:stun.l.google.com:19302"},
},
},
}

// Create a new RTCPeerConnection
peerConnection, err := webrtc.NewRTCPeerConnection(config)
peerConnection, err := webrtc.NewPeerConnection(config)
util.Check(err)

// Set the handler for ICE connection state
Expand All @@ -36,13 +36,13 @@ func main() {
})

// Create a audio track
opusTrack, err := peerConnection.NewRTCSampleTrack(webrtc.DefaultPayloadTypeOpus, "audio", "pion1")
opusTrack, err := peerConnection.NewSampleTrack(webrtc.DefaultPayloadTypeOpus, "audio", "pion1")
util.Check(err)
_, err = peerConnection.AddTrack(opusTrack)
util.Check(err)

// Create a video track
vp8Track, err := peerConnection.NewRTCSampleTrack(webrtc.DefaultPayloadTypeVP8, "video", "pion2")
vp8Track, err := peerConnection.NewSampleTrack(webrtc.DefaultPayloadTypeVP8, "video", "pion2")
util.Check(err)
_, err = peerConnection.AddTrack(vp8Track)
util.Check(err)
Expand All @@ -59,7 +59,7 @@ func main() {
fmt.Println(util.Encode(offer))

// Wait for the answer to be pasted
answer := webrtc.RTCSessionDescription{}
answer := webrtc.SessionDescription{}
util.Decode(util.MustReadStdin(), &answer)

// Set the remote SessionDescription
Expand Down
12 changes: 6 additions & 6 deletions examples/gstreamer-send/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ func main() {
webrtc.RegisterDefaultCodecs()

// Prepare the configuration
config := webrtc.RTCConfiguration{
IceServers: []webrtc.RTCIceServer{
config := webrtc.Configuration{
ICEServers: []webrtc.ICEServer{
{
URLs: []string{"stun:stun.l.google.com:19302"},
},
},
}

// Create a new RTCPeerConnection
peerConnection, err := webrtc.NewRTCPeerConnection(config)
peerConnection, err := webrtc.NewPeerConnection(config)
util.Check(err)

// Set the handler for ICE connection state
Expand All @@ -41,19 +41,19 @@ func main() {
})

// Create a audio track
opusTrack, err := peerConnection.NewRTCSampleTrack(webrtc.DefaultPayloadTypeOpus, "audio", "pion1")
opusTrack, err := peerConnection.NewSampleTrack(webrtc.DefaultPayloadTypeOpus, "audio", "pion1")
util.Check(err)
_, err = peerConnection.AddTrack(opusTrack)
util.Check(err)

// Create a video track
vp8Track, err := peerConnection.NewRTCSampleTrack(webrtc.DefaultPayloadTypeVP8, "video", "pion2")
vp8Track, err := peerConnection.NewSampleTrack(webrtc.DefaultPayloadTypeVP8, "video", "pion2")
util.Check(err)
_, err = peerConnection.AddTrack(vp8Track)
util.Check(err)

// Wait for the offer to be pasted
offer := webrtc.RTCSessionDescription{}
offer := webrtc.SessionDescription{}
util.Decode(util.MustReadStdin(), &offer)

// Set the remote SessionDescription
Expand Down
12 changes: 6 additions & 6 deletions examples/janus-gateway/streaming/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@ func main() {
webrtc.RegisterDefaultCodecs()

// Prepare the configuration
config := webrtc.RTCConfiguration{
IceServers: []webrtc.RTCIceServer{
config := webrtc.Configuration{
ICEServers: []webrtc.ICEServer{
{
URLs: []string{"stun:stun.l.google.com:19302"},
},
},
}

// Create a new RTCPeerConnection
peerConnection, err := webrtc.NewRTCPeerConnection(config)
peerConnection, err := webrtc.NewPeerConnection(config)
util.Check(err)

peerConnection.OnICEConnectionStateChange(func(connectionState ice.ConnectionState) {
fmt.Printf("Connection State has changed %s \n", connectionState.String())
})

peerConnection.OnTrack(func(track *webrtc.RTCTrack) {
peerConnection.OnTrack(func(track *webrtc.Track) {
if track.Codec.Name == webrtc.Opus {
return
}
Expand Down Expand Up @@ -98,8 +98,8 @@ func main() {
util.Check(err)

if msg.Jsep != nil {
err = peerConnection.SetRemoteDescription(webrtc.RTCSessionDescription{
Type: webrtc.RTCSdpTypeOffer,
err = peerConnection.SetRemoteDescription(webrtc.SessionDescription{
Type: webrtc.SDPTypeOffer,
Sdp: msg.Jsep["sdp"].(string),
})
util.Check(err)
Expand Down
Loading

0 comments on commit 0e7086d

Please sign in to comment.