From 4b7047d688a1ff488813bf59c20449038986cf70 Mon Sep 17 00:00:00 2001 From: zijiren233 Date: Sun, 15 Oct 2023 15:24:28 +0800 Subject: [PATCH] Feat: update proto model --- proto/message.pb.go | 285 +++++++++++++++++++++++++++----------------- proto/message.proto | 24 ++-- room/current.go | 32 ++--- room/movies.go | 10 +- room/user.go | 35 +++--- 5 files changed, 228 insertions(+), 158 deletions(-) diff --git a/proto/message.pb.go b/proto/message.pb.go index 4318160..31d3d4e 100644 --- a/proto/message.pb.go +++ b/proto/message.pb.go @@ -99,26 +99,22 @@ func (ElementMessageType) EnumDescriptor() ([]byte, []int) { return file_proto_message_proto_rawDescGZIP(), []int{0} } -type MovieInfo struct { +type BaseMovieInfo struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Url string `protobuf:"bytes,2,opt,name=url,proto3" json:"url,omitempty"` - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` - Live bool `protobuf:"varint,4,opt,name=live,proto3" json:"live,omitempty"` - Proxy bool `protobuf:"varint,5,opt,name=proxy,proto3" json:"proxy,omitempty"` - RtmpSource bool `protobuf:"varint,6,opt,name=rtmpSource,proto3" json:"rtmpSource,omitempty"` - Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` - Headers map[string]string `protobuf:"bytes,8,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - PullKey string `protobuf:"bytes,9,opt,name=pullKey,proto3" json:"pullKey,omitempty"` - CreatedAt int64 `protobuf:"varint,10,opt,name=createdAt,proto3" json:"createdAt,omitempty"` - Creator string `protobuf:"bytes,11,opt,name=creator,proto3" json:"creator,omitempty"` + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Live bool `protobuf:"varint,3,opt,name=live,proto3" json:"live,omitempty"` + Proxy bool `protobuf:"varint,4,opt,name=proxy,proto3" json:"proxy,omitempty"` + RtmpSource bool `protobuf:"varint,5,opt,name=rtmpSource,proto3" json:"rtmpSource,omitempty"` + Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` + Headers map[string]string `protobuf:"bytes,7,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } -func (x *MovieInfo) Reset() { - *x = MovieInfo{} +func (x *BaseMovieInfo) Reset() { + *x = BaseMovieInfo{} if protoimpl.UnsafeEnabled { mi := &file_proto_message_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -126,13 +122,13 @@ func (x *MovieInfo) Reset() { } } -func (x *MovieInfo) String() string { +func (x *BaseMovieInfo) String() string { return protoimpl.X.MessageStringOf(x) } -func (*MovieInfo) ProtoMessage() {} +func (*BaseMovieInfo) ProtoMessage() {} -func (x *MovieInfo) ProtoReflect() protoreflect.Message { +func (x *BaseMovieInfo) ProtoReflect() protoreflect.Message { mi := &file_proto_message_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -144,67 +140,118 @@ func (x *MovieInfo) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use MovieInfo.ProtoReflect.Descriptor instead. -func (*MovieInfo) Descriptor() ([]byte, []int) { +// Deprecated: Use BaseMovieInfo.ProtoReflect.Descriptor instead. +func (*BaseMovieInfo) Descriptor() ([]byte, []int) { return file_proto_message_proto_rawDescGZIP(), []int{0} } -func (x *MovieInfo) GetId() uint64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *MovieInfo) GetUrl() string { +func (x *BaseMovieInfo) GetUrl() string { if x != nil { return x.Url } return "" } -func (x *MovieInfo) GetName() string { +func (x *BaseMovieInfo) GetName() string { if x != nil { return x.Name } return "" } -func (x *MovieInfo) GetLive() bool { +func (x *BaseMovieInfo) GetLive() bool { if x != nil { return x.Live } return false } -func (x *MovieInfo) GetProxy() bool { +func (x *BaseMovieInfo) GetProxy() bool { if x != nil { return x.Proxy } return false } -func (x *MovieInfo) GetRtmpSource() bool { +func (x *BaseMovieInfo) GetRtmpSource() bool { if x != nil { return x.RtmpSource } return false } -func (x *MovieInfo) GetType() string { +func (x *BaseMovieInfo) GetType() string { if x != nil { return x.Type } return "" } -func (x *MovieInfo) GetHeaders() map[string]string { +func (x *BaseMovieInfo) GetHeaders() map[string]string { if x != nil { return x.Headers } return nil } +type MovieInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Base *BaseMovieInfo `protobuf:"bytes,2,opt,name=base,proto3" json:"base,omitempty"` + PullKey string `protobuf:"bytes,3,opt,name=pullKey,proto3" json:"pullKey,omitempty"` + CreatedAt int64 `protobuf:"varint,4,opt,name=createdAt,proto3" json:"createdAt,omitempty"` + Creator string `protobuf:"bytes,5,opt,name=creator,proto3" json:"creator,omitempty"` +} + +func (x *MovieInfo) Reset() { + *x = MovieInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_message_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MovieInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MovieInfo) ProtoMessage() {} + +func (x *MovieInfo) ProtoReflect() protoreflect.Message { + mi := &file_proto_message_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MovieInfo.ProtoReflect.Descriptor instead. +func (*MovieInfo) Descriptor() ([]byte, []int) { + return file_proto_message_proto_rawDescGZIP(), []int{1} +} + +func (x *MovieInfo) GetId() uint64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *MovieInfo) GetBase() *BaseMovieInfo { + if x != nil { + return x.Base + } + return nil +} + func (x *MovieInfo) GetPullKey() string { if x != nil { return x.PullKey @@ -239,7 +286,7 @@ type Status struct { func (x *Status) Reset() { *x = Status{} if protoimpl.UnsafeEnabled { - mi := &file_proto_message_proto_msgTypes[1] + mi := &file_proto_message_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -252,7 +299,7 @@ func (x *Status) String() string { func (*Status) ProtoMessage() {} func (x *Status) ProtoReflect() protoreflect.Message { - mi := &file_proto_message_proto_msgTypes[1] + mi := &file_proto_message_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -265,7 +312,7 @@ func (x *Status) ProtoReflect() protoreflect.Message { // Deprecated: Use Status.ProtoReflect.Descriptor instead. func (*Status) Descriptor() ([]byte, []int) { - return file_proto_message_proto_rawDescGZIP(), []int{1} + return file_proto_message_proto_rawDescGZIP(), []int{2} } func (x *Status) GetSeek() float64 { @@ -301,7 +348,7 @@ type Current struct { func (x *Current) Reset() { *x = Current{} if protoimpl.UnsafeEnabled { - mi := &file_proto_message_proto_msgTypes[2] + mi := &file_proto_message_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -314,7 +361,7 @@ func (x *Current) String() string { func (*Current) ProtoMessage() {} func (x *Current) ProtoReflect() protoreflect.Message { - mi := &file_proto_message_proto_msgTypes[2] + mi := &file_proto_message_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -327,7 +374,7 @@ func (x *Current) ProtoReflect() protoreflect.Message { // Deprecated: Use Current.ProtoReflect.Descriptor instead. func (*Current) Descriptor() ([]byte, []int) { - return file_proto_message_proto_rawDescGZIP(), []int{2} + return file_proto_message_proto_rawDescGZIP(), []int{3} } func (x *Current) GetMovie() *MovieInfo { @@ -354,7 +401,7 @@ type ElementMessage struct { Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` Rate float64 `protobuf:"fixed64,4,opt,name=rate,proto3" json:"rate,omitempty"` Seek float64 `protobuf:"fixed64,5,opt,name=seek,proto3" json:"seek,omitempty"` - Current *Current `protobuf:"bytes,6,opt,name=current,proto3,oneof" json:"current,omitempty"` + Current *Current `protobuf:"bytes,6,opt,name=current,proto3" json:"current,omitempty"` PeopleNum int64 `protobuf:"varint,7,opt,name=peopleNum,proto3" json:"peopleNum,omitempty"` Time int64 `protobuf:"varint,8,opt,name=time,proto3" json:"time,omitempty"` } @@ -362,7 +409,7 @@ type ElementMessage struct { func (x *ElementMessage) Reset() { *x = ElementMessage{} if protoimpl.UnsafeEnabled { - mi := &file_proto_message_proto_msgTypes[3] + mi := &file_proto_message_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -375,7 +422,7 @@ func (x *ElementMessage) String() string { func (*ElementMessage) ProtoMessage() {} func (x *ElementMessage) ProtoReflect() protoreflect.Message { - mi := &file_proto_message_proto_msgTypes[3] + mi := &file_proto_message_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -388,7 +435,7 @@ func (x *ElementMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use ElementMessage.ProtoReflect.Descriptor instead. func (*ElementMessage) Descriptor() ([]byte, []int) { - return file_proto_message_proto_rawDescGZIP(), []int{3} + return file_proto_message_proto_rawDescGZIP(), []int{4} } func (x *ElementMessage) GetType() ElementMessageType { @@ -451,30 +498,34 @@ var File_proto_message_proto protoreflect.FileDescriptor var file_proto_message_proto_rawDesc = []byte{ 0x0a, 0x13, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe6, 0x02, 0x0a, - 0x09, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, - 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x76, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, - 0x6c, 0x69, 0x76, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x74, - 0x6d, 0x70, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, - 0x72, 0x74, 0x6d, 0x70, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x37, - 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, - 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, - 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x75, 0x6c, 0x6c, 0x4b, - 0x65, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x75, 0x6c, 0x6c, 0x4b, 0x65, - 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, - 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x63, 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x4a, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8c, 0x02, 0x0a, + 0x0d, 0x42, 0x61, 0x73, 0x65, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, + 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x76, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x04, 0x6c, 0x69, 0x76, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x78, + 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x1e, + 0x0a, 0x0a, 0x72, 0x74, 0x6d, 0x70, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0a, 0x72, 0x74, 0x6d, 0x70, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x3b, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x07, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x61, 0x73, 0x65, + 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x1a, + 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x97, 0x01, 0x0a, 0x09, + 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x04, 0x62, 0x61, 0x73, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x42, 0x61, 0x73, 0x65, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x62, + 0x61, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x75, 0x6c, 0x6c, 0x4b, 0x65, 0x79, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x75, 0x6c, 0x6c, 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x0a, + 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, + 0x72, 0x65, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x6f, 0x72, 0x22, 0x4a, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x72, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x6c, 0x61, 0x79, 0x69, @@ -484,7 +535,7 @@ var file_proto_message_proto_rawDesc = []byte{ 0x6f, 0x74, 0x6f, 0x2e, 0x4d, 0x6f, 0x76, 0x69, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x6d, 0x6f, 0x76, 0x69, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x86, 0x02, 0x0a, 0x0e, + 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0xf5, 0x01, 0x0a, 0x0e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2d, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, @@ -494,29 +545,28 @@ var file_proto_message_proto_rawDesc = []byte{ 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x72, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x01, 0x52, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x12, 0x2d, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, + 0x01, 0x52, 0x04, 0x73, 0x65, 0x65, 0x6b, 0x12, 0x28, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x74, 0x88, 0x01, 0x01, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x65, 0x6f, 0x70, 0x6c, 0x65, - 0x4e, 0x75, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x65, 0x6f, 0x70, 0x6c, - 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x63, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x74, 0x2a, 0xdb, 0x01, 0x0a, 0x12, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, - 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, - 0x52, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x48, 0x41, 0x54, 0x5f, 0x4d, 0x45, 0x53, 0x53, - 0x41, 0x47, 0x45, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x4c, 0x41, 0x59, 0x10, 0x03, 0x12, - 0x09, 0x0a, 0x05, 0x50, 0x41, 0x55, 0x53, 0x45, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x48, - 0x45, 0x43, 0x4b, 0x5f, 0x53, 0x45, 0x45, 0x4b, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x4f, - 0x4f, 0x5f, 0x46, 0x41, 0x53, 0x54, 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x4f, 0x4f, 0x5f, - 0x53, 0x4c, 0x4f, 0x57, 0x10, 0x07, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, - 0x5f, 0x52, 0x41, 0x54, 0x45, 0x10, 0x08, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x48, 0x41, 0x4e, 0x47, - 0x45, 0x5f, 0x53, 0x45, 0x45, 0x4b, 0x10, 0x09, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x48, 0x41, 0x4e, - 0x47, 0x45, 0x5f, 0x43, 0x55, 0x52, 0x52, 0x45, 0x4e, 0x54, 0x10, 0x0a, 0x12, 0x11, 0x0a, 0x0d, - 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x4d, 0x4f, 0x56, 0x49, 0x45, 0x53, 0x10, 0x0b, 0x12, - 0x11, 0x0a, 0x0d, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x50, 0x45, 0x4f, 0x50, 0x4c, 0x45, - 0x10, 0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x65, 0x6f, 0x70, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x65, 0x6f, 0x70, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, + 0x69, 0x6d, 0x65, 0x2a, 0xdb, 0x01, 0x0a, 0x12, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x4d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, + 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, + 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x48, 0x41, 0x54, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, + 0x47, 0x45, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x4c, 0x41, 0x59, 0x10, 0x03, 0x12, 0x09, + 0x0a, 0x05, 0x50, 0x41, 0x55, 0x53, 0x45, 0x10, 0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x43, 0x48, 0x45, + 0x43, 0x4b, 0x5f, 0x53, 0x45, 0x45, 0x4b, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x4f, 0x4f, + 0x5f, 0x46, 0x41, 0x53, 0x54, 0x10, 0x06, 0x12, 0x0c, 0x0a, 0x08, 0x54, 0x4f, 0x4f, 0x5f, 0x53, + 0x4c, 0x4f, 0x57, 0x10, 0x07, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, + 0x52, 0x41, 0x54, 0x45, 0x10, 0x08, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, + 0x5f, 0x53, 0x45, 0x45, 0x4b, 0x10, 0x09, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x48, 0x41, 0x4e, 0x47, + 0x45, 0x5f, 0x43, 0x55, 0x52, 0x52, 0x45, 0x4e, 0x54, 0x10, 0x0a, 0x12, 0x11, 0x0a, 0x0d, 0x43, + 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x4d, 0x4f, 0x56, 0x49, 0x45, 0x53, 0x10, 0x0b, 0x12, 0x11, + 0x0a, 0x0d, 0x43, 0x48, 0x41, 0x4e, 0x47, 0x45, 0x5f, 0x50, 0x45, 0x4f, 0x50, 0x4c, 0x45, 0x10, + 0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -532,26 +582,28 @@ func file_proto_message_proto_rawDescGZIP() []byte { } var file_proto_message_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_proto_message_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_proto_message_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_proto_message_proto_goTypes = []interface{}{ (ElementMessageType)(0), // 0: proto.ElementMessageType - (*MovieInfo)(nil), // 1: proto.MovieInfo - (*Status)(nil), // 2: proto.Status - (*Current)(nil), // 3: proto.Current - (*ElementMessage)(nil), // 4: proto.ElementMessage - nil, // 5: proto.MovieInfo.HeadersEntry + (*BaseMovieInfo)(nil), // 1: proto.BaseMovieInfo + (*MovieInfo)(nil), // 2: proto.MovieInfo + (*Status)(nil), // 3: proto.Status + (*Current)(nil), // 4: proto.Current + (*ElementMessage)(nil), // 5: proto.ElementMessage + nil, // 6: proto.BaseMovieInfo.HeadersEntry } var file_proto_message_proto_depIdxs = []int32{ - 5, // 0: proto.MovieInfo.headers:type_name -> proto.MovieInfo.HeadersEntry - 1, // 1: proto.Current.movie:type_name -> proto.MovieInfo - 2, // 2: proto.Current.status:type_name -> proto.Status - 0, // 3: proto.ElementMessage.type:type_name -> proto.ElementMessageType - 3, // 4: proto.ElementMessage.current:type_name -> proto.Current - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 6, // 0: proto.BaseMovieInfo.headers:type_name -> proto.BaseMovieInfo.HeadersEntry + 1, // 1: proto.MovieInfo.base:type_name -> proto.BaseMovieInfo + 2, // 2: proto.Current.movie:type_name -> proto.MovieInfo + 3, // 3: proto.Current.status:type_name -> proto.Status + 0, // 4: proto.ElementMessage.type:type_name -> proto.ElementMessageType + 4, // 5: proto.ElementMessage.current:type_name -> proto.Current + 6, // [6:6] is the sub-list for method output_type + 6, // [6:6] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_proto_message_proto_init() } @@ -561,7 +613,7 @@ func file_proto_message_proto_init() { } if !protoimpl.UnsafeEnabled { file_proto_message_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MovieInfo); i { + switch v := v.(*BaseMovieInfo); i { case 0: return &v.state case 1: @@ -573,7 +625,7 @@ func file_proto_message_proto_init() { } } file_proto_message_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Status); i { + switch v := v.(*MovieInfo); i { case 0: return &v.state case 1: @@ -585,7 +637,7 @@ func file_proto_message_proto_init() { } } file_proto_message_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Current); i { + switch v := v.(*Status); i { case 0: return &v.state case 1: @@ -597,6 +649,18 @@ func file_proto_message_proto_init() { } } file_proto_message_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Current); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_message_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ElementMessage); i { case 0: return &v.state @@ -609,14 +673,13 @@ func file_proto_message_proto_init() { } } } - file_proto_message_proto_msgTypes[3].OneofWrappers = []interface{}{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto_message_proto_rawDesc, NumEnums: 1, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/message.proto b/proto/message.proto index 61eaccc..8e91b88 100644 --- a/proto/message.proto +++ b/proto/message.proto @@ -19,18 +19,22 @@ enum ElementMessageType { CHANGE_PEOPLE = 12; } +message BaseMovieInfo { + string url = 1; + string name = 2; + bool live = 3; + bool proxy = 4; + bool rtmpSource = 5; + string type = 6; + map headers = 7; +} + message MovieInfo { uint64 id = 1; - string url = 2; - string name = 3; - bool live = 4; - bool proxy = 5; - bool rtmpSource = 6; - string type = 7; - map headers = 8; - string pullKey = 9; - int64 createdAt = 10; - string creator = 11; + BaseMovieInfo base = 2; + string pullKey = 3; + int64 createdAt = 4; + string creator = 5; } message Status { diff --git a/room/current.go b/room/current.go index ecb666e..3fa889f 100644 --- a/room/current.go +++ b/room/current.go @@ -87,17 +87,19 @@ func (c *current) SetSeekRate(seek, rate, timeDiff float64) Status { func (c *Current) Proto() *pb.Current { return &pb.Current{ Movie: &pb.MovieInfo{ - Id: c.Movie.Id, - Url: c.Movie.Url, - Name: c.Movie.Name, - Live: c.Movie.Live, - Proxy: c.Movie.Proxy, - RtmpSource: c.Movie.RtmpSource, - Type: c.Movie.Type, - Headers: c.Movie.Headers, - PullKey: c.Movie.PullKey, - CreatedAt: c.Movie.CreatedAt, - Creator: c.Movie.Creator, + Id: c.Movie.Id, + Base: &pb.BaseMovieInfo{ + Url: c.Movie.BaseMovieInfo.Url, + Name: c.Movie.BaseMovieInfo.Name, + Live: c.Movie.BaseMovieInfo.Live, + Proxy: c.Movie.BaseMovieInfo.Proxy, + RtmpSource: c.Movie.BaseMovieInfo.RtmpSource, + Type: c.Movie.BaseMovieInfo.Type, + Headers: c.Movie.BaseMovieInfo.Headers, + }, + PullKey: c.Movie.PullKey, + CreatedAt: c.Movie.CreatedAt, + Creator: c.Movie.Creator, }, Status: &pb.Status{ Seek: c.Status.Seek, @@ -108,7 +110,7 @@ func (c *Current) Proto() *pb.Current { } func (c *Current) updateSeek() { - if c.Movie.Live { + if c.Movie.BaseMovieInfo.Live { c.Status.lastUpdate = time.Now() return } @@ -127,7 +129,7 @@ func (c *Current) setLiveStatus() Status { } func (c *Current) SetStatus(playing bool, seek, rate, timeDiff float64) Status { - if c.Movie.Live { + if c.Movie.BaseMovieInfo.Live { return c.setLiveStatus() } c.Status.Playing = playing @@ -142,7 +144,7 @@ func (c *Current) SetStatus(playing bool, seek, rate, timeDiff float64) Status { } func (c *Current) SetSeekRate(seek, rate, timeDiff float64) Status { - if c.Movie.Live { + if c.Movie.BaseMovieInfo.Live { return c.setLiveStatus() } if c.Status.Playing { @@ -156,7 +158,7 @@ func (c *Current) SetSeekRate(seek, rate, timeDiff float64) Status { } func (c *Current) SetSeek(seek, timeDiff float64) Status { - if c.Movie.Live { + if c.Movie.BaseMovieInfo.Live { return c.setLiveStatus() } if c.Status.Playing { diff --git a/room/movies.go b/room/movies.go index 9566dd9..f8a4f2b 100644 --- a/room/movies.go +++ b/room/movies.go @@ -149,11 +149,11 @@ func (m *movies) range_(f func(e *dllist.Element[*Movie]) bool) (interrupt bool) } type MovieInfo struct { - Id uint64 `json:"id"` - BaseMovieInfo - PullKey string `json:"pullKey"` - CreatedAt int64 `json:"createdAt"` - Creator string `json:"creator"` + Id uint64 `json:"id"` + BaseMovieInfo BaseMovieInfo `json:"base"` + PullKey string `json:"pullKey"` + CreatedAt int64 `json:"createdAt"` + Creator string `json:"creator"` } func (m *movies) MovieList() (movies []MovieInfo) { diff --git a/room/user.go b/room/user.go index 2fc867f..82ec0f2 100644 --- a/room/user.go +++ b/room/user.go @@ -7,7 +7,6 @@ import ( "time" "github.com/gorilla/websocket" - pb "github.com/synctv-org/synctv/proto" "github.com/zijiren233/gencontainer/dllist" "github.com/zijiren233/stream" "golang.org/x/crypto/bcrypt" @@ -159,7 +158,7 @@ func (u *User) NewMovieWithBaseMovie(baseMovie BaseMovieInfo, conf ...MovieConf) return NewMovieWithBaseMovie(atomic.AddUint64(&u.room.mid, 1), baseMovie, append(conf, WithCreator(u))...) } -func (u *User) Movie(id uint64) (*pb.MovieInfo, error) { +func (u *User) Movie(id uint64) (*MovieInfo, error) { u.room.movies.lock.RLock() defer u.room.movies.lock.RUnlock() @@ -167,20 +166,22 @@ func (u *User) Movie(id uint64) (*pb.MovieInfo, error) { if err != nil { return nil, err } - movie := &pb.MovieInfo{ - Id: m.Id(), - Url: m.Url, - Name: m.Name, - Live: m.Live, - Proxy: m.Proxy, - RtmpSource: m.RtmpSource, - Type: m.Type, - Headers: m.Headers, - PullKey: m.PullKey, - CreatedAt: m.CreatedAt, - Creator: m.Creator().Name(), - } - if movie.Proxy && u.name != movie.Creator { + movie := &MovieInfo{ + Id: m.Id(), + BaseMovieInfo: BaseMovieInfo{ + Url: m.Url, + Name: m.Name, + Live: m.Live, + Proxy: m.Proxy, + RtmpSource: m.RtmpSource, + Type: m.Type, + Headers: m.Headers, + }, + PullKey: m.PullKey, + CreatedAt: m.CreatedAt, + Creator: m.Creator().Name(), + } + if movie.BaseMovieInfo.Proxy && u.name != movie.Creator { m.Headers = nil } return movie, nil @@ -208,7 +209,7 @@ func (u *User) Movies() []*MovieInfo { Creator: e.Value.Creator().Name(), } if e.Value.Proxy && u.name != m.Creator { - m.Headers = nil + m.BaseMovieInfo.Headers = nil } movies = append(movies, m) return true