forked from keroserene/go-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
peerconnection_windows.go
133 lines (113 loc) · 4.25 KB
/
peerconnection_windows.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
// +build windows
package webrtc
/*
#include "peerconnection.h"
#include "string.h"
*/
import "C"
import (
"unsafe"
)
func init() {
// mod, err := syscall.LoadDLL("webrtc.dll")
}
//export dll_AddIceCandidate
func dll_AddIceCandidate(cgoPeer C.CGO_Peer, cgoIC *C.CGO_IceCandidate) C.int {
r1, _, _ := myfuncs["dll_AddIceCandidate"].Call(uintptr(cgoPeer), uintptr(unsafe.Pointer(cgoIC)))
return C.int(r1)
}
//export dll_CreateAnswer
func dll_CreateAnswer(cgoPeer C.CGO_Peer) C.CGO_sdpString {
r1, _, _ := myfuncs["dll_CreateAnswer"].Call(uintptr(cgoPeer))
// The caller is going to call free using C.free, that will invoke gcc's free which
// is NOT the same as MSVC's free
res := C.strdup((*C.char)(unsafe.Pointer(r1)))
myfuncs["dll_Free"].Call(r1)
return C.CGO_sdpString(res)
}
//export dll_CreateDataChannel
func dll_CreateDataChannel(cgoPeer C.CGO_Peer, label *C.char, dict unsafe.Pointer) unsafe.Pointer {
r1, _, _ := myfuncs["dll_CreateDataChannel"].Call(uintptr(cgoPeer), uintptr(unsafe.Pointer(label)), uintptr(unsafe.Pointer(dict)))
return unsafe.Pointer(r1)
}
//export dll_CreateOffer
func dll_CreateOffer(cgoPeer C.CGO_Peer) C.CGO_sdpString {
r1, _, _ := myfuncs["dll_CreateOffer"].Call(uintptr(cgoPeer))
// The caller is going to call free using C.free, that will invoke gcc's free which
// is NOT the same as MSVC's free
res := C.strdup((*C.char)(unsafe.Pointer(r1)))
myfuncs["dll_Free"].Call(r1)
return C.CGO_sdpString(res)
}
//export dll_GetLocalDescription
func dll_GetLocalDescription(cgoPeer C.CGO_Peer) C.CGO_sdp {
r1, _, _ := myfuncs["dll_GetLocalDescription"].Call(uintptr(cgoPeer))
return C.CGO_sdp(r1)
}
//export dll_GetRemoteDescription
func dll_GetRemoteDescription(cgoPeer C.CGO_Peer) C.CGO_sdp {
r1, _, _ := myfuncs["dll_GetRemoteDescription"].Call(uintptr(cgoPeer))
return C.CGO_sdp(r1)
}
//export dll_GetSignalingState
func dll_GetSignalingState(cgoPeer C.CGO_Peer) C.int {
r1, _, _ := myfuncs["dll_GetSignalingState"].Call(uintptr(cgoPeer))
return C.int(r1)
}
//export dll_IceConnectionState
func dll_IceConnectionState(cgoPeer C.CGO_Peer) C.int {
r1, _, _ := myfuncs["dll_IceConnectionState"].Call(uintptr(cgoPeer))
return C.int(r1)
}
//export dll_IceGatheringState
func dll_IceGatheringState(cgoPeer C.CGO_Peer) C.int {
r1, _, _ := myfuncs["dll_IceGatheringState"].Call(uintptr(cgoPeer))
return C.int(r1)
}
//export dll_InitializePeer
func dll_InitializePeer(goPc C.int) C.CGO_Peer {
r1, _, _ := myfuncs["dll_InitializePeer"].Call(uintptr(goPc))
return C.CGO_Peer(r1)
}
//export dll_SetLocalDescription
func dll_SetLocalDescription(cgoPeer C.CGO_Peer, sdp C.CGO_sdp) C.int {
r1, _, _ := myfuncs["dll_SetLocalDescription"].Call(uintptr(cgoPeer), uintptr(unsafe.Pointer(sdp)))
return C.int(r1)
}
//export dll_SetRemoteDescription
func dll_SetRemoteDescription(cgoPeer C.CGO_Peer, sdp C.CGO_sdp) C.int {
r1, _, _ := myfuncs["dll_SetRemoteDescription"].Call(uintptr(cgoPeer), uintptr(unsafe.Pointer(sdp)))
return C.int(r1)
}
//export dll_CreatePeerConnection
func dll_CreatePeerConnection(cgoPeer C.CGO_Peer, cgoConfig *C.CGO_Configuration) C.int {
r1, _, _ := myfuncs["dll_CreatePeerConnection"].Call(uintptr(cgoPeer), uintptr(unsafe.Pointer(cgoConfig)))
return C.int(r1)
}
//export dll_SetConfiguration
func dll_SetConfiguration(cgoPeer C.CGO_Peer, cgoConfig *C.CGO_Configuration) C.int {
r1, _, _ := myfuncs["dll_SetConfiguration"].Call(uintptr(cgoPeer), uintptr(unsafe.Pointer(cgoConfig)))
return C.int(r1)
}
//export dll_Close
func dll_Close(peer C.CGO_Peer) {
myfuncs["dll_Close"].Call(uintptr(peer))
}
//export dll_fakeIceCandidateError
func dll_fakeIceCandidateError(peer C.CGO_Peer) {
myfuncs["dll_fakeIceCandidateError"].Call(uintptr(peer))
}
//export dll_DeserializeSDP
func dll_DeserializeSDP(sdpType *C.char, msg *C.char) C.CGO_sdp {
r1, _, _ := myfuncs["dll_DeserializeSDP"].Call(uintptr(unsafe.Pointer(sdpType)), uintptr(unsafe.Pointer(msg)))
return C.CGO_sdp(unsafe.Pointer(r1))
}
//export dll_SerializeSDP
func dll_SerializeSDP(sdp C.CGO_sdp) C.CGO_sdpString {
r1, _, _ := myfuncs["dll_SerializeSDP"].Call(uintptr(sdp))
// The caller is going to call free using C.free, that will invoke gcc's free which
// is NOT the same as MSVC's free
res := C.strdup((*C.char)(unsafe.Pointer(r1)))
myfuncs["dll_Free"].Call(r1)
return C.CGO_sdpString(res)
}