Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
sha256sum ${FILENAME} | tee -a ${FILENAME}.sha256
- name: Archive artifacts
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: jacktrip-agent-arm
path: jacktrip-agent-arm-*
46 changes: 46 additions & 0 deletions pkg/client/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ type PingStats struct {
// LatestRtt is the latest rtt sent via socket ping.
LatestRtt time.Duration `json:"latest_rtt" db:"latest_rtt"`

// AudioInputLatency is the latest client-side audio input device latency
AudioInputLatency time.Duration `json:"audio_input_latency" db:"audio_input_latency"`

// AudioOutputLatency is the latest client-side audio output device latency
AudioOutputLatency time.Duration `json:"audio_output_latency" db:"audio_output_latency"`

// ClientBufferLatency is the latest client-side receiver buffer latency
ClientBufferLatency time.Duration `json:"client_buffer_latency" db:"client_buffer_latency"`

// ServerBufferLatency is the latest server-side receiver buffer latency
ServerBufferLatency time.Duration `json:"server_buffer_latency" db:"server_buffer_latency"`

// timestamp when the device stats were last updated
StatsUpdatedAt time.Time `json:"stats_updated_at" db:"stats_updated_at"`

Expand Down Expand Up @@ -162,3 +174,37 @@ type DeviceHeartbeat struct {
// Type of sound device ("snd_rpi_hifiberry_dacplusadcpro")
Type string `json:"type" db:"type"`
}

// DeviceHeartbeatWithConfig is used to represent ping statistics with config for an audio device
type DeviceHeartbeatWithConfig struct {
PingStats
DeviceConfig
ALSAConfig

// unique identifier for an audio device
ID string `json:"id" db:"id"`

// MAC address of the device
MAC string `json:"mac" db:"mac"`

// User identifier of the device's owner
OwnerID string `json:"ownerId" db:"owner_id"`

// audio server that the device is connected to (may be empty)
ServerID string `json:"serverId" db:"server_id"`

// Current image version for the device
Version string `json:"version" db:"version"`

// Descriptive name for the device
Name string `json:"name" db:"name"`

// frames per period
Period int `json:"period" db:"period"`

// size of jitter queue buffer
QueueBuffer int `json:"queueBuffer" db:"queue_buffer"`

// strategy to use for the network jitter buffer
BufferStrategy int `json:"bufferStrategy" db:"buffer_strategy"`
}
20 changes: 20 additions & 0 deletions pkg/client/devices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,23 @@ func TestDeviceHeartbeat(t *testing.T) {
assert.Equal(-1*time.Duration(10291), target.StdDevRtt)
assert.Equal("2021-08-11 10:28:32.487013776 +0000 UTC", target.StatsUpdatedAt.String())
}

func TestStructDeviceHeartbeatWithConfig(t *testing.T) {
assert := assert.New(t)
var data string
var device DeviceHeartbeatWithConfig
// Construct using JSON
data = `{"id": "lmnop", "mac": "mac-address", "ownerId": "mr-rogers", "serverID": "thatserveroverthere", "version": "v1.0.0", "name": "myJacktripDevice", "period": 128, "queueBuffer": 16}`
device = DeviceHeartbeatWithConfig{}
err := json.Unmarshal([]byte(data), &device)
assert.Nil(err)
assert.Equal("lmnop", device.ID)
assert.Equal("mac-address", device.MAC)
assert.Equal("mr-rogers", device.OwnerID)
assert.Equal("thatserveroverthere", device.ServerID)
assert.Equal("v1.0.0", device.Version)
assert.Equal("myJacktripDevice", device.Name)
assert.Equal(128, device.Period)
assert.Equal(16, device.QueueBuffer)
assert.Equal(false, bool(device.EnableUSB))
}