Implement JSValue for more structures

Previously was only implemented for PeerConnection.
This commit is contained in:
WofWca
2025-02-11 21:41:11 +04:00
committed by GitHub
parent 4ee374714a
commit 99eb390362
7 changed files with 35 additions and 0 deletions

View File

@@ -36,6 +36,11 @@ type DataChannel struct {
api *API
}
// JSValue returns the underlying RTCDataChannel
func (d *DataChannel) JSValue() js.Value {
return d.underlying
}
// OnOpen sets an event handler which is invoked when
// the underlying data transport has been established (or re-established).
func (d *DataChannel) OnOpen(f func()) {

View File

@@ -17,6 +17,11 @@ type DTLSTransport struct {
underlying js.Value
}
// JSValue returns the underlying RTCDtlsTransport
func (r *DTLSTransport) JSValue() js.Value {
return r.underlying
}
// ICETransport returns the currently-configured *ICETransport or nil
// if one has not been configured
func (r *DTLSTransport) ICETransport() *ICETransport {

View File

@@ -15,6 +15,11 @@ type ICETransport struct {
underlying js.Value
}
// JSValue returns the underlying RTCIceTransport
func (t *ICETransport) JSValue() js.Value {
return t.underlying
}
// GetSelectedCandidatePair returns the selected candidate pair on which packets are sent
// if there is no selected pair nil is returned
func (t *ICETransport) GetSelectedCandidatePair() (*ICECandidatePair, error) {

View File

@@ -13,3 +13,8 @@ type RTPReceiver struct {
// Pointer to the underlying JavaScript RTCRTPReceiver object.
underlying js.Value
}
// JSValue returns the underlying RTCRtpReceiver
func (r *RTPReceiver) JSValue() js.Value {
return r.underlying
}

View File

@@ -13,3 +13,8 @@ type RTPSender struct {
// Pointer to the underlying JavaScript RTCRTPSender object.
underlying js.Value
}
// JSValue returns the underlying RTCRtpSender
func (s *RTPSender) JSValue() js.Value {
return s.underlying
}

View File

@@ -16,6 +16,11 @@ type RTPTransceiver struct {
underlying js.Value
}
// JSValue returns the underlying RTCRtpTransceiver
func (r *RTPTransceiver) JSValue() js.Value {
return r.underlying
}
// Direction returns the RTPTransceiver's current direction
func (r *RTPTransceiver) Direction() RTPTransceiverDirection {
return NewRTPTransceiverDirection(r.underlying.Get("direction").String())

View File

@@ -14,6 +14,11 @@ type SCTPTransport struct {
underlying js.Value
}
// JSValue returns the underlying RTCSctpTransport
func (r *SCTPTransport) JSValue() js.Value {
return r.underlying
}
// Transport returns the DTLSTransport instance the SCTPTransport is sending over.
func (r *SCTPTransport) Transport() *DTLSTransport {
underlying := r.underlying.Get("transport")