Rails API, app Flutter, infrastruttura Docker/MediaMTX, sito marketing e documentazione di deploy. Co-authored-by: Cursor <cursoragent@cursor.com>
20 lines
444 B
Ruby
20 lines
444 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
|
|
end
|