# place.stream.media.viewCount

> A streamplace node's report of view counts for one place.stream.video over a closed time window. Published in the reporting node's server repo (not the streamer's), so a video served by multiple nodes accumulates multiple records — consumers are expected to sum across trusted reporters. The rkey is conventionally `<windowStart-as-tid>-<video-rkey>` so re-running the aggregator over the same window is idempotent. Counts represent the reporting node's best effort given the data it has; the `tracks` array carries the objective byte / duration totals it observed.

- Kind: record
- Record key: any
- Authority: media.stream.place
- Lexicon: 1
- Published by [stream.place](https://lexicon.garden/identity/did:plc:rbvrr34edl5ddpuwcubjiost), not the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:rbvrr34edl5ddpuwcubjiost/place.stream.media.viewCount)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:rbvrr34edl5ddpuwcubjiost/place.stream.media.viewCount/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:rbvrr34edl5ddpuwcubjiost/place.stream.media.viewCount/analytics)

## Record (`place.stream.media.viewCount`)

Type: record · key any

### Properties

- `count` (integer, required): Number of distinct sessions the reporting node observed as a view over [windowStart, windowEnd).
  - Constraints: minimum: 0
- `indexedAt` (string · datetime, required): When the reporting node ran this aggregation. Useful for ordering successive reports.
- `tracks` (array): Per-track totals of bytes + playback duration the reporting node served over the window. Each entry references the place.stream.media.track record whose bytes were transferred, so user-contributed tracks (transcripts, transcodes published by other accounts) attribute naturally to their own records.
  - `items` (ref)
    - Reference: `#trackUsage`
- `video` (string · at-uri, required): AT-URI of the place.stream.video this count is for.
- `windowEnd` (string · datetime, required): Exclusive upper bound of the aggregation window.
- `windowStart` (string · datetime, required): Inclusive lower bound of the aggregation window.

## #trackUsage (`place.stream.media.viewCount#trackUsage`)

Type: object

One row of the tracks array: bytes + duration transferred for a single place.stream.media.track record over the window.

### Properties

- `bytes` (integer, required): Total bytes served from this track over the window. Sum across attributed segment_requests' Range intersections with the track's segment offsets in the metafile.
  - Constraints: minimum: 0
- `durationMs` (integer, required): Total playback duration served from this track, in milliseconds. Per HLS segment in the range: (overlap bytes / segment bytes) * segment duration, so partial-segment fetches credit a proportional share of duration.
  - Constraints: minimum: 0
- `track` (ref, required): Strong reference to the place.stream.media.track record whose bytes were transferred.
  - Reference: `com.atproto.repo.strongRef`

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "A streamplace node's report of view counts for one place.stream.video over a closed time window. Published in the reporting node's server repo (not the streamer's), so a video served by multiple nodes accumulates multiple records — consumers are expected to sum across trusted reporters. The rkey is conventionally `<windowStart-as-tid>-<video-rkey>` so re-running the aggregator over the same window is idempotent. Counts represent the reporting node's best effort given the data it has; the `tracks` array carries the objective byte / duration totals it observed.",
      "key": "any",
      "record": {
        "properties": {
          "count": {
            "description": "Number of distinct sessions the reporting node observed as a view over [windowStart, windowEnd).",
            "minimum": 0,
            "type": "integer"
          },
          "indexedAt": {
            "description": "When the reporting node ran this aggregation. Useful for ordering successive reports.",
            "format": "datetime",
            "type": "string"
          },
          "tracks": {
            "description": "Per-track totals of bytes + playback duration the reporting node served over the window. Each entry references the place.stream.media.track record whose bytes were transferred, so user-contributed tracks (transcripts, transcodes published by other accounts) attribute naturally to their own records.",
            "items": {
              "ref": "#trackUsage",
              "type": "ref"
            },
            "type": "array"
          },
          "video": {
            "description": "AT-URI of the place.stream.video this count is for.",
            "format": "at-uri",
            "type": "string"
          },
          "windowEnd": {
            "description": "Exclusive upper bound of the aggregation window.",
            "format": "datetime",
            "type": "string"
          },
          "windowStart": {
            "description": "Inclusive lower bound of the aggregation window.",
            "format": "datetime",
            "type": "string"
          }
        },
        "required": [
          "video",
          "count",
          "windowStart",
          "windowEnd",
          "indexedAt"
        ],
        "type": "object"
      },
      "type": "record"
    },
    "trackUsage": {
      "description": "One row of the tracks array: bytes + duration transferred for a single place.stream.media.track record over the window.",
      "properties": {
        "bytes": {
          "description": "Total bytes served from this track over the window. Sum across attributed segment_requests' Range intersections with the track's segment offsets in the metafile.",
          "minimum": 0,
          "type": "integer"
        },
        "durationMs": {
          "description": "Total playback duration served from this track, in milliseconds. Per HLS segment in the range: (overlap bytes / segment bytes) * segment duration, so partial-segment fetches credit a proportional share of duration.",
          "minimum": 0,
          "type": "integer"
        },
        "track": {
          "description": "Strong reference to the place.stream.media.track record whose bytes were transferred.",
          "ref": "com.atproto.repo.strongRef",
          "type": "ref"
        }
      },
      "required": [
        "track",
        "bytes",
        "durationMs"
      ],
      "type": "object"
    }
  },
  "id": "place.stream.media.viewCount",
  "lexicon": 1
}
```
