Skip to content

Commit

Permalink
cn sync screenshot upload (#1201)
Browse files Browse the repository at this point in the history
* cn sync screenshot upload

* review updates

---------

Co-authored-by: hussain-khalid <[email protected]>
Co-authored-by: saudsami <[email protected]>
  • Loading branch information
3 people authored Sep 9, 2024
1 parent 6a94aed commit a92417c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 23 deletions.
41 changes: 25 additions & 16 deletions shared/video-sdk/develop/screenshot-upload/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ When you enable screenshot upload, you set the interval between screenshots. Aft

## Prerequisites

Before implementing the <Vg k="COMPANY"/> video screenshot upload feature, take the following steps:
Before implementing the <Vg k="COMPANY"/> local screenshot upload feature, take the following steps:

1. **Activate video screenshot upload service**
1. **Activate local screenshot upload service**

Log in to [Agora Console](https://console.agora.io), select the project for which you want to activate the video screenshot upload service, and then click **Configure**. Scroll down to the features section to find **Video Screenshot Upload** and click **Config**.
Log in to [Agora Console](https://console.agora.io), select the project for which you want to activate the local screenshot upload service, and then click **Configure**. Scroll down to the features section to find **Video Screenshot Upload** and click **Config**.

![Enable screenshot upload](/images/video-sdk/enable-screen-shoot-upload.png)

Expand All @@ -37,11 +37,11 @@ Before implementing the <Vg k="COMPANY"/> video screenshot upload feature, take

Fill in the following information:

- **Snapshot Callback Address**: The server address to receive callback notifications of video screenshot upload results.
- **Screenshot Callback Address**: The server address to receive callback notifications of local screenshot upload results.
- **Storage**: Third-party cloud storage provider. Select AWS.

<Admonition type="info" title="Information">
Currently, the Agora video screenshot upload service supports Amazon S3 as third-party cloud storage provider. If you want to use other provider, [contact](mailto:[email protected]) technical support.
Currently, the Agora local screenshot upload service supports Amazon S3 as the third-party cloud storage provider. If you want to use other provider, [contact](mailto:[email protected]) technical support.
</Admonition>

- **Region**: The data center region setting for third-party cloud storage. See [AWS Official Documentation](https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region) for details.
Expand All @@ -50,10 +50,11 @@ Before implementing the <Vg k="COMPANY"/> video screenshot upload feature, take
- **Bucket Name**: String type, the bucket name of the third-party cloud storage. The bucket name must comply with the naming rules of the corresponding third-party cloud storage service.
- **Endpoint**: Specify the access domain (Endpoint) of the bucket. See [AWS Official Documentation](https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region) for details.
- **Filename Prefix**: (Optional) JSON Array, an array composed of multiple strings, indicating the storage location of screenshots in the third-party cloud storage. For example, if `fileNamePrefix` = `["directory1","directory2"]`, the prefix `directory1/directory2/` will be added to the screenshot filename, that is, `directory1/directory2/xxx.jpg`. The prefix length, including slashes, must not exceed 128 characters. The string should not contain symbols such as slashes, underscores, parentheses, and so on. The supported character set is as follows:

- 26 lowercase English letters a-z
- 26 uppercase English letters A-Z
- 10 digits 0-9
<p/>
<p/>
<details title = "Example">
<summary>Sample configuration</summary>
- Snapshot Callback Address: `https://webhook.site/2e75da2d-xxxx-xxxx-xxx-a0ef44a5259d`
Expand All @@ -68,19 +69,18 @@ Before implementing the <Vg k="COMPANY"/> video screenshot upload feature, take

3. **Integrate SDK**

Integrate the <Vpd k="SDK" /> (including the video screenshot upload dynamic library) into your project, join a channel, and publish a video stream. See [SDK quickstart](../../video-calling/get-started/get-started-sdk) for details.
Integrate the <Vpd k="SDK" /> (including the local screenshot upload dynamic library) into your project, join a channel, and publish a video stream. See [SDK quickstart](../../video-calling/get-started/get-started-sdk) for details.

## Implement video screenshot upload
## Implement local screenshot upload

You enable screenshot upload in your <Vpd k="NAME" /> client and handle the notification callback from Agora on your callback server.

### Enable screenshot upload

Call the `enableContentInspect` method to enable the video screenshot upload feature. After successfully enabling the feature, the SDK will capture screenshots at the specified frequency and upload them to the Agora cloud server. To implement this logic, refer to the following code:
Call the `enableContentInspect` method to enable the local screenshot upload feature. After successfully enabling the feature, the SDK will capture screenshots at the specified frequency and upload them to the Agora cloud server. To implement this logic, refer to the following code:

<ProjectImplement/>


### HTTP notification callback

After a screenshot is successfully uploaded to the <Vg k="AGORA_BACKEND" />, Agora sends a message notification callback to your application server in the form of an `HTTPS` `POST` request. The data format is `JSON`, and the character encoding is `UTF-8`.
Expand All @@ -106,8 +106,8 @@ The request body is a JSON Object, containing the following fields:
| :-------------- | :---------- | :----------------------------------------------------------- |
| `requestId` | String | Callback notification ID, identifying an event notification from the Agora business server. |
| `callbackParam` | JSON Object | Custom fields passed in the callback, currently includes the `cname` field, representing the channel name. |
| `callbackData` | String | String data passed through by the SDK video screenshot upload module. |
| `checksum` | String | MD5 value calculated from the parameters `callbackAddr`, `code`, `object`, and `requestId`. Used to verify whether this callback notification comes from the video screenshot upload service. |
| `callbackData` | String | String data passed through by the SDK local screenshot upload module. |
| `checksum` | String | MD5 value calculated from the parameters `callbackAddr`, `code`, `object`, and `requestId`. Used to verify whether this callback notification comes from the local screenshot upload service. |
| `object` | String | Name of the screenshot file. The naming convention for this file is: `<OSS prefix>/<year month day>/<sid>_<cname>__uid_s_<uid>__uid_e_<type>_utc.jpg`. The meanings of the fields in the filename are as follows: <ul><li>`<sid>`: Screenshot ID, a unique identifier for a screenshot.</li><li>`<cname>`: Channel name to which the user being screenshotted belongs.</li><li>`<uid>`: The user ID set when joining the channel.</li><li>`<type>`: File type, supports only `video`.</li><li>`<utc>`: Unix timestamp of this screenshot. UTC time, consists of year, month, day, hour, minute, second, and millisecond. For example, if `utc` is equal to `20190611073246073`, it represents the start time of this slice file as UTC June 11, 2019, 7:32:46.073 AM.</li></ul> |
| `code` | Number | Status code of this screenshot. `200` indicates that the screenshot is completed. |
| `msg` | String | Status of this screenshot. `"Supervise complete"` indicates that the screenshot is completed. |
Expand Down Expand Up @@ -135,26 +135,35 @@ The request body is a JSON Object, containing the following fields:
```
</details>

#### Response

After receiving the message notification, your application server is expected to respond. The response package format is JSON. In any of the following cases, the Agora service considers the notification as failed:

- After sending a message notification, no response is received from your server within 5 seconds.
- The HTTP status code of the response is not `200`, or the response body format is not JSON.

The Agora service immediately retries and sends the message notification again after the first notification fails. It attempts to notify you three times in total.

## Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.

<Reference/>

### Video screenshot upload dynamic library
### local screenshot upload dynamic library

You can find details about the name of the video screenshot upload dynamic library and the increase in app size after integration in [App size optimization](../best-practices/downloads).
You can find details about the name of the local screenshot upload dynamic library and the increase in app size after integration in [App size optimization](../best-practices/app-size-optimization).

### HTTP status codes

The HTTP status codes for the application server responses are as follows:

| Status Code | Description |
| :---------- | :---------------------------------------------------------- |
| `200` | Successful request. |
| `200` | Successful request. |
| `201` | Successful request and creation of a new resource. |
| `206` | No user streamed during the entire screenshot process, or some screenshot files were not uploaded to the third-party cloud storage. |
| `400` | Syntax error in the request (For example, parameter error), and the server cannot understand it. |
| `401` | Unauthorized (App ID or Customer Certificate mismatch). |
| `401` | Unauthorized (App ID or Customer Certificate mismatch). |
| `404` | The server cannot find the requested resource (webpage). |
| `500` | Internal server error, unable to complete the request. |
| `504` | Internal server error. The server acting as a gateway or proxy did not receive a timely response from the upstream server. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
ContentInspectConfig config = new ContentInspectConfig();
config.extraInfo = "YourExtraInfo";
config.moduleCount = 1;
// The type of the feature module is video screenshot upload
// The type of the feature module is local screenshot upload
config.modules[0].type = ContentInspectConfig.CONTENT_INSPECT_TYPE_SUPERVISE;
// The frequency of video screenshot upload is once every 2 seconds
// The frequency of local screenshot upload is once every 2 seconds
config.modules[0].interval = 2;
mRtcEngine.enableContentInspect(true, config);
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ let inspectExtraConfig = AgoraContentInspectConfig()
inspectExtraConfig.extraInfo = "YourExtraInfo"
var modules = [AgoraContentInspectModule]()
let module1 = AgoraContentInspectModule()
// The type of the feature module is video screenshot upload
// The type of the feature module is local screenshot upload
module1.type = .supervise
// The frequency of video screenshot upload is once every 2 seconds
// The frequency of local screenshot upload is once every 2 seconds
module1.interval = 2
modules.append(module1)
inspectExtraConfig.modules = modules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```javascript
const inspectConfig = {
// Set the interval for video screenshot to 2000 milliseconds (2 seconds), with a minimum value of 1000.
// Set the interval for local screenshot to 2000 milliseconds (2 seconds), with a minimum value of 1000.
interval: 2000,
// (Optional) Set the address prefix for third-party cloud storage.
ossFilePrefix: "https://your-cloud-storage.com/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ void CMainFrame::OnBtnEnableContentInspect() {

ContentInspectConfig config;
ContentInspectModule module1;
// The type of the feature module is video screenshot upload
// The type of the feature module is local screenshot upload
module1.type = kContentInspectSupervise;
// The frequency of video screenshot upload is once every 2 seconds
// The frequency of local screenshot upload is once every 2 seconds
module1.interval = 2;

config.moduleCount = 1;
Expand Down

0 comments on commit a92417c

Please sign in to comment.