> For the complete documentation index, see [llms.txt](https://portal-integracao.intelbras.com.br/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://portal-integracao.intelbras.com.br/defense-ia-and-lite/readme/reproducao.md).

# Reprodução

### Como usar:

* Substitua as variáveis `{{host}}`, `{{loginToken}}` e demais identificadores pelos valores reais do ambiente.
* Utilize variáveis globais do seu projeto quando disponíveis para evitar hardcode.
* Ajuste parâmetros de query conforme o cenário (paginação, filtros, IDs).
* Campos JSON opcionais podem ser removidos ou adicionados sem alterar a estrutura base.
* Sempre valide os tipos esperados pelo backend antes de enviar requisições em lote.

***

### Convenções e autenticação

* Códigos de resultado (padrão): `code: 1000` indica sucesso
* Content-Type: `application/json;charset=UTF-8`
* Idioma (opcional): `Accept-Language: en`
* Autenticação: header `X-Subject-Token: {{loginToken}}` (obtenha o token no seu fluxo de login do projeto)
* Base URL: `http://{{host}}/iams/api/v1.1`

***

### Erros comuns (modelo):

| Situação                   |                       Sintoma | Como resolver                             |
| -------------------------- | ----------------------------: | ----------------------------------------- |
| Token ausente/expirado     |                         `401` | Refaça login e atualize `X-Subject-Token` |
| Content-Type incorreto     |  `415 Unsupported Media Type` | Use `application/json;charset=UTF-8`      |
| Campos obrigatórios vazios | `400` / mensagem de validação | Revise a seção **Parâmetros** do endpoint |

***

### Gravação de pesquisa

**Tópico**: Consulta gravações armazenadas de um canal/câmera dentro de um intervalo de tempo.

* Método: `POST /brms/api/v1.0/SS/Record/QueryRecords`
* Headers: `X-Subject-Token`, `Content-Type`

Exemplo (curl):

```bash
curl --location 'https://{{Host}}/brms/api/v1.0/SS/Record/QueryRecords' 
--header 'X-Subject-Token: 815AA7850E1C48A681ba561f6b766c44' 
--header 'Content-Type: application/json' 
--header 'Cookie: Path=/; JSESSIONID=291F4548138B8F72B83DAFDE0CF2A3CF' 
--data '{
    "data": {
        "endTime": "1688628279",
        "streamType": "0",
        "recordType": "0",
        "recordSource": "3",
        "startTime": "1688541879",
        "channelId": "1000001$1$0$0",
        "page": "",
        "session": ""
    }
}'
```

Resposta (modelo – sucesso):

```json
{
    "code": 1000,
    "desc": "Success",
    "data": {
        "session": null,
        "pageCount": "0",
        "records": []
    }
}
```

### Reprodução de Vídeo Por Tempo

**Tópico**: Inicia a reprodução de gravações armazenadas de um canal/câmera dentro de um intervalo de tempo específico.

* Método: `POST /brms/api/v1.0/SS/Playback/StartPlaybackByTime`

Exemplo (curl):

```bash
curl --location 'https://{{Host}}/brms/api/v1.0/SS/Playback/StartPlaybackByTime' 
--header 'X-Subject-Token: DC9ABA10FB79401Ba66e58c9749238fe' 
--header 'Content-Type: application/json' 
--header 'Cookie: Path=/' 
--data-raw '{
    "data": {
        "enableRtsps": "0",
        "endTime": "1688615989",
        "streamType": "0",
        "recordType": "0",
        "ssId": "100101@video#local",
        "streamId": "112",
        "recordSource": "3",
        "startTime": "1688541879",
        "channelId": "1000005$1$0$2"
    }
}'
```

Resposta (modelo – sucesso):

```json
{
    "code": 1000,
    "desc": "Success",
    "data": {
        "sessionId": "PB2023070600012345",
        "playbackUrl": "rtsp://192.168.1.100:554/playback/PB2023070600012345",
        "protocol": "RTSP",
        "streamType": "0",
        "recordType": "0",
        "startTime": "1688541879",
        "endTime": "1688615989",
        "duration": "74110",
        "channelId": "100101$1$0$0",
        "recordSource": "3"
    }
}
```

### Reproduzir Vídeo Por Arquivo

**Tópico**: Inicia a reprodução de um **arquivo específico de gravação** previamente armazenado no sistema.

* Método: `POST /brms/api/v1.0/SS/Playback/StartPlaybackByFile`

Exemplo (curl):

```bash
curl --location 'https://{{Host}]/brms/api/v1.0/SS/Playback/StartPlaybackByFile' 
--header 'X-Subject-Token: CBB23C068483481Dbf25cb689a776075' 
--header 'Content-Type: application/json' 
--header 'Cookie: Path=/' 
--data '{
    "data": {
        "ssId": "1001",
        "endTime": "1540853395",
        "fileName": "{fe69f729-9d4b-42d4-b6a0-56189aaa4e1e}",
        "diskId": "1540852944-1540853395",
        "startTime": "1540852944",
        "recordSource": "3",
        "channelId": "1000040$1$0$0",
        "streamId": "5875",
        "enableRtsps": "0",
        "playbackType": "0"
    }
}'
```

Resposta (modelo – sucesso):

```json
{
    "code": 1000,
    "desc": "Success",
    "data": {
        "sessionId": "PB2024011500098765",
        "playbackUrl": "rtsp://192.168.1.100:554/playback/PB2024011500098765",
        "protocol": "RTSP",
        "channelId": "1000040$1$0$0",
        "fileName": "{fe69f729-9d4b-42d4-b6a0-56189aaa4e1e}",
        "diskId": "1540852944-1540853395",
        "startTime": "1540852944",
        "endTime": "1540853395",
        "duration": "451",
        "recordSource": "3",
        "streamId": "5875",
        "playbackType": "0"
    }
}
```

### Obter URL de Mídia de Fluxo Para Reprodução de Vídeo (HLS)

**Tópico**: Obtém a **URL de streaming HLS (.m3u8)** para reprodução de vídeo gravado de um canal/câmera dentro de um intervalo de tempo específico.

* Método: `GET /brms/api/v1.1/video/playback/channel/{channelId}/hls`

Exemplo (curl):

```bash
curl --location 'https://{{Host}}/brms/api/v1.1/video/playback/channel/1000014$1$0$0/hls?recordSource=3&streamId=39977&recordType=3&streamType=1&startTime=1621302659&endTime=1621302917&protocol=http' 
--header 'X-Subject-Token: CBB23C068483481Dbf25cb689a776075' 
--header 'Cookie: Path=/'
```

Resposta (modelo – sucesso):

```json
{
    "code": 1000,
    "desc": "Success",
    "data": {
        "streamUrl": "http://{{Host}}/vod/center/cameraid/1000014%240/substream/1/recordtype/1/totallength/258/begintime/1621302659/endtime/1621302917.m3u8"
    }
}
```

***

Notas Finais:&#x20;

* Utilize variáveis globais do projeto para evitar **hardcode** e facilitar manutenção entre ambientes (dev, homologação e produção).
* Valide previamente os parâmetros obrigatórios, como `startTime`, `endTime`, `recordSource`, `streamType` e `recordType`, garantindo que estejam no formato esperado (geralmente timestamp Unix).
* Certifique-se de que o **token de autenticação (X-Subject-Token)** esteja válido antes de realizar chamadas de reprodução ou busca.
* Para fluxos HLS (`.m3u8`), confirme que o cliente/player suporta streaming HTTP adaptativo.
* Em reproduções via RTSP, valide se a porta (geralmente 554) está liberada na rede/firewall.
* Trate corretamente códigos de retorno da API (ex.: `code != 1000`) implementando logs e controle de exceções.
* Sempre encerre sessões de playback ou pesquisa quando não forem mais necessárias, evitando consumo excessivo de recursos no servidor.
* Em ambientes produtivos, priorize comunicação via **HTTPS** para maior segurança.
* Realize testes com diferentes intervalos de tempo e tipos de gravação para validar desempenho e integridade dos dados retornados.

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://portal-integracao.intelbras.com.br/defense-ia-and-lite/readme/reproducao.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
