some video retated fixes
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ycc 2024-05-27 18:38:38 +02:00
parent 17c991f442
commit c284b15788
6 changed files with 91 additions and 29 deletions

55
client/helpers/call.go Normal file
View File

@ -0,0 +1,55 @@
package helpers
import (
"forge.redroom.link/yves/meowlib"
"forge.redroom.link/yves/meowlib/client"
)
func BuildCallRequestMessage(users []string, expiry uint64, srvuid string) ([]byte, string, error) {
// Server: get the invitation server
server, err := client.GetConfig().GetIdentity().MessageServers.LoadServer(srvuid)
if err != nil {
return nil, "BuildCallRequestMessage: LoadServer", err
}
toSrvMsg, err := server.BuildVideoRoomRequestMessage(users, expiry)
if err != nil {
return nil, "BuildCallRequestMessage: BuildVideoRoomRequestMessage", err
}
msg, err := server.ProcessOutboundMessage(toSrvMsg)
if err != nil {
return nil, "BuildCallRequestMessage: ProcessOutboundMessage", err
}
return msg, "", nil
}
func ReadCallRequestResponseMessage(data []byte, srvuid string) (*meowlib.VideoData, string, error) {
server, err := client.GetConfig().GetIdentity().MessageServers.LoadServer(srvuid)
if err != nil {
return nil, "ReadCallRequestResponseMessage: LoadServer", err
}
// Server inbound processing : get the invitation server
serverMsg, err := server.ProcessInboundServerResponse(data)
if err != nil {
return nil, "ReadCallRequestResponseMessage: ProcessInboundServerResponse", err
}
return serverMsg.VideoData, "", nil
}
func BuildCallMessage(videodata *meowlib.VideoData, srvuid string, peer_idx int, replyToUid string, filelist []string) ([]byte, string, error) {
peer := client.GetConfig().GetIdentity().Peers[peer_idx]
// Creating User message
usermessage, err := peer.BuildSimpleUserMessage(nil)
if err != nil {
return nil, "BuildCallMessage : BuildSimpleUserMessage", err
}
usermessage.Status.AnswerToUuid = replyToUid
return messageBuildPostprocess(usermessage, srvuid, peer)
}
func BuildCancelCallMessage() {
}

View File

@ -1,16 +1,39 @@
package helpers package helpers
import ( import (
"forge.redroom.link/yves/meowlib"
"forge.redroom.link/yves/meowlib/client" "forge.redroom.link/yves/meowlib/client"
) )
func messageBuildPostprocess(msg *meowlib.UserMessage, srvuid string, peer *client.Peer) ([]byte, string, error) {
// Get the message server
srv, err := client.GetConfig().GetIdentity().MessageServers.LoadServer(srvuid)
if err != nil {
return nil, "messageBuildPostprocess : LoadServer", err
}
// Prepare cyphered + packed user message
packedMsg, err := peer.ProcessOutboundUserMessage(msg)
if err != nil {
return nil, "messageBuildPostprocess : ProcessOutboundUserMessage", err
}
// Creating Server message for transporting the user message
toServerMessage := srv.BuildToServerMessageFromUserMessage(packedMsg)
data, err := srv.ProcessOutboundMessage(toServerMessage)
if err != nil {
return nil, "messageBuildPostprocess : ProcessOutboundMessage", err
}
// Store message
err = peer.StoreMessage(msg, nil)
if err != nil {
return nil, "messageBuildPostprocess : StoreMessage", err
}
return data, "", nil
}
func PrepareUserMessage(message string, srvuid string, peer_idx int, replyToUid string, filelist []string) ([]byte, string, error) { func PrepareUserMessage(message string, srvuid string, peer_idx int, replyToUid string, filelist []string) ([]byte, string, error) {
peer := client.GetConfig().GetIdentity().Peers[peer_idx] peer := client.GetConfig().GetIdentity().Peers[peer_idx]
srv, err := client.GetConfig().GetIdentity().MessageServers.LoadServer(srvuid)
if err != nil {
return nil, "PrepareServerMessage : LoadServer", err
}
// Creating User message // Creating User message
usermessage, err := peer.BuildSimpleUserMessage([]byte(message)) usermessage, err := peer.BuildSimpleUserMessage([]byte(message))
if err != nil { if err != nil {
@ -23,23 +46,9 @@ func PrepareUserMessage(message string, srvuid string, peer_idx int, replyToUid
} }
} }
usermessage.Status.AnswerToUuid = replyToUid usermessage.Status.AnswerToUuid = replyToUid
// Prepare cyphered + packed user message
packedMsg, err := peer.ProcessOutboundUserMessage(usermessage) return messageBuildPostprocess(usermessage, srvuid, peer)
if err != nil {
return nil, "PrepareServerMessage : ProcessOutboundUserMessage", err
}
// Creating Server message for transporting the user message
toServerMessage := srv.BuildToServerMessageFromUserMessage(packedMsg)
data, err := srv.ProcessOutboundMessage(toServerMessage)
if err != nil {
return nil, "PrepareServerMessage : ProcessOutboundMessage", err
}
// Store message
err = peer.StoreMessage(usermessage, filelist)
if err != nil {
return nil, "PrepareServerMessage : StoreMessage", err
}
return data, "", nil
} }
func SendAck(messageUid string, srvuid string, peer_idx int, received int64, processed int64) ([]byte, string, error) { func SendAck(messageUid string, srvuid string, peer_idx int, received int64, processed int64) ([]byte, string, error) {

View File

@ -15,6 +15,7 @@ import (
type PeerStorage struct { type PeerStorage struct {
DbFile string `json:"db_file,omitempty"` DbFile string `json:"db_file,omitempty"`
db *badger.DB db *badger.DB
cache map[string]*Peer
} }
// Open a badger database from struct PeerStorage // Open a badger database from struct PeerStorage

View File

@ -168,7 +168,7 @@ func (ints *Server) BuildMessageRequestMessage(lookupKeys []string) ([]byte, err
} }
// BuildVideoRoomRequestMessage creates a video room request to server and returns it as protobuf serialized byte array // BuildVideoRoomRequestMessage creates a video room request to server and returns it as protobuf serialized byte array
func (ints *Server) BuildVideoRoomRequestMessage(users []string, expiry uint64) ([]byte, error) { func (ints *Server) BuildVideoRoomRequestMessage(users []string, expiry uint64) (*meowlib.ToServerMessage, error) {
var msg meowlib.ToServerMessage var msg meowlib.ToServerMessage
msg.Uuid = uuid.New().String() msg.Uuid = uuid.New().String()
msg.Type = "1" msg.Type = "1"
@ -181,11 +181,7 @@ func (ints *Server) BuildVideoRoomRequestMessage(users []string, expiry uint64)
} }
} }
msg.VideoData.Credentials = videocreds msg.VideoData.Credentials = videocreds
out, err := proto.Marshal(&msg) return &msg, nil
if err != nil {
return nil, err
}
return out, nil
} }
// BuildToServerMessageInvitation creates an invitation message to server and returns it as a meowlib.ToServerMessage // BuildToServerMessageInvitation creates an invitation message to server and returns it as a meowlib.ToServerMessage

View File

@ -33,7 +33,6 @@ message Invitation {
string from=9; // used in step 3 the answer public key to check the signature in user message string from=9; // used in step 3 the answer public key to check the signature in user message
} }
// structure for requesting incoming messages // structure for requesting incoming messages
message ConversationRequest { message ConversationRequest {
string lookup_key = 1; // lookup key for a conversation string lookup_key = 1; // lookup key for a conversation
@ -91,6 +90,8 @@ message FromServerMessage {
repeated PackedUserMessage device_messages = 9; // messages from other devices belonging to the same user repeated PackedUserMessage device_messages = 9; // messages from other devices belonging to the same user
VideoData video_data = 10; // video call data VideoData video_data = 10; // video call data
repeated ContactCard contactCard = 11; // contact list for a personae
} }
message MatriochkaServer { message MatriochkaServer {

View File

@ -10,7 +10,7 @@ import (
type VideoServer struct { type VideoServer struct {
Url string `json:"url,omitempty"` Url string `json:"url,omitempty"`
ApiKey string `json:"api_key,omitempty"` ApiKey string `json:"api_key,omitempty"`
ApiSecret string `json:"secret,omitempty"` ApiSecret string `json:"api_secret,omitempty"`
} }
func (s *VideoServer) GetJoinToken(room, username string, validity time.Duration) (string, error) { func (s *VideoServer) GetJoinToken(room, username string, validity time.Duration) (string, error) {