Skip to content

Commit

Permalink
Add JS code snippets for streaming + use call.create (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarbugli authored Aug 2, 2023
2 parents 77bf723 + 502e621 commit 1e1ab57
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 5 deletions.
4 changes: 3 additions & 1 deletion docusaurus/video/docusaurus/docs/api/basics/calls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ const callType = 'default';
const callId = 'my-first-call';
const call = client.call(callType, callId);

call.create({ data: { created_by_id: 'john' } });
// or
call.getOrCreate({ data: { created_by_id: 'john' } });

// optionally provide additional data
call.getOrCreate({
call.create({
data: {
created_by_id: 'john',
members: [{ user_id: 'john', role: 'admin' }, { user_id: 'jack' }],
Expand Down
15 changes: 11 additions & 4 deletions docusaurus/video/docusaurus/docs/api/basics/get_started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ const callType = 'default';
const callId = 'my-first-call';
const call = client.call(callType, callId);

call.getOrCreate({ data: { created_by_id: 'john' } });
call.create({ data: { created_by_id: 'john' } });

// optionally provide additional data
call.getOrCreate({
call.create({
data: {
created_by_id: 'john',
members: [{ user_id: 'john', role: 'admin' }, { user_id: 'jack' }],
Expand Down Expand Up @@ -458,8 +458,15 @@ curl -X POST "https://video.stream-io-api.com/video/call/default/${CALL_ID}/star
<TabItem value="js" label="JavaScript">

```js
const resp = await call.getOrCreate();
const address = resp.call.ingress.rtmp.address;
const resp = await call.getOrCreate({ data: { created_by_id: 'john' } });
// user ID of an existing user
const userId = 'jane';
const token = client.createToken(userId);

const address = resp.call.ingress.rtmp.address.replace(
'<your_token_here>',
token,
);
```

</TabItem>
Expand Down
63 changes: 63 additions & 0 deletions docusaurus/video/docusaurus/docs/api/streaming/backstage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,75 @@ slug: /streaming/backstage
title: Backstage
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

## Introduction

## Configuration

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
// call level
call.update({
settings_override: {
backstage: {
enabled: true,
},
},
});

// or call type level
client.updateCallType('<call type name>', {
settings: {
backstage: {
enabled: true,
},
},
});
```

</TabItem>
</Tabs>

## Backstage Permissions

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
client.updateCallType('<call type name>', {
grants: {
host: [OwnCapability.JOIN_BACKSTAGE],
},
});
```

</TabItem>
</Tabs>

## Go Live

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
call.goLive();
```

</TabItem>
</Tabs>

## Stop Live

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
call.stopLive();
```

</TabItem>
</Tabs>
40 changes: 40 additions & 0 deletions docusaurus/video/docusaurus/docs/api/streaming/rtmp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,48 @@ slug: /streaming/rtmp
title: RTMP
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

## RTMP support overview

## RTMP publishing

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
const resp = await call.getOrCreate({ data: { created_by_id: 'john' } });
// user ID of an existing user
const userId = 'jane';
const token = client.createToken(userId);

const address = resp.call.ingress.rtmp.address.replace(
'<your_token_here>',
token,
);
```

</TabItem>
<TabItem value="py" label="Python">

```py
def hello_world():
print("Hello, world!")
```

</TabItem>
<TabItem value="go" label="Golang">

```go
callResponse, err := client.GetOrCreateCall(models.CallTypeDefault, callID, &models.GetOrCreateCallRequest{})
if err != nil {
panic(err)
}
addressToUse := callResponse.Call.Ingress.Rtmp.Address
```

</TabItem>
</Tabs>

## RTMP relay

0 comments on commit 1e1ab57

Please sign in to comment.