-
Notifications
You must be signed in to change notification settings - Fork 356
Code Deep Dive
giongto35 edited this page May 12, 2021
·
9 revisions
Room is the core building block of Cloud Gaming stream in CloudRetro. Room Includes Game + Video Stream + Audio Stream + Input Stream.
-
func NewRoom(roomID string, game games.GameMetadata, onlineStorage *storage.Client, cfg worker.Config): Create a New Game Room: Initialize Game Emulator, Encoder, Video Stream Listener, Audio Stream Listener inside.
- for input := range peerconnection.InputChannel: Listen from PeerConnection Input Channel and pass input to WebRTC Input Data Channel.
- webRTC.ImageChannel <- webrtc.WebFrame{Data: data.Data, Timestamp: data.Timestamp} : Pass image from emulator to WebRTC Video stream
- webRTC.AudioChannel <- audio : Pass audio from emulator to WebRTC Audio Stream
Worker runs multiple gaming sessions inside a worker
- func NewHandler(cfg worker.Config, wrk *Worker) *Handler : Worker Handler includes Rooms, Cloud Storage, User Sessions, and connection with Coordinator.
User firstly connects to Coordinator. Coordinator first finds the best worker to user and setup peer to peer connection.
- func (o *Server) getBestWorkerClient(client *BrowserClient, zone string) (*WorkerClient, error) : get Best Worker Client for new user
- bc.Send(cws.WSPacket{ID: "init", Data: createInitPackage(}, nil) : First init message that trigger peer to peer connection setup
-
func (o *Server) useragentRoutes(bc *BrowserClient) : User's Routing to setup Peer to Peer Connection
- https://github.com/giongto35/cloud-game/blob/master/docs/STREAMING.md : Details of WebRTC connection setup