Documentation ¶
Index ¶
- func GetFrameSizeFor(hz int, frame int) int
- func New(conf worker.Config, log *logger.Logger, done chan struct{}) (services service.Group)
- func ResampleStretchNew(pcm []int16, size int) []int16
- type Buffer
- type CloudSaveRoom
- type CloudStorage
- type Connection
- type GamingRoom
- type OnFull
- type OracleDataStorageClient
- type RecordingRoom
- type Room
- func (r *Room) AddUser(user *Session)
- func (r *Room) CleanupUser(user *Session)
- func (r *Room) Close()
- func (r *Room) EnableAutosave(periodSec int)
- func (r *Room) GetEmulator() emulator.Emulator
- func (r *Room) GetId() string
- func (r *Room) GetLog() *logger.Logger
- func (r *Room) HasSave() bool
- func (r *Room) HasUser(u *Session) bool
- func (r *Room) IsEmpty() bool
- func (r *Room) LoadGame() error
- func (r *Room) PollUserInput(session *Session)
- func (r *Room) SaveGame() error
- func (r *Room) StartEmulator()
- func (r *Room) ToggleMultitap()
- type Router
- type Samples
- type Session
- func (s *Session) Disconnect()
- func (s *Session) GetPeerConn() *webrtc.Peer
- func (s *Session) GetPlayerIndex() int
- func (s *Session) GetSetRoom(v GamingRoom) GamingRoom
- func (s *Session) Id() com.Uid
- func (s *Session) IsConnected() bool
- func (s *Session) SendAudio(sample *media.Sample) error
- func (s *Session) SendVideo(sample *media.Sample) error
- func (s *Session) SetPlayerIndex(index int)
- func (s *Session) SetRoom(room GamingRoom)
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFrameSizeFor ¶
GetFrameSizeFor calculates audio frame size, i.e. 48k*frame/1000*2
func ResampleStretchNew ¶
ResampleStretchNew does a simple stretching of audio samples. something like: [1,2,3,4,5,6] -> [1,2,x,x,3,4,x,x,5,6,x,x] -> [1,2,1,2,3,4,3,4,5,6,5,6]
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a simple non-thread safe ring buffer for audio samples. It should be used for 16bit PCM (LE interleaved) data.
func (*Buffer) Write ¶
Write fills the buffer with data calling a callback function when the internal buffer fills out.
Consider two cases:
1. Underflow, when the length of written data is less than the buffer's available space. 2. Overflow, when the length exceeds the current available buffer space. In the both cases we overwrite any previous values in the buffer and move the internal write pointer on the length of written data. In the first case we won't call the callback, but it will be called every time when the internal buffer overflows until all samples are read.
type CloudSaveRoom ¶
type CloudSaveRoom struct { GamingRoom // contains filtered or unexported fields }
func WithCloudStorage ¶
func WithCloudStorage(room GamingRoom, storage CloudStorage) *CloudSaveRoom
func (*CloudSaveRoom) Download ¶
func (c *CloudSaveRoom) Download() error
func (*CloudSaveRoom) HasSave ¶
func (c *CloudSaveRoom) HasSave() bool
func (*CloudSaveRoom) SaveGame ¶
func (c *CloudSaveRoom) SaveGame() error
type CloudStorage ¶
type CloudStorage interface { Save(name string, localPath string) (err error) Load(name string) (data []byte, err error) }
func GetCloudStorage ¶
func GetCloudStorage(provider, key string) (CloudStorage, error)
type Connection ¶ added in v3.0.5
type GamingRoom ¶
type GamingRoom interface { GetId() string Close() CleanupUser(*Session) HasSave() bool StartEmulator() SaveGame() error LoadGame() error ToggleMultitap() HasUser(*Session) bool AddUser(*Session) PollUserInput(*Session) EnableAutosave(periodS int) GetEmulator() emulator.Emulator GetLog() *logger.Logger }
type OnFull ¶
type OnFull func(s Samples)
Buffer is a simple non-thread safe ring buffer for audio samples. It should be used for 16bit PCM (LE interleaved) data.
type OracleDataStorageClient ¶
type OracleDataStorageClient struct {
// contains filtered or unexported fields
}
func NewOracleDataStorageClient ¶
func NewOracleDataStorageClient(accessURL string) (*OracleDataStorageClient, error)
NewOracleDataStorageClient returns either a new Oracle Data Storage client or some error in case of failure. Oracle infrastructure access is based on pre-authenticated requests, see: https://docs.oracle.com/en-us/iaas/Content/Object/Tasks/usingpreauthenticatedrequests.htm
It follows broken Google Cloud Storage client design.
type RecordingRoom ¶
type RecordingRoom struct { GamingRoom // contains filtered or unexported fields }
func WithRecording ¶
func WithRecording(room GamingRoom, rec bool, recUser string, game string, conf worker.Config) *RecordingRoom
func (*RecordingRoom) Close ¶
func (r *RecordingRoom) Close()
func (*RecordingRoom) IsRecording ¶
func (r *RecordingRoom) IsRecording() bool
func (*RecordingRoom) ToggleRecording ¶
func (r *RecordingRoom) ToggleRecording(active bool, user string)
type Room ¶
type Room struct {
// contains filtered or unexported fields
}
func (*Room) CleanupUser ¶
func (*Room) EnableAutosave ¶
func (*Room) GetEmulator ¶
func (*Room) PollUserInput ¶
func (*Room) StartEmulator ¶
func (r *Room) StartEmulator()
func (*Room) ToggleMultitap ¶
func (r *Room) ToggleMultitap()
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router tracks and routes freshly connected users to a game room. Basically, it holds user connection data until some user makes (connects to) a new room (game), then it manages all the cross-references between room and users. Rooms and users has 1-to-n relationship.
func (*Router) GetRoom ¶
func (r *Router) GetRoom(id string) GamingRoom
func (*Router) RemoveDisconnect ¶ added in v3.0.5
func (*Router) SetRoom ¶
func (r *Router) SetRoom(room GamingRoom)
type Samples ¶
type Samples []int16
Buffer is a simple non-thread safe ring buffer for audio samples. It should be used for 16bit PCM (LE interleaved) data.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents WebRTC connection of the user.
func (*Session) Disconnect ¶ added in v3.0.5
func (s *Session) Disconnect()
func (*Session) GetPeerConn ¶
func (*Session) GetPlayerIndex ¶
func (*Session) GetSetRoom ¶
func (s *Session) GetSetRoom(v GamingRoom) GamingRoom
func (*Session) IsConnected ¶
func (*Session) SetPlayerIndex ¶
func (*Session) SetRoom ¶
func (s *Session) SetRoom(room GamingRoom)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
image
Package image contains functions for rotations of points in a 2-dimensional space.
|
Package image contains functions for rotations of points in a 2-dimensional space. |
h264
Package h264 implements cgo bindings for [x264](https://www.videolan.org/developers/x264.html) library.
|
Package h264 implements cgo bindings for [x264](https://www.videolan.org/developers/x264.html) library. |