# place.stream.media.viewCount

> Published by [did:web:stream.place](https://lexicon.garden/identity/did:web:stream.place)

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:web:stream.place/place.stream.media.viewCount)
- [Documentation](https://lexicon.garden/lexicon/did:web:stream.place/place.stream.media.viewCount/docs)
- [Examples](https://lexicon.garden/lexicon/did:web:stream.place/place.stream.media.viewCount/examples)

## Definitions

### `place.stream.media.viewCount`

**Type**: `record`

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`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `count` | `integer` | Yes | Number of distinct sessions the reporting node observed as a view over [windowStart, windowEnd). |
| `video` | `string` (at-uri) | Yes | AT-URI of the place.stream.video this count is for. |
| `tracks` | `array` | No | 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. |
| `indexedAt` | `string` (datetime) | Yes | When the reporting node ran this aggregation. Useful for ordering successive reports. |
| `windowEnd` | `string` (datetime) | Yes | Exclusive upper bound of the aggregation window. |
| `windowStart` | `string` (datetime) | Yes | Inclusive lower bound of the aggregation window. |

### `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.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `bytes` | `integer` | Yes | 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. |
| `track` | `ref` → `com.atproto.repo.strongRef` | Yes | Strong reference to the place.stream.media.track record whose bytes were transferred. |
| `durationMs` | `integer` | Yes | 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. |

## Raw Schema

```json
{
  "id": "place.stream.media.viewCount",
  "defs": {
    "main": {
      "key": "any",
      "type": "record",
      "record": {
        "type": "object",
        "required": [
          "video",
          "count",
          "windowStart",
          "windowEnd",
          "indexedAt"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "minimum": 0,
            "description": "Number of distinct sessions the reporting node observed as a view over [windowStart, windowEnd)."
          },
          "video": {
            "type": "string",
            "format": "at-uri",
            "description": "AT-URI of the place.stream.video this count is for."
          },
          "tracks": {
            "type": "array",
            "items": {
              "ref": "#trackUsage",
              "type": "ref"
            },
            "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."
          },
          "indexedAt": {
            "type": "string",
            "format": "datetime",
            "description": "When the reporting node ran this aggregation. Useful for ordering successive reports."
          },
          "windowEnd": {
            "type": "string",
            "format": "datetime",
            "description": "Exclusive upper bound of the aggregation window."
          },
          "windowStart": {
            "type": "string",
            "format": "datetime",
            "description": "Inclusive lower bound of the aggregation window."
          }
        }
      },
      "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."
    },
    "trackUsage": {
      "type": "object",
      "required": [
        "track",
        "bytes",
        "durationMs"
      ],
      "properties": {
        "bytes": {
          "type": "integer",
          "minimum": 0,
          "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."
        },
        "track": {
          "ref": "com.atproto.repo.strongRef",
          "type": "ref",
          "description": "Strong reference to the place.stream.media.track record whose bytes were transferred."
        },
        "durationMs": {
          "type": "integer",
          "minimum": 0,
          "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."
        }
      },
      "description": "One row of the tracks array: bytes + duration transferred for a single place.stream.media.track record over the window."
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1
}
```
