From 922ba64a84626b697dcce0b4da84f3b00629b9ac Mon Sep 17 00:00:00 2001 From: Charles Hathaway Date: Sun, 17 Sep 2023 16:29:46 -0700 Subject: [PATCH] add: Go module, proto definitions --- cmd/signaler/main.go | 7 ++++ go.mod | 3 ++ proto/signaler_service.proto | 76 ++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 cmd/signaler/main.go create mode 100644 go.mod create mode 100644 proto/signaler_service.proto diff --git a/cmd/signaler/main.go b/cmd/signaler/main.go new file mode 100644 index 0000000..e354c43 --- /dev/null +++ b/cmd/signaler/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Printf("Hello world!\n") +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..8d409e8 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/chathaway-codes/home-sensors/v2 + +go 1.21.1 diff --git a/proto/signaler_service.proto b/proto/signaler_service.proto new file mode 100644 index 0000000..630db15 --- /dev/null +++ b/proto/signaler_service.proto @@ -0,0 +1,76 @@ +syntax = "proto3"; + +service SignalerService { + rpc ListCameras(ListCamerasRequest) returns (ListCamerasResponse); + + // CreateSession creates a new session that can be seen bv the provided Camera and Peer. + // + // Optionally, wait_for_update can be set to prevent returning until the Camera has seen the + // session request, populated candidates, and returned a session offer. + rpc CreateSession(CreateSessionRequest) returns (Session); + // UpdateSession updates the session + rpc UpdateSession(UpdateSessionRequest) returns (Session); + // ListSessions lists all sessions the client should consider. + // + // TODO: it would be better if we could alert a camera to poll for sessions + // i.e., with websockets (or streaming RPCs). + rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse); +} + +message ListCamerasRequest {} + +message ListCamerasResponse { + repeated Camera cameras = 1; +} + +message CreateSessionRequest { + Session session = 1; + + // If true, will keep the connection alive until an update is received. + // This is useful if we need to wait for a remote to detect the session + // request and update it with their candidates, offer, or answer. + bool wait_for_update = 2; +} + +message UpdateSessionRequest { + Session session = 1; + + // If true, will keep the connection alive until an update is received. + // This is useful if we need to wait for a remote to detect the session + // request and update it with their candidates, offer, or answer. + bool wait_for_update = 2; +} + +message Camera { + message Identifier { + string id = 1; + } + Identifier identifier = 1; +} + +message IceCandidate { + // Copied from https://pkg.go.dev/github.com/pion/webrtc/v4#ICECandidateInit + string candidate = 1; + optional string sdp_mid = 2; + optional int32 sdp_line_index = 3; + optional string username_fragment = 4; +} + +message IceSessionDescription { + // Copied from https://pkg.go.dev/github.com/pion/webrtc/v4#SessionDescription + int sdp_type = 1; + string sdp = 2; +} + +message Session { + message Identifier { + string id = 1; + } + Identifier id = 1; + Camera.Identifier camera = 2; + repeated IceCandidate client_ice_candidates = 3; + repeated IceCandidate camera_ice_candidates = 4; + + IceSessionDescription camera_offer = 5; + IceSessionDescription client_answer = 6; +} \ No newline at end of file