diff --git a/Makefile b/Makefile index 79e938c15..e2a41db8c 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,11 @@ server: generate } generate: wire - $(WIRE) + @{ \ + echo "wiring" ;\ + cd cmd/server ;\ + $(WIRE) ;\ + } GO_TARGET=proto/livekit proto: protoc protoc-gen-go twirp-gen @@ -26,7 +30,13 @@ proto: protoc protoc-gen-go twirp-gen --twirp_opt=paths=source_relative \ --plugin=$(PROTOC_GEN_GO) \ -I=proto \ - proto/*.proto ;\ + proto/room.proto proto/model.proto ;\ + protoc --go_out=$(GO_TARGET) --go-grpc_out=$(GO_TARGET) \ + --go_opt=paths=source_relative \ + --go-grpc_opt=paths=source_relative \ + --plugin=$(PROTOC_GEN_GO) \ + -I=proto \ + proto/rtc.proto ;\ } protoc: diff --git a/cmd/server/main.go b/cmd/server/main.go index b9de227a6..91d18dbd5 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -14,9 +14,12 @@ import ( "github.com/urfave/cli/v2" "github.com/urfave/negroni" + "google.golang.org/grpc" "github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/logger" + "github.com/livekit/livekit-server/pkg/node" + "github.com/livekit/livekit-server/pkg/rtc" "github.com/livekit/livekit-server/pkg/service" "github.com/livekit/livekit-server/proto/livekit" ) @@ -75,9 +78,9 @@ func startServer(c *cli.Context) error { type LivekitServer struct { config *config.Config roomServer livekit.TwirpServer - rtcServer livekit.TwirpServer + rtcServer livekit.RTCServiceServer roomHttp *http.Server - rtcHttp *http.Server + rtcGrpc *grpc.Server running bool doneChan chan bool } @@ -88,7 +91,7 @@ func NewLivekitServer(conf *config.Config, s = &LivekitServer{ config: conf, roomServer: livekit.NewRoomServiceServer(roomService), - rtcServer: livekit.NewRTCServiceServer(rtcService), + rtcServer: rtcService, } roomHandler := configureMiddlewares(conf, s.roomServer) @@ -97,14 +100,8 @@ func NewLivekitServer(conf *config.Config, Handler: roomHandler, } - rtcMux := http.NewServeMux() - rtcMux.Handle(livekit.RTCServicePathPrefix, s.rtcServer) - rtcMux.HandleFunc("/rtc/Signal", rtcService.Signal) - rtcHandler := configureMiddlewares(conf, rtcMux) - s.rtcHttp = &http.Server{ - Addr: fmt.Sprintf(":%d", conf.RTCPort), - Handler: rtcHandler, - } + s.rtcGrpc = grpc.NewServer() + livekit.RegisterRTCServiceServer(s.rtcGrpc, s.rtcServer) return } @@ -121,7 +118,9 @@ func (s *LivekitServer) Start() error { if err != nil { return err } - rtcLn, err := net.Listen("tcp", s.rtcHttp.Addr) + + rtcAddr := fmt.Sprintf(":%d", s.config.RTCPort) + rtcLn, err := net.Listen("tcp", rtcAddr) if err != nil { return err } @@ -131,8 +130,8 @@ func (s *LivekitServer) Start() error { s.roomHttp.Serve(roomLn) }() go func() { - logger.GetLogger().Infow("starting RTC service", "address", s.rtcHttp.Addr) - s.rtcHttp.Serve(rtcLn) + logger.GetLogger().Infow("starting RTC service", "address", rtcAddr) + s.rtcGrpc.Serve(rtcLn) }() <-s.doneChan @@ -143,7 +142,7 @@ func (s *LivekitServer) Start() error { wg.Add(2) go func() { defer wg.Done() - s.rtcHttp.Shutdown(ctx) + s.rtcGrpc.GracefulStop() }() go func() { defer wg.Done() @@ -166,3 +165,7 @@ func configureMiddlewares(conf *config.Config, handler http.Handler) *negroni.Ne n.UseHandler(handler) return n } + +func newManager(conf *config.Config, localNode *node.Node) (*rtc.RoomManager, error) { + return rtc.NewRoomManager(conf.RTC, localNode.Ip) +} diff --git a/cmd/server/wire.go b/cmd/server/wire.go index 58d8da5c3..f4d2b4ef1 100644 --- a/cmd/server/wire.go +++ b/cmd/server/wire.go @@ -15,6 +15,7 @@ func InitializeServer(conf *config.Config) (*LivekitServer, error) { NewLivekitServer, node.NodeSet, service.ServiceSet, + newManager, ) return &LivekitServer{}, nil } diff --git a/cmd/server/wire_gen.go b/cmd/server/wire_gen.go index 687cc4a92..73fc8745c 100644 --- a/cmd/server/wire_gen.go +++ b/cmd/server/wire_gen.go @@ -18,11 +18,15 @@ func InitializeServer(conf *config.Config) (*LivekitServer, error) { if err != nil { return nil, err } - roomService, err := service.NewRoomService(conf, nodeNode) + roomManager, err := newManager(conf, nodeNode) if err != nil { return nil, err } - rtcService := service.NewRTCService() + roomService, err := service.NewRoomService(conf, roomManager, nodeNode) + if err != nil { + return nil, err + } + rtcService := service.NewRTCService(roomManager) livekitServer, err := NewLivekitServer(conf, roomService, rtcService) if err != nil { return nil, err diff --git a/go.mod b/go.mod index 8fb384136..9c9b6f1c5 100644 --- a/go.mod +++ b/go.mod @@ -18,5 +18,6 @@ require ( github.com/urfave/cli/v2 v2.2.0 github.com/urfave/negroni v1.0.0 go.uber.org/zap v1.16.0 + google.golang.org/grpc v1.33.1 gopkg.in/yaml.v2 v2.3.0 ) diff --git a/go.sum b/go.sum index 682171127..930a53306 100644 --- a/go.sum +++ b/go.sum @@ -531,6 +531,7 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2El google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= @@ -542,6 +543,8 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.1 h1:DGeFlSan2f+WEtCERJ4J9GJWk15TxUi8QGagfI87Xyc= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/pkg/data/redis.go b/pkg/data/redis.go deleted file mode 100644 index ba213e4d8..000000000 --- a/pkg/data/redis.go +++ /dev/null @@ -1,2 +0,0 @@ -package data - diff --git a/pkg/rtc/manager.go b/pkg/rtc/manager.go index 2d58b70f9..824beef9c 100644 --- a/pkg/rtc/manager.go +++ b/pkg/rtc/manager.go @@ -56,7 +56,3 @@ func (m *RoomManager) DeleteRoom(roomId string) error { delete(m.rooms, roomId) return nil } - -func (m *RoomManager) NewWebRTCPeer(me MediaEngine) (*WebRTCPeer, error) { - return nil, nil -} diff --git a/pkg/service/rtc.go b/pkg/service/rtc.go index e3aedfc06..dbdeb5ea6 100644 --- a/pkg/service/rtc.go +++ b/pkg/service/rtc.go @@ -1,31 +1,21 @@ package service import ( - "context" - "net/http" - + "github.com/livekit/livekit-server/pkg/rtc" "github.com/livekit/livekit-server/proto/livekit" ) type RTCService struct { + livekit.UnimplementedRTCServiceServer + manager *rtc.RoomManager } -func (s *RTCService) Join(ctx context.Context, req *livekit.JoinRequest) (res *livekit.JoinResponse, err error) { - return +func (s *RTCService) Signal(stream livekit.RTCService_SignalServer) error { + return nil } -func (s *RTCService) Offer(ctx context.Context, offer *livekit.SessionDescription) (answer *livekit.SessionDescription, err error) { - return -} - -func (s *RTCService) Trickle(ctx context.Context, req *livekit.TrickleRequest) (res *livekit.TrickleResponse, err error) { - return -} - -func (s *RTCService) Signal(w http.ResponseWriter, r *http.Request) { - -} - -func NewRTCService() *RTCService { - return &RTCService{} +func NewRTCService(manager *rtc.RoomManager) *RTCService { + return &RTCService{ + manager: manager, + } } diff --git a/pkg/service/service.go b/pkg/service/service.go index 2e77b1b5d..948b6bebf 100644 --- a/pkg/service/service.go +++ b/pkg/service/service.go @@ -7,6 +7,7 @@ import ( "github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/node" + "github.com/livekit/livekit-server/pkg/rtc" "github.com/livekit/livekit-server/proto/livekit" ) @@ -15,10 +16,10 @@ var ServiceSet = wire.NewSet( NewRTCService, ) -func NewRoomService(conf *config.Config, localNode *node.Node) (livekit.RoomService, error) { +func NewRoomService(conf *config.Config, manager *rtc.RoomManager, localNode *node.Node) (livekit.RoomService, error) { if conf.MultiNode { return nil, fmt.Errorf("multinode is not supported") } else { - return NewSimpleRoomService(conf, localNode) + return NewSimpleRoomService(manager, localNode) } } diff --git a/pkg/service/simpleroom.go b/pkg/service/simpleroom.go index b3dc649e4..297f3123b 100644 --- a/pkg/service/simpleroom.go +++ b/pkg/service/simpleroom.go @@ -5,7 +5,6 @@ import ( "github.com/twitchtv/twirp" - "github.com/livekit/livekit-server/pkg/config" "github.com/livekit/livekit-server/pkg/node" "github.com/livekit/livekit-server/pkg/rtc" "github.com/livekit/livekit-server/proto/livekit" @@ -18,12 +17,7 @@ type SimpleRoomService struct { manager *rtc.RoomManager } -func NewSimpleRoomService(conf *config.Config, localNode *node.Node) (svc *SimpleRoomService, err error) { - manager, err := rtc.NewRoomManager(conf.RTC, localNode.Ip) - if err != nil { - return - } - +func NewSimpleRoomService(manager *rtc.RoomManager, localNode *node.Node) (svc *SimpleRoomService, err error) { svc = &SimpleRoomService{ localNode: localNode, manager: manager, diff --git a/proto/livekit/model.pb.go b/proto/livekit/model.pb.go index 542813293..94e4a31ac 100644 --- a/proto/livekit/model.pb.go +++ b/proto/livekit/model.pb.go @@ -258,26 +258,27 @@ func init() { func init() { proto.RegisterFile("model.proto", fileDescriptor_4c16552f9fdb66d8) } var fileDescriptor_4c16552f9fdb66d8 = []byte{ - // 327 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0xcd, 0x6a, 0xeb, 0x30, - 0x10, 0x85, 0x71, 0x12, 0xc7, 0xf1, 0x38, 0xb9, 0xf7, 0x22, 0x2e, 0xd4, 0xa5, 0x94, 0x06, 0x77, - 0xe3, 0x6e, 0xb2, 0x68, 0xdf, 0xa0, 0x29, 0x85, 0x6c, 0x4a, 0x50, 0xbb, 0xea, 0xc6, 0xa8, 0x96, - 0xa0, 0x22, 0xd6, 0x0f, 0xd2, 0xb8, 0x24, 0xaf, 0xd4, 0xa7, 0x2c, 0x92, 0x93, 0xd0, 0xe5, 0xf9, - 0x24, 0xbe, 0x39, 0xc3, 0x40, 0xa1, 0x0c, 0x17, 0xdd, 0xca, 0x3a, 0x83, 0x86, 0x64, 0x9d, 0xfc, - 0x12, 0x3b, 0x89, 0xd5, 0x0e, 0x26, 0x2f, 0x86, 0x0b, 0xf2, 0x07, 0x46, 0x92, 0x97, 0xc9, 0x32, - 0xa9, 0x73, 0x3a, 0x92, 0x3c, 0x66, 0x5b, 0x8e, 0x8e, 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6, 0xf9, - 0x91, 0x6c, 0x38, 0x29, 0x21, 0xb3, 0xec, 0xd0, 0x19, 0xc6, 0x63, 0xe5, 0x39, 0x3d, 0xc5, 0xc7, - 0xfc, 0xfd, 0x74, 0xb7, 0x8f, 0x69, 0xbc, 0xe3, 0xc3, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3f, - 0xc9, 0x32, 0xc0, 0xd6, 0x01, 0x00, 0x00, + // 349 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0x5f, 0xcb, 0xd3, 0x30, + 0x14, 0xc6, 0xe9, 0xb6, 0xae, 0xeb, 0xe9, 0xa6, 0x12, 0x04, 0x2b, 0x22, 0x8e, 0x7a, 0x53, 0x2f, + 0xec, 0x50, 0xbf, 0x81, 0x13, 0x61, 0x37, 0x32, 0xa2, 0x57, 0xde, 0x94, 0xac, 0x0d, 0x2e, 0xac, + 0xf9, 0x43, 0x72, 0x3a, 0xb6, 0xaf, 0xe4, 0xa7, 0x7c, 0x49, 0xda, 0x8e, 0xf7, 0xaa, 0x3c, 0xbf, + 0x84, 0xdf, 0x79, 0x4e, 0x03, 0x99, 0xd4, 0x2d, 0xef, 0x2a, 0x63, 0x35, 0x6a, 0x92, 0x74, 0xe2, + 0xca, 0x2f, 0x02, 0x8b, 0x0b, 0x2c, 0x7e, 0xe9, 0x96, 0x93, 0x17, 0x30, 0x13, 0x6d, 0x1e, 0x6d, + 0xa3, 0x32, 0xa5, 0x33, 0xd1, 0x86, 0x6c, 0xf2, 0xd9, 0x98, 0x0d, 0x79, 0x0b, 0x2b, 0x8b, 0x4d, + 0x6d, 0xb4, 0xc5, 0x7c, 0xbe, 0x8d, 0xca, 0x0d, 0x4d, 0x2c, 0x36, 0x47, 0x6d, 0x91, 0x94, 0x10, + 0x3b, 0x64, 0xe8, 0xf2, 0xc5, 0x36, 0x2a, 0xb3, 0xaf, 0xa4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 0xdf, 0x3c, + 0x7d, 0x3f, 0x3b, 0x6e, 0xaf, 0xdc, 0xee, 0xc2, 0x03, 0x4f, 0xf0, 0xb4, 0x0c, 0xf1, 0xdb, 0x53, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x01, 0x7e, 0x05, 0x01, 0xfe, 0x01, 0x00, 0x00, } diff --git a/proto/livekit/room.pb.go b/proto/livekit/room.pb.go new file mode 100644 index 000000000..870c675ce --- /dev/null +++ b/proto/livekit/room.pb.go @@ -0,0 +1,294 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: room.proto + +package livekit + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type CreateRoomRequest struct { + RoomId string `protobuf:"bytes,1,opt,name=room_id,json=roomId,proto3" json:"room_id,omitempty"` + // number of seconds the room should cleanup after being empty + EmptyTimeout uint32 `protobuf:"varint,2,opt,name=empty_timeout,json=emptyTimeout,proto3" json:"empty_timeout,omitempty"` + MaxParticipants uint32 `protobuf:"varint,3,opt,name=max_participants,json=maxParticipants,proto3" json:"max_participants,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CreateRoomRequest) Reset() { *m = CreateRoomRequest{} } +func (m *CreateRoomRequest) String() string { return proto.CompactTextString(m) } +func (*CreateRoomRequest) ProtoMessage() {} +func (*CreateRoomRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c5fd27dd97284ef4, []int{0} +} + +func (m *CreateRoomRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CreateRoomRequest.Unmarshal(m, b) +} +func (m *CreateRoomRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CreateRoomRequest.Marshal(b, m, deterministic) +} +func (m *CreateRoomRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreateRoomRequest.Merge(m, src) +} +func (m *CreateRoomRequest) XXX_Size() int { + return xxx_messageInfo_CreateRoomRequest.Size(m) +} +func (m *CreateRoomRequest) XXX_DiscardUnknown() { + xxx_messageInfo_CreateRoomRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_CreateRoomRequest proto.InternalMessageInfo + +func (m *CreateRoomRequest) GetRoomId() string { + if m != nil { + return m.RoomId + } + return "" +} + +func (m *CreateRoomRequest) GetEmptyTimeout() uint32 { + if m != nil { + return m.EmptyTimeout + } + return 0 +} + +func (m *CreateRoomRequest) GetMaxParticipants() uint32 { + if m != nil { + return m.MaxParticipants + } + return 0 +} + +type GetRoomRequest struct { + RoomId string `protobuf:"bytes,1,opt,name=room_id,json=roomId,proto3" json:"room_id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetRoomRequest) Reset() { *m = GetRoomRequest{} } +func (m *GetRoomRequest) String() string { return proto.CompactTextString(m) } +func (*GetRoomRequest) ProtoMessage() {} +func (*GetRoomRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c5fd27dd97284ef4, []int{1} +} + +func (m *GetRoomRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetRoomRequest.Unmarshal(m, b) +} +func (m *GetRoomRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetRoomRequest.Marshal(b, m, deterministic) +} +func (m *GetRoomRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetRoomRequest.Merge(m, src) +} +func (m *GetRoomRequest) XXX_Size() int { + return xxx_messageInfo_GetRoomRequest.Size(m) +} +func (m *GetRoomRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetRoomRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetRoomRequest proto.InternalMessageInfo + +func (m *GetRoomRequest) GetRoomId() string { + if m != nil { + return m.RoomId + } + return "" +} + +type RoomInfo struct { + RoomId string `protobuf:"bytes,1,opt,name=room_id,json=roomId,proto3" json:"room_id,omitempty"` + NodeIp string `protobuf:"bytes,2,opt,name=node_ip,json=nodeIp,proto3" json:"node_ip,omitempty"` + NodeRtcPort uint32 `protobuf:"varint,3,opt,name=node_rtc_port,json=nodeRtcPort,proto3" json:"node_rtc_port,omitempty"` + CreationTime int64 `protobuf:"varint,4,opt,name=creation_time,json=creationTime,proto3" json:"creation_time,omitempty"` + Token string `protobuf:"bytes,5,opt,name=token,proto3" json:"token,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *RoomInfo) Reset() { *m = RoomInfo{} } +func (m *RoomInfo) String() string { return proto.CompactTextString(m) } +func (*RoomInfo) ProtoMessage() {} +func (*RoomInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_c5fd27dd97284ef4, []int{2} +} + +func (m *RoomInfo) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_RoomInfo.Unmarshal(m, b) +} +func (m *RoomInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_RoomInfo.Marshal(b, m, deterministic) +} +func (m *RoomInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_RoomInfo.Merge(m, src) +} +func (m *RoomInfo) XXX_Size() int { + return xxx_messageInfo_RoomInfo.Size(m) +} +func (m *RoomInfo) XXX_DiscardUnknown() { + xxx_messageInfo_RoomInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_RoomInfo proto.InternalMessageInfo + +func (m *RoomInfo) GetRoomId() string { + if m != nil { + return m.RoomId + } + return "" +} + +func (m *RoomInfo) GetNodeIp() string { + if m != nil { + return m.NodeIp + } + return "" +} + +func (m *RoomInfo) GetNodeRtcPort() uint32 { + if m != nil { + return m.NodeRtcPort + } + return 0 +} + +func (m *RoomInfo) GetCreationTime() int64 { + if m != nil { + return m.CreationTime + } + return 0 +} + +func (m *RoomInfo) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +type DeleteRoomRequest struct { + RoomId string `protobuf:"bytes,1,opt,name=room_id,json=roomId,proto3" json:"room_id,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DeleteRoomRequest) Reset() { *m = DeleteRoomRequest{} } +func (m *DeleteRoomRequest) String() string { return proto.CompactTextString(m) } +func (*DeleteRoomRequest) ProtoMessage() {} +func (*DeleteRoomRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c5fd27dd97284ef4, []int{3} +} + +func (m *DeleteRoomRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DeleteRoomRequest.Unmarshal(m, b) +} +func (m *DeleteRoomRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DeleteRoomRequest.Marshal(b, m, deterministic) +} +func (m *DeleteRoomRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteRoomRequest.Merge(m, src) +} +func (m *DeleteRoomRequest) XXX_Size() int { + return xxx_messageInfo_DeleteRoomRequest.Size(m) +} +func (m *DeleteRoomRequest) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteRoomRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteRoomRequest proto.InternalMessageInfo + +func (m *DeleteRoomRequest) GetRoomId() string { + if m != nil { + return m.RoomId + } + return "" +} + +type DeleteRoomResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DeleteRoomResponse) Reset() { *m = DeleteRoomResponse{} } +func (m *DeleteRoomResponse) String() string { return proto.CompactTextString(m) } +func (*DeleteRoomResponse) ProtoMessage() {} +func (*DeleteRoomResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c5fd27dd97284ef4, []int{4} +} + +func (m *DeleteRoomResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DeleteRoomResponse.Unmarshal(m, b) +} +func (m *DeleteRoomResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DeleteRoomResponse.Marshal(b, m, deterministic) +} +func (m *DeleteRoomResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteRoomResponse.Merge(m, src) +} +func (m *DeleteRoomResponse) XXX_Size() int { + return xxx_messageInfo_DeleteRoomResponse.Size(m) +} +func (m *DeleteRoomResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteRoomResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteRoomResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*CreateRoomRequest)(nil), "livekit.CreateRoomRequest") + proto.RegisterType((*GetRoomRequest)(nil), "livekit.GetRoomRequest") + proto.RegisterType((*RoomInfo)(nil), "livekit.RoomInfo") + proto.RegisterType((*DeleteRoomRequest)(nil), "livekit.DeleteRoomRequest") + proto.RegisterType((*DeleteRoomResponse)(nil), "livekit.DeleteRoomResponse") +} + +func init() { proto.RegisterFile("room.proto", fileDescriptor_c5fd27dd97284ef4) } + +var fileDescriptor_c5fd27dd97284ef4 = []byte{ + // 360 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x4d, 0x6f, 0xda, 0x40, + 0x10, 0x95, 0x4b, 0xc1, 0x65, 0x80, 0xb6, 0xac, 0x90, 0xb0, 0xe8, 0x05, 0xb9, 0x17, 0x90, 0x5a, + 0xa3, 0x36, 0xca, 0x29, 0xb7, 0x7c, 0x28, 0xe2, 0x86, 0x9c, 0x9c, 0x72, 0xb1, 0x8c, 0x99, 0x24, + 0x2b, 0xb0, 0x67, 0xb3, 0x1e, 0x10, 0x91, 0xf2, 0x4f, 0xf2, 0x87, 0xf2, 0xb3, 0xa2, 0x5d, 0xcc, + 0x47, 0x04, 0x91, 0x38, 0x59, 0xf3, 0xde, 0xb3, 0xe7, 0xbd, 0x37, 0x06, 0xd0, 0x44, 0x69, 0xa0, + 0x34, 0x31, 0x09, 0x77, 0x26, 0x17, 0x38, 0x95, 0xec, 0xbf, 0x40, 0xf3, 0x42, 0x63, 0xcc, 0x18, + 0x12, 0xa5, 0x21, 0x3e, 0xcd, 0x31, 0x67, 0xd1, 0x06, 0xd7, 0x68, 0x23, 0x39, 0xf1, 0x9c, 0xae, + 0xd3, 0xab, 0x86, 0x15, 0x33, 0x0e, 0x27, 0xe2, 0x37, 0x34, 0x30, 0x55, 0xfc, 0x1c, 0xb1, 0x4c, + 0x91, 0xe6, 0xec, 0x7d, 0xe9, 0x3a, 0xbd, 0x46, 0x58, 0xb7, 0xe0, 0xed, 0x0a, 0x13, 0x7d, 0xf8, + 0x99, 0xc6, 0xcb, 0x48, 0xc5, 0x9a, 0x65, 0x22, 0x55, 0x9c, 0x71, 0xee, 0x95, 0xac, 0xee, 0x47, + 0x1a, 0x2f, 0x47, 0x3b, 0xb0, 0xdf, 0x87, 0xef, 0xd7, 0xc8, 0xc7, 0xac, 0xf6, 0x5f, 0x1d, 0xf8, + 0x66, 0x84, 0xc3, 0xec, 0x9e, 0x3e, 0x37, 0xd8, 0x06, 0x37, 0xa3, 0x09, 0x46, 0x52, 0x59, 0x6b, + 0xd5, 0xb0, 0x62, 0xc6, 0xa1, 0x12, 0x3e, 0x34, 0x2c, 0xa1, 0x39, 0x89, 0x14, 0x69, 0x2e, 0x1c, + 0xd5, 0x0c, 0x18, 0x72, 0x32, 0x22, 0xcd, 0x26, 0x5d, 0x62, 0xba, 0x90, 0x94, 0xd9, 0x80, 0xde, + 0xd7, 0xae, 0xd3, 0x2b, 0x85, 0xf5, 0x35, 0x68, 0x02, 0x8a, 0x16, 0x94, 0x99, 0xa6, 0x98, 0x79, + 0x65, 0xfb, 0xfd, 0xd5, 0xe0, 0xff, 0x81, 0xe6, 0x25, 0xce, 0xf0, 0xb8, 0x1a, 0xfd, 0x16, 0x88, + 0x5d, 0x75, 0xae, 0x28, 0xcb, 0xf1, 0xff, 0x9b, 0x03, 0x35, 0x03, 0xdc, 0xa0, 0x5e, 0xc8, 0x04, + 0xc5, 0x19, 0xc0, 0xf6, 0x34, 0xa2, 0x13, 0x14, 0x27, 0x0b, 0xf6, 0xee, 0xd5, 0x69, 0x6e, 0xb8, + 0x4d, 0x43, 0xa7, 0xe0, 0x16, 0xcd, 0x8a, 0xf6, 0x86, 0xfd, 0xd8, 0xf5, 0xa1, 0xd7, 0xae, 0x00, + 0xb6, 0xce, 0x76, 0x76, 0xee, 0x85, 0xeb, 0xfc, 0x3a, 0xc8, 0xad, 0xa2, 0x9c, 0xff, 0xbb, 0x1b, + 0x3c, 0x48, 0x7e, 0x9c, 0x8f, 0x83, 0x84, 0xd2, 0x41, 0x21, 0x5c, 0x3f, 0xff, 0xe6, 0xa8, 0x17, + 0xa8, 0x07, 0xf6, 0x4f, 0x5c, 0x83, 0xe3, 0x8a, 0x1d, 0x4f, 0xde, 0x03, 0x00, 0x00, 0xff, 0xff, + 0x88, 0x0b, 0xf0, 0x4d, 0xa6, 0x02, 0x00, 0x00, +} diff --git a/proto/livekit/service.twirp.go b/proto/livekit/room.twirp.go similarity index 59% rename from proto/livekit/service.twirp.go rename to proto/livekit/room.twirp.go index ecdf8637a..8f62eb13f 100644 --- a/proto/livekit/service.twirp.go +++ b/proto/livekit/room.twirp.go @@ -1,13 +1,13 @@ // Code generated by protoc-gen-twirp v7.1.0, DO NOT EDIT. -// source: service.proto +// source: room.proto /* Package livekit is a generated twirp stub package. This code was generated with github.com/twitchtv/twirp/protoc-gen-twirp v7.1.0. It is generated from these files: + room.proto model.proto - service.proto */ package livekit @@ -41,6 +41,7 @@ const _ = twirp.TwirpPackageIsVersion7 // ===================== // Room service that can be performed on any node +// they are simple HTTP req/responses type RoomService interface { // TODO: how do we secure room service? // should be accessible to only internal servers, not external @@ -1047,1017 +1048,6 @@ func (s *roomServiceServer) PathPrefix() string { return baseServicePath(s.pathPrefix, "livekit", "RoomService") } -// ==================== -// RTCService Interface -// ==================== - -// RTC methods performed on target node -type RTCService interface { - Join(context.Context, *JoinRequest) (*JoinResponse, error) - - // offer allows client to initiate a RTC session - Offer(context.Context, *SessionDescription) (*SessionDescription, error) - - // trickle sends more ICE candidates to server - Trickle(context.Context, *TrickleRequest) (*TrickleResponse, error) -} - -// ========================== -// RTCService Protobuf Client -// ========================== - -type rTCServiceProtobufClient struct { - client HTTPClient - urls [3]string - interceptor twirp.Interceptor - opts twirp.ClientOptions -} - -// NewRTCServiceProtobufClient creates a Protobuf client that implements the RTCService interface. -// It communicates using Protobuf and can be configured with a custom HTTPClient. -func NewRTCServiceProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) RTCService { - if c, ok := client.(*http.Client); ok { - client = withoutRedirects(c) - } - - clientOpts := twirp.ClientOptions{} - for _, o := range opts { - o(&clientOpts) - } - - // Build method URLs: []/./ - serviceURL := sanitizeBaseURL(baseURL) - serviceURL += baseServicePath(clientOpts.PathPrefix(), "livekit", "RTCService") - urls := [3]string{ - serviceURL + "Join", - serviceURL + "Offer", - serviceURL + "Trickle", - } - - return &rTCServiceProtobufClient{ - client: client, - urls: urls, - interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), - opts: clientOpts, - } -} - -func (c *rTCServiceProtobufClient) Join(ctx context.Context, in *JoinRequest) (*JoinResponse, error) { - ctx = ctxsetters.WithPackageName(ctx, "livekit") - ctx = ctxsetters.WithServiceName(ctx, "RTCService") - ctx = ctxsetters.WithMethodName(ctx, "Join") - caller := c.callJoin - if c.interceptor != nil { - caller = func(ctx context.Context, req *JoinRequest) (*JoinResponse, error) { - resp, err := c.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*JoinRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*JoinRequest) when calling interceptor") - } - return c.callJoin(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*JoinResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*JoinResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - return caller(ctx, in) -} - -func (c *rTCServiceProtobufClient) callJoin(ctx context.Context, in *JoinRequest) (*JoinResponse, error) { - out := new(JoinResponse) - ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) - if err != nil { - twerr, ok := err.(twirp.Error) - if !ok { - twerr = twirp.InternalErrorWith(err) - } - callClientError(ctx, c.opts.Hooks, twerr) - return nil, err - } - - callClientResponseReceived(ctx, c.opts.Hooks) - - return out, nil -} - -func (c *rTCServiceProtobufClient) Offer(ctx context.Context, in *SessionDescription) (*SessionDescription, error) { - ctx = ctxsetters.WithPackageName(ctx, "livekit") - ctx = ctxsetters.WithServiceName(ctx, "RTCService") - ctx = ctxsetters.WithMethodName(ctx, "Offer") - caller := c.callOffer - if c.interceptor != nil { - caller = func(ctx context.Context, req *SessionDescription) (*SessionDescription, error) { - resp, err := c.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*SessionDescription) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*SessionDescription) when calling interceptor") - } - return c.callOffer(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*SessionDescription) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*SessionDescription) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - return caller(ctx, in) -} - -func (c *rTCServiceProtobufClient) callOffer(ctx context.Context, in *SessionDescription) (*SessionDescription, error) { - out := new(SessionDescription) - ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) - if err != nil { - twerr, ok := err.(twirp.Error) - if !ok { - twerr = twirp.InternalErrorWith(err) - } - callClientError(ctx, c.opts.Hooks, twerr) - return nil, err - } - - callClientResponseReceived(ctx, c.opts.Hooks) - - return out, nil -} - -func (c *rTCServiceProtobufClient) Trickle(ctx context.Context, in *TrickleRequest) (*TrickleResponse, error) { - ctx = ctxsetters.WithPackageName(ctx, "livekit") - ctx = ctxsetters.WithServiceName(ctx, "RTCService") - ctx = ctxsetters.WithMethodName(ctx, "Trickle") - caller := c.callTrickle - if c.interceptor != nil { - caller = func(ctx context.Context, req *TrickleRequest) (*TrickleResponse, error) { - resp, err := c.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*TrickleRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*TrickleRequest) when calling interceptor") - } - return c.callTrickle(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*TrickleResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*TrickleResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - return caller(ctx, in) -} - -func (c *rTCServiceProtobufClient) callTrickle(ctx context.Context, in *TrickleRequest) (*TrickleResponse, error) { - out := new(TrickleResponse) - ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out) - if err != nil { - twerr, ok := err.(twirp.Error) - if !ok { - twerr = twirp.InternalErrorWith(err) - } - callClientError(ctx, c.opts.Hooks, twerr) - return nil, err - } - - callClientResponseReceived(ctx, c.opts.Hooks) - - return out, nil -} - -// ====================== -// RTCService JSON Client -// ====================== - -type rTCServiceJSONClient struct { - client HTTPClient - urls [3]string - interceptor twirp.Interceptor - opts twirp.ClientOptions -} - -// NewRTCServiceJSONClient creates a JSON client that implements the RTCService interface. -// It communicates using JSON and can be configured with a custom HTTPClient. -func NewRTCServiceJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) RTCService { - if c, ok := client.(*http.Client); ok { - client = withoutRedirects(c) - } - - clientOpts := twirp.ClientOptions{} - for _, o := range opts { - o(&clientOpts) - } - - // Build method URLs: []/./ - serviceURL := sanitizeBaseURL(baseURL) - serviceURL += baseServicePath(clientOpts.PathPrefix(), "livekit", "RTCService") - urls := [3]string{ - serviceURL + "Join", - serviceURL + "Offer", - serviceURL + "Trickle", - } - - return &rTCServiceJSONClient{ - client: client, - urls: urls, - interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...), - opts: clientOpts, - } -} - -func (c *rTCServiceJSONClient) Join(ctx context.Context, in *JoinRequest) (*JoinResponse, error) { - ctx = ctxsetters.WithPackageName(ctx, "livekit") - ctx = ctxsetters.WithServiceName(ctx, "RTCService") - ctx = ctxsetters.WithMethodName(ctx, "Join") - caller := c.callJoin - if c.interceptor != nil { - caller = func(ctx context.Context, req *JoinRequest) (*JoinResponse, error) { - resp, err := c.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*JoinRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*JoinRequest) when calling interceptor") - } - return c.callJoin(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*JoinResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*JoinResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - return caller(ctx, in) -} - -func (c *rTCServiceJSONClient) callJoin(ctx context.Context, in *JoinRequest) (*JoinResponse, error) { - out := new(JoinResponse) - ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out) - if err != nil { - twerr, ok := err.(twirp.Error) - if !ok { - twerr = twirp.InternalErrorWith(err) - } - callClientError(ctx, c.opts.Hooks, twerr) - return nil, err - } - - callClientResponseReceived(ctx, c.opts.Hooks) - - return out, nil -} - -func (c *rTCServiceJSONClient) Offer(ctx context.Context, in *SessionDescription) (*SessionDescription, error) { - ctx = ctxsetters.WithPackageName(ctx, "livekit") - ctx = ctxsetters.WithServiceName(ctx, "RTCService") - ctx = ctxsetters.WithMethodName(ctx, "Offer") - caller := c.callOffer - if c.interceptor != nil { - caller = func(ctx context.Context, req *SessionDescription) (*SessionDescription, error) { - resp, err := c.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*SessionDescription) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*SessionDescription) when calling interceptor") - } - return c.callOffer(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*SessionDescription) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*SessionDescription) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - return caller(ctx, in) -} - -func (c *rTCServiceJSONClient) callOffer(ctx context.Context, in *SessionDescription) (*SessionDescription, error) { - out := new(SessionDescription) - ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out) - if err != nil { - twerr, ok := err.(twirp.Error) - if !ok { - twerr = twirp.InternalErrorWith(err) - } - callClientError(ctx, c.opts.Hooks, twerr) - return nil, err - } - - callClientResponseReceived(ctx, c.opts.Hooks) - - return out, nil -} - -func (c *rTCServiceJSONClient) Trickle(ctx context.Context, in *TrickleRequest) (*TrickleResponse, error) { - ctx = ctxsetters.WithPackageName(ctx, "livekit") - ctx = ctxsetters.WithServiceName(ctx, "RTCService") - ctx = ctxsetters.WithMethodName(ctx, "Trickle") - caller := c.callTrickle - if c.interceptor != nil { - caller = func(ctx context.Context, req *TrickleRequest) (*TrickleResponse, error) { - resp, err := c.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*TrickleRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*TrickleRequest) when calling interceptor") - } - return c.callTrickle(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*TrickleResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*TrickleResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - return caller(ctx, in) -} - -func (c *rTCServiceJSONClient) callTrickle(ctx context.Context, in *TrickleRequest) (*TrickleResponse, error) { - out := new(TrickleResponse) - ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out) - if err != nil { - twerr, ok := err.(twirp.Error) - if !ok { - twerr = twirp.InternalErrorWith(err) - } - callClientError(ctx, c.opts.Hooks, twerr) - return nil, err - } - - callClientResponseReceived(ctx, c.opts.Hooks) - - return out, nil -} - -// ========================= -// RTCService Server Handler -// ========================= - -type rTCServiceServer struct { - RTCService - interceptor twirp.Interceptor - hooks *twirp.ServerHooks - pathPrefix string // prefix for routing - jsonSkipDefaults bool // do not include unpopulated fields (default values) in the response -} - -// NewRTCServiceServer builds a TwirpServer that can be used as an http.Handler to handle -// HTTP requests that are routed to the right method in the provided svc implementation. -// The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks). -func NewRTCServiceServer(svc RTCService, opts ...interface{}) TwirpServer { - serverOpts := twirp.ServerOptions{} - for _, opt := range opts { - switch o := opt.(type) { - case twirp.ServerOption: - o(&serverOpts) - case *twirp.ServerHooks: // backwards compatibility, allow to specify hooks as an argument - twirp.WithServerHooks(o)(&serverOpts) - case nil: // backwards compatibility, allow nil value for the argument - continue - default: - panic(fmt.Sprintf("Invalid option type %T on NewRTCServiceServer", o)) - } - } - - return &rTCServiceServer{ - RTCService: svc, - pathPrefix: serverOpts.PathPrefix(), - interceptor: twirp.ChainInterceptors(serverOpts.Interceptors...), - hooks: serverOpts.Hooks, - jsonSkipDefaults: serverOpts.JSONSkipDefaults, - } -} - -// writeError writes an HTTP response with a valid Twirp error format, and triggers hooks. -// If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err) -func (s *rTCServiceServer) writeError(ctx context.Context, resp http.ResponseWriter, err error) { - writeError(ctx, resp, err, s.hooks) -} - -// RTCServicePathPrefix is a convenience constant that could used to identify URL paths. -// Should be used with caution, it only matches routes generated by Twirp Go clients, -// that add a "/twirp" prefix by default, and use CamelCase service and method names. -// More info: https://twitchtv.github.io/twirp/docs/routing.html -const RTCServicePathPrefix = "/twirp/livekit.RTCService/" - -func (s *rTCServiceServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) { - ctx := req.Context() - ctx = ctxsetters.WithPackageName(ctx, "livekit") - ctx = ctxsetters.WithServiceName(ctx, "RTCService") - ctx = ctxsetters.WithResponseWriter(ctx, resp) - - var err error - ctx, err = callRequestReceived(ctx, s.hooks) - if err != nil { - s.writeError(ctx, resp, err) - return - } - - if req.Method != "POST" { - msg := fmt.Sprintf("unsupported method %q (only POST is allowed)", req.Method) - s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) - return - } - - // Verify path format: []/./ - prefix, pkgService, method := parseTwirpPath(req.URL.Path) - if pkgService != "livekit.RTCService" { - msg := fmt.Sprintf("no handler for path %q", req.URL.Path) - s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) - return - } - if prefix != s.pathPrefix { - msg := fmt.Sprintf("invalid path prefix %q, expected %q, on path %q", prefix, s.pathPrefix, req.URL.Path) - s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) - return - } - - switch method { - case "Join": - s.serveJoin(ctx, resp, req) - return - case "Offer": - s.serveOffer(ctx, resp, req) - return - case "Trickle": - s.serveTrickle(ctx, resp, req) - return - default: - msg := fmt.Sprintf("no handler for path %q", req.URL.Path) - s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path)) - return - } -} - -func (s *rTCServiceServer) serveJoin(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - header := req.Header.Get("Content-Type") - i := strings.Index(header, ";") - if i == -1 { - i = len(header) - } - switch strings.TrimSpace(strings.ToLower(header[:i])) { - case "application/json": - s.serveJoinJSON(ctx, resp, req) - case "application/protobuf": - s.serveJoinProtobuf(ctx, resp, req) - default: - msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) - twerr := badRouteError(msg, req.Method, req.URL.Path) - s.writeError(ctx, resp, twerr) - } -} - -func (s *rTCServiceServer) serveJoinJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - var err error - ctx = ctxsetters.WithMethodName(ctx, "Join") - ctx, err = callRequestRouted(ctx, s.hooks) - if err != nil { - s.writeError(ctx, resp, err) - return - } - - reqContent := new(JoinRequest) - unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true} - if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil { - s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded")) - return - } - - handler := s.RTCService.Join - if s.interceptor != nil { - handler = func(ctx context.Context, req *JoinRequest) (*JoinResponse, error) { - resp, err := s.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*JoinRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*JoinRequest) when calling interceptor") - } - return s.RTCService.Join(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*JoinResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*JoinResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - - // Call service method - var respContent *JoinResponse - func() { - defer ensurePanicResponses(ctx, resp, s.hooks) - respContent, err = handler(ctx, reqContent) - }() - - if err != nil { - s.writeError(ctx, resp, err) - return - } - if respContent == nil { - s.writeError(ctx, resp, twirp.InternalError("received a nil *JoinResponse and nil error while calling Join. nil responses are not supported")) - return - } - - ctx = callResponsePrepared(ctx, s.hooks) - - var buf bytes.Buffer - marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults} - if err = marshaler.Marshal(&buf, respContent); err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) - return - } - - ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) - respBytes := buf.Bytes() - resp.Header().Set("Content-Type", "application/json") - resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) - resp.WriteHeader(http.StatusOK) - - if n, err := resp.Write(respBytes); err != nil { - msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) - twerr := twirp.NewError(twirp.Unknown, msg) - ctx = callError(ctx, s.hooks, twerr) - } - callResponseSent(ctx, s.hooks) -} - -func (s *rTCServiceServer) serveJoinProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - var err error - ctx = ctxsetters.WithMethodName(ctx, "Join") - ctx, err = callRequestRouted(ctx, s.hooks) - if err != nil { - s.writeError(ctx, resp, err) - return - } - - buf, err := ioutil.ReadAll(req.Body) - if err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to read request body")) - return - } - reqContent := new(JoinRequest) - if err = proto.Unmarshal(buf, reqContent); err != nil { - s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) - return - } - - handler := s.RTCService.Join - if s.interceptor != nil { - handler = func(ctx context.Context, req *JoinRequest) (*JoinResponse, error) { - resp, err := s.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*JoinRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*JoinRequest) when calling interceptor") - } - return s.RTCService.Join(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*JoinResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*JoinResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - - // Call service method - var respContent *JoinResponse - func() { - defer ensurePanicResponses(ctx, resp, s.hooks) - respContent, err = handler(ctx, reqContent) - }() - - if err != nil { - s.writeError(ctx, resp, err) - return - } - if respContent == nil { - s.writeError(ctx, resp, twirp.InternalError("received a nil *JoinResponse and nil error while calling Join. nil responses are not supported")) - return - } - - ctx = callResponsePrepared(ctx, s.hooks) - - respBytes, err := proto.Marshal(respContent) - if err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) - return - } - - ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) - resp.Header().Set("Content-Type", "application/protobuf") - resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) - resp.WriteHeader(http.StatusOK) - if n, err := resp.Write(respBytes); err != nil { - msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) - twerr := twirp.NewError(twirp.Unknown, msg) - ctx = callError(ctx, s.hooks, twerr) - } - callResponseSent(ctx, s.hooks) -} - -func (s *rTCServiceServer) serveOffer(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - header := req.Header.Get("Content-Type") - i := strings.Index(header, ";") - if i == -1 { - i = len(header) - } - switch strings.TrimSpace(strings.ToLower(header[:i])) { - case "application/json": - s.serveOfferJSON(ctx, resp, req) - case "application/protobuf": - s.serveOfferProtobuf(ctx, resp, req) - default: - msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) - twerr := badRouteError(msg, req.Method, req.URL.Path) - s.writeError(ctx, resp, twerr) - } -} - -func (s *rTCServiceServer) serveOfferJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - var err error - ctx = ctxsetters.WithMethodName(ctx, "Offer") - ctx, err = callRequestRouted(ctx, s.hooks) - if err != nil { - s.writeError(ctx, resp, err) - return - } - - reqContent := new(SessionDescription) - unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true} - if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil { - s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded")) - return - } - - handler := s.RTCService.Offer - if s.interceptor != nil { - handler = func(ctx context.Context, req *SessionDescription) (*SessionDescription, error) { - resp, err := s.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*SessionDescription) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*SessionDescription) when calling interceptor") - } - return s.RTCService.Offer(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*SessionDescription) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*SessionDescription) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - - // Call service method - var respContent *SessionDescription - func() { - defer ensurePanicResponses(ctx, resp, s.hooks) - respContent, err = handler(ctx, reqContent) - }() - - if err != nil { - s.writeError(ctx, resp, err) - return - } - if respContent == nil { - s.writeError(ctx, resp, twirp.InternalError("received a nil *SessionDescription and nil error while calling Offer. nil responses are not supported")) - return - } - - ctx = callResponsePrepared(ctx, s.hooks) - - var buf bytes.Buffer - marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults} - if err = marshaler.Marshal(&buf, respContent); err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) - return - } - - ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) - respBytes := buf.Bytes() - resp.Header().Set("Content-Type", "application/json") - resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) - resp.WriteHeader(http.StatusOK) - - if n, err := resp.Write(respBytes); err != nil { - msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) - twerr := twirp.NewError(twirp.Unknown, msg) - ctx = callError(ctx, s.hooks, twerr) - } - callResponseSent(ctx, s.hooks) -} - -func (s *rTCServiceServer) serveOfferProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - var err error - ctx = ctxsetters.WithMethodName(ctx, "Offer") - ctx, err = callRequestRouted(ctx, s.hooks) - if err != nil { - s.writeError(ctx, resp, err) - return - } - - buf, err := ioutil.ReadAll(req.Body) - if err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to read request body")) - return - } - reqContent := new(SessionDescription) - if err = proto.Unmarshal(buf, reqContent); err != nil { - s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) - return - } - - handler := s.RTCService.Offer - if s.interceptor != nil { - handler = func(ctx context.Context, req *SessionDescription) (*SessionDescription, error) { - resp, err := s.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*SessionDescription) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*SessionDescription) when calling interceptor") - } - return s.RTCService.Offer(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*SessionDescription) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*SessionDescription) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - - // Call service method - var respContent *SessionDescription - func() { - defer ensurePanicResponses(ctx, resp, s.hooks) - respContent, err = handler(ctx, reqContent) - }() - - if err != nil { - s.writeError(ctx, resp, err) - return - } - if respContent == nil { - s.writeError(ctx, resp, twirp.InternalError("received a nil *SessionDescription and nil error while calling Offer. nil responses are not supported")) - return - } - - ctx = callResponsePrepared(ctx, s.hooks) - - respBytes, err := proto.Marshal(respContent) - if err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) - return - } - - ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) - resp.Header().Set("Content-Type", "application/protobuf") - resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) - resp.WriteHeader(http.StatusOK) - if n, err := resp.Write(respBytes); err != nil { - msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) - twerr := twirp.NewError(twirp.Unknown, msg) - ctx = callError(ctx, s.hooks, twerr) - } - callResponseSent(ctx, s.hooks) -} - -func (s *rTCServiceServer) serveTrickle(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - header := req.Header.Get("Content-Type") - i := strings.Index(header, ";") - if i == -1 { - i = len(header) - } - switch strings.TrimSpace(strings.ToLower(header[:i])) { - case "application/json": - s.serveTrickleJSON(ctx, resp, req) - case "application/protobuf": - s.serveTrickleProtobuf(ctx, resp, req) - default: - msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type")) - twerr := badRouteError(msg, req.Method, req.URL.Path) - s.writeError(ctx, resp, twerr) - } -} - -func (s *rTCServiceServer) serveTrickleJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - var err error - ctx = ctxsetters.WithMethodName(ctx, "Trickle") - ctx, err = callRequestRouted(ctx, s.hooks) - if err != nil { - s.writeError(ctx, resp, err) - return - } - - reqContent := new(TrickleRequest) - unmarshaler := jsonpb.Unmarshaler{AllowUnknownFields: true} - if err = unmarshaler.Unmarshal(req.Body, reqContent); err != nil { - s.writeError(ctx, resp, malformedRequestError("the json request could not be decoded")) - return - } - - handler := s.RTCService.Trickle - if s.interceptor != nil { - handler = func(ctx context.Context, req *TrickleRequest) (*TrickleResponse, error) { - resp, err := s.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*TrickleRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*TrickleRequest) when calling interceptor") - } - return s.RTCService.Trickle(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*TrickleResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*TrickleResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - - // Call service method - var respContent *TrickleResponse - func() { - defer ensurePanicResponses(ctx, resp, s.hooks) - respContent, err = handler(ctx, reqContent) - }() - - if err != nil { - s.writeError(ctx, resp, err) - return - } - if respContent == nil { - s.writeError(ctx, resp, twirp.InternalError("received a nil *TrickleResponse and nil error while calling Trickle. nil responses are not supported")) - return - } - - ctx = callResponsePrepared(ctx, s.hooks) - - var buf bytes.Buffer - marshaler := &jsonpb.Marshaler{OrigName: true, EmitDefaults: !s.jsonSkipDefaults} - if err = marshaler.Marshal(&buf, respContent); err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response")) - return - } - - ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) - respBytes := buf.Bytes() - resp.Header().Set("Content-Type", "application/json") - resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) - resp.WriteHeader(http.StatusOK) - - if n, err := resp.Write(respBytes); err != nil { - msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) - twerr := twirp.NewError(twirp.Unknown, msg) - ctx = callError(ctx, s.hooks, twerr) - } - callResponseSent(ctx, s.hooks) -} - -func (s *rTCServiceServer) serveTrickleProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) { - var err error - ctx = ctxsetters.WithMethodName(ctx, "Trickle") - ctx, err = callRequestRouted(ctx, s.hooks) - if err != nil { - s.writeError(ctx, resp, err) - return - } - - buf, err := ioutil.ReadAll(req.Body) - if err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to read request body")) - return - } - reqContent := new(TrickleRequest) - if err = proto.Unmarshal(buf, reqContent); err != nil { - s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded")) - return - } - - handler := s.RTCService.Trickle - if s.interceptor != nil { - handler = func(ctx context.Context, req *TrickleRequest) (*TrickleResponse, error) { - resp, err := s.interceptor( - func(ctx context.Context, req interface{}) (interface{}, error) { - typedReq, ok := req.(*TrickleRequest) - if !ok { - return nil, twirp.InternalError("failed type assertion req.(*TrickleRequest) when calling interceptor") - } - return s.RTCService.Trickle(ctx, typedReq) - }, - )(ctx, req) - if resp != nil { - typedResp, ok := resp.(*TrickleResponse) - if !ok { - return nil, twirp.InternalError("failed type assertion resp.(*TrickleResponse) when calling interceptor") - } - return typedResp, err - } - return nil, err - } - } - - // Call service method - var respContent *TrickleResponse - func() { - defer ensurePanicResponses(ctx, resp, s.hooks) - respContent, err = handler(ctx, reqContent) - }() - - if err != nil { - s.writeError(ctx, resp, err) - return - } - if respContent == nil { - s.writeError(ctx, resp, twirp.InternalError("received a nil *TrickleResponse and nil error while calling Trickle. nil responses are not supported")) - return - } - - ctx = callResponsePrepared(ctx, s.hooks) - - respBytes, err := proto.Marshal(respContent) - if err != nil { - s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response")) - return - } - - ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK) - resp.Header().Set("Content-Type", "application/protobuf") - resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes))) - resp.WriteHeader(http.StatusOK) - if n, err := resp.Write(respBytes); err != nil { - msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error()) - twerr := twirp.NewError(twirp.Unknown, msg) - ctx = callError(ctx, s.hooks, twerr) - } - callResponseSent(ctx, s.hooks) -} - -func (s *rTCServiceServer) ServiceDescriptor() ([]byte, int) { - return twirpFileDescriptor0, 1 -} - -func (s *rTCServiceServer) ProtocGenTwirpVersion() string { - return "v7.1.0" -} - -// PathPrefix returns the base service path, in the form: "//./" -// that is everything in a Twirp route except for the . This can be used for routing, -// for example to identify the requests that are targeted to this service in a mux. -func (s *rTCServiceServer) PathPrefix() string { - return baseServicePath(s.pathPrefix, "livekit", "RTCService") -} - // ===== // Utils // ===== @@ -2605,38 +1595,28 @@ func callClientError(ctx context.Context, h *twirp.ClientHooks, err twirp.Error) } var twirpFileDescriptor0 = []byte{ - // 528 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4d, 0x6f, 0xd3, 0x40, - 0x10, 0x95, 0x9b, 0x2f, 0x32, 0x49, 0xda, 0x66, 0x15, 0x14, 0xcb, 0xe5, 0x10, 0x99, 0x4b, 0x2a, - 0xa1, 0x48, 0x24, 0xe2, 0x02, 0x5c, 0x20, 0x45, 0x28, 0x5c, 0xa8, 0xdc, 0x9c, 0xb8, 0x44, 0xc6, - 0x9e, 0x48, 0xab, 0xc4, 0xbb, 0xcb, 0xee, 0xb6, 0xb4, 0x12, 0x3f, 0x80, 0xff, 0xc0, 0xbf, 0xe1, - 0xc4, 0xcf, 0x42, 0xbb, 0x6b, 0x3b, 0x2e, 0x29, 0x6d, 0x6f, 0x9e, 0x99, 0xe7, 0xdd, 0xf7, 0xe6, - 0x3d, 0x2d, 0xf4, 0x14, 0xca, 0x2b, 0x9a, 0xe0, 0x44, 0x48, 0xae, 0x39, 0x69, 0x6d, 0xe9, 0x15, - 0x6e, 0xa8, 0x0e, 0x7f, 0x40, 0x7f, 0x2e, 0x31, 0xd6, 0x18, 0x71, 0x9e, 0x45, 0xf8, 0xed, 0x12, - 0x95, 0x26, 0x43, 0x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 0x6f, 0xc9, 0x7d, 0xde, 0x05, 0xf7, 0x0d, 0xc9, 0x5b, 0x68, 0xe5, 0x06, 0x55, 0x96, 0x70, - 0xdb, 0xe2, 0xc0, 0xdf, 0x1f, 0x38, 0x02, 0xef, 0xdb, 0x5f, 0x8a, 0x47, 0xe7, 0x6b, 0xd3, 0x3e, - 0x42, 0xb3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4c, 0xd8, 0xff, 0xa8, 0x95, 0x04, 0x00, 0x00, + // 360 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x4d, 0x6f, 0xda, 0x40, + 0x10, 0x95, 0x4b, 0xc1, 0x65, 0x80, 0xb6, 0xac, 0x90, 0xb0, 0xe8, 0x05, 0xb9, 0x17, 0x90, 0x5a, + 0xa3, 0x36, 0xca, 0x29, 0xb7, 0x7c, 0x28, 0xe2, 0x86, 0x9c, 0x9c, 0x72, 0xb1, 0x8c, 0x99, 0x24, + 0x2b, 0xb0, 0x67, 0xb3, 0x1e, 0x10, 0x91, 0xf2, 0x4f, 0xf2, 0x87, 0xf2, 0xb3, 0xa2, 0x5d, 0xcc, + 0x47, 0x04, 0x91, 0x38, 0x59, 0xf3, 0xde, 0xb3, 0xe7, 0xbd, 0x37, 0x06, 0xd0, 0x44, 0x69, 0xa0, + 0x34, 0x31, 0x09, 0x77, 0x26, 0x17, 0x38, 0x95, 0xec, 0xbf, 0x40, 0xf3, 0x42, 0x63, 0xcc, 0x18, + 0x12, 0xa5, 0x21, 0x3e, 0xcd, 0x31, 0x67, 0xd1, 0x06, 0xd7, 0x68, 0x23, 0x39, 0xf1, 0x9c, 0xae, + 0xd3, 0xab, 0x86, 0x15, 0x33, 0x0e, 0x27, 0xe2, 0x37, 0x34, 0x30, 0x55, 0xfc, 0x1c, 0xb1, 0x4c, + 0x91, 0xe6, 0xec, 0x7d, 0xe9, 0x3a, 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0xbb, 0x1b, + 0x3c, 0x48, 0x7e, 0x9c, 0x8f, 0x83, 0x84, 0xd2, 0x41, 0x21, 0x5c, 0x3f, 0xff, 0xe6, 0xa8, 0x17, + 0xa8, 0x07, 0xf6, 0x4f, 0x5c, 0x83, 0xe3, 0x8a, 0x1d, 0x4f, 0xde, 0x03, 0x00, 0x00, 0xff, 0xff, + 0x88, 0x0b, 0xf0, 0x4d, 0xa6, 0x02, 0x00, 0x00, } diff --git a/proto/livekit/rtc.pb.go b/proto/livekit/rtc.pb.go new file mode 100644 index 000000000..8699505f4 --- /dev/null +++ b/proto/livekit/rtc.pb.go @@ -0,0 +1,441 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: rtc.proto + +package livekit + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +type SignalRequest struct { + // Types that are valid to be assigned to Message: + // *SignalRequest_Join + // *SignalRequest_Negotiate + // *SignalRequest_Trickle + Message isSignalRequest_Message `protobuf_oneof:"message"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SignalRequest) Reset() { *m = SignalRequest{} } +func (m *SignalRequest) String() string { return proto.CompactTextString(m) } +func (*SignalRequest) ProtoMessage() {} +func (*SignalRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_85bd91e80f756774, []int{0} +} + +func (m *SignalRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SignalRequest.Unmarshal(m, b) +} +func (m *SignalRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SignalRequest.Marshal(b, m, deterministic) +} +func (m *SignalRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignalRequest.Merge(m, src) +} +func (m *SignalRequest) XXX_Size() int { + return xxx_messageInfo_SignalRequest.Size(m) +} +func (m *SignalRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SignalRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SignalRequest proto.InternalMessageInfo + +type isSignalRequest_Message interface { + isSignalRequest_Message() +} + +type SignalRequest_Join struct { + Join *JoinRequest `protobuf:"bytes,1,opt,name=join,proto3,oneof"` +} + +type SignalRequest_Negotiate struct { + Negotiate *SessionDescription `protobuf:"bytes,2,opt,name=negotiate,proto3,oneof"` +} + +type SignalRequest_Trickle struct { + Trickle *Trickle `protobuf:"bytes,3,opt,name=trickle,proto3,oneof"` +} + +func (*SignalRequest_Join) isSignalRequest_Message() {} + +func (*SignalRequest_Negotiate) isSignalRequest_Message() {} + +func (*SignalRequest_Trickle) isSignalRequest_Message() {} + +func (m *SignalRequest) GetMessage() isSignalRequest_Message { + if m != nil { + return m.Message + } + return nil +} + +func (m *SignalRequest) GetJoin() *JoinRequest { + if x, ok := m.GetMessage().(*SignalRequest_Join); ok { + return x.Join + } + return nil +} + +func (m *SignalRequest) GetNegotiate() *SessionDescription { + if x, ok := m.GetMessage().(*SignalRequest_Negotiate); ok { + return x.Negotiate + } + return nil +} + +func (m *SignalRequest) GetTrickle() *Trickle { + if x, ok := m.GetMessage().(*SignalRequest_Trickle); ok { + return x.Trickle + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*SignalRequest) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*SignalRequest_Join)(nil), + (*SignalRequest_Negotiate)(nil), + (*SignalRequest_Trickle)(nil), + } +} + +type SignalResponse struct { + // Types that are valid to be assigned to Message: + // *SignalResponse_Jin + // *SignalResponse_Negotiate + // *SignalResponse_Trickle + Message isSignalResponse_Message `protobuf_oneof:"message"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SignalResponse) Reset() { *m = SignalResponse{} } +func (m *SignalResponse) String() string { return proto.CompactTextString(m) } +func (*SignalResponse) ProtoMessage() {} +func (*SignalResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_85bd91e80f756774, []int{1} +} + +func (m *SignalResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SignalResponse.Unmarshal(m, b) +} +func (m *SignalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SignalResponse.Marshal(b, m, deterministic) +} +func (m *SignalResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignalResponse.Merge(m, src) +} +func (m *SignalResponse) XXX_Size() int { + return xxx_messageInfo_SignalResponse.Size(m) +} +func (m *SignalResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SignalResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SignalResponse proto.InternalMessageInfo + +type isSignalResponse_Message interface { + isSignalResponse_Message() +} + +type SignalResponse_Jin struct { + Jin *JoinResponse `protobuf:"bytes,1,opt,name=jin,proto3,oneof"` +} + +type SignalResponse_Negotiate struct { + Negotiate *SessionDescription `protobuf:"bytes,2,opt,name=negotiate,proto3,oneof"` +} + +type SignalResponse_Trickle struct { + Trickle *Trickle `protobuf:"bytes,3,opt,name=trickle,proto3,oneof"` +} + +func (*SignalResponse_Jin) isSignalResponse_Message() {} + +func (*SignalResponse_Negotiate) isSignalResponse_Message() {} + +func (*SignalResponse_Trickle) isSignalResponse_Message() {} + +func (m *SignalResponse) GetMessage() isSignalResponse_Message { + if m != nil { + return m.Message + } + return nil +} + +func (m *SignalResponse) GetJin() *JoinResponse { + if x, ok := m.GetMessage().(*SignalResponse_Jin); ok { + return x.Jin + } + return nil +} + +func (m *SignalResponse) GetNegotiate() *SessionDescription { + if x, ok := m.GetMessage().(*SignalResponse_Negotiate); ok { + return x.Negotiate + } + return nil +} + +func (m *SignalResponse) GetTrickle() *Trickle { + if x, ok := m.GetMessage().(*SignalResponse_Trickle); ok { + return x.Trickle + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*SignalResponse) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*SignalResponse_Jin)(nil), + (*SignalResponse_Negotiate)(nil), + (*SignalResponse_Trickle)(nil), + } +} + +type JoinRequest struct { + RoomId string `protobuf:"bytes,1,opt,name=room_id,json=roomId,proto3" json:"room_id,omitempty"` + Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` + PeerId string `protobuf:"bytes,3,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"` + Offer *SessionDescription `protobuf:"bytes,4,opt,name=offer,proto3" json:"offer,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *JoinRequest) Reset() { *m = JoinRequest{} } +func (m *JoinRequest) String() string { return proto.CompactTextString(m) } +func (*JoinRequest) ProtoMessage() {} +func (*JoinRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_85bd91e80f756774, []int{2} +} + +func (m *JoinRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_JoinRequest.Unmarshal(m, b) +} +func (m *JoinRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_JoinRequest.Marshal(b, m, deterministic) +} +func (m *JoinRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_JoinRequest.Merge(m, src) +} +func (m *JoinRequest) XXX_Size() int { + return xxx_messageInfo_JoinRequest.Size(m) +} +func (m *JoinRequest) XXX_DiscardUnknown() { + xxx_messageInfo_JoinRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_JoinRequest proto.InternalMessageInfo + +func (m *JoinRequest) GetRoomId() string { + if m != nil { + return m.RoomId + } + return "" +} + +func (m *JoinRequest) GetToken() string { + if m != nil { + return m.Token + } + return "" +} + +func (m *JoinRequest) GetPeerId() string { + if m != nil { + return m.PeerId + } + return "" +} + +func (m *JoinRequest) GetOffer() *SessionDescription { + if m != nil { + return m.Offer + } + return nil +} + +type JoinResponse struct { + Answer *SessionDescription `protobuf:"bytes,1,opt,name=answer,proto3" json:"answer,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *JoinResponse) Reset() { *m = JoinResponse{} } +func (m *JoinResponse) String() string { return proto.CompactTextString(m) } +func (*JoinResponse) ProtoMessage() {} +func (*JoinResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_85bd91e80f756774, []int{3} +} + +func (m *JoinResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_JoinResponse.Unmarshal(m, b) +} +func (m *JoinResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_JoinResponse.Marshal(b, m, deterministic) +} +func (m *JoinResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_JoinResponse.Merge(m, src) +} +func (m *JoinResponse) XXX_Size() int { + return xxx_messageInfo_JoinResponse.Size(m) +} +func (m *JoinResponse) XXX_DiscardUnknown() { + xxx_messageInfo_JoinResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_JoinResponse proto.InternalMessageInfo + +func (m *JoinResponse) GetAnswer() *SessionDescription { + if m != nil { + return m.Answer + } + return nil +} + +type Trickle struct { + // serialized JSON structure of candidate init + CandidateInit string `protobuf:"bytes,1,opt,name=candidate_init,json=candidateInit,proto3" json:"candidate_init,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Trickle) Reset() { *m = Trickle{} } +func (m *Trickle) String() string { return proto.CompactTextString(m) } +func (*Trickle) ProtoMessage() {} +func (*Trickle) Descriptor() ([]byte, []int) { + return fileDescriptor_85bd91e80f756774, []int{4} +} + +func (m *Trickle) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Trickle.Unmarshal(m, b) +} +func (m *Trickle) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Trickle.Marshal(b, m, deterministic) +} +func (m *Trickle) XXX_Merge(src proto.Message) { + xxx_messageInfo_Trickle.Merge(m, src) +} +func (m *Trickle) XXX_Size() int { + return xxx_messageInfo_Trickle.Size(m) +} +func (m *Trickle) XXX_DiscardUnknown() { + xxx_messageInfo_Trickle.DiscardUnknown(m) +} + +var xxx_messageInfo_Trickle proto.InternalMessageInfo + +func (m *Trickle) GetCandidateInit() string { + if m != nil { + return m.CandidateInit + } + return "" +} + +type SessionDescription struct { + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Sdp string `protobuf:"bytes,2,opt,name=sdp,proto3" json:"sdp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SessionDescription) Reset() { *m = SessionDescription{} } +func (m *SessionDescription) String() string { return proto.CompactTextString(m) } +func (*SessionDescription) ProtoMessage() {} +func (*SessionDescription) Descriptor() ([]byte, []int) { + return fileDescriptor_85bd91e80f756774, []int{5} +} + +func (m *SessionDescription) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SessionDescription.Unmarshal(m, b) +} +func (m *SessionDescription) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SessionDescription.Marshal(b, m, deterministic) +} +func (m *SessionDescription) XXX_Merge(src proto.Message) { + xxx_messageInfo_SessionDescription.Merge(m, src) +} +func (m *SessionDescription) XXX_Size() int { + return xxx_messageInfo_SessionDescription.Size(m) +} +func (m *SessionDescription) XXX_DiscardUnknown() { + xxx_messageInfo_SessionDescription.DiscardUnknown(m) +} + +var xxx_messageInfo_SessionDescription proto.InternalMessageInfo + +func (m *SessionDescription) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *SessionDescription) GetSdp() string { + if m != nil { + return m.Sdp + } + return "" +} + +func init() { + proto.RegisterType((*SignalRequest)(nil), "livekit.SignalRequest") + proto.RegisterType((*SignalResponse)(nil), "livekit.SignalResponse") + proto.RegisterType((*JoinRequest)(nil), "livekit.JoinRequest") + proto.RegisterType((*JoinResponse)(nil), "livekit.JoinResponse") + proto.RegisterType((*Trickle)(nil), "livekit.Trickle") + proto.RegisterType((*SessionDescription)(nil), "livekit.SessionDescription") +} + +func init() { proto.RegisterFile("rtc.proto", fileDescriptor_85bd91e80f756774) } + +var fileDescriptor_85bd91e80f756774 = []byte{ + // 406 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x93, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0x87, 0x63, 0x92, 0xda, 0xf2, 0x94, 0x56, 0xd5, 0xa8, 0x50, 0x0b, 0x2e, 0xc8, 0x12, 0x52, + 0x41, 0xe0, 0xf4, 0xcf, 0x0d, 0xc4, 0xa5, 0xe5, 0xe0, 0xc0, 0x6d, 0xd3, 0x13, 0x97, 0xca, 0xb5, + 0xa7, 0x66, 0x9a, 0x64, 0xd7, 0xec, 0x6e, 0x83, 0x78, 0x03, 0x5e, 0x87, 0x37, 0x44, 0x5e, 0xaf, + 0xdd, 0x88, 0x48, 0x70, 0xe4, 0xe4, 0x9d, 0xd1, 0xf7, 0x5b, 0x7d, 0x33, 0xb6, 0x21, 0xd6, 0xb6, + 0xcc, 0x1a, 0xad, 0xac, 0xc2, 0x68, 0xc9, 0x6b, 0x5a, 0xb0, 0x4d, 0x7f, 0x05, 0xb0, 0x37, 0xe7, + 0x5a, 0x16, 0x4b, 0x41, 0xdf, 0xee, 0xc9, 0x58, 0x7c, 0x0d, 0x93, 0x3b, 0xc5, 0x32, 0x09, 0x5e, + 0x04, 0xc7, 0xbb, 0x67, 0x87, 0x99, 0x27, 0xb3, 0x4f, 0x8a, 0xa5, 0x67, 0xf2, 0x91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, 0xfa, 0x0e, 0x70, 0xfb, 0x3e, 0x44, 0x98, 0xd8, 0x1f, 0x0d, 0xf9, + 0x88, 0x3b, 0xe3, 0x01, 0x8c, 0x4d, 0xd5, 0xf8, 0x05, 0xb4, 0xc7, 0xb3, 0xcf, 0x00, 0xe2, 0xea, + 0x72, 0x4e, 0x7a, 0xcd, 0x25, 0xe1, 0x07, 0x08, 0xbb, 0xd7, 0x8f, 0x4f, 0x1f, 0x54, 0x37, 0xbf, + 0xe1, 0x67, 0x47, 0x5b, 0xfd, 0x6e, 0xd6, 0xe3, 0xe0, 0x24, 0xb8, 0x38, 0xfd, 0x32, 0xad, 0xd9, + 0x7e, 0xbd, 0xbf, 0xc9, 0x4a, 0xb5, 0x9a, 0x7a, 0xb0, 0x7f, 0xbe, 0x35, 0xa4, 0xd7, 0xa4, 0xa7, + 0xee, 0x37, 0xe9, 0x9b, 0x37, 0xa1, 0x2b, 0xcf, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xa9, 0x3d, + 0xb9, 0xb1, 0x42, 0x03, 0x00, 0x00, +} diff --git a/proto/livekit/rtc_grpc.pb.go b/proto/livekit/rtc_grpc.pb.go new file mode 100644 index 000000000..f205418a3 --- /dev/null +++ b/proto/livekit/rtc_grpc.pb.go @@ -0,0 +1,129 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package livekit + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion7 + +// RTCServiceClient is the client API for RTCService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type RTCServiceClient interface { + Signal(ctx context.Context, opts ...grpc.CallOption) (RTCService_SignalClient, error) +} + +type rTCServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewRTCServiceClient(cc grpc.ClientConnInterface) RTCServiceClient { + return &rTCServiceClient{cc} +} + +func (c *rTCServiceClient) Signal(ctx context.Context, opts ...grpc.CallOption) (RTCService_SignalClient, error) { + stream, err := c.cc.NewStream(ctx, &_RTCService_serviceDesc.Streams[0], "/livekit.RTCService/Signal", opts...) + if err != nil { + return nil, err + } + x := &rTCServiceSignalClient{stream} + return x, nil +} + +type RTCService_SignalClient interface { + Send(*SignalRequest) error + Recv() (*SignalResponse, error) + grpc.ClientStream +} + +type rTCServiceSignalClient struct { + grpc.ClientStream +} + +func (x *rTCServiceSignalClient) Send(m *SignalRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *rTCServiceSignalClient) Recv() (*SignalResponse, error) { + m := new(SignalResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// RTCServiceServer is the server API for RTCService service. +// All implementations must embed UnimplementedRTCServiceServer +// for forward compatibility +type RTCServiceServer interface { + Signal(RTCService_SignalServer) error + mustEmbedUnimplementedRTCServiceServer() +} + +// UnimplementedRTCServiceServer must be embedded to have forward compatible implementations. +type UnimplementedRTCServiceServer struct { +} + +func (UnimplementedRTCServiceServer) Signal(RTCService_SignalServer) error { + return status.Errorf(codes.Unimplemented, "method Signal not implemented") +} +func (UnimplementedRTCServiceServer) mustEmbedUnimplementedRTCServiceServer() {} + +// UnsafeRTCServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to RTCServiceServer will +// result in compilation errors. +type UnsafeRTCServiceServer interface { + mustEmbedUnimplementedRTCServiceServer() +} + +func RegisterRTCServiceServer(s *grpc.Server, srv RTCServiceServer) { + s.RegisterService(&_RTCService_serviceDesc, srv) +} + +func _RTCService_Signal_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(RTCServiceServer).Signal(&rTCServiceSignalServer{stream}) +} + +type RTCService_SignalServer interface { + Send(*SignalResponse) error + Recv() (*SignalRequest, error) + grpc.ServerStream +} + +type rTCServiceSignalServer struct { + grpc.ServerStream +} + +func (x *rTCServiceSignalServer) Send(m *SignalResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *rTCServiceSignalServer) Recv() (*SignalRequest, error) { + m := new(SignalRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +var _RTCService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "livekit.RTCService", + HandlerType: (*RTCServiceServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Signal", + Handler: _RTCService_Signal_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "rtc.proto", +} diff --git a/proto/livekit/service.pb.go b/proto/livekit/service.pb.go deleted file mode 100644 index d51751e88..000000000 --- a/proto/livekit/service.pb.go +++ /dev/null @@ -1,528 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: service.proto - -package livekit - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type CreateRoomRequest struct { - RoomId string `protobuf:"bytes,1,opt,name=room_id,json=roomId,proto3" json:"room_id,omitempty"` - // number of seconds the room should cleanup after being empty - EmptyTimeout uint32 `protobuf:"varint,2,opt,name=empty_timeout,json=emptyTimeout,proto3" json:"empty_timeout,omitempty"` - MaxParticipants uint32 `protobuf:"varint,3,opt,name=max_participants,json=maxParticipants,proto3" json:"max_participants,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateRoomRequest) Reset() { *m = CreateRoomRequest{} } -func (m *CreateRoomRequest) String() string { return proto.CompactTextString(m) } -func (*CreateRoomRequest) ProtoMessage() {} -func (*CreateRoomRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a0b84a42fa06f626, []int{0} -} - -func (m *CreateRoomRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateRoomRequest.Unmarshal(m, b) -} -func (m *CreateRoomRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateRoomRequest.Marshal(b, m, deterministic) -} -func (m *CreateRoomRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateRoomRequest.Merge(m, src) -} -func (m *CreateRoomRequest) XXX_Size() int { - return xxx_messageInfo_CreateRoomRequest.Size(m) -} -func (m *CreateRoomRequest) XXX_DiscardUnknown() { - xxx_messageInfo_CreateRoomRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateRoomRequest proto.InternalMessageInfo - -func (m *CreateRoomRequest) GetRoomId() string { - if m != nil { - return m.RoomId - } - return "" -} - -func (m *CreateRoomRequest) GetEmptyTimeout() uint32 { - if m != nil { - return m.EmptyTimeout - } - return 0 -} - -func (m *CreateRoomRequest) GetMaxParticipants() uint32 { - if m != nil { - return m.MaxParticipants - } - return 0 -} - -type GetRoomRequest struct { - RoomId string `protobuf:"bytes,1,opt,name=room_id,json=roomId,proto3" json:"room_id,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetRoomRequest) Reset() { *m = GetRoomRequest{} } -func (m *GetRoomRequest) String() string { return proto.CompactTextString(m) } -func (*GetRoomRequest) ProtoMessage() {} -func (*GetRoomRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a0b84a42fa06f626, []int{1} -} - -func (m *GetRoomRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetRoomRequest.Unmarshal(m, b) -} -func (m *GetRoomRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetRoomRequest.Marshal(b, m, deterministic) -} -func (m *GetRoomRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetRoomRequest.Merge(m, src) -} -func (m *GetRoomRequest) XXX_Size() int { - return xxx_messageInfo_GetRoomRequest.Size(m) -} -func (m *GetRoomRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetRoomRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetRoomRequest proto.InternalMessageInfo - -func (m *GetRoomRequest) GetRoomId() string { - if m != nil { - return m.RoomId - } - return "" -} - -type RoomInfo struct { - RoomId string `protobuf:"bytes,1,opt,name=room_id,json=roomId,proto3" json:"room_id,omitempty"` - NodeIp string `protobuf:"bytes,2,opt,name=node_ip,json=nodeIp,proto3" json:"node_ip,omitempty"` - NodeRtcPort uint32 `protobuf:"varint,3,opt,name=node_rtc_port,json=nodeRtcPort,proto3" json:"node_rtc_port,omitempty"` - CreationTime int64 `protobuf:"varint,4,opt,name=creation_time,json=creationTime,proto3" json:"creation_time,omitempty"` - Token string `protobuf:"bytes,5,opt,name=token,proto3" json:"token,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RoomInfo) Reset() { *m = RoomInfo{} } -func (m *RoomInfo) String() string { return proto.CompactTextString(m) } -func (*RoomInfo) ProtoMessage() {} -func (*RoomInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_a0b84a42fa06f626, []int{2} -} - -func (m *RoomInfo) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_RoomInfo.Unmarshal(m, b) -} -func (m *RoomInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_RoomInfo.Marshal(b, m, deterministic) -} -func (m *RoomInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_RoomInfo.Merge(m, src) -} -func (m *RoomInfo) XXX_Size() int { - return xxx_messageInfo_RoomInfo.Size(m) -} -func (m *RoomInfo) XXX_DiscardUnknown() { - xxx_messageInfo_RoomInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_RoomInfo proto.InternalMessageInfo - -func (m *RoomInfo) GetRoomId() string { - if m != nil { - return m.RoomId - } - return "" -} - -func (m *RoomInfo) GetNodeIp() string { - if m != nil { - return m.NodeIp - } - return "" -} - -func (m *RoomInfo) GetNodeRtcPort() uint32 { - if m != nil { - return m.NodeRtcPort - } - return 0 -} - -func (m *RoomInfo) GetCreationTime() int64 { - if m != nil { - return m.CreationTime - } - return 0 -} - -func (m *RoomInfo) GetToken() string { - if m != nil { - return m.Token - } - return "" -} - -type DeleteRoomRequest struct { - RoomId string `protobuf:"bytes,1,opt,name=room_id,json=roomId,proto3" json:"room_id,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteRoomRequest) Reset() { *m = DeleteRoomRequest{} } -func (m *DeleteRoomRequest) String() string { return proto.CompactTextString(m) } -func (*DeleteRoomRequest) ProtoMessage() {} -func (*DeleteRoomRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a0b84a42fa06f626, []int{3} -} - -func (m *DeleteRoomRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteRoomRequest.Unmarshal(m, b) -} -func (m *DeleteRoomRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteRoomRequest.Marshal(b, m, deterministic) -} -func (m *DeleteRoomRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteRoomRequest.Merge(m, src) -} -func (m *DeleteRoomRequest) XXX_Size() int { - return xxx_messageInfo_DeleteRoomRequest.Size(m) -} -func (m *DeleteRoomRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteRoomRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteRoomRequest proto.InternalMessageInfo - -func (m *DeleteRoomRequest) GetRoomId() string { - if m != nil { - return m.RoomId - } - return "" -} - -type DeleteRoomResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteRoomResponse) Reset() { *m = DeleteRoomResponse{} } -func (m *DeleteRoomResponse) String() string { return proto.CompactTextString(m) } -func (*DeleteRoomResponse) ProtoMessage() {} -func (*DeleteRoomResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a0b84a42fa06f626, []int{4} -} - -func (m *DeleteRoomResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteRoomResponse.Unmarshal(m, b) -} -func (m *DeleteRoomResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteRoomResponse.Marshal(b, m, deterministic) -} -func (m *DeleteRoomResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteRoomResponse.Merge(m, src) -} -func (m *DeleteRoomResponse) XXX_Size() int { - return xxx_messageInfo_DeleteRoomResponse.Size(m) -} -func (m *DeleteRoomResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteRoomResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteRoomResponse proto.InternalMessageInfo - -type JoinRequest struct { - RoomId string `protobuf:"bytes,1,opt,name=room_id,json=roomId,proto3" json:"room_id,omitempty"` - Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` - PeerId string `protobuf:"bytes,3,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"` - Offer *SessionDescription `protobuf:"bytes,4,opt,name=offer,proto3" json:"offer,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *JoinRequest) Reset() { *m = JoinRequest{} } -func (m *JoinRequest) String() string { return proto.CompactTextString(m) } -func (*JoinRequest) ProtoMessage() {} -func (*JoinRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a0b84a42fa06f626, []int{5} -} - -func (m *JoinRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_JoinRequest.Unmarshal(m, b) -} -func (m *JoinRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_JoinRequest.Marshal(b, m, deterministic) -} -func (m *JoinRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_JoinRequest.Merge(m, src) -} -func (m *JoinRequest) XXX_Size() int { - return xxx_messageInfo_JoinRequest.Size(m) -} -func (m *JoinRequest) XXX_DiscardUnknown() { - xxx_messageInfo_JoinRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_JoinRequest proto.InternalMessageInfo - -func (m *JoinRequest) GetRoomId() string { - if m != nil { - return m.RoomId - } - return "" -} - -func (m *JoinRequest) GetToken() string { - if m != nil { - return m.Token - } - return "" -} - -func (m *JoinRequest) GetPeerId() string { - if m != nil { - return m.PeerId - } - return "" -} - -func (m *JoinRequest) GetOffer() *SessionDescription { - if m != nil { - return m.Offer - } - return nil -} - -type JoinResponse struct { - Answer *SessionDescription `protobuf:"bytes,1,opt,name=answer,proto3" json:"answer,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *JoinResponse) Reset() { *m = JoinResponse{} } -func (m *JoinResponse) String() string { return proto.CompactTextString(m) } -func (*JoinResponse) ProtoMessage() {} -func (*JoinResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a0b84a42fa06f626, []int{6} -} - -func (m *JoinResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_JoinResponse.Unmarshal(m, b) -} -func (m *JoinResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_JoinResponse.Marshal(b, m, deterministic) -} -func (m *JoinResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_JoinResponse.Merge(m, src) -} -func (m *JoinResponse) XXX_Size() int { - return xxx_messageInfo_JoinResponse.Size(m) -} -func (m *JoinResponse) XXX_DiscardUnknown() { - xxx_messageInfo_JoinResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_JoinResponse proto.InternalMessageInfo - -func (m *JoinResponse) GetAnswer() *SessionDescription { - if m != nil { - return m.Answer - } - return nil -} - -type TrickleRequest struct { - Candidate string `protobuf:"bytes,1,opt,name=candidate,proto3" json:"candidate,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *TrickleRequest) Reset() { *m = TrickleRequest{} } -func (m *TrickleRequest) String() string { return proto.CompactTextString(m) } -func (*TrickleRequest) ProtoMessage() {} -func (*TrickleRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_a0b84a42fa06f626, []int{7} -} - -func (m *TrickleRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TrickleRequest.Unmarshal(m, b) -} -func (m *TrickleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TrickleRequest.Marshal(b, m, deterministic) -} -func (m *TrickleRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_TrickleRequest.Merge(m, src) -} -func (m *TrickleRequest) XXX_Size() int { - return xxx_messageInfo_TrickleRequest.Size(m) -} -func (m *TrickleRequest) XXX_DiscardUnknown() { - xxx_messageInfo_TrickleRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_TrickleRequest proto.InternalMessageInfo - -func (m *TrickleRequest) GetCandidate() string { - if m != nil { - return m.Candidate - } - return "" -} - -type TrickleResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *TrickleResponse) Reset() { *m = TrickleResponse{} } -func (m *TrickleResponse) String() string { return proto.CompactTextString(m) } -func (*TrickleResponse) ProtoMessage() {} -func (*TrickleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_a0b84a42fa06f626, []int{8} -} - -func (m *TrickleResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TrickleResponse.Unmarshal(m, b) -} -func (m *TrickleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TrickleResponse.Marshal(b, m, deterministic) -} -func (m *TrickleResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_TrickleResponse.Merge(m, src) -} -func (m *TrickleResponse) XXX_Size() int { - return xxx_messageInfo_TrickleResponse.Size(m) -} -func (m *TrickleResponse) XXX_DiscardUnknown() { - xxx_messageInfo_TrickleResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_TrickleResponse proto.InternalMessageInfo - -type SessionDescription struct { - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - Sdp []byte `protobuf:"bytes,2,opt,name=sdp,proto3" json:"sdp,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SessionDescription) Reset() { *m = SessionDescription{} } -func (m *SessionDescription) String() string { return proto.CompactTextString(m) } -func (*SessionDescription) ProtoMessage() {} -func (*SessionDescription) Descriptor() ([]byte, []int) { - return fileDescriptor_a0b84a42fa06f626, []int{9} -} - -func (m *SessionDescription) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SessionDescription.Unmarshal(m, b) -} -func (m *SessionDescription) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SessionDescription.Marshal(b, m, deterministic) -} -func (m *SessionDescription) XXX_Merge(src proto.Message) { - xxx_messageInfo_SessionDescription.Merge(m, src) -} -func (m *SessionDescription) XXX_Size() int { - return xxx_messageInfo_SessionDescription.Size(m) -} -func (m *SessionDescription) XXX_DiscardUnknown() { - xxx_messageInfo_SessionDescription.DiscardUnknown(m) -} - -var xxx_messageInfo_SessionDescription proto.InternalMessageInfo - -func (m *SessionDescription) GetType() string { - if m != nil { - return m.Type - } - return "" -} - -func (m *SessionDescription) GetSdp() []byte { - if m != nil { - return m.Sdp - } - return nil -} - -func init() { - proto.RegisterType((*CreateRoomRequest)(nil), "livekit.CreateRoomRequest") - proto.RegisterType((*GetRoomRequest)(nil), "livekit.GetRoomRequest") - proto.RegisterType((*RoomInfo)(nil), "livekit.RoomInfo") - proto.RegisterType((*DeleteRoomRequest)(nil), "livekit.DeleteRoomRequest") - proto.RegisterType((*DeleteRoomResponse)(nil), "livekit.DeleteRoomResponse") - proto.RegisterType((*JoinRequest)(nil), "livekit.JoinRequest") - proto.RegisterType((*JoinResponse)(nil), "livekit.JoinResponse") - proto.RegisterType((*TrickleRequest)(nil), "livekit.TrickleRequest") - proto.RegisterType((*TrickleResponse)(nil), "livekit.TrickleResponse") - proto.RegisterType((*SessionDescription)(nil), "livekit.SessionDescription") -} - -func init() { proto.RegisterFile("service.proto", fileDescriptor_a0b84a42fa06f626) } - -var fileDescriptor_a0b84a42fa06f626 = []byte{ - // 528 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4d, 0x6f, 0xd3, 0x40, - 0x10, 0x95, 0x9b, 0x2f, 0x32, 0x49, 0xda, 0x66, 0x15, 0x14, 0xcb, 0xe5, 0x10, 0x99, 0x4b, 0x2a, - 0xa1, 0x48, 0x24, 0xe2, 0x02, 0x5c, 0x20, 0x45, 0x28, 0x5c, 0xa8, 0xdc, 0x9c, 0xb8, 0x44, 0xc6, - 0x9e, 0x48, 0xab, 0xc4, 0xbb, 0xcb, 0xee, 0xb6, 0xb4, 0x12, 0x3f, 0x80, 0xff, 0xc0, 0xbf, 0xe1, - 0xc4, 0xcf, 0x42, 0xbb, 0x6b, 0x3b, 0x2e, 0x29, 0x6d, 0x6f, 0x9e, 0x99, 0xe7, 0xdd, 0xf7, 0xe6, - 0x3d, 0x2d, 0xf4, 0x14, 0xca, 0x2b, 0x9a, 0xe0, 0x44, 0x48, 0xae, 0x39, 0x69, 0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0x42, 0xc9, 0x0c, 0xea, 0xc6, - 0x1d, 0x32, 0x28, 0xff, 0xa9, 0xc4, 0x26, 0x78, 0xfa, 0x4f, 0x37, 0xb7, 0xf0, 0x1d, 0x34, 0x3e, - 0x1b, 0x6f, 0xc9, 0x7d, 0xde, 0x05, 0xf7, 0x0d, 0xc9, 0x5b, 0x68, 0xe5, 0x06, 0x55, 0x96, 0x70, - 0xdb, 0xe2, 0xc0, 0xdf, 0x1f, 0x38, 0x02, 0xef, 0xdb, 0x5f, 0x8a, 0x47, 0xe7, 0x6b, 0xd3, 0x3e, - 0x42, 0xb3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4c, 0xd8, 0xff, 0xa8, 0x95, 0x04, 0x00, 0x00, -} diff --git a/proto/model.proto b/proto/model.proto index cb59d32bc..b8493329a 100644 --- a/proto/model.proto +++ b/proto/model.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package livekit; -option go_package = "livekit"; +option go_package = "github.com/livekit/livekit-server/proto/livekit"; // internal types, declaring in proto to get serialization for free diff --git a/proto/service.proto b/proto/room.proto similarity index 53% rename from proto/service.proto rename to proto/room.proto index a947ab50e..c6b7385fa 100644 --- a/proto/service.proto +++ b/proto/room.proto @@ -1,10 +1,10 @@ syntax = "proto3"; package livekit; -option go_package = "livekit"; - +option go_package = "github.com/livekit/livekit-server/proto/livekit"; // Room service that can be performed on any node +// they are simple HTTP req/responses service RoomService { // TODO: how do we secure room service? // should be accessible to only internal servers, not external @@ -38,37 +38,3 @@ message DeleteRoomRequest { message DeleteRoomResponse { } - -// RTC methods performed on target node -service RTCService { - rpc Join(JoinRequest) returns (JoinResponse); - - // offer allows client to initiate a RTC session - rpc Offer(SessionDescription) returns (SessionDescription); - - // trickle sends more ICE candidates to server - rpc Trickle(TrickleRequest) returns (TrickleResponse); -} - -message JoinRequest { - string room_id = 1; - string token = 2; - string peer_id = 3; - SessionDescription offer = 4; -} - -message JoinResponse { - SessionDescription answer = 1; -} - -message TrickleRequest { - string candidate = 1; -} - -message TrickleResponse { -} - -message SessionDescription { - string type = 1; // "answer" | "offer" | "pranswer" | "rollback" - bytes sdp = 2; -} diff --git a/proto/rtc.proto b/proto/rtc.proto new file mode 100644 index 000000000..5182ee122 --- /dev/null +++ b/proto/rtc.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; + +package livekit; +option go_package = "github.com/livekit/livekit-server/proto/livekit"; + +// RTC methods performed on target node +service RTCService { + rpc Signal(stream SignalRequest) returns (stream SignalResponse); +} + +message SignalRequest { + oneof message { + JoinRequest join = 1; + SessionDescription negotiate = 2; + Trickle trickle = 3; + } +} + +message SignalResponse { + oneof message { + JoinResponse jin = 1; + SessionDescription negotiate = 2; + Trickle trickle = 3; + } +} + +message JoinRequest { + string room_id = 1; + string token = 2; + string peer_id = 3; + SessionDescription offer = 4; +} + +message JoinResponse { + SessionDescription answer = 1; +} + +message Trickle { + // serialized JSON structure of candidate init + string candidate_init = 1; +} + +message SessionDescription { + string type = 1; // "answer" | "offer" | "pranswer" | "rollback" + string sdp = 2; +}