Skip to content

Commit

Permalink
v0.1 documentation review feedback (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz authored Nov 10, 2023
2 parents 6c7a44b + 5745d40 commit 998ecf0
Show file tree
Hide file tree
Showing 16 changed files with 499 additions and 533 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ call.stopHLSBroadcasting();
```py
call.start_broadcasting()

// to end broadcasting
# to end broadcasting
call.stop_broadcasting()
```

Expand Down
81 changes: 81 additions & 0 deletions docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

You can create a call by providing the call type and an ID:

- The [call type](/api/call_types/builtin) controls which features are enabled and sets up permissions. Call type settings and permissions can be set from API, or using the [Stream Dashboard](https://dashboard.getstream.io/).
- Calls IDs can be reused, which means they can be joined multiple times, so it's possible to set up recurring calls.

You can optionally restrict call access by providing a list of existing users.

It's also possible to store any custom data with the call object.

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

```js
const callType = 'default';
const callId = 'my-first-call';
const call = client.video.call(callType, callId);

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

// optionally provide additional data
call.create({
data: {
created_by_id: 'john',
// Call members need to be existing users
members: [{ user_id: 'john', role: 'admin' }, { user_id: 'jack' }],
custom: {
color: 'blue',
},
},
});
```

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

```py
from getstream.models.call_request import CallRequest

call = client.video.call("default", "id")
response = call.create(
data=CallRequest(
created_by_id="sacha",
),
)

# optionally provide additional data
response = call.create(
data=CallRequest(
created_by_id="sacha",
# Call members need to be existing users
members=[
MemberRequest(user_id: "john", role: "admin"),
MemberRequest(user_id: "jack"),
],
custom={"color": "blue"},
),
)
```

</TabItem>

<TabItem value="curl" label="cURL">

```bash
curl -X POST "https://video.stream-io-api.com/video/call/default/${CALL_ID}?api_key=${API_KEY}" \
-H "Content-Type: application/json" \
-H "Authorization: ${JWT_TOKEN}" \
-d '{
"data": {
"created_by_id": "[email protected]",
"settings_override": { "audio": { "access_request_enabled": false } }
},
"members": [ { "role": "speaker", "user_id": "[email protected]" } ]
}'
```

</TabItem>
</Tabs>
2 changes: 1 addition & 1 deletion docusaurus/video/docusaurus/docs/api/_common_/go_live.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ call.goLive({ start_hls: true, start_recording: true });
<TabItem value="py" label="Python">

```py
call.go_live()
call.go_live(start_hls=True, start_recording=True)
```

</TabItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

You can restrict call access by defining a list of members who are allowed to join the call. Call members need to be existing users. Every call member has a call-level role, [you can configure roles](/api/call_types/permissions/) on the call type.

Call members can receive [push notifications](/api/call_types/settings/#push-notifications-settings).

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

```js
// Call members need to be existing users
call.updateCallMembers({
// You can add new members
// You can also update the role of existing members
update_members: [{ user_id: 'sara' }, { user_id: 'emily', role: 'admin' }],
});
```

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

```py
# Call members need to be existing users
# You can also update the role of existing members
call.update_members(update_members=[
MemberRequest(user_id: "sara"),
MemberRequest(user_id: "emily", role: "admin")])
```

</TabItem>
<TabItem value="curl" label="cURL">

```bash
curl -X PUT "https://video.stream-io-api.com/video/call/default/${CALL_ID}/members?api_key=${API_KEY}" \
-H "Content-Type: application/json" \
-H "Authorization: ${JWT_TOKEN}" \
-d '{
"update_members": [
{ "user_id": "sara" },
{ "user_id": "emily", "role": "admin" }
]
}'
```

</TabItem>
</Tabs>

You can also remove call members:

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

```js
call.updateCallMembers({
remove_members: ['sara'],
});
```

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

```py
call.update_members(
remove_members=[
MemberRequest(user_id: 'jack', role: 'admin')
]
)
```

</TabItem>
</Tabs>
43 changes: 30 additions & 13 deletions docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx
Original file line number Diff line number Diff line change
@@ -1,33 +1,50 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';


<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 resp = await call.get();

// userId of existing user
const userId = 'jane';
await client.upsertUsers({
users: {
[userId]: {
id: userId,
},
},
});
const token = client.createToken(userId);
const rtmpURL = resp.call.ingress.rtmp.address;
const streamKey = token;

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

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

```py
response = call.create(GetOrCreateCallRequest(
data=CallRequest(
created_by_id="sacha",
),
),)
resp = call.get()
# user ID of an existing user
user_id = 'jane'
client.upsert_users(
users={
user_id: {'id': user_id}
}
)

# the token will be valid for 1 hour
exp = int(time.time()) + 60 * 60

token = client.create_token(user_id,expiration=exp)

rtmp_url = response.data().call.ingress.rtmp.address
stream_key = token
print(rtmp_url, stream_key)
```

</TabItem>
</Tabs>
</Tabs>
55 changes: 55 additions & 0 deletions docusaurus/video/docusaurus/docs/api/_common_/update-call.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

Default call settings are inherited from the [call type](/api/call_types/settings/). These settings can be overridden if necessary.

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

```js
call.update({
settings_override: {
audio: { mic_default_on: true, default_device: 'speaker' },
},
});

// or to update custom data
call.update({ custom: { color: 'red' } });
```

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

```py
call.update(
settings_override=CallSettingsRequest(
audio=AudioSettingsRequest(
mic_default_on=True,
default_device="speaker",
),
)
)

# or to update custom data
call.update(custom= { 'color': 'red' })
```

</TabItem>
<TabItem value="curl" label="cURL">

```bash
curl -X PUT "https://video.stream-io-api.com/video/call/default/${CALL_ID}?api_key=${API_KEY}" \
-H "Content-Type: application/json" \
-H "Authorization: ${JWT_TOKEN}" \
-d '{
"settings_override": {
"audio": {
"mic_default_on": true
}
}
}'

```

</TabItem>
</Tabs>
Loading

0 comments on commit 998ecf0

Please sign in to comment.