Logger.brs
Logger.brs
File:
See Logging for full details on enabling dev logging and viewing output.
source/utils/Logger.brsPurpose
Three-level logging facade.GTV_Log is gated on the IS_DEV_BUILD compile-time constant; GTV_Warn and GTV_Error always print.Functions
Output format examples
| Function | Example output |
|---|---|
GTV_Log("PlaylistTask", "Parsed 42 channels") | [GTV][PlaylistTask] Parsed 42 channels |
GTV_Warn("MainScene", "Auto-login failed") | [GTV][WARN][MainScene] Auto-login failed |
GTV_Error("HandshakeTask", "event=handshake_failed code=-1") | [GTV][ERROR][HandshakeTask] event=handshake_failed code=-1 |
HttpClient.brs
HttpClient.brs
File: Performs an async GET. Returns:
Performs an async POST with a JSON body. Same return shape as
Builds a URL-encoded query string from an AssocArray. Values are escaped with Escapes a string using
Builds the
source/utils/HttpClient.brsPurpose
HTTP request wrapper for all backend calls. Handles TLS certificates, platform headers, user-agent, async execution, and timeout cancellation. The function signature defaults to15 000 ms; callers pass TIMEOUT_HTTP = 12 000 ms or TIMEOUT_AUTH = 15 000 ms explicitly.Functions
GTV_HttpGet.GTV_UrlEncode.roUrlTransfer.Escape().User-Agent header string.Example: GlobalTV_Roku/1.0.7 (roku; Roku Express; 12.5.0)Request headers set on every call
| Header | Value |
|---|---|
Content-Type | application/json |
X-Platform | roku (PLATFORM constant) |
User-Agent | GTV_BuildUserAgent() result |
Timeout constants (from AppConstants)
| Constant | Value | Used for |
|---|---|---|
TIMEOUT_HTTP | 12 000 ms | Standard requests (playlist, metrics, ads poll) |
TIMEOUT_AUTH | 15 000 ms | Auth requests |
TIMEOUT_HEALTH | 2 500 ms | Health pings only |
RegistryManager.brs
RegistryManager.brs
File:
source/utils/RegistryManager.brsPurpose
Thin wrapper aroundroRegistrySection for persistent key-value storage. All reads/writes use the registry section "GlobalTV" (REG_SECTION constant). Flush is called automatically on every write.Core functions
Credential functions
Server / cache functions
Channel index functions
Safe-area margin functions
Registry key names (from AppConstants)
| Constant | Key string | Stores |
|---|---|---|
REG_KEY_USER | "username" | Saved username |
REG_KEY_PASS | "password" | Saved password |
REG_KEY_SERVER | "lastServer" | Last active server URL |
REG_KEY_CHANNEL | "lastChannelIndex" | Last viewed channel index |
REG_KEY_SAFE_MARGIN | "uiSafeMarginPct" | UI safe-area margin percentage |
REG_KEY_SERVER_PROFILES | "serverProfiles" | JSON-encoded server profile list |
ServerManager.brs
ServerManager.brs
File:
source/utils/ServerManager.brsPurpose
Server list management. Maintains a list of server profiles (LAN and WAN), builds probe sequences with LAN-first retry behavior, resolves the active server, and provides CRUD operations on profiles.Key functions
Default server profiles
LAN retry behavior
SERVER_LAN_FORCE_RETRIES = 3 — the LAN server URL is inserted 3 times at the head of the probe list before WAN servers are tried. This prioritizes the local server without completely blocking on a single failure.M3UParser.brs
M3UParser.brs
File: Parses an M3U8 string. Returns:Strict mode (
When enabled (the default), any Supported
source/utils/M3UParser.brsPurpose
M3U8 playlist parser. Extracts channel metadata from#EXTINF lines and builds sorted channel and category arrays. Enforces or relaxes channel number requirements via PARSER_STRICT_CHANNEL_NUMBER.Main function
Strict mode (PARSER_STRICT_CHANNEL_NUMBER = true)
When enabled (the default), any #EXTINF entry that does not have a valid channel-number attribute greater than 0 is dropped and counted in droppedMissingNumber. Duplicate channel numbers are also dropped.When disabled, entries without a channel-number receive an auto-incremented fallback index and are counted in fallbackAssigned.Attribute extraction
Supported #EXTINF attributes
| Attribute | Channel field |
|---|---|
tvg-id | id |
tvg-name | name (falls back to trailing comma label) |
tvg-logo | logo |
group-title | group (default: "General") |
channel-number | number |
URL normalization
Stream ID extraction
Sorting
Channels are sorted ascending bychannel.number using an insertion sort (GTV_SortChannels).HealthCheck.brs
HealthCheck.brs
File: Sends an async GET to
source/utils/HealthCheck.brsPurpose
Single-function HTTP health prober. Used byServerManager, ConnectivityTask, and all tasks that need to determine whether a server is reachable before making a real request.Function
baseUrl + PATH_HEALTH (/health) with a timeout of TIMEOUT_HEALTH = 2 500 ms.Returns true if the HTTP response code is in the range 200–499 (i.e., the server is up even if it returns a client error). Returns false on timeout, connection failure, or HTTP 5xx.TLS
Forhttps:// URLs, CERTS = "common:/certs/ca-bundle.crt" is applied automatically.Usage pattern
NetworkDetector.brs
NetworkDetector.brs
File:
source/utils/NetworkDetector.brsPurpose
Device-level network state detection. UsesroDeviceInfo.GetConnectionType() to check whether the Roku device has any network interface active, without making an outbound HTTP request.Functions
Difference from HealthCheck
GTV_IsOnline() is a cheap local check (no network I/O). GTV_PingServer() makes an outbound HTTP call. ConnectivityTask uses both: GTV_IsOnline() writes to m.global.isOnline and GTV_PingServer() writes to m.global.hasInternet.