Files
webrtc/rtptransceiver.go
Alex Browne 0f1ddf0825 Add JavaScript/WASM bindings
Resolves #478. Adds minimal JavaScript/WASM bindings. This makes it
possible to compile core parts of pions/webrtc to WASM and run it in the
browser. Only data channels are supported for now and there is
limited/no support for certificates and credentials.
2019-03-08 00:26:17 +01:00

51 lines
1.1 KiB
Go

// +build !js
package webrtc
import "fmt"
// RTPTransceiver represents a combination of an RTPSender and an RTPReceiver that share a common mid.
type RTPTransceiver struct {
Mid string
Sender *RTPSender
Receiver *RTPReceiver
Direction RTPTransceiverDirection
// currentDirection RTPTransceiverDirection
// firedDirection RTPTransceiverDirection
// receptive bool
stopped bool
}
func (t *RTPTransceiver) setSendingTrack(track *Track) error {
if track == nil {
return fmt.Errorf("track must not be nil")
}
t.Sender.track = track
switch t.Direction {
case RTPTransceiverDirectionRecvonly:
t.Direction = RTPTransceiverDirectionSendrecv
case RTPTransceiverDirectionInactive:
t.Direction = RTPTransceiverDirectionSendonly
default:
return fmt.Errorf("invalid state change in RTPTransceiver.setSending")
}
return nil
}
// Stop irreversibly stops the RTPTransceiver
func (t *RTPTransceiver) Stop() error {
if t.Sender != nil {
if err := t.Sender.Stop(); err != nil {
return err
}
}
if t.Receiver != nil {
if err := t.Receiver.Stop(); err != nil {
return err
}
}
return nil
}