This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebrtc.go
1392 lines (1178 loc) · 39.3 KB
/
webrtc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// +build js,wasm
// http://w3c.github.io/webrtc-pc/
package wasm
import (
"time"
)
// https://www.w3.org/TR/WebCryptoAPI/#dfn-AlgorithmIdentifier
// TODO
type AlgorithmIdentifier string
// https://heycam.github.io/webidl/#common-DOMTimeStamp
// typedef unsigned long long DOMTimeStamp;
func NewRTCPeerConnection(configuration ...RTCConfiguration) RTCPeerConnection {
jsRTCPeerConnection := jsGlobal.get("RTCPeerConnection")
switch len(configuration) {
case 0:
return wrapRTCPeerConnection(jsRTCPeerConnection.jsNew())
default:
return wrapRTCPeerConnection(jsRTCPeerConnection.jsNew(configuration[0].JSValue()))
}
}
func NewRTCSessionDescription(descriptionInitDict RTCSessionDescriptionInit) RTCSessionDescription {
if jsSD := jsGlobal.get("RTCSessionDescription"); jsSD.valid() {
return wrapRTCSessionDescription(jsSD.jsNew(descriptionInitDict.JSValue()))
}
return nil
}
func NewRTCIceCandidate(candidateInitDict ...RTCIceCandidateInit) RTCIceCandidate {
if jsIC := jsGlobal.get("RTCIceCandidate"); jsIC.valid() {
switch len(candidateInitDict) {
case 0:
return wrapRTCIceCandidate(jsIC.jsNew())
default:
return wrapRTCIceCandidate(jsIC.jsNew(candidateInitDict[0].JSValue()))
}
}
return nil
}
func NewRTCPeerConnectionIceEvent(typ string, eventInitDict ...RTCPeerConnectionIceEventInit) RTCPeerConnectionIceEvent {
if jsIE := jsGlobal.get("RTCPeerConnectionIceEvent"); jsIE.valid() {
switch len(eventInitDict) {
case 0:
return wrapRTCPeerConnectionIceEvent(jsIE.jsNew(typ))
default:
return wrapRTCPeerConnectionIceEvent(jsIE.jsNew(typ, eventInitDict[0].JSValue()))
}
}
return nil
}
func NewRTCPeerConnectionIceErrorEvent(typ string, eventInitDict RTCPeerConnectionIceErrorEventInit) RTCPeerConnectionIceErrorEvent {
if jsEE := jsGlobal.get("RTCPeerConnectionIceErrorEvent"); jsEE.valid() {
return wrapRTCPeerConnectionIceErrorEvent(jsEE.jsNew(typ, eventInitDict.JSValue()))
}
return nil
}
func NewRTCTrackEvent(typ string, eventInitDict RTCTrackEventInit) RTCTrackEvent {
if jsTE := jsGlobal.get("RTCTrackEvent"); jsTE.valid() {
return wrapRTCTrackEvent(jsTE.jsNew(typ, eventInitDict.JSValue()))
}
return nil
}
func NewRTCDataChannelEvent(typ string, eventInitDict RTCDataChannelEventInit) RTCDataChannelEvent {
if jsCE := jsGlobal.get("RTCDataChannelEvent"); jsCE.valid() {
return wrapRTCDataChannelEvent(jsCE.jsNew(typ, eventInitDict.JSValue()))
}
return nil
}
func NewRTCDTMFToneChangeEvent(typ string, eventInitDict RTCDTMFToneChangeEventInit) RTCDTMFToneChangeEvent {
if jsTCE := jsGlobal.get("RTCDTMFToneChangeEvent"); jsTCE.valid() {
return wrapRTCDTMFToneChangeEvent(jsTCE.jsNew(typ, eventInitDict.JSValue()))
}
return nil
}
func NewRTCStatsEvent(typ string, eventInitDict RTCStatsEventInit) RTCStatsEvent {
if jsSE := jsGlobal.get("RTCStatsEvent"); jsSE.valid() {
return wrapRTCStatsEvent(jsSE.jsNew(typ, eventInitDict.JSValue()))
}
return nil
}
func NewRTCError(detail RTCErrorDetailType, message string) RTCError {
if jsE := jsGlobal.get("RTCError"); jsE.valid() {
return wrapRTCError(jsE.jsNew(string(detail), message))
}
return nil
}
func NewRTCErrorEvent(typ string, eventInitDict RTCErrorEventInit) RTCErrorEvent {
if jsEE := jsGlobal.get("RTCErrorEvent"); jsEE.valid() {
return wrapRTCErrorEvent(jsEE.jsNew(typ, eventInitDict.JSValue()))
}
return nil
}
type (
// http://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection
RTCPeerConnection interface {
EventTarget
CreateOffer(...RTCOfferOptions) func() (RTCSessionDescriptionInit, error)
CreateAnswer(...RTCAnswerOptions) func() (RTCSessionDescriptionInit, error)
SetLocalDescription(RTCSessionDescriptionInit) func() error
LocalDescription() RTCSessionDescription
CurrentLocalDescription() RTCSessionDescription
PendingLocalDescription() RTCSessionDescription
SetRemoteDescription(RTCSessionDescriptionInit) func() error
RemoteDescription() RTCSessionDescription
CurrentRemoteDescription() RTCSessionDescription
PendingRemoteDescription() RTCSessionDescription
AddIceCandidate(RTCIceCandidateInit) func() error
SignalingState() RTCSignalingState
IceGatheringState() RTCIceGatheringState
IceConnectionState() RTCIceConnectionState
ConnectionState() RTCPeerConnectionState
CanTrickleIceCandidates() bool
DefaultIceServers() []RTCIceServer
Configuration() RTCConfiguration
SetConfiguration(RTCConfiguration)
Close()
OnNegotiationNeeded(func(Event)) EventHandler
OnIceCandidate(func(RTCPeerConnectionIceEvent)) EventHandler
OnIceCandidateError(func(RTCPeerConnectionIceErrorEvent)) EventHandler
OnSignalingStateChange(func(Event)) EventHandler
OnIceConnectionStateChange(func(Event)) EventHandler
OnIceGatheringStateChange(func(Event)) EventHandler
OnConnectionStateChange(func(Event)) EventHandler
// http://w3c.github.io/webrtc-pc/#sec.cert-mgmt
//GenerateCertificate(AlgorithmIdentifier) func() (RTCCertificate, error) // static TODO
GenerateCertificate(string) func() (RTCCertificate, error) // static
// http://w3c.github.io/webrtc-pc/#rtp-media-api
Senders() []RTCRtpSender
Receivers() []RTCRtpReceiver
Transceivers() []RTCRtpTransceiver
AddTrack(MediaStreamTrack, ...MediaStream) RTCRtpSender
RemoveTrack(RTCRtpSender)
AddTransceiver(MediaStreamTrack, ...RTCRtpTransceiverInit) RTCRtpTransceiver // (MediaStreamTrack or DOMString) trackOrKind
OnTrack(func(RTCTrackEvent)) EventHandler
// http://w3c.github.io/webrtc-pc/#rtcpeerconnection-interface-extensions-0
SCTP() RTCSctpTransport
CreateDataChannel(string, ...RTCDataChannelInit) RTCDataChannel
OnDataChannel(func(RTCDataChannelEvent)) EventHandler
// http://w3c.github.io/webrtc-pc/#rtcpeerconnection-interface-extensions-1
Stats(...MediaStreamTrack) func() (RTCStatsReport, error)
OnStatsEnded(func(RTCStatsEvent)) EventHandler
}
// http://w3c.github.io/webrtc-pc/#dom-rtcpeerconnectionerrorcallback
// callback RTCPeerConnectionErrorCallback = void (DOMException error);
RTCPeerConnectionErrorCallback interface {
Callback
}
// http://w3c.github.io/webrtc-pc/#dom-rtcsessiondescriptioncallback
// callback RTCSessionDescriptionCallback = void (RTCSessionDescriptionInit description);
RTCSessionDescriptionCallback interface {
Callback
}
// http://w3c.github.io/webrtc-pc/#dom-rtcsessiondescription
RTCSessionDescription interface {
Type() RTCSdpType
Sdp() string
ToJSON() string
}
// http://w3c.github.io/webrtc-pc/#dom-rtcicecandidate
RTCIceCandidate interface {
Candidate() string
SdpMid() string
SdpMLineIndex() uint16
Foundation() string
Component() RTCIceComponent
Priority() uint
Address() string
Protocol() RTCIceProtocol
Port() uint16
Type() RTCIceCandidateType
TcpType() RTCIceTcpCandidateType
RelatedAddress() string
RelatedPort() uint16
UsernameFragment() string
ToJSON() RTCIceCandidateInit
}
// http://w3c.github.io/webrtc-pc/#dom-rtcpeerconnectioniceevent
RTCPeerConnectionIceEvent interface {
Event
Candidate() RTCIceCandidate
URL() string
}
// http://w3c.github.io/webrtc-pc/#dom-rtcpeerconnectioniceerrorevent
RTCPeerConnectionIceErrorEvent interface {
Event
HostCandidate() string
URL() string
ErrorCode() uint16
ErrorText() string
}
// http://w3c.github.io/webrtc-pc/#dom-rtccertificate
RTCCertificate interface {
Expires() time.Time
SupportedAlgorithms() []AlgorithmIdentifier // static
Fingerprints() []RTCDtlsFingerprint
JSValue() jsValue
}
// http://w3c.github.io/webrtc-pc/#dom-rtcrtpsender
RTCRtpSender interface {
Track() MediaStreamTrack
Transport() RTCDtlsTransport
RTCPTransport() RTCDtlsTransport
Capabilities(string) RTCRtpCapabilities // static
SetParameters(RTCRtpSendParameters) func() error
Parameters() RTCRtpSendParameters
ReplaceTrack(MediaStreamTrack) func() error
SetStreams(...MediaStream)
Stats() func() (RTCStatsReport, error)
// http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface-extensions
DTMF() RTCDTMFSender
}
// http://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver
RTCRtpReceiver interface {
Track() MediaStreamTrack
Transport() RTCDtlsTransport
RTCPTransport() RTCDtlsTransport
Capabilities(string) RTCRtpCapabilities // static
Parameters() RTCRtpReceiveParameters
ContributingSources() []RTCRtpContributingSource
SynchronizationSources() []RTCRtpSynchronizationSource
Stats() func() (RTCStatsReport, error)
}
// http://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver
RTCRtpTransceiver interface {
Mid() string
Sender() RTCRtpSender
Receiver() RTCRtpReceiver
Stopped() bool
Direction() RTCRtpTransceiverDirection
SetDirection(RTCRtpTransceiverDirection)
CurrentDirection() RTCRtpTransceiverDirection
Stop()
SetCodecPreferences([]RTCRtpCodecCapability)
}
// http://w3c.github.io/webrtc-pc/#dom-rtcdtlstransport
RTCDtlsTransport interface {
EventTarget
IceTransport() RTCIceTransport
State() RTCDtlsTransportState
RemoteCertificates() []ArrayBuffer
OnStateChange(func(Event)) EventHandler
OnError(func(RTCErrorEvent)) EventHandler
}
// http://w3c.github.io/webrtc-pc/#dom-rtcicetransport
RTCIceTransport interface {
EventTarget
Role() RTCIceRole
Component() RTCIceComponent
State() RTCIceTransportState
GatheringState() RTCIceGathererState
LocalCandidates() []RTCIceCandidate
RemoteCandidates() []RTCIceCandidate
SelectedCandidatePair() RTCIceCandidatePair
LocalParameters() RTCIceParameters
RemoteParameters() RTCIceParameters
OnStateChange(func(Event)) EventHandler
OnGatheringStateChange(func(Event)) EventHandler
OnSelectedCandidatePairChange(func(Event)) EventHandler
}
// http://w3c.github.io/webrtc-pc/#dom-rtctrackevent
RTCTrackEvent interface {
Event
Receiver() RTCRtpReceiver
Track() MediaStreamTrack
Streams() []MediaStream
Transceiver() RTCRtpTransceiver
}
// http://w3c.github.io/webrtc-pc/#dom-rtcsctptransport
RTCSctpTransport interface {
EventTarget // this isn't in standart
Transport() RTCDtlsTransport
State() RTCSctpTransportState
MaxMessageSize() float64
MaxChannels() uint16
OnStateChange(func(Event)) EventHandler
}
// http://w3c.github.io/webrtc-pc/#dom-rtcdatachannel
RTCDataChannel interface {
EventTarget
Label() string
Ordered() bool
MaxPacketLifeTime() uint16
MaxRetransmits() uint16
Protocol() string
Negotiated() bool
Id() uint16
Priority() RTCPriorityType
ReadyState() RTCDataChannelState
BufferedAmount() uint
BufferedAmountLowThreshold() uint
OnOpen(func(Event)) EventHandler
OnBufferedAmountLow(func(Event)) EventHandler
OnError(func(RTCErrorEvent)) EventHandler
OnClose(func(Event)) EventHandler
Close()
OnMessage(func(MessageEvent)) EventHandler
BinaryType() string
Send(interface{}) // string, Blob, ArrayBuffer, ArrayBufferView
}
// http://w3c.github.io/webrtc-pc/#dom-rtcdatachannelevent
RTCDataChannelEvent interface {
Event
Channel() RTCDataChannel
}
// http://w3c.github.io/webrtc-pc/#dom-rtcdtmfsender
RTCDTMFSender interface {
EventTarget
InsertDTMF(string, ...uint)
OnToneChange(func(RTCDTMFToneChangeEvent)) EventHandler
CanInsertDTMF() bool
ToneBuffer() string
}
// http://w3c.github.io/webrtc-pc/#dom-rtcdtmftonechangeevent
RTCDTMFToneChangeEvent interface {
Event
Tone() string
}
// http://w3c.github.io/webrtc-pc/#dom-rtcstatsreport
RTCStatsReport interface {
// TODO https://www.w3.org/TR/webrtc-stats/
/*
Map() map[string]RTCStats // TODO
Get(string) RTCStats
Has(string) RTCStats
Values() []RTCStats
Keys() []string
*/
}
// http://w3c.github.io/webrtc-pc/#dom-rtcstatsevent
RTCStatsEvent interface {
Event
Report() RTCStatsReport
}
// http://w3c.github.io/webrtc-pc/#dfn-rtcerror
RTCError interface {
ErrorDetail() RTCErrorDetailType
SDPLineNumber() int
HttpRequestStatusCode() int
SCTPCauseCode() int
ReceivedAlert() uint
SentAlert() uint
Message() string
Name() string
}
// http://w3c.github.io/webrtc-pc/#dom-rtcerrorevent
RTCErrorEvent interface {
Event
Error() RTCError
}
)
// http://w3c.github.io/webrtc-pc/#dom-rtcicecredentialtype
type RTCIceCredentialType string
const (
RTCIceCredentialTypePassword RTCIceCredentialType = "password"
RTCIceCredentialTypeOAuth RTCIceCredentialType = "oauth"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcicetransportpolicy
type RTCIceTransportPolicy string
const (
RTCIceTransportPolicyRelay RTCIceTransportPolicy = "relay"
RTCIceTransportPolicyAll RTCIceTransportPolicy = "all"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcbundlepolicy
type RTCBundlePolicy string
const (
RTCBundlePolicyBalanced RTCBundlePolicy = "balanced"
RTCBundlePolicyMaxCompat RTCBundlePolicy = "max-compat"
RTCBundlePolicyMaxBundle RTCBundlePolicy = "max-bundle"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcrtcpmuxpolicy
type RTCRtcpMuxPolicy string
const (
RTCRtcpMuxPolicyNegotiate RTCRtcpMuxPolicy = "negotiate"
RTCRtcpMuxPolicyRequire RTCRtcpMuxPolicy = "require"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcsignalingstate
type RTCSignalingState string
const (
RTCSignalingStateStable RTCSignalingState = "stable"
RTCSignalingStateHaveLocalOffer RTCSignalingState = "have-local-offer"
RTCSignalingStateHaveRemoteOffer RTCSignalingState = "have-remote-offer"
RTCSignalingStateHaveLocalPranswer RTCSignalingState = "have-local-pranswer"
RTCSignalingStateHaveRemotePranswer RTCSignalingState = "have-remote-pranswer"
RTCSignalingStateClosed RTCSignalingState = "closed"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcicegatheringstate
type RTCIceGatheringState string
const (
RTCIceGatheringStateNew RTCIceGatheringState = "new"
RTCIceGatheringStateGathering RTCIceGatheringState = "gathering"
RTCIceGatheringStateComplete RTCIceGatheringState = "complete"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcpeerconnectionstate
type RTCPeerConnectionState string
const (
RTCPeerConnectionStateClosed RTCPeerConnectionState = "closed"
RTCPeerConnectionStateFailed RTCPeerConnectionState = "failed"
RTCPeerConnectionStateDisconnected RTCPeerConnectionState = "disconnected"
RTCPeerConnectionStateNew RTCPeerConnectionState = "new"
RTCPeerConnectionStateConnecting RTCPeerConnectionState = "connecting"
RTCPeerConnectionStateConnected RTCPeerConnectionState = "connected"
)
// http://w3c.github.io/webrtc-pc/#dom-rtciceconnectionstate
type RTCIceConnectionState string
const (
RTCIceConnectionStateClosed RTCIceConnectionState = "closed"
RTCIceConnectionStateFailed RTCIceConnectionState = "failed"
RTCIceConnectionStateDisconnected RTCIceConnectionState = "disconnected"
RTCIceConnectionStateNew RTCIceConnectionState = "new"
RTCIceConnectionStateChecking RTCIceConnectionState = "checking"
RTCIceConnectionStateCompleted RTCIceConnectionState = "completed"
RTCIceConnectionStateConnected RTCIceConnectionState = "connected"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcsdptype
type RTCSdpType string
const (
RTCSdpTypeOffer RTCSdpType = "offer"
RTCSdpTypePranswer RTCSdpType = "pranswer"
RTCSdpTypeAnswer RTCSdpType = "answer"
RTCSdpTypeRollback RTCSdpType = "rollback"
)
// http://w3c.github.io/webrtc-pc/#dom-rtciceprotocol
type RTCIceProtocol string
const (
RTCIceProtocolUDP RTCIceProtocol = "udp"
RTCIceProtocolTCP RTCIceProtocol = "tcp"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcicetcpcandidatetype
type RTCIceTcpCandidateType string
const (
RTCIceTcpCandidateTypeActive RTCIceTcpCandidateType = "active"
RTCIceTcpCandidateTypePassive RTCIceTcpCandidateType = "passive"
RTCIceTcpCandidateTypeSo RTCIceTcpCandidateType = "so"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcicecandidatetype
type RTCIceCandidateType string
const (
RTCIceCandidateTypeHost RTCIceCandidateType = "host"
RTCIceCandidateTypeSrflx RTCIceCandidateType = "srflx"
RTCIceCandidateTypePrflx RTCIceCandidateType = "prflx"
RTCIceCandidateTypeRelay RTCIceCandidateType = "relay"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcprioritytype
type RTCPriorityType string
const (
RTCPriorityTypeVeryLow RTCPriorityType = "very-low"
RTCPriorityTypeLow RTCPriorityType = "low"
RTCPriorityTypeMedium RTCPriorityType = "medium"
RTCPriorityTypeHigh RTCPriorityType = "high"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverdirection
type RTCRtpTransceiverDirection string
const (
RTCRtpTransceiverDirectionSendRecv RTCRtpTransceiverDirection = "sendrecv"
RTCRtpTransceiverDirectionSendOnly RTCRtpTransceiverDirection = "sendonly"
RTCRtpTransceiverDirectionRecvOnly RTCRtpTransceiverDirection = "recvonly"
RTCRtpTransceiverDirectionInactive RTCRtpTransceiverDirection = "inactive"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcdtxstatus
type RTCDtxStatus string
const (
RTCDtxStatusDisabled RTCDtxStatus = "disabled"
RTCDtxStatusEnabled RTCDtxStatus = "enabled"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcdegradationpreference
type RTCDegradationPreference string
const (
RTCDegradationPreferenceMaintainFramerate RTCDegradationPreference = "maintain-framerate"
RTCDegradationPreferenceMaintainResolution RTCDegradationPreference = "maintain-resolution"
RTCDegradationPreferenceBalanced RTCDegradationPreference = "balanced"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcdtlstransportstate
type RTCDtlsTransportState string
const (
RTCDtlsTransportStateNew RTCDtlsTransportState = "new"
RTCDtlsTransportStateConnecting RTCDtlsTransportState = "connecting"
RTCDtlsTransportStateConnected RTCDtlsTransportState = "connected"
RTCDtlsTransportStateClosed RTCDtlsTransportState = "closed"
RTCDtlsTransportStateFailed RTCDtlsTransportState = "failed"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcicegathererstate
type RTCIceGathererState string
const (
RTCIceGathererStateNew RTCIceGathererState = "new"
RTCIceGathererStateGathering RTCIceGathererState = "gathering"
RTCIceGathererStateComplete RTCIceGathererState = "complete"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcicetransportstate
type RTCIceTransportState string
const (
RTCIceTransportStateNew RTCIceTransportState = "new"
RTCIceTransportStateChecking RTCIceTransportState = "checking"
RTCIceTransportStateConnected RTCIceTransportState = "connected"
RTCIceTransportStateCompleted RTCIceTransportState = "completed"
RTCIceTransportStateDisconnected RTCIceTransportState = "disconnected"
RTCIceTransportStateFailed RTCIceTransportState = "failed"
RTCIceTransportStateClosed RTCIceTransportState = "closed"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcicerole
type RTCIceRole string
const (
RTCIceRoleControlling RTCIceRole = "controlling"
RTCIceRoleControlled RTCIceRole = "controlled"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcicecomponent
type RTCIceComponent string
const (
RTCIceComponentRTP RTCIceComponent = "rtp"
RTCIceComponentRTCP RTCIceComponent = "rtcp"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcsctptransportstate
type RTCSctpTransportState string
const (
RTCSctpTransportStateConnecting RTCSctpTransportState = "connecting"
RTCSctpTransportStateConnected RTCSctpTransportState = "connected"
RTCSctpTransportStateClosed RTCSctpTransportState = "closed"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcdatachannelstate
type RTCDataChannelState string
const (
RTCDataChannelStateConnecting RTCDataChannelState = "connecting"
RTCDataChannelStateOpen RTCDataChannelState = "open"
RTCDataChannelStateClosing RTCDataChannelState = "closing"
RTCDataChannelStateClosed RTCDataChannelState = "closed"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcerrordetailtype
type RTCErrorDetailType string
const (
RTCErrorDetailTypeDataChannelFailure RTCErrorDetailType = "data-channel-failure"
RTCErrorDetailTypeDTLSFailure RTCErrorDetailType = "dtls-failure"
RTCErrorDetailTypeFingerprintFailure RTCErrorDetailType = "fingerprint-failure"
RTCErrorDetailTypeIdpBadScriptFailure RTCErrorDetailType = "idp-bad-script-failure"
RTCErrorDetailTypeIdpExecutionFailure RTCErrorDetailType = "idp-execution-failure"
RTCErrorDetailTypeIdpLoadFailure RTCErrorDetailType = "idp-load-failure"
RTCErrorDetailTypeIdpNeedLogin RTCErrorDetailType = "idp-need-login"
RTCErrorDetailTypeIdpTimeout RTCErrorDetailType = "idp-timeout"
RTCErrorDetailTypeIdpTLSFailure RTCErrorDetailType = "idp-tls-failure"
RTCErrorDetailTypeIdpTokenExpired RTCErrorDetailType = "idp-token-expired"
RTCErrorDetailTypeIdpTokenInvalid RTCErrorDetailType = "idp-token-invalid"
RTCErrorDetailTypeSCTPFailure RTCErrorDetailType = "sctp-failure"
RTCErrorDetailTypeSDPSyntaxError RTCErrorDetailType = "sdp-syntax-error"
RTCErrorDetailTypeHardwareEncoderNotAvailable RTCErrorDetailType = "hardware-encoder-not-available"
RTCErrorDetailTypeHardwareEncoderError RTCErrorDetailType = "hardware-encoder-error"
)
// http://w3c.github.io/webrtc-pc/#dom-rtcconfiguration
type RTCConfiguration struct {
IceServers []RTCIceServer
IceTransportPolicy RTCIceTransportPolicy // all
BundlePolicy RTCBundlePolicy // balanced
RTCPMuxPolicy RTCRtcpMuxPolicy // require
PeerIdentity string
Certificates []RTCCertificate
IceCandidatePoolSize uint8 // 0
}
func wrapRTCConfiguration(v Value) RTCConfiguration {
c := RTCConfiguration{}
if v.valid() {
c.IceServers = toRTCIceServerSlice(v.get("iceServers"))
c.IceTransportPolicy = RTCIceTransportPolicy(v.get("iceTransportPolicy").toString())
c.BundlePolicy = RTCBundlePolicy(v.get("bundlePolicy").toString())
c.RTCPMuxPolicy = RTCRtcpMuxPolicy(v.get("rtcpMuxPolicy").toString())
c.PeerIdentity = v.get("peerIdentity").toString()
c.Certificates = toRTCCertificateSlice(v.get("certificates"))
c.IceCandidatePoolSize = v.get("iceCandidatePoolSize").toUint8()
}
return c
}
func (p RTCConfiguration) JSValue() jsValue {
o := jsObject.New()
o.Set("iceServers", ToJSArray(p.IceServers))
o.Set("iceTransportPolicy", string(p.IceTransportPolicy))
o.Set("bundlePolicy", string(p.BundlePolicy))
o.Set("rtcpMuxPolicy", string(p.RTCPMuxPolicy))
o.Set("peerIdentity", p.PeerIdentity)
o.Set("certificates", ToJSArray(p.Certificates))
o.Set("iceCandidatePoolSize", p.IceCandidatePoolSize)
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcoauthcredential
type RTCOAuthCredential struct {
MacKey string
AccessToken string
}
func (p RTCOAuthCredential) JSValue() jsValue {
o := jsObject.New()
o.Set("macKey", p.MacKey)
o.Set("accessToken", p.AccessToken)
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtciceserver
type RTCIceServer struct {
URLs []string // required (DOMString or sequence<DOMString>)
Username string
Credential string // (DOMString or RTCOAuthCredential) TODO
CredentialType RTCIceCredentialType // "password"
}
func wrapRTCIceServer(v Value) RTCIceServer {
s := RTCIceServer{}
if v.valid() {
s.URLs = stringSequenceToSlice(v.get("urls"))
s.Username = v.get("username").toString()
s.Credential = v.get("credential").toString()
s.CredentialType = RTCIceCredentialType(v.get("credentialType").toString())
}
return s
}
func (p RTCIceServer) JSValue() jsValue {
o := jsObject.New()
o.Set("urls", ToJSArray(p.URLs))
o.Set("username", p.Username)
o.Set("credential", p.Credential)
o.Set("credentialType", string(p.CredentialType))
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcofferansweroptions
type RTCOfferAnswerOptions struct {
VoiceActivityDetection bool // true
}
func (p RTCOfferAnswerOptions) JSValue() jsValue {
o := jsObject.New()
o.Set("voiceActivityDetection", p.VoiceActivityDetection)
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcofferoptions
type RTCOfferOptions struct {
RTCOfferAnswerOptions
IceRestart bool // false
}
func (p RTCOfferOptions) JSValue() jsValue {
o := p.RTCOfferAnswerOptions.JSValue()
o.Set("iceRestart", p.IceRestart)
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcansweroptions
type RTCAnswerOptions struct {
RTCOfferAnswerOptions
}
// http://w3c.github.io/webrtc-pc/#dom-rtccertificateexpiration
type RTCCertificateExpiration struct {
Expires time.Time
}
func (p RTCCertificateExpiration) JSValue() jsValue {
o := jsObject.New()
o.Set("expires", p.Expires.UnixNano()/int64(time.Millisecond))
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcsessiondescriptioninit
type RTCSessionDescriptionInit struct {
Type RTCSdpType // required
SDP string // ""
}
func wrapRTCSessionDescriptionInit(v Value) RTCSessionDescriptionInit {
ret := RTCSessionDescriptionInit{}
if v.valid() {
ret.Type = RTCSdpType(v.get("type").toString())
ret.SDP = v.get("sdp").toString()
}
return ret
}
func (p RTCSessionDescriptionInit) JSValue() jsValue {
o := jsObject.New()
o.Set("type", string(p.Type))
o.Set("sdp", p.SDP)
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcicecandidateinit
type RTCIceCandidateInit struct {
Candidate string
SdpMid string
SdpMLineIndex uint16
UsernameFragment string
}
func wrapRTCIceCandidateInit(v Value) RTCIceCandidateInit {
i := RTCIceCandidateInit{}
if v.valid() {
i.Candidate = v.get("candidate").toString()
i.SdpMid = v.get("sdpMid").toString()
i.SdpMLineIndex = v.get("sdpMLineIndex").toUint16()
i.UsernameFragment = v.get("usernameFragment").toString()
}
return i
}
func (p RTCIceCandidateInit) JSValue() jsValue {
o := jsObject.New()
o.Set("candidate", p.Candidate)
o.Set("sdpMid", p.SdpMid)
o.Set("sdpMLineIndex", p.SdpMLineIndex)
o.Set("usernameFragment", p.UsernameFragment)
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcpeerconnectioniceeventinit
type RTCPeerConnectionIceEventInit struct {
EventInit
Candidate RTCIceCandidate
URL string
}
func (p RTCPeerConnectionIceEventInit) JSValue() jsValue {
o := p.EventInit.JSValue()
o.Set("candidate", JSValueOf(p.Candidate))
o.Set("url", p.URL)
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcpeerconnectioniceerroreventinit
type RTCPeerConnectionIceErrorEventInit struct {
EventInit
HostCandidate string
URL string
ErrorCode uint16 // required
StatusText string
}
func (p RTCPeerConnectionIceErrorEventInit) JSValue() jsValue {
o := p.EventInit.JSValue()
o.Set("hostCandidate", p.HostCandidate)
o.Set("url", p.URL)
o.Set("errorCode", p.ErrorCode)
o.Set("statusText", p.StatusText)
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverinit
type RTCRtpTransceiverInit struct {
Direction RTCRtpTransceiverDirection
Streams []MediaStream
SendEncodings []RTCRtpEncodingParameters
}
func (p RTCRtpTransceiverInit) JSValue() jsValue {
o := jsObject.New()
o.Set("direction", string(p.Direction))
o.Set("streams", ToJSArray(p.Streams))
o.Set("sendEncodings", ToJSArray(p.SendEncodings))
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcrtpparameters
type RTCRtpParameters struct {
HeaderExtensions []RTCRtpHeaderExtensionParameters
RTCP RTCRtcpParameters
Codecs []RTCRtpCodecParameters
}
func wrapRTCRtpParameters(v Value) RTCRtpParameters {
p := RTCRtpParameters{}
if v.valid() {
p.HeaderExtensions = toRTCRtpHeaderExtensionParametersSlice(v.get("headerExtensions"))
p.RTCP = wrapRTCRtcpParameters(v.get("rtcp"))
p.Codecs = toRTCRtpCodecParametersSlice(v.get("codecs"))
}
return p
}
func (p RTCRtpParameters) JSValue() jsValue {
o := jsObject.New()
o.Set("headerExtensions", ToJSArray(p.HeaderExtensions))
o.Set("rtcp", p.RTCP.JSValue())
o.Set("codecs", ToJSArray(p.Codecs))
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcrtpsendparameters
type RTCRtpSendParameters struct {
RTCRtpParameters
TransactionId string
Encodings []RTCRtpEncodingParameters
DegradationPreference RTCDegradationPreference // balanced
Priority RTCPriorityType // low
}
func wrapRTCRtpSendParameters(v Value) RTCRtpSendParameters {
p := RTCRtpSendParameters{}
if v.valid() {
p.RTCRtpParameters = wrapRTCRtpParameters(v)
p.TransactionId = v.get("transactionId").toString()
p.Encodings = toRTCRtpEncodingParametersSlice(v.get("encodings"))
p.DegradationPreference = RTCDegradationPreference(v.get("degradationPreference").toString())
p.Priority = RTCPriorityType(v.get("priority").toString())
}
return p
}
func (p RTCRtpSendParameters) JSValue() jsValue {
o := p.RTCRtpParameters.JSValue()
o.Set("transactionId", p.TransactionId)
o.Set("encodings", ToJSArray(p.Encodings))
o.Set("degradationPreference", string(p.DegradationPreference))
o.Set("priority", string(p.Priority))
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiveparameters
type RTCRtpReceiveParameters struct {
RTCRtpParameters
Encodings []RTCRtpDecodingParameters
}
func wrapRTCRtpReceiveParameters(v Value) RTCRtpReceiveParameters {
p := RTCRtpReceiveParameters{}
if v.valid() {
p.Encodings = toRTCRtpDecodingParametersSlice(v)
}
return p
}
func (p RTCRtpReceiveParameters) JSValue() jsValue {
o := p.RTCRtpParameters.JSValue()
o.Set("encodings", ToJSArray(p.Encodings))
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcrtpcodingparameters
type RTCRtpCodingParameters struct {
RID string
}
func wrapRTCRtpCodingParameters(v Value) RTCRtpCodingParameters {
p := RTCRtpCodingParameters{}
if v.valid() {
p.RID = v.get("rid").toString()
}
return p
}
func (p RTCRtpCodingParameters) JSValue() jsValue {
o := jsObject.New()
o.Set("rid", p.RID)
return o
}
// http://w3c.github.io/webrtc-pc/#dom-rtcrtpdecodingparameters
type RTCRtpDecodingParameters struct {
RTCRtpCodingParameters
}
func wrapRTCRtpDecodingParameters(v Value) RTCRtpDecodingParameters {
p := RTCRtpDecodingParameters{}
if v.valid() {
p.RTCRtpCodingParameters = wrapRTCRtpCodingParameters(v)
}
return p
}
// http://w3c.github.io/webrtc-pc/#dom-rtcrtpencodingparameters
type RTCRtpEncodingParameters struct {
RTCRtpCodingParameters
CodecPayloadType uint8
DTX RTCDtxStatus
Active bool // true
PTime uint
MaxBitrate uint
MaxFramerate float64
ScaleResolutionDownBy float64
}
func wrapRTCRtpEncodingParameters(v Value) RTCRtpEncodingParameters {
p := RTCRtpEncodingParameters{}
if v.valid() {
p.RTCRtpCodingParameters = wrapRTCRtpCodingParameters(v)
p.CodecPayloadType = v.get("codecPayloadType").toUint8()
p.DTX = RTCDtxStatus(v.get("dtx").toString())
p.Active = v.get("active").toBool()
p.PTime = v.get("ptime").toUint()
p.MaxBitrate = v.get("maxBitrate").toUint()
p.MaxFramerate = v.get("maxFramerate").toFloat64()
p.ScaleResolutionDownBy = v.get("scaleResolutionDownBy").toFloat64()