mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
go fmt.
This commit is contained in:
parent
dfe8b8b57d
commit
ee13e40d4c
@ -18,7 +18,6 @@ type CaptureManagerCtx struct {
|
|||||||
broadcast *BroacastManagerCtx
|
broadcast *BroacastManagerCtx
|
||||||
audio *StreamSinkManagerCtx
|
audio *StreamSinkManagerCtx
|
||||||
video *StreamSinkManagerCtx
|
video *StreamSinkManagerCtx
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCtx {
|
func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCtx {
|
||||||
@ -53,7 +52,8 @@ func (manager *CaptureManagerCtx) Start() {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
_ = <- manager.desktop.GetBeforeScreenSizeChangeChannel()
|
<-manager.desktop.GetBeforeScreenSizeChangeChannel()
|
||||||
|
|
||||||
if manager.video.Started() {
|
if manager.video.Started() {
|
||||||
manager.video.destroyPipeline()
|
manager.video.destroyPipeline()
|
||||||
}
|
}
|
||||||
@ -66,7 +66,8 @@ func (manager *CaptureManagerCtx) Start() {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
framerate := <- manager.desktop.GetAfterScreenSizeChangeChannel();
|
framerate := <-manager.desktop.GetAfterScreenSizeChangeChannel()
|
||||||
|
|
||||||
if manager.video.Started() {
|
if manager.video.Started() {
|
||||||
manager.video.SetChangeFramerate(framerate)
|
manager.video.SetChangeFramerate(framerate)
|
||||||
err := manager.video.createPipeline()
|
err := manager.video.createPipeline()
|
||||||
|
@ -110,6 +110,7 @@ func NewVideoPipeline(rtpCodec codec.RTPCodec, display string, pipelineSrc strin
|
|||||||
// https://gstreamer.freedesktop.org/documentation/aom/av1enc.html?gi-language=c
|
// https://gstreamer.freedesktop.org/documentation/aom/av1enc.html?gi-language=c
|
||||||
// gstreamer1.0-plugins-bad
|
// gstreamer1.0-plugins-bad
|
||||||
// av1enc usage-profile=1
|
// av1enc usage-profile=1
|
||||||
|
// TODO: check for plugin.
|
||||||
if err := gst.CheckPlugins([]string{"ximagesrc", "vpx"}); err != nil {
|
if err := gst.CheckPlugins([]string{"ximagesrc", "vpx"}); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@ package capture
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
@ -180,7 +180,7 @@ func (manager *StreamSinkManagerCtx) destroyPipeline() {
|
|||||||
manager.pipeline = nil
|
manager.pipeline = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *StreamSinkManagerCtx) GetSampleChannel() (chan types.Sample) {
|
func (manager *StreamSinkManagerCtx) GetSampleChannel() chan types.Sample {
|
||||||
if manager.pipeline != nil {
|
if manager.pipeline != nil {
|
||||||
return manager.pipeline.Sample
|
return manager.pipeline.Sample
|
||||||
}
|
}
|
||||||
|
@ -50,12 +50,12 @@ func (manager *DesktopManagerCtx) Start() {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
desktopErrorMessage := <- xevent.EventErrorChannel
|
msg := <-xevent.EventErrorChannel
|
||||||
manager.logger.Warn().
|
manager.logger.Warn().
|
||||||
Uint8("error_code", desktopErrorMessage.Error_code).
|
Uint8("error_code", msg.Error_code).
|
||||||
Str("message", desktopErrorMessage.Message).
|
Str("message", msg.Message).
|
||||||
Uint8("request_code", desktopErrorMessage.Request_code).
|
Uint8("request_code", msg.Request_code).
|
||||||
Uint8("minor_code", desktopErrorMessage.Minor_code).
|
Uint8("minor_code", msg.Minor_code).
|
||||||
Msg("X event error occurred")
|
Msg("X event error occurred")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -79,11 +79,11 @@ func (manager *DesktopManagerCtx) Start() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *DesktopManagerCtx) GetBeforeScreenSizeChangeChannel() (chan bool) {
|
func (manager *DesktopManagerCtx) GetBeforeScreenSizeChangeChannel() chan bool {
|
||||||
return manager.beforeScreenSizeChangeChannel
|
return manager.beforeScreenSizeChangeChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *DesktopManagerCtx) GetAfterScreenSizeChangeChannel() (chan int16) {
|
func (manager *DesktopManagerCtx) GetAfterScreenSizeChangeChannel() chan int16 {
|
||||||
return manager.afterScreenSizeChangeChannel
|
return manager.afterScreenSizeChangeChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,22 +5,22 @@ import (
|
|||||||
"m1k1o/neko/internal/types"
|
"m1k1o/neko/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (manager *DesktopManagerCtx) GetCursorChangedChannel() (chan uint64) {
|
func (manager *DesktopManagerCtx) GetCursorChangedChannel() chan uint64 {
|
||||||
return xevent.CursorChangedChannel
|
return xevent.CursorChangedChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *DesktopManagerCtx) GetClipboardUpdatedChannel() (chan bool) {
|
func (manager *DesktopManagerCtx) GetClipboardUpdatedChannel() chan bool {
|
||||||
return xevent.ClipboardUpdatedChannel
|
return xevent.ClipboardUpdatedChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *DesktopManagerCtx) GetFileChooserDialogOpenedChannel() (chan bool) {
|
func (manager *DesktopManagerCtx) GetFileChooserDialogOpenedChannel() chan bool {
|
||||||
return xevent.FileChooserDialogOpenedChannel
|
return xevent.FileChooserDialogOpenedChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *DesktopManagerCtx) GetFileChooserDialogClosedChannel() (chan bool) {
|
func (manager *DesktopManagerCtx) GetFileChooserDialogClosedChannel() chan bool {
|
||||||
return xevent.FileChooserDialogClosedChannel
|
return xevent.FileChooserDialogClosedChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *DesktopManagerCtx) GetEventErrorChannel() (chan types.DesktopErrorMessage) {
|
func (manager *DesktopManagerCtx) GetEventErrorChannel() chan types.DesktopErrorMessage {
|
||||||
return xevent.EventErrorChannel
|
return xevent.EventErrorChannel
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import "C"
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"m1k1o/neko/internal/types"
|
"m1k1o/neko/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -25,20 +26,22 @@ func init() {
|
|||||||
FileChooserDialogOpenedChannel = make(chan bool)
|
FileChooserDialogOpenedChannel = make(chan bool)
|
||||||
EventErrorChannel = make(chan types.DesktopErrorMessage)
|
EventErrorChannel = make(chan types.DesktopErrorMessage)
|
||||||
|
|
||||||
// Dummy goroutines since there is no consumer for the channel otherwise
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
_ = <-CursorChangedChannel
|
// TODO: Unused.
|
||||||
|
<-CursorChangedChannel
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
_ = <-FileChooserDialogClosedChannel
|
// TODO: Unused.
|
||||||
|
<-FileChooserDialogClosedChannel
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
_ = <-FileChooserDialogOpenedChannel
|
// TODO: Unused.
|
||||||
|
<-FileChooserDialogOpenedChannel
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
@ -72,7 +75,12 @@ func goXEventUnmapNotify(window C.Window) {
|
|||||||
|
|
||||||
//export goXEventError
|
//export goXEventError
|
||||||
func goXEventError(event *C.XErrorEvent, message *C.char) {
|
func goXEventError(event *C.XErrorEvent, message *C.char) {
|
||||||
EventErrorChannel <- types.DesktopErrorMessage{ uint8(event.error_code), C.GoString(message), uint8(event.request_code), uint8(event.minor_code) }
|
EventErrorChannel <- types.DesktopErrorMessage{
|
||||||
|
Error_code: uint8(event.error_code),
|
||||||
|
Message: C.GoString(message),
|
||||||
|
Request_code: uint8(event.request_code),
|
||||||
|
Minor_code: uint8(event.minor_code),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//export goXEventActive
|
//export goXEventActive
|
||||||
|
@ -50,11 +50,16 @@ func (manager *SessionManager) New(id string, admin bool, socket types.WebSocket
|
|||||||
manager.capture.Video().AddListener()
|
manager.capture.Video().AddListener()
|
||||||
manager.mu.Unlock()
|
manager.mu.Unlock()
|
||||||
|
|
||||||
manager.sessionChannel <- types.SessionInformation{ "created", id, session }
|
manager.sessionChannel <- types.SessionInformation{
|
||||||
|
Type: "created",
|
||||||
|
Id: id,
|
||||||
|
Session: session,
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
_ = <- manager.hostChannel
|
// TODO: Unused.
|
||||||
|
<-manager.hostChannel
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return session
|
return session
|
||||||
@ -76,7 +81,10 @@ func (manager *SessionManager) SetHost(id string) error {
|
|||||||
if ok {
|
if ok {
|
||||||
manager.host = id
|
manager.host = id
|
||||||
|
|
||||||
manager.hostChannel <- types.HostInformation{ "host", id }
|
manager.hostChannel <- types.HostInformation{
|
||||||
|
Type: "host",
|
||||||
|
Id: id,
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +102,10 @@ func (manager *SessionManager) GetHost() (types.Session, bool) {
|
|||||||
func (manager *SessionManager) ClearHost() {
|
func (manager *SessionManager) ClearHost() {
|
||||||
id := manager.host
|
id := manager.host
|
||||||
manager.host = ""
|
manager.host = ""
|
||||||
manager.hostChannel <- types.HostInformation{ "host_cleared", id }
|
manager.hostChannel <- types.HostInformation{
|
||||||
|
Type: "host_cleared",
|
||||||
|
Id: id,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *SessionManager) Has(id string) bool {
|
func (manager *SessionManager) Has(id string) bool {
|
||||||
@ -171,7 +182,11 @@ func (manager *SessionManager) Destroy(id string) {
|
|||||||
manager.capture.Video().RemoveListener()
|
manager.capture.Video().RemoveListener()
|
||||||
manager.mu.Unlock()
|
manager.mu.Unlock()
|
||||||
|
|
||||||
manager.sessionChannel <- types.SessionInformation{ "destroyed", id, session }
|
manager.sessionChannel <- types.SessionInformation{
|
||||||
|
Type: "destroyed",
|
||||||
|
Id: id,
|
||||||
|
Session: session,
|
||||||
|
}
|
||||||
manager.logger.Err(err).Str("session_id", id).Msg("destroying session")
|
manager.logger.Err(err).Str("session_id", id).Msg("destroying session")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -229,10 +244,10 @@ func (manager *SessionManager) AdminBroadcast(v interface{}, exclude interface{}
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *SessionManager) GetSessionChannel() (chan types.SessionInformation) {
|
func (manager *SessionManager) GetSessionChannel() chan types.SessionInformation {
|
||||||
return manager.sessionChannel
|
return manager.sessionChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *SessionManager) GetHostChannel() (chan types.HostInformation) {
|
func (manager *SessionManager) GetHostChannel() chan types.HostInformation {
|
||||||
return manager.hostChannel
|
return manager.hostChannel
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,11 @@ func (session *Session) SetPeer(peer types.Peer) error {
|
|||||||
func (session *Session) SetConnected(connected bool) error {
|
func (session *Session) SetConnected(connected bool) error {
|
||||||
session.connected = connected
|
session.connected = connected
|
||||||
if connected {
|
if connected {
|
||||||
session.manager.sessionChannel <- types.SessionInformation{ "connected", session.id, session }
|
session.manager.sessionChannel <- types.SessionInformation{
|
||||||
|
Type: "connected",
|
||||||
|
Id: session.id,
|
||||||
|
Session: session,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ type StreamSinkManager interface {
|
|||||||
|
|
||||||
ListenersCount() int
|
ListenersCount() int
|
||||||
Started() bool
|
Started() bool
|
||||||
GetSampleChannel() (chan Sample)
|
GetSampleChannel() chan Sample
|
||||||
SetChangeFramerate(rate int16)
|
SetChangeFramerate(rate int16)
|
||||||
SetAdaptiveFramerate(allow bool)
|
SetAdaptiveFramerate(allow bool)
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,7 @@ func H264() RTPCodec {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Profile ID.
|
// TODO: Profile ID.
|
||||||
func AV1() RTPCodec {
|
func AV1() RTPCodec {
|
||||||
return RTPCodec{
|
return RTPCodec{
|
||||||
|
@ -43,8 +43,8 @@ type DesktopErrorMessage struct {
|
|||||||
type DesktopManager interface {
|
type DesktopManager interface {
|
||||||
Start()
|
Start()
|
||||||
Shutdown() error
|
Shutdown() error
|
||||||
GetBeforeScreenSizeChangeChannel() (chan bool)
|
GetBeforeScreenSizeChangeChannel() chan bool
|
||||||
GetAfterScreenSizeChangeChannel() (chan int16)
|
GetAfterScreenSizeChangeChannel() chan int16
|
||||||
|
|
||||||
// clipboard
|
// clipboard
|
||||||
ReadClipboard() string
|
ReadClipboard() string
|
||||||
@ -72,9 +72,9 @@ type DesktopManager interface {
|
|||||||
GetScreenshotImage() *image.RGBA
|
GetScreenshotImage() *image.RGBA
|
||||||
|
|
||||||
// xevent
|
// xevent
|
||||||
GetCursorChangedChannel() (chan uint64)
|
GetCursorChangedChannel() chan uint64
|
||||||
GetClipboardUpdatedChannel() (chan bool)
|
GetClipboardUpdatedChannel() chan bool
|
||||||
GetFileChooserDialogOpenedChannel() (chan bool)
|
GetFileChooserDialogOpenedChannel() chan bool
|
||||||
GetFileChooserDialogClosedChannel() (chan bool)
|
GetFileChooserDialogClosedChannel() chan bool
|
||||||
GetEventErrorChannel() (chan DesktopErrorMessage)
|
GetEventErrorChannel() chan DesktopErrorMessage
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,6 @@ type SessionManager interface {
|
|||||||
Clear() error
|
Clear() error
|
||||||
Broadcast(v interface{}, exclude interface{}) error
|
Broadcast(v interface{}, exclude interface{}) error
|
||||||
AdminBroadcast(v interface{}, exclude interface{}) error
|
AdminBroadcast(v interface{}, exclude interface{}) error
|
||||||
GetSessionChannel() (chan SessionInformation)
|
GetSessionChannel() chan SessionInformation
|
||||||
GetHostChannel() (chan HostInformation)
|
GetHostChannel() chan HostInformation
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ func (manager *WebRTCManager) Start() {
|
|||||||
time.Sleep(50 * time.Millisecond)
|
time.Sleep(50 * time.Millisecond)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
newSample := <-manager.capture.Audio().GetSampleChannel()
|
newSample := <-manager.capture.Audio().GetSampleChannel()
|
||||||
err := manager.audioTrack.WriteSample(media.Sample(newSample))
|
err := manager.audioTrack.WriteSample(media.Sample(newSample))
|
||||||
if err != nil && errors.Is(err, io.ErrClosedPipe) {
|
if err != nil && errors.Is(err, io.ErrClosedPipe) {
|
||||||
@ -87,6 +88,7 @@ func (manager *WebRTCManager) Start() {
|
|||||||
time.Sleep(50 * time.Millisecond)
|
time.Sleep(50 * time.Millisecond)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
newSample := <-manager.capture.Video().GetSampleChannel()
|
newSample := <-manager.capture.Video().GetSampleChannel()
|
||||||
err := manager.videoTrack.WriteSample(media.Sample(newSample))
|
err := manager.videoTrack.WriteSample(media.Sample(newSample))
|
||||||
if err != nil && errors.Is(err, io.ErrClosedPipe) {
|
if err != nil && errors.Is(err, io.ErrClosedPipe) {
|
||||||
|
Loading…
Reference in New Issue
Block a user