Change from Media -> Track

We expect single tracks, so use proper terminology
This commit is contained in:
Sean DuBois
2018-06-12 23:59:56 -07:00
parent 3b5cdcf60d
commit c7ca757fa8
3 changed files with 21 additions and 21 deletions

View File

@@ -37,7 +37,7 @@ func startWebrtc(pipeline *gst.Pipeline) {
// Set a handler for when a new remote track starts, this handler starts a gstreamer pipeline // Set a handler for when a new remote track starts, this handler starts a gstreamer pipeline
// with the first track and assumes it is VP8 video data. // with the first track and assumes it is VP8 video data.
peerConnection.Ontrack = func(mediaType webrtc.MediaType, packets <-chan *rtp.Packet) { peerConnection.Ontrack = func(mediaType webrtc.TrackType, packets <-chan *rtp.Packet) {
go func() { go func() {
track := atomic.AddUint64(&trackCount, 1) track := atomic.AddUint64(&trackCount, 1)
fmt.Printf("Track %d has started \n", track) fmt.Printf("Track %d has started \n", track)

View File

@@ -36,7 +36,7 @@ func main() {
// Set a handler for when a new remote track starts, this handler saves buffers to disk as // 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. // 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 // In your application this is where you would handle/process video
peerConnection.Ontrack = func(mediaType webrtc.MediaType, packets <-chan *rtp.Packet) { peerConnection.Ontrack = func(mediaType webrtc.TrackType, packets <-chan *rtp.Packet) {
go func() { go func() {
track := atomic.AddUint64(&trackCount, 1) track := atomic.AddUint64(&trackCount, 1)
fmt.Printf("Track %d has started \n", track) fmt.Printf("Track %d has started \n", track)

View File

@@ -13,29 +13,29 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
// MediaType determines the type of media we are sending receiving // TrackType determines the type of media we are sending receiving
type MediaType int type TrackType int
const ( const (
// G711 is a MediaType // G711 is a TrackType
G711 MediaType = iota G711 TrackType = iota
// G722 is a MediaType // G722 is a TrackType
G722 MediaType = iota G722 TrackType = iota
// ILBC is a MediaType // ILBC is a TrackType
ILBC MediaType = iota ILBC TrackType = iota
// ISAC is a MediaType // ISAC is a TrackType
ISAC MediaType = iota ISAC TrackType = iota
// H264 is a MediaType // H264 is a TrackType
H264 MediaType = iota H264 TrackType = iota
// VP8 is a MediaType // VP8 is a TrackType
VP8 MediaType = iota VP8 TrackType = iota
// Opus is a MediaType // Opus is a TrackType
Opus MediaType = iota Opus TrackType = iota
) )
// RTCPeerConnection represents a WebRTC connection between itself and a remote peer // RTCPeerConnection represents a WebRTC connection between itself and a remote peer
type RTCPeerConnection struct { type RTCPeerConnection struct {
Ontrack func(mediaType MediaType, buffers <-chan *rtp.Packet) Ontrack func(mediaType TrackType, buffers <-chan *rtp.Packet)
LocalDescription *sdp.SessionDescription LocalDescription *sdp.SessionDescription
tlscfg *dtls.TLSCfg tlscfg *dtls.TLSCfg
@@ -78,10 +78,10 @@ func (r *RTCPeerConnection) CreateOffer() error {
return nil return nil
} }
// AddStream adds a new media to the RTCPeerConnection // AddTrack adds a new track to the RTCPeerConnection
// This function returns a channel to push buffers on, and an error if the channel can't be added // This function returns a channel to push buffers on, and an error if the channel can't be added
// Closing the channel ends this stream // Closing the channel ends this stream
func (r *RTCPeerConnection) AddStream(mediaType MediaType) (buffers chan<- []byte, err error) { func (r *RTCPeerConnection) AddTrack(mediaType TrackType) (buffers chan<- []byte, err error) {
return nil, nil return nil, nil
} }