{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/clousd-com/json-schema/clousd-com-stream-stats-schema.json",
  "title": "StreamStats",
  "description": "Live picture quality of one device: what came in from the phone, what went out to each viewer\nand what the browsers last said about themselves.\n",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/clousd-com-openapi.yml#/components/schemas/StreamStats",
  "type": "object",
  "properties": {
    "phone": {
      "type": "string"
    },
    "running": {
      "type": "boolean",
      "description": "The phone screen is being captured right now"
    },
    "viewers": {
      "type": "integer",
      "description": "Browsers watching right now"
    },
    "encoder": {
      "type": "string",
      "description": "Phone encoder doing the capture; empty means scrcpy picked one"
    },
    "fps_in": {
      "type": "number",
      "description": "Frames from the phone over the last second (0 when no frame arrived for 2 s)"
    },
    "kbps_in": {
      "type": "number",
      "description": "Kbit/s from the phone over the last second"
    },
    "last_frame_age_ms": {
      "type": "integer",
      "description": "Age of the last frame, ms; -1 means there were no frames at all"
    },
    "pli_per_min": {
      "type": "number",
      "description": "Key frame requests from viewers per minute: it grows when the picture falls apart"
    },
    "dropped": {
      "type": "integer",
      "description": "Frames the gateway dropped since start (a viewer could not keep up)"
    },
    "up_s": {
      "type": "integer",
      "description": "Seconds the capture has been running"
    },
    "g2g_ms_last": {
      "type": "number",
      "description": "Last glass-to-glass measurement (phone screen to browser), ms"
    },
    "g2g_age_s": {
      "type": "integer",
      "description": "Seconds since that measurement; -1 means it was never measured"
    },
    "bitrate_kbps": {
      "type": "integer",
      "description": "Bitrate the encoder runs at right now"
    },
    "abr": {
      "type": "object",
      "description": "Quality ladder: 4000 -> 2500 -> 1500 -> 800 kbit/s (the top rung is the gateway -bitrate, 4 Mbit/s by default)",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "auto",
            "manual",
            false
          ]
        },
        "rung": {
          "type": "integer",
          "description": "Current rung, 0 is the top one"
        },
        "rungs": {
          "type": "integer"
        },
        "ladder_kbps": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "reason": {
          "type": "string",
          "description": "Why the ladder sits on this rung"
        },
        "changed_at": {
          "type": "string",
          "description": "When the rung last changed (RFC3339; empty if it never did)"
        }
      }
    },
    "peers": {
      "type": "array",
      "description": "What went out to each viewer (gateway counters)",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "frames": {
            "type": "integer"
          },
          "keys": {
            "type": "integer",
            "description": "Key frames sent"
          },
          "pli": {
            "type": "integer"
          },
          "dropped": {
            "type": "integer"
          },
          "kbps": {
            "type": "number"
          },
          "age_s": {
            "type": "integer",
            "description": "Seconds this viewer has been connected"
          },
          "rtt_ms": {
            "type": "integer",
            "description": "From RTCP; -1 means the viewer has never answered over RTCP yet"
          },
          "loss_pct": {
            "type": "number"
          }
        }
      }
    },
    "clients": {
      "type": "array",
      "description": "What the browser last said about itself (one sample per viewer, sent every 10 s)",
      "items": {
        "type": "object",
        "properties": {
          "viewer": {
            "type": "string"
          },
          "rtt_ms": {
            "type": "number"
          },
          "fps": {
            "type": "number"
          },
          "kbps": {
            "type": "number"
          },
          "jitter_ms": {
            "type": "number"
          },
          "dropped": {
            "type": "integer"
          },
          "g2g_ms": {
            "type": "number"
          },
          "g2g_age_s": {
            "type": "integer",
            "description": "-1 means this viewer never measured glass-to-glass"
          },
          "age_s": {
            "type": "integer",
            "description": "Seconds since the sample"
          }
        }
      }
    }
  }
}