# SRT

The datarhei Core includes a simple SRT server for publishing and playing streams. It is not enabled by default. You have to enable it in the config in the [srt section](/core/configuration/srt.md) or via the corresponding environment variables.

SRT is a modern live streaming protocol with a low latency and network failure tolerance. [Read more](https://www.haivision.com/products/srt-secure-reliable-transport/).

The SRT server supports publishing and requesting streams, similar to an RTMP server. With your SRT client you have to connect to the SRT server always in caller mode and live transmission mode.

Example:

```
srt://127.0.0.1:6000?mode=caller&transmode=live&streamid=...
```

## Passphrase

If a passphrase is set in the config (or via environment variable), you have to provide the passphrase in the SRT URL. Example SRT URL with the passphrase `foobarfoobar`:

```
srt://127.0.0.1:6000?mode=caller&transmode=live&streamid=...&passphrase=foobarfoobar
```

## StreamID

In order to define whether you want to publish or request a resource, you have to provide your intent in the streamid.

The `streamid` is formatted as follows:

```
[resource],mode:[request|publish],token:[token]
```

The `resource` is the name of the stream. This can be anything. You can publish only one stream with that same name.

The mode is either `request` or `publish`. If you don't provide a mode, `request` will be assumed. You can only request resources that are currently publishing. You can only publish resources that are not already publishing.

The `token` is the one defined in the config (see [srt.token](/core/configuration/srt.md#token)). If no token is configured, you can omit the token in the streamid.

### Examples

Publishing the resource `12345` with the token `foobar`:

```
12345,mode:publish,token:foobar
```

Publishing the resource 12345 with no token defined in the configuration:

```
12345,mode:publish
```

Requesting the resource 12345 with no token defined in the configuration:

```
12345
```

Requesting the resource 12345 with the token `foobar`:

```
12345,token:foobar
```

The whole SRT URL might look like this for the last example:

```
srt://127.0.0.1:6000?mode=caller&transmode=live&streamid=12345,token:foobar
```

## API

Via the [SRT endpoint](/core/api-srt/srt.md) in the API you can gather statistics about the currently connected SRT clients.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.datarhei.com/core/guides/srt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
