test RTP timestamps

This commit is contained in:
KingKDot
2026-08-05 12:06:13 -05:00
parent c3bcc2cdcc
commit 49604b8b53
14 changed files with 430 additions and 68 deletions
@@ -3,6 +3,7 @@ package handlers
import (
"context"
"encoding/binary"
"encoding/json"
"fmt"
"log"
"net/url"
@@ -182,6 +183,11 @@ func handleWebrtcP2POffer(ctx context.Context, env *runtime.Env, cmdID string, p
log.Printf("webrtc: P2P congestion target=%d Mbps applied=%d Mbps", bps/1_000_000, applied/1_000_000)
}
},
OnInput: func(data []byte) {
if kind == webrtcpub.KindDesktop {
handleP2PDesktopInput(env, data)
}
},
}
answerSDP, err := webrtcpub.StartP2POffer(ctx, kind, sessionID, offerSDP, callbacks, hasVideo, hasAudio)
@@ -206,6 +212,67 @@ func handleWebrtcP2POffer(ctx context.Context, env *runtime.Env, cmdID string, p
return nil
}
type p2pDesktopInput struct {
Type string `json:"type"`
X int32 `json:"x"`
Y int32 `json:"y"`
Button int `json:"button"`
Delta int32 `json:"delta"`
Code string `json:"code"`
Text string `json:"text"`
}
func handleP2PDesktopInput(env *runtime.Env, data []byte) {
if env == nil || len(data) == 0 || len(data) > 4096 {
return
}
var input p2pDesktopInput
if err := json.Unmarshal(data, &input); err != nil {
return
}
move := func() {
absX, absY := resolveDesktopPoint(env.SelectedDisplay, input.X, input.Y)
setCursorPos(absX, absY)
}
switch input.Type {
case "mouse_move":
if env.MouseControl {
move()
}
case "mouse_down":
if env.MouseControl {
move()
sendMouseDown(input.Button)
}
case "mouse_up":
if env.MouseControl {
move()
sendMouseUp(input.Button)
}
case "mouse_wheel":
if env.MouseControl {
move()
sendMouseWheel(input.Delta)
}
case "key_down":
if env.KeyboardControl {
if vk := keyCodeToVK(input.Code); vk != 0 {
sendKeyDown(vk)
}
}
case "key_up":
if env.KeyboardControl {
if vk := keyCodeToVK(input.Code); vk != 0 {
sendKeyUp(vk)
}
}
case "text_input":
if env.KeyboardControl && input.Text != "" {
sendTextInput(input.Text)
}
}
}
func parseICEServers(value interface{}) []webrtcpub.ICEServer {
items, ok := value.([]interface{})
if !ok {