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:
parent
732764991b
commit
45679f1b86
@ -5,8 +5,8 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"demodesk/neko"
|
"demodesk/neko"
|
||||||
"demodesk/neko/modules"
|
|
||||||
"demodesk/neko/internal/config"
|
"demodesk/neko/internal/config"
|
||||||
|
"demodesk/neko/modules"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -3,8 +3,8 @@ package members
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"demodesk/neko/internal/utils"
|
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
|
"demodesk/neko/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MemberDataPayload struct {
|
type MemberDataPayload struct {
|
||||||
|
@ -6,9 +6,9 @@ import (
|
|||||||
|
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
|
|
||||||
|
"demodesk/neko/internal/http/auth"
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/utils"
|
"demodesk/neko/internal/utils"
|
||||||
"demodesk/neko/internal/http/auth"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type key int
|
type key int
|
||||||
|
@ -3,9 +3,9 @@ package room
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"demodesk/neko/internal/utils"
|
|
||||||
"demodesk/neko/internal/types/event"
|
"demodesk/neko/internal/types/event"
|
||||||
"demodesk/neko/internal/types/message"
|
"demodesk/neko/internal/types/message"
|
||||||
|
"demodesk/neko/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BroadcastStatusPayload struct {
|
type BroadcastStatusPayload struct {
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
//"strings"
|
//"strings"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"demodesk/neko/internal/utils"
|
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
|
"demodesk/neko/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ClipboardPayload struct {
|
type ClipboardPayload struct {
|
||||||
|
@ -5,10 +5,10 @@ import (
|
|||||||
|
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
|
|
||||||
|
"demodesk/neko/internal/http/auth"
|
||||||
"demodesk/neko/internal/types/event"
|
"demodesk/neko/internal/types/event"
|
||||||
"demodesk/neko/internal/types/message"
|
"demodesk/neko/internal/types/message"
|
||||||
"demodesk/neko/internal/utils"
|
"demodesk/neko/internal/utils"
|
||||||
"demodesk/neko/internal/http/auth"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ControlStatusPayload struct {
|
type ControlStatusPayload struct {
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
|
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
|
|
||||||
"demodesk/neko/internal/types"
|
|
||||||
"demodesk/neko/internal/http/auth"
|
"demodesk/neko/internal/http/auth"
|
||||||
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/utils"
|
"demodesk/neko/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ package room
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"demodesk/neko/internal/utils"
|
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
|
"demodesk/neko/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type KeyboardMapData struct {
|
type KeyboardMapData struct {
|
||||||
@ -28,7 +28,7 @@ func (h *RoomHandler) keyboardMapSet(w http.ResponseWriter, r *http.Request) {
|
|||||||
Variant: data.Variant,
|
Variant: data.Variant,
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil{
|
if err != nil {
|
||||||
utils.HttpInternalServerError(w, "Unable to change keyboard map.")
|
utils.HttpInternalServerError(w, "Unable to change keyboard map.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ func (h *RoomHandler) keyboardMapSet(w http.ResponseWriter, r *http.Request) {
|
|||||||
func (h *RoomHandler) keyboardMapGet(w http.ResponseWriter, r *http.Request) {
|
func (h *RoomHandler) keyboardMapGet(w http.ResponseWriter, r *http.Request) {
|
||||||
data, err := h.desktop.GetKeyboardMap()
|
data, err := h.desktop.GetKeyboardMap()
|
||||||
|
|
||||||
if err != nil{
|
if err != nil {
|
||||||
utils.HttpInternalServerError(w, "Unable to get keyboard map.")
|
utils.HttpInternalServerError(w, "Unable to get keyboard map.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package room
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"image/jpeg"
|
"image/jpeg"
|
||||||
"strconv"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/types/event"
|
"demodesk/neko/internal/types/event"
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package room
|
package room
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"demodesk/neko/internal/utils"
|
"demodesk/neko/internal/utils"
|
||||||
)
|
)
|
||||||
@ -62,7 +62,7 @@ func (h *RoomHandler) uploadDrop(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
defer srcFile.Close()
|
defer srcFile.Close()
|
||||||
|
|
||||||
dstFile, err := os.OpenFile(path, os.O_APPEND | os.O_CREATE | os.O_WRONLY, 0644)
|
dstFile, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.HttpInternalServerError(w, err)
|
utils.HttpInternalServerError(w, err)
|
||||||
return
|
return
|
||||||
@ -125,7 +125,7 @@ func (h *RoomHandler) uploadDialogPost(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
defer srcFile.Close()
|
defer srcFile.Close()
|
||||||
|
|
||||||
dstFile, err := os.OpenFile(path, os.O_APPEND | os.O_CREATE | os.O_WRONLY, 0644)
|
dstFile, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.HttpInternalServerError(w, err)
|
utils.HttpInternalServerError(w, err)
|
||||||
return
|
return
|
||||||
|
@ -7,10 +7,10 @@ import (
|
|||||||
|
|
||||||
"demodesk/neko/internal/api/members"
|
"demodesk/neko/internal/api/members"
|
||||||
"demodesk/neko/internal/api/room"
|
"demodesk/neko/internal/api/room"
|
||||||
|
"demodesk/neko/internal/config"
|
||||||
"demodesk/neko/internal/http/auth"
|
"demodesk/neko/internal/http/auth"
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/utils"
|
"demodesk/neko/internal/utils"
|
||||||
"demodesk/neko/internal/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ApiManagerCtx struct {
|
type ApiManagerCtx struct {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"demodesk/neko/internal/utils"
|
|
||||||
"demodesk/neko/internal/types"
|
|
||||||
"demodesk/neko/internal/http/auth"
|
"demodesk/neko/internal/http/auth"
|
||||||
|
"demodesk/neko/internal/types"
|
||||||
|
"demodesk/neko/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SessionLoginPayload struct {
|
type SessionLoginPayload struct {
|
||||||
|
@ -2,8 +2,8 @@ package capture
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
@ -8,8 +8,8 @@ package gst
|
|||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
|
@ -7,9 +7,9 @@ import (
|
|||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
|
"demodesk/neko/internal/config"
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/types/codec"
|
"demodesk/neko/internal/types/codec"
|
||||||
"demodesk/neko/internal/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type CaptureManagerCtx struct {
|
type CaptureManagerCtx struct {
|
||||||
@ -29,18 +29,18 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt
|
|||||||
broadcastPipeline := config.BroadcastPipeline
|
broadcastPipeline := config.BroadcastPipeline
|
||||||
if broadcastPipeline == "" {
|
if broadcastPipeline == "" {
|
||||||
broadcastPipeline = fmt.Sprintf(
|
broadcastPipeline = fmt.Sprintf(
|
||||||
"flvmux name=mux ! rtmpsink location='{url} live=1' " +
|
"flvmux name=mux ! rtmpsink location='{url} live=1' "+
|
||||||
"pulsesrc device=%s " +
|
"pulsesrc device=%s "+
|
||||||
"! audio/x-raw,channels=2 " +
|
"! audio/x-raw,channels=2 "+
|
||||||
"! audioconvert " +
|
"! audioconvert "+
|
||||||
"! queue " +
|
"! queue "+
|
||||||
"! voaacenc " +
|
"! voaacenc "+
|
||||||
"! mux. " +
|
"! mux. "+
|
||||||
"ximagesrc display-name=%s show-pointer=true use-damage=false " +
|
"ximagesrc display-name=%s show-pointer=true use-damage=false "+
|
||||||
"! video/x-raw " +
|
"! video/x-raw "+
|
||||||
"! videoconvert " +
|
"! videoconvert "+
|
||||||
"! queue " +
|
"! queue "+
|
||||||
"! x264enc threads=4 bitrate=4096 key-int-max=15 byte-stream=true byte-stream=true tune=zerolatency speed-preset=veryfast " +
|
"! x264enc threads=4 bitrate=4096 key-int-max=15 byte-stream=true byte-stream=true tune=zerolatency speed-preset=veryfast "+
|
||||||
"! mux.", config.Device, config.Display,
|
"! mux.", config.Device, config.Display,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -48,11 +48,11 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt
|
|||||||
screencastPipeline := config.ScreencastPipeline
|
screencastPipeline := config.ScreencastPipeline
|
||||||
if screencastPipeline == "" {
|
if screencastPipeline == "" {
|
||||||
screencastPipeline = fmt.Sprintf(
|
screencastPipeline = fmt.Sprintf(
|
||||||
"ximagesrc display-name=%s show-pointer=true use-damage=false " +
|
"ximagesrc display-name=%s show-pointer=true use-damage=false "+
|
||||||
"! video/x-raw,framerate=%s " +
|
"! video/x-raw,framerate=%s "+
|
||||||
"! videoconvert " +
|
"! videoconvert "+
|
||||||
"! queue " +
|
"! queue "+
|
||||||
"! jpegenc quality=%s " +
|
"! jpegenc quality=%s "+
|
||||||
"! appsink name=appsink", config.Display, config.ScreencastRate, config.ScreencastQuality,
|
"! appsink name=appsink", config.Display, config.ScreencastRate, config.ScreencastQuality,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -69,11 +69,11 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt
|
|||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"pulsesrc device=%s " +
|
"pulsesrc device=%s "+
|
||||||
"! audio/x-raw,channels=2 " +
|
"! audio/x-raw,channels=2 "+
|
||||||
"! audioconvert " +
|
"! audioconvert "+
|
||||||
"! queue " +
|
"! queue "+
|
||||||
"! %s " +
|
"! %s "+
|
||||||
"! appsink name=appsink", config.Device, config.AudioCodec.Pipeline,
|
"! appsink name=appsink", config.Device, config.AudioCodec.Pipeline,
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
@ -83,70 +83,70 @@ func New(desktop types.DesktopManager, config *config.Capture) *CaptureManagerCt
|
|||||||
bitrate := screen.Width * screen.Height * 12
|
bitrate := screen.Width * screen.Height * 12
|
||||||
|
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"ximagesrc display-name=%s show-pointer=false use-damage=false " +
|
"ximagesrc display-name=%s show-pointer=false use-damage=false "+
|
||||||
"! video/x-raw,framerate=25/1 " +
|
"! video/x-raw,framerate=25/1 "+
|
||||||
"! videoconvert " +
|
"! videoconvert "+
|
||||||
"! queue " +
|
"! queue "+
|
||||||
"! vp8enc target-bitrate=%d cpu-used=16 threads=4 deadline=100000 error-resilient=partitions keyframe-max-dist=15 auto-alt-ref=true min-quantizer=6 max-quantizer=12 " +
|
"! vp8enc target-bitrate=%d cpu-used=16 threads=4 deadline=100000 error-resilient=partitions keyframe-max-dist=15 auto-alt-ref=true min-quantizer=6 max-quantizer=12 "+
|
||||||
"! appsink name=appsink", config.Display, bitrate,
|
"! appsink name=appsink", config.Display, bitrate,
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
"hq": streamNew(codec.VP8(), func() string {
|
"hq": streamNew(codec.VP8(), func() string {
|
||||||
screen := desktop.GetScreenSize()
|
screen := desktop.GetScreenSize()
|
||||||
width := int(math.Ceil(float64(screen.Width) / 6) * 5)
|
width := int(math.Ceil(float64(screen.Width)/6) * 5)
|
||||||
height := int(math.Ceil(float64(screen.Height) / 6) * 5)
|
height := int(math.Ceil(float64(screen.Height)/6) * 5)
|
||||||
bitrate := width * height * 12
|
bitrate := width * height * 12
|
||||||
|
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"ximagesrc display-name=%s show-pointer=false use-damage=false " +
|
"ximagesrc display-name=%s show-pointer=false use-damage=false "+
|
||||||
"! video/x-raw,framerate=25/1 " +
|
"! video/x-raw,framerate=25/1 "+
|
||||||
"! videoconvert " +
|
"! videoconvert "+
|
||||||
"! queue " +
|
"! queue "+
|
||||||
"! videoscale " +
|
"! videoscale "+
|
||||||
"! video/x-raw,width=%d,height=%d " +
|
"! video/x-raw,width=%d,height=%d "+
|
||||||
"! queue " +
|
"! queue "+
|
||||||
"! vp8enc target-bitrate=%d cpu-used=16 threads=4 deadline=100000 error-resilient=partitions keyframe-max-dist=15 auto-alt-ref=true min-quantizer=6 max-quantizer=12 " +
|
"! vp8enc target-bitrate=%d cpu-used=16 threads=4 deadline=100000 error-resilient=partitions keyframe-max-dist=15 auto-alt-ref=true min-quantizer=6 max-quantizer=12 "+
|
||||||
"! appsink name=appsink", config.Display, width, height, bitrate,
|
"! appsink name=appsink", config.Display, width, height, bitrate,
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
"mq": streamNew(codec.VP8(), func() string {
|
"mq": streamNew(codec.VP8(), func() string {
|
||||||
screen := desktop.GetScreenSize()
|
screen := desktop.GetScreenSize()
|
||||||
width := int(math.Ceil(float64(screen.Width) / 6) * 4)
|
width := int(math.Ceil(float64(screen.Width)/6) * 4)
|
||||||
height := int(math.Ceil(float64(screen.Height) / 6) * 4)
|
height := int(math.Ceil(float64(screen.Height)/6) * 4)
|
||||||
bitrate := width * height * 8
|
bitrate := width * height * 8
|
||||||
|
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"ximagesrc display-name=%s show-pointer=false use-damage=false " +
|
"ximagesrc display-name=%s show-pointer=false use-damage=false "+
|
||||||
"! video/x-raw,framerate=125/10 " +
|
"! video/x-raw,framerate=125/10 "+
|
||||||
"! videoconvert " +
|
"! videoconvert "+
|
||||||
"! queue " +
|
"! queue "+
|
||||||
"! videoscale " +
|
"! videoscale "+
|
||||||
"! video/x-raw,width=%d,height=%d " +
|
"! video/x-raw,width=%d,height=%d "+
|
||||||
"! queue " +
|
"! queue "+
|
||||||
"! vp8enc target-bitrate=%d cpu-used=16 threads=4 deadline=100000 error-resilient=partitions keyframe-max-dist=15 auto-alt-ref=true min-quantizer=12 max-quantizer=24 " +
|
"! vp8enc target-bitrate=%d cpu-used=16 threads=4 deadline=100000 error-resilient=partitions keyframe-max-dist=15 auto-alt-ref=true min-quantizer=12 max-quantizer=24 "+
|
||||||
"! appsink name=appsink", config.Display, width, height, bitrate,
|
"! appsink name=appsink", config.Display, width, height, bitrate,
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
"lq": streamNew(codec.VP8(), func() string {
|
"lq": streamNew(codec.VP8(), func() string {
|
||||||
screen := desktop.GetScreenSize()
|
screen := desktop.GetScreenSize()
|
||||||
width := int(math.Ceil(float64(screen.Width) / 6) * 3)
|
width := int(math.Ceil(float64(screen.Width)/6) * 3)
|
||||||
height := int(math.Ceil(float64(screen.Height) / 6) * 3)
|
height := int(math.Ceil(float64(screen.Height)/6) * 3)
|
||||||
bitrate := width * height * 4
|
bitrate := width * height * 4
|
||||||
|
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"ximagesrc display-name=%s show-pointer=false use-damage=false " +
|
"ximagesrc display-name=%s show-pointer=false use-damage=false "+
|
||||||
"! video/x-raw,framerate=125/10 " +
|
"! video/x-raw,framerate=125/10 "+
|
||||||
"! videoconvert " +
|
"! videoconvert "+
|
||||||
"! queue " +
|
"! queue "+
|
||||||
"! videoscale " +
|
"! videoscale "+
|
||||||
"! video/x-raw,width=%d,height=%d " +
|
"! video/x-raw,width=%d,height=%d "+
|
||||||
"! queue " +
|
"! queue "+
|
||||||
"! vp8enc target-bitrate=%d cpu-used=16 threads=4 deadline=100000 error-resilient=partitions keyframe-max-dist=15 auto-alt-ref=true min-quantizer=12 max-quantizer=24 " +
|
"! vp8enc target-bitrate=%d cpu-used=16 threads=4 deadline=100000 error-resilient=partitions keyframe-max-dist=15 auto-alt-ref=true min-quantizer=12 max-quantizer=24 "+
|
||||||
"! appsink name=appsink", config.Display, width, height, bitrate,
|
"! appsink name=appsink", config.Display, width, height, bitrate,
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
videoIDs: []string{ "hd", "hq", "mq", "lq" },
|
videoIDs: []string{"hd", "hq", "mq", "lq"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,15 +2,15 @@ package capture
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"demodesk/neko/internal/types"
|
|
||||||
"demodesk/neko/internal/capture/gst"
|
"demodesk/neko/internal/capture/gst"
|
||||||
|
"demodesk/neko/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScreencastManagerCtx struct {
|
type ScreencastManagerCtx struct {
|
||||||
@ -146,7 +146,7 @@ func (manager *ScreencastManagerCtx) createPipeline() error {
|
|||||||
|
|
||||||
manager.pipeline.Start()
|
manager.pipeline.Start()
|
||||||
manager.sample = manager.pipeline.Sample
|
manager.sample = manager.pipeline.Sample
|
||||||
manager.emitUpdate <-true
|
manager.emitUpdate <- true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,15 +2,15 @@ package capture
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
|
"demodesk/neko/internal/capture/gst"
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/types/codec"
|
"demodesk/neko/internal/types/codec"
|
||||||
"demodesk/neko/internal/capture/gst"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type StreamManagerCtx struct {
|
type StreamManagerCtx struct {
|
||||||
@ -146,7 +146,7 @@ func (manager *StreamManagerCtx) createPipeline() error {
|
|||||||
manager.pipeline.Start()
|
manager.pipeline.Start()
|
||||||
|
|
||||||
manager.sample = manager.pipeline.Sample
|
manager.sample = manager.pipeline.Sample
|
||||||
manager.emitUpdate <-true
|
manager.emitUpdate <- true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package desktop
|
package desktop
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -49,10 +49,10 @@ func (manager *DesktopManagerCtx) DropFiles(x int, y int, files []string) bool {
|
|||||||
go drop.OpenWindow(files)
|
go drop.OpenWindow(files)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case succeeded := <- finished:
|
case succeeded := <-finished:
|
||||||
return succeeded
|
return succeeded
|
||||||
case <-time.After(1 * time.Second):
|
case <-time.After(1 * time.Second):
|
||||||
drop.CloseWindow();
|
drop.CloseWindow()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ func OpenWindow(files []string) {
|
|||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
|
|
||||||
size := C.int(len(files))
|
size := C.int(len(files))
|
||||||
urisUnsafe := C.dragUrisMake(size);
|
urisUnsafe := C.dragUrisMake(size)
|
||||||
defer C.dragUrisFree(urisUnsafe, size)
|
defer C.dragUrisFree(urisUnsafe, size)
|
||||||
|
|
||||||
for i, file := range files {
|
for i, file := range files {
|
||||||
|
@ -2,8 +2,8 @@ package desktop
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -22,7 +22,7 @@ func (manager *DesktopManagerCtx) HandleFileChooserDialog(uri string) error {
|
|||||||
"search", "--name", FILE_CHOOSER_DIALOG_NAME, "windowfocus",
|
"search", "--name", FILE_CHOOSER_DIALOG_NAME, "windowfocus",
|
||||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||||
"key", "--clearmodifiers", "ctrl+l",
|
"key", "--clearmodifiers", "ctrl+l",
|
||||||
"type", "--args", "1", uri + "//",
|
"type", "--args", "1", uri+"//",
|
||||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||||
"key", "Delete", // remove autocomplete results
|
"key", "Delete", // remove autocomplete results
|
||||||
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
"sleep", FILE_CHOOSER_DIALOG_SHORT_SLEEP,
|
||||||
|
@ -2,16 +2,16 @@ package desktop
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/kataras/go-events"
|
"github.com/kataras/go-events"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"demodesk/neko/internal/config"
|
"demodesk/neko/internal/config"
|
||||||
"demodesk/neko/internal/desktop/xorg"
|
|
||||||
"demodesk/neko/internal/desktop/xevent"
|
"demodesk/neko/internal/desktop/xevent"
|
||||||
|
"demodesk/neko/internal/desktop/xorg"
|
||||||
)
|
)
|
||||||
|
|
||||||
var mu = sync.Mutex{}
|
var mu = sync.Mutex{}
|
||||||
|
@ -8,9 +8,9 @@ package xevent
|
|||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/kataras/go-events"
|
"github.com/kataras/go-events"
|
||||||
)
|
)
|
||||||
|
@ -2,11 +2,11 @@ package desktop
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
"regexp"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"demodesk/neko/internal/types"
|
|
||||||
"demodesk/neko/internal/desktop/xorg"
|
"demodesk/neko/internal/desktop/xorg"
|
||||||
|
"demodesk/neko/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Refactor.
|
// TODO: Refactor.
|
||||||
|
@ -242,7 +242,7 @@ func GetCursorImage() *types.CursorImage {
|
|||||||
Yhot: uint16(cur.yhot),
|
Yhot: uint16(cur.yhot),
|
||||||
Serial: uint64(cur.cursor_serial),
|
Serial: uint64(cur.cursor_serial),
|
||||||
// Xlib stores 32-bit data in longs, even if longs are 64-bits long.
|
// Xlib stores 32-bit data in longs, even if longs are 64-bits long.
|
||||||
Pixels: C.GoBytes(unsafe.Pointer(cur.pixels), C.int(width * height * 8)),
|
Pixels: C.GoBytes(unsafe.Pointer(cur.pixels), C.int(width*height*8)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ func GetScreenshotImage() *image.RGBA {
|
|||||||
|
|
||||||
var w, h C.int
|
var w, h C.int
|
||||||
pixelsUnsafe := C.XGetScreenshot(&w, &h)
|
pixelsUnsafe := C.XGetScreenshot(&w, &h)
|
||||||
pixels := C.GoBytes(unsafe.Pointer(pixelsUnsafe), w * h * 3)
|
pixels := C.GoBytes(unsafe.Pointer(pixelsUnsafe), w*h*3)
|
||||||
defer C.free(unsafe.Pointer(pixelsUnsafe))
|
defer C.free(unsafe.Pointer(pixelsUnsafe))
|
||||||
|
|
||||||
width := int(w)
|
width := int(w)
|
||||||
@ -288,7 +288,7 @@ func goSetScreenRates(index C.int, rate_index C.int, rateC C.short) {
|
|||||||
rate := int16(rateC)
|
rate := int16(rateC)
|
||||||
|
|
||||||
// filter out all irrelevant rates
|
// filter out all irrelevant rates
|
||||||
if rate > 60 || (rate > 30 && rate % 10 != 0){
|
if rate > 60 || (rate > 30 && rate%10 != 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"demodesk/neko/internal/types"
|
|
||||||
"demodesk/neko/internal/config"
|
"demodesk/neko/internal/config"
|
||||||
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/utils"
|
"demodesk/neko/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ func New() types.MembersDatabase {
|
|||||||
return &MembersDatabaseCtx{}
|
return &MembersDatabaseCtx{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type MembersDatabaseCtx struct {}
|
type MembersDatabaseCtx struct{}
|
||||||
|
|
||||||
func (manager *MembersDatabaseCtx) Connect() error {
|
func (manager *MembersDatabaseCtx) Connect() error {
|
||||||
return nil
|
return nil
|
||||||
|
@ -2,9 +2,9 @@ package file
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"fmt"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package database
|
package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"demodesk/neko/internal/config"
|
||||||
"demodesk/neko/internal/session/database/dummy"
|
"demodesk/neko/internal/session/database/dummy"
|
||||||
"demodesk/neko/internal/session/database/file"
|
"demodesk/neko/internal/session/database/file"
|
||||||
"demodesk/neko/internal/session/database/object"
|
"demodesk/neko/internal/session/database/object"
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(config *config.Session) types.MembersDatabase {
|
func New(config *config.Session) types.MembersDatabase {
|
||||||
|
@ -8,9 +8,9 @@ import (
|
|||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
|
"demodesk/neko/internal/config"
|
||||||
"demodesk/neko/internal/session/database"
|
"demodesk/neko/internal/session/database"
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/config"
|
|
||||||
"demodesk/neko/internal/utils"
|
"demodesk/neko/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/base64"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"image/png"
|
"image/png"
|
||||||
"encoding/base64"
|
|
||||||
|
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
)
|
)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/rs/zerolog"
|
"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) Tracef(format string, args ...interface{}) {}
|
||||||
|
@ -3,18 +3,18 @@ package webrtc
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/pion/webrtc/v3"
|
"github.com/pion/webrtc/v3"
|
||||||
"github.com/pion/webrtc/v3/pkg/media"
|
"github.com/pion/webrtc/v3/pkg/media"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
|
"demodesk/neko/internal/config"
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/types/event"
|
"demodesk/neko/internal/types/event"
|
||||||
"demodesk/neko/internal/types/message"
|
"demodesk/neko/internal/types/message"
|
||||||
"demodesk/neko/internal/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(desktop types.DesktopManager, capture types.CaptureManager, config *config.WebRTC) *WebRTCManagerCtx {
|
func New(desktop types.DesktopManager, capture types.CaptureManager, config *config.WebRTC) *WebRTCManagerCtx {
|
||||||
@ -58,7 +58,7 @@ func (manager *WebRTCManagerCtx) Start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
audio.AddListener(&listener)
|
audio.AddListener(&listener)
|
||||||
manager.audioStop = func(){
|
manager.audioStop = func() {
|
||||||
audio.RemoveListener(&listener)
|
audio.RemoveListener(&listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package webrtc
|
package webrtc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/utils"
|
"demodesk/neko/internal/utils"
|
||||||
|
@ -39,7 +39,6 @@ func (ws *WebSocketManagerCtx) fileChooserDialogEvents() {
|
|||||||
}, nil)
|
}, nil)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// when new user joins, and someone holds dialog, he shouldd be notified about it.
|
// when new user joins, and someone holds dialog, he shouldd be notified about it.
|
||||||
ws.sessions.OnConnected(func(session types.Session) {
|
ws.sessions.OnConnected(func(session types.Session) {
|
||||||
if file_chooser_dialog_member == nil {
|
if file_chooser_dialog_member == nil {
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"demodesk/neko/internal/types/message"
|
"demodesk/neko/internal/types/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func (h *MessageHandlerCtx) keyboardMap(session types.Session, payload *message.KeyboardMap) error {
|
func (h *MessageHandlerCtx) keyboardMap(session types.Session, payload *message.KeyboardMap) error {
|
||||||
if !session.IsHost() {
|
if !session.IsHost() {
|
||||||
h.logger.Debug().Str("id", session.ID()).Msg("is not the host")
|
h.logger.Debug().Str("id", session.ID()).Msg("is not the host")
|
||||||
|
@ -2,8 +2,8 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/types/message"
|
|
||||||
"demodesk/neko/internal/types/event"
|
"demodesk/neko/internal/types/event"
|
||||||
|
"demodesk/neko/internal/types/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h *MessageHandlerCtx) sendUnicast(session types.Session, payload *message.SendUnicast) error {
|
func (h *MessageHandlerCtx) sendUnicast(session types.Session, payload *message.SendUnicast) error {
|
||||||
@ -28,6 +28,6 @@ func (h *MessageHandlerCtx) sendBroadcast(session types.Session, payload *messag
|
|||||||
Sender: session.ID(),
|
Sender: session.ID(),
|
||||||
Subject: payload.Subject,
|
Subject: payload.Subject,
|
||||||
Body: payload.Body,
|
Body: payload.Body,
|
||||||
}, []string{ session.ID() })
|
}, []string{session.ID()})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ func (h *MessageHandlerCtx) SessionDeleted(session types.Session) error {
|
|||||||
message.MemberID{
|
message.MemberID{
|
||||||
Event: event.MEMBER_DELETED,
|
Event: event.MEMBER_DELETED,
|
||||||
ID: session.ID(),
|
ID: session.ID(),
|
||||||
}, nil);
|
}, nil)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,10 @@ import (
|
|||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"demodesk/neko/internal/websocket/handler"
|
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/types/event"
|
"demodesk/neko/internal/types/event"
|
||||||
"demodesk/neko/internal/types/message"
|
"demodesk/neko/internal/types/message"
|
||||||
|
"demodesk/neko/internal/websocket/handler"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New(
|
func New(
|
||||||
|
10
neko.go
10
neko.go
@ -6,14 +6,14 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
|
"demodesk/neko/internal/api"
|
||||||
|
"demodesk/neko/internal/capture"
|
||||||
"demodesk/neko/internal/config"
|
"demodesk/neko/internal/config"
|
||||||
"demodesk/neko/internal/desktop"
|
"demodesk/neko/internal/desktop"
|
||||||
"demodesk/neko/internal/capture"
|
|
||||||
"demodesk/neko/internal/webrtc"
|
|
||||||
"demodesk/neko/internal/session"
|
|
||||||
"demodesk/neko/internal/websocket"
|
|
||||||
"demodesk/neko/internal/api"
|
|
||||||
"demodesk/neko/internal/http"
|
"demodesk/neko/internal/http"
|
||||||
|
"demodesk/neko/internal/session"
|
||||||
|
"demodesk/neko/internal/webrtc"
|
||||||
|
"demodesk/neko/internal/websocket"
|
||||||
"demodesk/neko/modules"
|
"demodesk/neko/modules"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
|
Loading…
Reference in New Issue
Block a user