github.com/pion/webrtc/v3@v3.2.24/rtptransceiver_js.go (about) 1 // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly> 2 // SPDX-License-Identifier: MIT 3 4 //go:build js && wasm 5 // +build js,wasm 6 7 package webrtc 8 9 import ( 10 "syscall/js" 11 ) 12 13 // RTPTransceiver represents a combination of an RTPSender and an RTPReceiver that share a common mid. 14 type RTPTransceiver struct { 15 // Pointer to the underlying JavaScript RTCRTPTransceiver object. 16 underlying js.Value 17 } 18 19 // Direction returns the RTPTransceiver's current direction 20 func (r *RTPTransceiver) Direction() RTPTransceiverDirection { 21 return NewRTPTransceiverDirection(r.underlying.Get("direction").String()) 22 } 23 24 // Sender returns the RTPTransceiver's RTPSender if it has one 25 func (r *RTPTransceiver) Sender() *RTPSender { 26 underlying := r.underlying.Get("sender") 27 if underlying.IsNull() { 28 return nil 29 } 30 31 return &RTPSender{underlying: underlying} 32 } 33 34 // Receiver returns the RTPTransceiver's RTPReceiver if it has one 35 func (r *RTPTransceiver) Receiver() *RTPReceiver { 36 underlying := r.underlying.Get("receiver") 37 if underlying.IsNull() { 38 return nil 39 } 40 41 return &RTPReceiver{underlying: underlying} 42 }