Skip to content

Commit

Permalink
Recording JS code snippets (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz authored Jul 26, 2023
1 parent b86c643 commit 2901e4b
Showing 1 changed file with 222 additions and 0 deletions.
222 changes: 222 additions & 0 deletions docusaurus/video/docusaurus/docs/api/recording/recording_calls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,234 @@ slug: /recording/calls
title: Recording calls
---

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

## Enabling / Disabling call recording

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

```js
// Disable on call level
call.update({
settings_override: {
recording: {
mode: RecordSettingsRequestModeEnum.DISABLED,
},
},
});

// Disable on call type level
client.updateCallType('<call type name>', {
settings: {
recording: {
mode: RecordSettingsModeEnum.DISABLED,
},
},
});

// Enable
call.update({
settings_override: {
recording: {
mode: RecordSettingsRequestModeEnum.AVAILABLE,
},
},
});

// Other settings
call.update({
settings_override: {
recording: {
audio_only: false,
quality: RecordSettingsRequestQualityEnum._1080P,
},
},
});
```

</TabItem>
</Tabs>

## Start call recording

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

```js
call.startRecording();
```

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

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

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

```go
func main() {
apiKey := os.Getenv("API_KEY")
apiSecret := os.Getenv("API_SECRET")
userID := os.Getenv("USER_ID")
url := os.Getenv("URL")

if apiKey == "" || apiSecret == "" || userID == "" || url == "" {
panic("API_KEY, API_SECRET, USER_ID and URL env variables must be set")
}

tokenProvider := videosdk.UserToken(apiSecret, userID, 24*time.Hour)
sdk := videosdk.New(apiKey, tokenProvider)

token, err := tokenProvider(sdk.APIKey())
if err != nil {
panic(err)
}

client := videosdk.NewCoordinatorClientSDK(url, sdk.APIKey(), token)
startResponse, err := client.StartRecording(models.CallTypeDefault, callID, &models.StartRecordingRequest{
Type: "default", ID: callID,
})
if err != nil {
panic(err)
}
fmt.Println("response", startResponse)

stopResponse, err := client.StopRecording(models.CallTypeDefault, callID, &models.StopRecordingRequest{
Type: "default", ID: callID,
})
if err != nil {
panic(err)
}

fmt.Println("response", stopResponse)
}
```

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

```bash
curl -X POST "https://video.stream-io-api.com/video/call/default/${CALL_ID}/start_recording?api_key=${API_KEY}" \
-H "Authorization: ${JWT_TOKEN}"
```

</TabItem>
</Tabs>

## Stop call recording

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

```js
call.stopRecording();
```

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

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

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

```go
func main() {
apiKey := os.Getenv("API_KEY")
apiSecret := os.Getenv("API_SECRET")
userID := os.Getenv("USER_ID")
url := os.Getenv("URL")

if apiKey == "" || apiSecret == "" || userID == "" || url == "" {
panic("API_KEY, API_SECRET, USER_ID and URL env variables must be set")
}

tokenProvider := videosdk.UserToken(apiSecret, userID, 24*time.Hour)
sdk := videosdk.New(apiKey, tokenProvider)

token, err := tokenProvider(sdk.APIKey())
if err != nil {
panic(err)
}

client := videosdk.NewCoordinatorClientSDK(url, sdk.APIKey(), token)
startResponse, err := client.StartRecording(models.CallTypeDefault, callID, &models.StartRecordingRequest{
Type: "default", ID: callID,
})
if err != nil {
panic(err)
}
fmt.Println("response", startResponse)

stopResponse, err := client.StopRecording(models.CallTypeDefault, callID, &models.StopRecordingRequest{
Type: "default", ID: callID,
})
if err != nil {
panic(err)
}

fmt.Println("response", stopResponse)
}
```

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

```bash
curl -X POST "https://video.stream-io-api.com/video/call/default/${CALL_ID}/start_recording?api_key=${API_KEY}" \
-H "Authorization: ${JWT_TOKEN}"
```

</TabItem>
</Tabs>

## List call recording

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

```js
call.queryRecordings();

// optionally query recordings for a specific session
call.queryRecordings('<session ID>');
```

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

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

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

```go
TODO
```

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

```bash
curl -X GET "https://video.stream-io-api.com/video/call/default/${CALL_ID}/${SESSION_ID}/recordings?api_key=${API_KEY}" \
-H "Authorization: ${JWT_TOKEN}"
```

</TabItem>
</Tabs>

## Delete call recording

// TODO: Add API endpoint

0 comments on commit 2901e4b

Please sign in to comment.