Skip to content

Commit

Permalink
Move RTPSender and RTPReceiver to API
Browse files Browse the repository at this point in the history
Relates to #379
  • Loading branch information
backkem committed Feb 21, 2019
1 parent 585f50e commit 9cff417
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions peerconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ func (pc *PeerConnection) openSRTP() {

for i := range incomingSSRCes {
go func(ssrc uint32, codecType RTPCodecType) {
receiver := NewRTPReceiver(codecType, pc.dtlsTransport)
receiver := pc.api.NewRTPReceiver(codecType, pc.dtlsTransport)
<-receiver.Receive(RTPReceiveParameters{
encodings: RTPDecodingParameters{
RTPCodingParameters{SSRC: ssrc},
Expand Down Expand Up @@ -1129,7 +1129,7 @@ func (pc *PeerConnection) AddTrack(track *Track) (*RTPSender, error) {
return nil, err
}
} else {
sender := NewRTPSender(track, pc.dtlsTransport)
sender := pc.api.NewRTPSender(track, pc.dtlsTransport)
transceiver = pc.newRTPTransceiver(
nil,
sender,
Expand Down
15 changes: 10 additions & 5 deletions rtpreceiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,31 @@ type RTPReceiver struct {

rtpOut chan *rtp.Packet
rtpReadStream *srtp.ReadStreamSRTP
rtpOutDone chan bool
rtpOutDone chan struct{}

rtcpOut chan rtcp.Packet
rtcpReadStream *srtp.ReadStreamSRTCP
rtcpOutDone chan bool
rtcpOutDone chan struct{}

// A reference to the associated api object
api *API
}

// NewRTPReceiver constructs a new RTPReceiver
func NewRTPReceiver(kind RTPCodecType, transport *DTLSTransport) *RTPReceiver {
func (api *API) NewRTPReceiver(kind RTPCodecType, transport *DTLSTransport) *RTPReceiver {
return &RTPReceiver{
kind: kind,
transport: transport,

rtpOut: make(chan *rtp.Packet, 15),
rtpOutDone: make(chan bool),
rtpOutDone: make(chan struct{}),

rtcpOut: make(chan rtcp.Packet, 15),
rtcpOutDone: make(chan bool),
rtcpOutDone: make(chan struct{}),

hasRecv: make(chan bool),

api: api,
}
}

Expand Down
6 changes: 5 additions & 1 deletion rtpsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ type RTPSender struct {
Track *Track

transport *DTLSTransport

// A reference to the associated api object
api *API
}

// NewRTPSender constructs a new RTPSender
func NewRTPSender(track *Track, transport *DTLSTransport) *RTPSender {
func (api *API) NewRTPSender(track *Track, transport *DTLSTransport) *RTPSender {
r := &RTPSender{
Track: track,
transport: transport,
api: api,
}

r.Track.sampleInput = make(chan media.Sample, 15) // Is the buffering needed?
Expand Down

0 comments on commit 9cff417

Please sign in to comment.