L'encoder scende in congestione e risale piano; la regia imposta il pavimento, mostra lo stato del telefono e apre il selettore dal bitrate colorato. Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
740 B
Ruby
33 lines
740 B
Ruby
class DeviceState < ApplicationRecord
|
|
ROLES = %w[camera controller].freeze
|
|
|
|
belongs_to :stream_session
|
|
|
|
validates :device_role, inclusion: { in: ROLES }
|
|
validates :device_role, uniqueness: { scope: :stream_session_id }
|
|
|
|
def as_cable_payload
|
|
{
|
|
type: "device_state",
|
|
battery: battery_level,
|
|
network: network_type,
|
|
bitrate: current_bitrate,
|
|
fps: fps,
|
|
status: stream_session.status
|
|
}
|
|
end
|
|
|
|
def as_regia_payload
|
|
{
|
|
battery: battery_level,
|
|
network: network_type,
|
|
signal: signal_strength,
|
|
bitrate: current_bitrate,
|
|
target_bitrate: target_bitrate,
|
|
fps: fps,
|
|
thermal_state: thermal_state,
|
|
last_seen_at: last_seen_at&.iso8601
|
|
}
|
|
end
|
|
end
|