mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
format Go source code.
This commit is contained in:
@ -9,11 +9,11 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
OP_MOVE = 0x01
|
||||
OP_SCROLL = 0x02
|
||||
OP_MOVE = 0x01
|
||||
OP_SCROLL = 0x02
|
||||
OP_KEY_DOWN = 0x03
|
||||
OP_KEY_UP = 0x04
|
||||
OP_KEY_CLK = 0x05
|
||||
OP_KEY_UP = 0x04
|
||||
OP_KEY_CLK = 0x05
|
||||
)
|
||||
|
||||
type PayloadHeader struct {
|
||||
|
@ -8,17 +8,17 @@ import (
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
type nulllog struct {}
|
||||
type nulllog struct{}
|
||||
|
||||
func (l nulllog) Trace(msg string) {}
|
||||
func (l nulllog) Trace(msg string) {}
|
||||
func (l nulllog) Tracef(format string, args ...interface{}) {}
|
||||
func (l nulllog) Debug(msg string) {}
|
||||
func (l nulllog) Debug(msg string) {}
|
||||
func (l nulllog) Debugf(format string, args ...interface{}) {}
|
||||
func (l nulllog) Info(msg string) {}
|
||||
func (l nulllog) Infof(format string, args ...interface{}) {}
|
||||
func (l nulllog) Warn(msg string) {}
|
||||
func (l nulllog) Warnf(format string, args ...interface{}) {}
|
||||
func (l nulllog) Error(msg string) {}
|
||||
func (l nulllog) Info(msg string) {}
|
||||
func (l nulllog) Infof(format string, args ...interface{}) {}
|
||||
func (l nulllog) Warn(msg string) {}
|
||||
func (l nulllog) Warnf(format string, args ...interface{}) {}
|
||||
func (l nulllog) Error(msg string) {}
|
||||
func (l nulllog) Errorf(format string, args ...interface{}) {}
|
||||
|
||||
type logger struct {
|
||||
|
@ -3,39 +3,39 @@ package webrtc
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/pion/webrtc/v3"
|
||||
"github.com/pion/webrtc/v3/pkg/media"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"demodesk/neko/internal/config"
|
||||
"demodesk/neko/internal/types"
|
||||
"demodesk/neko/internal/types/event"
|
||||
"demodesk/neko/internal/types/message"
|
||||
"demodesk/neko/internal/config"
|
||||
)
|
||||
|
||||
func New(desktop types.DesktopManager, capture types.CaptureManager, config *config.WebRTC) *WebRTCManagerCtx {
|
||||
return &WebRTCManagerCtx{
|
||||
logger: log.With().Str("module", "webrtc").Logger(),
|
||||
desktop: desktop,
|
||||
capture: capture,
|
||||
config: config,
|
||||
logger: log.With().Str("module", "webrtc").Logger(),
|
||||
desktop: desktop,
|
||||
capture: capture,
|
||||
config: config,
|
||||
// TODO: Refactor.
|
||||
curImgListeners: map[uintptr]*func(cur *types.CursorImage){},
|
||||
curPosListeners: map[uintptr]*func(x, y int){},
|
||||
curImgListeners: map[uintptr]*func(cur *types.CursorImage){},
|
||||
curPosListeners: map[uintptr]*func(x, y int){},
|
||||
}
|
||||
}
|
||||
|
||||
type WebRTCManagerCtx struct {
|
||||
logger zerolog.Logger
|
||||
audioTrack *webrtc.TrackLocalStaticSample
|
||||
audioStop func()
|
||||
desktop types.DesktopManager
|
||||
capture types.CaptureManager
|
||||
config *config.WebRTC
|
||||
logger zerolog.Logger
|
||||
audioTrack *webrtc.TrackLocalStaticSample
|
||||
audioStop func()
|
||||
desktop types.DesktopManager
|
||||
capture types.CaptureManager
|
||||
config *config.WebRTC
|
||||
// TODO: Refactor.
|
||||
curImgListeners map[uintptr]*func(cur *types.CursorImage)
|
||||
curPosListeners map[uintptr]*func(x, y int)
|
||||
@ -58,7 +58,7 @@ func (manager *WebRTCManagerCtx) Start() {
|
||||
}
|
||||
|
||||
audio.AddListener(&listener)
|
||||
manager.audioStop = func(){
|
||||
manager.audioStop = func() {
|
||||
audio.RemoveListener(&listener)
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
||||
if videoStream.ListenersCount() == 0 {
|
||||
videoStream.Stop()
|
||||
}
|
||||
|
||||
|
||||
videoStream = newVideoStream
|
||||
return nil
|
||||
}
|
||||
@ -234,10 +234,10 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, videoID strin
|
||||
}
|
||||
|
||||
peer := &WebRTCPeerCtx{
|
||||
api: api,
|
||||
connection: connection,
|
||||
changeVideo: changeVideo,
|
||||
dataChannel: dataChannel,
|
||||
api: api,
|
||||
connection: connection,
|
||||
changeVideo: changeVideo,
|
||||
dataChannel: dataChannel,
|
||||
}
|
||||
|
||||
cursorChange := func(cur *types.CursorImage) {
|
||||
|
@ -3,15 +3,15 @@ package webrtc
|
||||
import "github.com/pion/webrtc/v3"
|
||||
|
||||
type WebRTCPeerCtx struct {
|
||||
api *webrtc.API
|
||||
connection *webrtc.PeerConnection
|
||||
dataChannel *webrtc.DataChannel
|
||||
changeVideo func(videoID string) error
|
||||
api *webrtc.API
|
||||
connection *webrtc.PeerConnection
|
||||
dataChannel *webrtc.DataChannel
|
||||
changeVideo func(videoID string) error
|
||||
}
|
||||
|
||||
func (webrtc_peer *WebRTCPeerCtx) SignalAnswer(sdp string) error {
|
||||
return webrtc_peer.connection.SetRemoteDescription(webrtc.SessionDescription{
|
||||
SDP: sdp,
|
||||
SDP: sdp,
|
||||
Type: webrtc.SDPTypeAnswer,
|
||||
})
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package webrtc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
|
||||
"demodesk/neko/internal/types"
|
||||
"demodesk/neko/internal/utils"
|
||||
@ -11,7 +11,7 @@ import (
|
||||
|
||||
const (
|
||||
OP_CURSOR_POSITION = 0x01
|
||||
OP_CURSOR_IMAGE = 0x02
|
||||
OP_CURSOR_IMAGE = 0x02
|
||||
)
|
||||
|
||||
type PayloadCursorPosition struct {
|
||||
@ -35,7 +35,7 @@ func (webrtc_peer *WebRTCPeerCtx) SendCursorPosition(x, y int) error {
|
||||
|
||||
data := PayloadCursorPosition{
|
||||
PayloadHeader: PayloadHeader{
|
||||
Event: OP_CURSOR_POSITION,
|
||||
Event: OP_CURSOR_POSITION,
|
||||
Length: 7,
|
||||
},
|
||||
X: uint16(x),
|
||||
@ -62,13 +62,13 @@ func (webrtc_peer *WebRTCPeerCtx) SendCursorImage(cur *types.CursorImage) error
|
||||
|
||||
data := PayloadCursorImage{
|
||||
PayloadHeader: PayloadHeader{
|
||||
Event: OP_CURSOR_IMAGE,
|
||||
Event: OP_CURSOR_IMAGE,
|
||||
Length: uint16(11 + len(img)),
|
||||
},
|
||||
Width: cur.Width,
|
||||
Width: cur.Width,
|
||||
Height: cur.Height,
|
||||
Xhot: cur.Xhot,
|
||||
Yhot: cur.Yhot,
|
||||
Xhot: cur.Xhot,
|
||||
Yhot: cur.Yhot,
|
||||
}
|
||||
|
||||
buffer := &bytes.Buffer{}
|
||||
|
Reference in New Issue
Block a user