-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsep.go
65 lines (53 loc) · 1.8 KB
/
jsep.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
package rawrtc
/*
#cgo CFLAGS : -g -I../../include
#cgo linux LDFLAGS: -L../../lib -ldl
#cgo windows LDFLAGS: -L../../lib
#include "api.h"
*/
import "C"
import (
"unsafe"
)
type CreateSessionDescriptionObserver struct {
fd unsafe.Pointer
OnSuccess func(desc SessionDescription)
OnFailure func(err *RTCError)
}
func (me *CreateSessionDescriptionObserver) Init(onSuccess func(desc SessionDescription), onFailure func(err *RTCError)) *CreateSessionDescriptionObserver {
me.OnSuccess = onSuccess
me.OnFailure = onFailure
return me
}
func (me *CreateSessionDescriptionObserver) release() {
C.CreateSessionDescriptionObserverRelease(me.fd)
mtx_.Lock()
delete(observers_, uintptr(unsafe.Pointer(me)))
mtx_.Unlock()
}
func NewCreateSessionDescriptionObserver(onSuccess func(desc SessionDescription), OnFailure func(err *RTCError)) *CreateSessionDescriptionObserver {
observer := new(CreateSessionDescriptionObserver).Init(onSuccess, OnFailure)
observer.fd = C.CreateCreateSessionDescriptionObserver(unsafe.Pointer(observer))
return observer
}
type SetSessionDescriptionObserver struct {
fd unsafe.Pointer
OnSuccess func()
OnFailure func(err *RTCError)
}
func (me *SetSessionDescriptionObserver) Init(onSuccess func(), onFailure func(err *RTCError)) *SetSessionDescriptionObserver {
me.OnSuccess = onSuccess
me.OnFailure = onFailure
return me
}
func (me *SetSessionDescriptionObserver) release() {
C.SetSessionDescriptionObserverRelease(me.fd)
mtx_.Lock()
delete(observers_, uintptr(unsafe.Pointer(me)))
mtx_.Unlock()
}
func NewSetSessionDescriptionObserver(onSuccess func(), onFailure func(err *RTCError)) *SetSessionDescriptionObserver {
observer := new(SetSessionDescriptionObserver).Init(onSuccess, onFailure)
observer.fd = C.CreateSetSessionDescriptionObserver(unsafe.Pointer(observer))
return observer
}